Explorar el Código

平台管理员,公司管理员场景列表

lyhzzz hace 2 años
padre
commit
5299d0b4f1

+ 63 - 0
src/main/java/com/fdkankan/ucenter/entity/UserRole.java

@@ -0,0 +1,63 @@
+package com.fdkankan.ucenter.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 用户角色关系表
+ * </p>
+ *
+ * @author 
+ * @since 2023-01-29
+ */
+@Getter
+@Setter
+@TableName("t_user_role")
+public class UserRole implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 用户表id
+     */
+    @TableField("user_id")
+    private Long userId;
+
+    /**
+     * 角色表id
+     */
+    @TableField("role_id")
+    private Long roleId;
+
+    /**
+     * 创建时间
+     */
+    @TableField("create_time")
+    private Date createTime;
+
+    /**
+     * 记录的状态,A: 生效,I: 禁用
+     */
+    @TableField("rec_status")
+    @TableLogic(value = "A",delval = "I")
+    private String recStatus;
+
+    /**
+     * 更新时间
+     */
+    @TableField("update_time")
+    private Date updateTime;
+
+
+}

+ 3 - 3
src/main/java/com/fdkankan/ucenter/generate/AutoGenerate.java

@@ -18,7 +18,7 @@ public class AutoGenerate {
         String path =System.getProperty("user.dir") ;
 
         generate(path,"ucenter", getTables(new String[]{
-                "t_agent_new_log",
+                "t_user_role",
         }));
 
 //        generate(path,"goods", getTables(new String[]{
@@ -46,8 +46,8 @@ public class AutoGenerate {
 
 
     public static void  generate(String path,String moduleName,  List<String> tables){
-        FastAutoGenerator.create("jdbc:mysql://120.24.144.164:3306/4dkankan_v4?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true",
-                "root","4Dage@4Dage#@168")
+        FastAutoGenerator.create("jdbc:mysql://120.77.76.141:13306/4dkankan_v4?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true",
+                "root","JK20220120%JIK")
                 .globalConfig(builder -> {
                     builder.author("")               //作者
                             .outputDir(path+"\\src\\main\\java")    //输出路径(写到java目录)

+ 18 - 0
src/main/java/com/fdkankan/ucenter/mapper/IUserRoleMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.ucenter.mapper;
+
+import com.fdkankan.ucenter.entity.UserRole;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 用户角色关系表 Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2023-01-29
+ */
+@Mapper
+public interface IUserRoleMapper extends BaseMapper<UserRole> {
+
+}

+ 20 - 0
src/main/java/com/fdkankan/ucenter/service/IUserRoleService.java

@@ -0,0 +1,20 @@
+package com.fdkankan.ucenter.service;
+
+import com.fdkankan.ucenter.entity.User;
+import com.fdkankan.ucenter.entity.UserRole;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Set;
+
+/**
+ * <p>
+ * 用户角色关系表 服务类
+ * </p>
+ *
+ * @author 
+ * @since 2023-01-29
+ */
+public interface IUserRoleService extends IService<UserRole> {
+
+    Set<Long> getByUser(User user);
+}

+ 9 - 1
src/main/java/com/fdkankan/ucenter/service/impl/AppSceneService.java

@@ -55,6 +55,8 @@ public class AppSceneService {
 
     @Autowired
     IScenePlusMapper scenePlusMapper;
+    @Autowired
+    IUserRoleService userRoleService;
 
     @Value("${fyun.host}")
     private String ossHost;
@@ -86,7 +88,13 @@ public class AppSceneService {
             if(cooperationNumList.size() >0){
                 param.setCooperationNumList(cooperationNumList );
             }
-            param.setUserId(user.getId());
+            Set<Long> roleIds = userRoleService.getByUser(user);
+            if(!roleIds.contains(5L)){
+                param.setUserId(user.getId());
+            }
+            if(roleIds.contains(6L)){
+                param.setCompanyId(user.getCompanyId());
+            }
         }
 
         Page<AppSceneVo> page =  scenePlusMapper.pageList(new Page<>(param.getPageNum(),param.getPageSize()),param);

+ 1 - 1
src/main/java/com/fdkankan/ucenter/service/impl/LoginService.java

@@ -192,7 +192,7 @@ public class LoginService {
         if(!file.exists()){
             fYunFileServiceInterface.downloadFile(QrCodeFilePath.LOGO_IMAGE_OSS,QrCodeFilePath.LOGO_IMAGE_LOCAL);
         }
-        MatrixToImageWriterUtil.createQRCode(NacosProperty.getMainUrl() + "app/index.html?m="+uuid, filePath,true,QrCodeFilePath.LOGO_IMAGE_LOCAL);
+        MatrixToImageWriterUtil.createQRCode(NacosProperty.getMainUrl() + "app/index.html?m="+uuid, filePath,false,null);
         JSONObject json = new JSONObject();
         json.put("url", filePath.replace(ConstantFilePath.BASE_PATH, ""));
         json.put("uuid", uuid);

+ 31 - 0
src/main/java/com/fdkankan/ucenter/service/impl/UserRoleServiceImpl.java

@@ -0,0 +1,31 @@
+package com.fdkankan.ucenter.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.ucenter.entity.User;
+import com.fdkankan.ucenter.entity.UserRole;
+import com.fdkankan.ucenter.mapper.IUserRoleMapper;
+import com.fdkankan.ucenter.service.IUserRoleService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 用户角色关系表 服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2023-01-29
+ */
+@Service
+public class UserRoleServiceImpl extends ServiceImpl<IUserRoleMapper, UserRole> implements IUserRoleService {
+
+    @Override
+    public Set<Long> getByUser(User user) {
+        LambdaQueryWrapper<UserRole> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(UserRole::getUserId,user.getId());
+        return this.list(wrapper).stream().map(UserRole::getRoleId).collect(Collectors.toSet());
+    }
+}

+ 3 - 0
src/main/java/com/fdkankan/ucenter/vo/request/AppSceneParam.java

@@ -31,5 +31,8 @@ public class AppSceneParam extends RequestBase {
     private String endTime;
     private String sceneNum;
 
+    private Long companyId;
+
+
 
 }

+ 5 - 0
src/main/resources/mapper/ucenter/ScenePlusMapper.xml

@@ -8,6 +8,7 @@
          p.camera_id,p.user_id ,p.data_source,p.scene_type,build_type
         FROM t_scene_pro p
         left join `t_camera_detail` tcd on p.camera_id = tcd.camera_id
+        left join t_company com on tcd.company_id = com.id
         WHERE is_upgrade = 0 and  p.rec_status = 'A'   AND ( p.status = 1 OR p.status = -2) AND p.scene_type != 99
         <include refid="commonWhere"></include>
         <if test="param.sceneName !=null and param.sceneName !=''">
@@ -20,6 +21,7 @@
         FROM t_scene_plus p
         LEFT JOIN t_scene_plus_ext e on p.id = e.plus_id
         left join `t_camera_detail` tcd on p.camera_id = tcd.camera_id
+        left join t_company com on tcd.company_id = com.id
         WHERE  p.rec_status = 'A' AND ( p.scene_status = 1 OR p.scene_status = -2) AND p.scene_type != 99
         <include refid="commonWhere"></include>
         <if test="param.sceneName !=null and param.sceneName !=''">
@@ -60,6 +62,9 @@
         <if test= 'param.cameraType != null' >
             and tcd.goods_id = #{param.cameraType}
         </if>
+        <if test= 'param.companyId != null' >
+            and com.id = #{param.companyId}
+        </if>
     </sql>
 
 

+ 5 - 0
src/main/resources/mapper/ucenter/UserRoleMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.ucenter.mapper.IUserRoleMapper">
+
+</mapper>