zhuwei 2 лет назад
Родитель
Сommit
9d2442ee1c

+ 2 - 1
blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/dto/UserDTO.java

@@ -5,6 +5,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
 import org.springblade.system.user.entity.User;
+import org.springblade.system.user.vo.DeptUserVO;
 
 import java.util.List;
 
@@ -24,6 +25,6 @@ public class UserDTO extends User {
      * 组织机构
      */
     @ApiModelProperty(value = "组织机构对象(内控)")
-    private List<SaveUserInfoByProjectDTO> deptList;
+    private List<DeptUserVO> deptList;
 
 }

+ 12 - 0
blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/entity/User.java

@@ -152,4 +152,16 @@ public class User extends TenantEntity {
     @ApiModelProperty(value = "职位")
     private String position;
 
+    /**
+     * 部门id负责人
+     */
+    @ApiModelProperty(value = "部门id负责人")
+    private String isLader;
+
+    /**
+     * 职位
+     */
+    @ApiModelProperty(value = "日单价")
+    private double oneMoney;
+
 }

+ 55 - 0
blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/vo/DeptUserVO.java

@@ -0,0 +1,55 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.system.user.vo;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.system.user.entity.User;
+
+/**
+ * 视图实体类
+ *
+ * @author Chill
+ */
+@Data
+@ApiModel(value = "机构对象", description = "机构对象")
+public class DeptUserVO {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 部门Id
+     */
+    @ApiModelProperty(value = "部门Id")
+    private Long deptId;
+
+    /**
+     * 性别
+     */
+    @ApiModelProperty(value = "岗位Id")
+    private Long postId;
+
+    /**
+     * 拓展信息
+     */
+    @ApiModelProperty(value = "是否负责人(1:是 2:否)")
+    private Integer isLader;
+}

+ 5 - 1
blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java

@@ -33,6 +33,7 @@ import org.springblade.core.tool.constant.BladeConstant;
 import org.springblade.core.tool.constant.RoleConstant;
 import org.springblade.core.tool.support.Kv;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.system.cache.DictCache;
 import org.springblade.system.entity.Dept;
 import org.springblade.system.enums.DictEnum;
@@ -138,7 +139,10 @@ public class DeptController extends BladeController {
     @PostMapping("/submit")
     @ApiOperationSupport(order = 6)
     @ApiOperation(value = "新增或修改", notes = "传入dept")
-    public R submit(@Valid @RequestBody Dept dept) {
+    public R submit(@Valid @RequestBody Dept dept, BladeUser bladeUser) {
+        if (StringUtil.isBlank(dept.getTenantId())) {
+            dept.setTenantId(bladeUser.getTenantId());
+        }
         if (deptService.submit(dept)) {
             CacheUtil.clear(SYS_CACHE);
             // 返回懒加载树更新节点所需字段

+ 5 - 0
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java

@@ -149,7 +149,12 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
             dept.setTenantId(parent.getTenantId());
             String ancestors = parent.getAncestors() + StringPool.COMMA + dept.getParentId();
             dept.setAncestors(ancestors);
+        } else {
+            dept.setTenantId(AuthUtil.getTenantId());
+            dept.setParentId(BladeConstant.TOP_PARENT_ID);
+            dept.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID));
         }
+
         dept.setIsDeleted(BladeConstant.DB_NOT_DELETED);
         return saveOrUpdate(dept);
     }

+ 55 - 1
blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java

@@ -60,6 +60,7 @@ import org.springblade.system.user.excel.UserExcel2;
 import org.springblade.system.user.excel.UserImporter;
 import org.springblade.system.user.service.IUserService;
 import org.springblade.system.user.util.AesInfoUtil;
