Ver Fonte

人员修改

wwh há 1 ano atrás
pai
commit
899fece5a3

+ 1 - 23
snowy-web-app/src/main/java/vip/xiaonuo/modular/people/controller/PeopleListController.java

@@ -77,29 +77,7 @@ public class PeopleListController {
     @ApiOperation("添加people_list")
     @CommonLog("添加people_list")
     @PostMapping("/biz/nongke/add")
-    public CommonResult<String> add(@RequestParam(name = "userName") String userName,
-                                    @RequestParam(name = "nickName") String nickName,
-                                    @RequestParam(name = "sex") Integer sex,
-                                    @RequestParam(name = "phone") String phone,
-                                    @RequestParam(name = "img") MultipartFile img,
-                                    @RequestParam(name = "manageArea") String manageArea,
-                                    @RequestParam(name = "orgId") String orgId) throws IOException {
-        PeopleListAddParam peopleListAddParam = new PeopleListAddParam();
-        String imageCom = "";
-        if (ObjectUtil.isNotEmpty(img)) {
-            if (uploadImage.getImageCom(img).equals("上传失败")) {
-                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                return new CommonResult(500, "图片上传失败", false);
-            }
-            imageCom = uploadImage.getImageCom(img);
-            peopleListAddParam.setImg(imageCom);
-        }
-        peopleListAddParam.setUserName(userName);
-        peopleListAddParam.setManageArea(manageArea);
-        peopleListAddParam.setSex(sex);
-        peopleListAddParam.setPhone(phone);
-        peopleListAddParam.setNickName(nickName);
-        peopleListAddParam.setOrgId(orgId);
+    public CommonResult<String> add(@RequestBody @Valid PeopleListAddParam peopleListAddParam) throws IOException {
         return peopleListService.add(peopleListAddParam);
     }
 

+ 2 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/people/param/PeopleListAddParam.java

@@ -50,5 +50,7 @@ public class PeopleListAddParam {
     @ApiModelProperty(value = "负责区域", position = 9)
     private String manageArea;
 
+    /*组织id*/
+    @ApiModelProperty(value = "组织id", position = 10)
     private String orgId;
 }

+ 5 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/people/service/impl/PeopleListServiceImpl.java

@@ -28,6 +28,7 @@ import vip.xiaonuo.common.exception.CommonException;
 import vip.xiaonuo.common.page.CommonPageRequest;
 
 import vip.xiaonuo.common.pojo.CommonResult;
+import vip.xiaonuo.common.util.CommonAvatarUtil;
 import vip.xiaonuo.modular.people.entity.PeopleList;
 import vip.xiaonuo.modular.people.mapper.PeopleListMapper;
 import vip.xiaonuo.modular.people.param.PeopleListAddParam;
@@ -75,6 +76,10 @@ public class PeopleListServiceImpl extends ServiceImpl<PeopleListMapper, PeopleL
         PeopleList one = peopleListMapper.selectOne(queryWrapper);
         if (ObjectUtil.isEmpty(one)) {
             PeopleList peopleList = BeanUtil.toBean(peopleListAddParam, PeopleList.class);
+            if(ObjectUtil.isEmpty(peopleList.getImg())) {
+                // 设置默认头像
+                peopleList.setImg(CommonAvatarUtil.generateImg(peopleList.getUserName()));
+            }
             this.save(peopleList);
             return CommonResult.ok();
         } else {