shudonghui 1 год назад
Родитель
Сommit
1fc41baac1

+ 15 - 2
sop-business/src/main/java/com/qmth/sop/business/bean/result/SysCustomResult.java

@@ -1,9 +1,11 @@
 package com.qmth.sop.business.bean.result;
 
 import com.qmth.sop.business.entity.SysCustom;
+import com.qmth.sop.business.entity.SysCustomRole;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * <p>
@@ -18,15 +20,26 @@ public class SysCustomResult extends SysCustom implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @ApiModelProperty(value = "名称")
+    @ApiModelProperty(value = "客户经理")
     private String managerName;
 
-    @ApiModelProperty(value = "编码")
+    @ApiModelProperty(value = "服务档位名称")
     private String level;
 
     @ApiModelProperty(value = "创建人")
     private String createName;
 
+    @ApiModelProperty(value = "项目角色配置")
+    private List<SysCustomRole>  roleList;
+
+    public List<SysCustomRole> getRoleList() {
+        return roleList;
+    }
+
+    public void setRoleList(List<SysCustomRole> roleList) {
+        this.roleList = roleList;
+    }
+
     public String getManagerName() {
         return managerName;
     }

+ 84 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/SysCustomRole.java

@@ -0,0 +1,84 @@
+package com.qmth.sop.business.entity;
+
+import java.io.Serializable;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.base.BaseEntity;
+import com.qmth.sop.common.contant.SystemConstant;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 客户角色配置表 模型.
+ * 
+ * @author: shudonghui
+ * @date: 2023-08-10 08:23:57
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
+ */
+@ApiModel(value = "sys_custom_role对象", description = "客户角色配置表")
+public class SysCustomRole implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+
+	@ApiModelProperty(value = "主键")
+	@JsonSerialize(using = ToStringSerializer.class)
+	private Long id;
+
+  	@ApiModelProperty(value = "客户id")
+	@JsonSerialize(using = ToStringSerializer.class)
+  	private long customId;
+  	@ApiModelProperty(value = "角色id")
+	@JsonSerialize(using = ToStringSerializer.class)
+  	private long roleId;
+  	@ApiModelProperty(value = "配额")
+	@JsonSerialize(using = ToStringSerializer.class)
+  	private long quota;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	/**
+	 * 客户id
+	 */	
+  	public void setCustomId(long customId) {
+		this.customId = customId;
+  	}
+ 	/**
+	 * 客户id
+	 */	 	
+  	public long getCustomId() {
+		return customId;
+  	}
+	/**
+	 * 角色id
+	 */	
+  	public void setRoleId(long roleId) {
+		this.roleId = roleId;
+  	}
+ 	/**
+	 * 角色id
+	 */	 	
+  	public long getRoleId() {
+		return roleId;
+  	}
+	/**
+	 * 配额
+	 */	
+  	public void setQuota(long quota) {
+		this.quota = quota;
+  	}
+ 	/**
+	 * 配额
+	 */	 	
+  	public long getQuota() {
+		return quota;
+  	}
+}

+ 23 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/SysCustomRoleMapper.java

@@ -0,0 +1,23 @@
+package com.qmth.sop.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.sop.business.entity.SysCustomRole;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Param;
+import java.util.Map;
+
+/**
+ * 客户角色配置表 Mapper 接口.
+ * 
+ * @author: shudonghui
+ * @date: 2023-08-10 08:23:58
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
+ */
+public interface SysCustomRoleMapper extends BaseMapper<SysCustomRole> {
+
+
+
+}

+ 22 - 0
sop-business/src/main/java/com/qmth/sop/business/service/SysCustomRoleService.java

@@ -0,0 +1,22 @@
+package com.qmth.sop.business.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.entity.SysCustomRole;
+import java.util.Map;
+
+/**
+ * 客户角色配置表 服务类
+ *
+ * @author: shudonghui
+ * @date: 2023-08-10 08:23:58
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
+ */
+public interface SysCustomRoleService extends IService<SysCustomRole>{
+
+
+
+
+}