+import org.springblade.system.user.vo.DeptUserVO;
 import org.springblade.system.user.vo.UserVO;
 import org.springblade.system.user.wrapper.UserWrapper;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -164,6 +165,33 @@ public class UserController {
     @PreAuth(RoleConstant.HAS_ROLE_ADMIN)
     public R submit(@Valid @RequestBody UserDTO user) {
         CacheUtil.clear(USER_CACHE);
+        // 内控系统拆分
+        List<DeptUserVO> deptList = user.getDeptList();
+        if (deptList != null && deptList.size() >= 1) {
+            String deptId = "";
+            String postId = "";
+            String isLaderpostId = "";
+            for (int i = 0; i < deptList.size(); i++) {
+                DeptUserVO deptUserVO = deptList.get(i);
+                if (i == 0) {
+                    deptId += deptUserVO.getDeptId() + "";
+                    postId += deptUserVO.getPostId() + "";
+                    if (deptUserVO.getIsLader() == 1) {
+                        isLaderpostId = deptUserVO.getDeptId() + "";
+                    }
+                } else {
+                    deptId += "," + deptUserVO.getDeptId();
+                    postId += "," + deptUserVO.getPostId() + ",";
+                    if (deptUserVO.getIsLader() == 1) {
+                        isLaderpostId = "," + deptUserVO.getDeptId();
+                    }
+                }
+            }
+            user.setPostId(postId);
+            user.setDeptId(deptId);
+        }
+
+
         return R.status(userService.submit(user));
     }
 
@@ -185,8 +213,34 @@ public class UserController {
     @PostMapping("/update")
     @ApiOperationSupport(order = 5)
     @ApiOperation(value = "修改", notes = "传入User")
-    public R update(@Valid @RequestBody User user) {
+    public R update(@Valid @RequestBody UserDTO user) {
         CacheUtil.clear(USER_CACHE);
+        // 内控系统拆分
+        List<DeptUserVO> deptList = user.getDeptList();
+        if (deptList != null && deptList.size() >= 1) {
+            String deptId = "";
+            String postId = "";
+            String isLaderpostId = "";
+            for (int i = 0; i < deptList.size(); i++) {
+                DeptUserVO deptUserVO = deptList.get(i);
+                if (i == 0) {
+                    deptId += deptUserVO.getDeptId() + "";
+                    postId += deptUserVO.getPostId() + "";
+                    if (deptUserVO.getIsLader() == 1) {
+                        isLaderpostId = deptUserVO.getDeptId() + "";
+                    }
+                } else {
+                    deptId += "," + deptUserVO.getDeptId();
+                    postId += "," + deptUserVO.getPostId() + ",";
+                    if (deptUserVO.getIsLader() == 1) {
+                        isLaderpostId = "," + deptUserVO.getDeptId();
+                    }
+                }
+            }
+            user.setIsLader(isLaderpostId);
+            user.setPostId(postId);
+            user.setDeptId(deptId);
+        }
         return R.status(userService.updateUser(user));
     }
 

+ 2 - 0
blade-service/blade-user/src/main/java/org/springblade/system/user/mapper/UserMapper.xml

@@ -32,6 +32,8 @@
         <result column="acc_code" property="accCode"/>
         <result column="sys_id" property="sysId"/>
         <result column="sys_type" property="sysType"/>
+        <result column="is_lader" property="isLader"/>
+        <result column="one_money" property="oneMoney"/>
     </resultMap>
     <update id="updateRoleIdById">
         UPDATE blade_user

+ 2 - 1
blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java

@@ -32,6 +32,7 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tenant.BladeTenantProperties;
 import org.springblade.core.tool.api.R;
@@ -118,7 +119,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
         if (userCount > 0L && Func.isEmpty(user.getId())) {
             throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
         }
-
         return save(user) && submitUserDept(user);
     }
 
@@ -171,6 +171,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
         //user.setUserType(1); //用户平台-WEB
         user.setName(user.getRealName());
         boolean b1 = save(user);
+
         if (b1) {
             //绑定用户与部门关系
             boolean b = submitUserDept(user);

BIN
target/blade-system.jar