Browse Source

部门 新增与修改角色的部门

Reiskuchen 5 years ago
parent
commit
f419e728d9

+ 3 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserController.java

@@ -107,11 +107,12 @@ public class UserController {
      * phone 电话号码
      * role 角色 0-普通员工 2-管理员
      * cost 成本
+     * departmentId 部门id 不传或0-其他部门 其他部门id-相应部门
      */
     @RequestMapping("/insertUser")
     public HttpRespMsg insertUser(String id, @RequestParam String name, @RequestParam String phone,
-                                  @RequestParam Integer role, Double cost) {
-        return userService.insertUser(id, name, phone, role, cost, request);
+                                  @RequestParam Integer role, Double cost, Integer departmentId) {
+        return userService.insertUser(id, name, phone, role, cost, departmentId, request);
     }
 
     /**

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/UserService.java

@@ -30,7 +30,8 @@ public interface UserService extends IService<User> {
 
     HttpRespMsg insertCompany(String companyName, String name, String phone);
 
-    HttpRespMsg insertUser(String id, String name, String phone, Integer role, Double cost, HttpServletRequest request);
+    HttpRespMsg insertUser(String id, String name, String phone, Integer role, Double cost, Integer departmentId,
+                           HttpServletRequest request);
 
     HttpRespMsg importUser(MultipartFile multipartFile, HttpServletRequest request);
 

+ 5 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -284,7 +284,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
     //新增或修改用户
     @Override
     public HttpRespMsg insertUser(String targetId, String name, String phone, Integer role, Double cost,
-                                  HttpServletRequest request) {
+                                  Integer departmentId, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             User creator = userMapper.selectById(request.getHeader("Token"));
@@ -314,7 +314,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                                     .setPhone(phone)
                                     .setRole(role)
                                     .setCompanyId(creator.getCompanyId())
-                                    .setCost(costValue);
+                                    .setCost(costValue)
+                                    .setDepartmentId(departmentId == null ? 0 : departmentId);
                             if (userMapper.insert(user) == 0) {
                                 httpRespMsg.setError("操作失败");
                             }
@@ -327,7 +328,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                         .setName(name)
                         .setPhone(phone)
                         .setRole(role)
-                        .setCost(costValue));
+                        .setCost(costValue)
+                        .setDepartmentId(departmentId == null ? 0 : departmentId));
             }
         } catch (NullPointerException e) {
             httpRespMsg.setError("数据有误 验证失败");