+ 2 - 2
sop-business/src/main/java/com/qmth/sop/business/service/SysCustomService.java

@@ -28,9 +28,9 @@ public interface SysCustomService extends IService<SysCustom>{
     */
     IPage<SysCustomResult>  query(Page<Map> iPage, ProductTypeEnum type, Long managerId, String name, Long levelId);
 
-    void add(SysCustom sysCustom);
+    void add(SysCustomResult sysCustom);
 
-    void update(SysCustom sysCustom);
+    void update(SysCustomResult sysCustom);
 
     void delete(Long id);
 

+ 37 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysCustomRoleServiceImpl.java

@@ -0,0 +1,37 @@
+package com.qmth.sop.business.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.sop.business.entity.SysCustomRole;
+import com.qmth.sop.business.entity.SysUser;
+import com.qmth.sop.business.mapper.SysCustomRoleMapper;
+import com.qmth.sop.business.service.SysCustomRoleService;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.ExceptionResultEnum;
+import com.qmth.sop.common.enums.FieldUniqueEnum;
+import com.qmth.sop.common.util.ResultUtil;
+import com.qmth.sop.common.util.ServletUtil;
+import org.springframework.dao.DuplicateKeyException;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * 客户角色配置表 服务实现.
+ *
+ * @author: shudonghui
+ * @date: 2023-08-10 08:23:58
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
+ */
+@Service
+public class SysCustomRoleServiceImpl extends ServiceImpl<SysCustomRoleMapper, SysCustomRole> implements SysCustomRoleService{
+
+
+
+}

+ 24 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysCustomServiceImpl.java

@@ -1,12 +1,16 @@
 package com.qmth.sop.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.sop.business.bean.result.SysCustomResult;
 import com.qmth.sop.business.entity.SysCustom;
+import com.qmth.sop.business.entity.SysCustomRole;
+import com.qmth.sop.business.entity.SysLevelRole;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.mapper.SysCustomMapper;
+import com.qmth.sop.business.service.SysCustomRoleService;
 import com.qmth.sop.business.service.SysCustomService;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ProductTypeEnum;
@@ -14,6 +18,7 @@ import com.qmth.sop.common.util.ServletUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.util.Map;
 import java.util.Objects;
 
@@ -28,7 +33,8 @@ import java.util.Objects;
  */
 @Service
 public class SysCustomServiceImpl extends ServiceImpl<SysCustomMapper, SysCustom> implements SysCustomService {
-
+    @Resource
+    SysCustomRoleService sysCustomRoleService;
 
     /**
      * 查询列表
@@ -38,12 +44,20 @@ public class SysCustomServiceImpl extends ServiceImpl<SysCustomMapper, SysCustom
      */
     @Override
     public IPage<SysCustomResult> query(Page<Map> iPage, ProductTypeEnum type, Long managerId, String name, Long levelId) {
-        return this.baseMapper.query(iPage, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(managerId) ? managerId : null, name, Objects.nonNull(levelId) ? levelId : null);
+        IPage<SysCustomResult> sysCustomResultIPage = this.baseMapper.query(iPage, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(managerId) ? managerId : null, name, Objects.nonNull(levelId) ? levelId : null);
+        sysCustomResultIPage.getRecords().forEach(e -> {
+            e.setRoleList(sysCustomRoleService.list(new QueryWrapper<SysCustomRole>().lambda().eq(SysCustomRole::getCustomId, e.getId())));
+        });
+        return  sysCustomResultIPage;
     }
 
     @Override
     @Transactional
-    public void add(SysCustom sysCustom) {
+    public void add(SysCustomResult sysCustom) {
+        sysCustom.getRoleList().forEach(e->{
+            e.setCustomId(sysCustom.getId());
+        });
+        sysCustomRoleService.saveBatch(sysCustom.getRoleList());
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         sysCustom.setCreateId(sysUser.getId());
         sysCustom.setCreateTime(System.currentTimeMillis());
@@ -52,7 +66,12 @@ public class SysCustomServiceImpl extends ServiceImpl<SysCustomMapper, SysCustom
 
     @Override
     @Transactional
-    public void update(SysCustom sysCustom) {
+    public void update(SysCustomResult sysCustom) {
+        sysCustomRoleService.remove(new QueryWrapper<SysCustomRole>().lambda().eq(SysCustomRole::getCustomId, sysCustom.getId()));
+        sysCustom.getRoleList().forEach(e->{
+            e.setCustomId(sysCustom.getId());
+        });
+        sysCustomRoleService.saveBatch(sysCustom.getRoleList());
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         sysCustom.setUpdateId(sysUser.getId());
         sysCustom.setUpdateTime(System.currentTimeMillis());
@@ -63,6 +82,7 @@ public class SysCustomServiceImpl extends ServiceImpl<SysCustomMapper, SysCustom
     @Override
     @Transactional
     public void delete(Long id) {
+        sysCustomRoleService.remove(new QueryWrapper<SysCustomRole>().lambda().eq(SysCustomRole::getCustomId, id));
         this.removeById(id);
     }
 

+ 1 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDingGroupServiceImpl.java

@@ -93,6 +93,7 @@ public class SysDingGroupServiceImpl extends ServiceImpl<SysDingGroupMapper, Sys
     @Override
     @Transactional
     public void delete(Long id) {
+        sysDingObjService.remove(new QueryWrapper<SysDingObj>().lambda().eq(SysDingObj::getDingGroupId, id));
         this.removeById(id);
     }
 

+ 6 - 1
sop-business/src/main/java/com/qmth/sop/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.sop.business.bean.dto.CustomImportDto;
 import com.qmth.sop.business.bean.dto.SysMessageExportDto;
 import com.qmth.sop.business.bean.dto.UserArchivesImportDto;
+import com.qmth.sop.business.bean.result.SysCustomResult;
 import com.qmth.sop.business.bean.result.SysMessageResult;
 import com.qmth.sop.business.entity.*;
 import com.qmth.sop.business.service.*;
@@ -14,6 +15,7 @@ import com.qmth.sop.business.util.excel.BasicExcelListener;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ProductTypeEnum;
 import com.qmth.sop.common.enums.UploadFileEnum;
+import com.qmth.sop.common.util.ServletUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -144,7 +146,10 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     sysCustom.setLevelId(sysLevel.getId());
                     sysCustom.setSync(false);
                     sysCustom.setEnable(true);
-                    sysCustomService.add(sysCustom);
+                    SysUser ssysUser = (SysUser) ServletUtil.getRequestUser();
+                    sysCustom.setCreateId(ssysUser.getId());
+                    sysCustom.setCreateTime(System.currentTimeMillis());
+                    sysCustomService.saveOrUpdate(sysCustom);
 
                 });
             }

+ 12 - 1
sop-business/src/main/resources/db/log/shudonghui_update_log.sql

@@ -134,4 +134,15 @@ UPDATE `sys_privilege` SET `name` = '重启', `url` = 'Restart', `type` = 'LINK'
 ALTER TABLE `sys_level_role`
     ADD COLUMN  `quota` bigint NOT NULL COMMENT '配额' AFTER `role_id`;
 ALTER TABLE `sys_level`
-    ADD COLUMN `devices` bigint NULL COMMENT '设备数量' AFTER `level`;
+    ADD COLUMN `devices` bigint NULL COMMENT '设备数量' AFTER `level`;
+------------------------------
+-----2023.8.10
+DROP TABLE IF EXISTS `sys_custom_role`;
+CREATE TABLE `sys_custom_role` (
+                                   `id` bigint NOT NULL COMMENT '主键',
+                                   `custom_id` bigint NOT NULL COMMENT '客户id',
+                                   `role_id` bigint NOT NULL COMMENT '角色id',
+                                   `quota` bigint NOT NULL COMMENT '配额',
+                                   PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='客户角色配置表';
+-------------------------------

+ 10 - 0
sop-business/src/main/resources/mapper/SysCustomRoleMapper.xml

@@ -0,0 +1,10 @@
+<?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.qmth.sop.business.mapper.SysCustomRoleMapper">
+
+    <select id="query" resultType="com.qmth.sop.business.entity.SysCustomRole">
+        select * from sys_custom_role a
+
+        order by a.create_time desc
+    </select>
+</mapper>

+ 21 - 10
sop-server/src/main/java/com/qmth/sop/server/api/SysCustomController.java

@@ -1,11 +1,16 @@
 package com.qmth.sop.server.api;
 
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.result.SysCustomResult;
-import com.qmth.sop.business.entity.SysCustom;
-import com.qmth.sop.business.entity.TBTask;
+import com.qmth.sop.business.bean.result.SysLevelResult;
+import com.qmth.sop.business.entity.*;
+import com.qmth.sop.business.service.SysCustomRoleService;
 import com.qmth.sop.business.service.SysCustomService;
 import com.qmth.sop.business.service.TBTaskService;
 import com.qmth.sop.business.templete.execute.AsyncSysCustomImportService;
@@ -49,6 +54,10 @@ public class SysCustomController {
     @Resource
     TBTaskService tbTaskService;
 
+    @Resource
+    SysCustomRoleService sysCustomRoleService;
+
+    @Aac(auth= BOOL.FALSE)
     @ApiOperation(value = "客户表查询接口")
     @RequestMapping(value = "/query", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "客户表列表信息", response = SysCustomResult.class)})
@@ -63,24 +72,24 @@ public class SysCustomController {
         return ResultUtil.ok(resultIPage);
     }
 
-    
+    @Aac(auth= BOOL.FALSE)
     @ApiOperation(value = "新增客户表接口")
     @RequestMapping(value = "/add", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "新增客户表信息", response = Object.class)})
-    public Result add(@ApiParam(value = "客户信息", required = true) @RequestBody(required = true) SysCustom sysCustom) {
+    public Result add(@ApiParam(value = "客户信息", required = true) @RequestBody(required = true) SysCustomResult sysCustom) {
         sysCustomService.add(sysCustom);
         return ResultUtil.ok();
     }
 
-
+    @Aac(auth= BOOL.FALSE)
     @ApiOperation(value = "修改客户表接口")
     @RequestMapping(value = "/update", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "修改客户表信息", response = Object.class)})
-    public Result update(@ApiParam(value = "客户信息", required = true) @RequestBody(required = true) SysCustom sysCustom) {
+    public Result update(@ApiParam(value = "客户信息", required = true) @RequestBody(required = true) SysCustomResult sysCustom) {
         sysCustomService.update(sysCustom);
         return ResultUtil.ok();
     }
-    
+    @Aac(auth= BOOL.FALSE)
     @ApiOperation(value = "删除客户表接口")
     @RequestMapping(value = "/delete", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "删除客户表信息", response = Object.class)})
@@ -94,13 +103,15 @@ public class SysCustomController {
      * @param id
      * @return
      */
-
+    @Aac(auth= BOOL.FALSE)
     @ApiOperation(value = "获取单个客户")
     @RequestMapping(value = "/get", method = RequestMethod.GET)
-    @ApiResponses({@ApiResponse(code = 200, message = "获取单个客户", response = SysCustom.class)})
+    @ApiResponses({@ApiResponse(code = 200, message = "获取单个客户", response = SysCustomResult.class)})
     public Result detail(@ApiParam(value = "客户id", required = true) @RequestParam(required = true) long id) {
         SysCustom sysCustom = sysCustomService.getById(id);
-        return ResultUtil.ok(sysCustom);
+        SysCustomResult sysCustomResult= JSON.toJavaObject((JSON) JSON.toJSON(sysCustom),SysCustomResult.class);
+        sysCustomResult.setRoleList(sysCustomRoleService.list(new QueryWrapper<SysCustomRole>().lambda().eq(SysCustomRole::getCustomId, sysCustom.getId())));
+        return ResultUtil.ok(sysCustomResult);
     }