From 40819a99333f60f3c95e49f9064459a89046c690 Mon Sep 17 00:00:00 2001 From: Vinjor Date: Wed, 14 Aug 2024 10:19:11 +0800 Subject: [PATCH] =?UTF-8?q?sysuser=E8=A1=A8=E5=8C=BA=E5=88=86=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E8=BF=98=E6=98=AF=E5=91=98=E5=B7=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CompanyServiceImpl.java | 2 ++ .../service/impl/CustomerMainServiceImpl.java | 2 ++ .../yudao/common/ErrorCodeConstants.java | 19 +++++++++++ .../service/impl/PropertyPosServiceImpl.java | 32 ++++++++++++++++++- .../service/impl/CompanyStaffServiceImpl.java | 2 ++ .../framework/common/config/CommonStr.java | 4 +++ .../system/api/user/dto/AdminUserRespDTO.java | 5 +++ .../module/system/api/user/dto/UserDTO.java | 4 +++ .../admin/user/vo/user/UserRespVO.java | 3 ++ .../admin/user/vo/user/UserSaveReqVO.java | 4 +++ .../dal/dataobject/user/AdminUserDO.java | 4 +++ .../service/user/AdminUserServiceImpl.java | 6 ++++ 12 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 dl-module-company/src/main/java/cn/iocoder/yudao/common/ErrorCodeConstants.java diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyServiceImpl.java index a484c752..62b69ff3 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyServiceImpl.java @@ -31,6 +31,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_STAFF; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; @@ -95,6 +96,7 @@ public class CompanyServiceImpl extends ServiceImpl impl userDTO.setDeptId(deptId); userDTO.setPassword(companyRespVO.getPassword()); userDTO.setMobile(companyRespVO.getMobilePhone()); + userDTO.setUserType(USER_TYPE_STAFF); Long userId = adminUserApi.createUser(userDTO); Set roleCodes = new HashSet<>(Arrays.asList(companyRespVO.getServiceCodes().split(StrUtil.COMMA))); permissionApi.assignUserRole(userId, roleCodes); diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java index b33f479a..87f8579c 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java @@ -43,6 +43,7 @@ import java.util.*; import static cn.iocoder.yudao.common.BaseConstants.*; import static cn.iocoder.yudao.common.DictBaseConstants.DICT_CUS_TYPE; +import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_CUS; /** * 客户管理 Service 实现类 @@ -119,6 +120,7 @@ public class CustomerMainServiceImpl extends ServiceImpl implements PropertyPosService { + @Resource + private DeptApi deptApi; @Override public String createPropertyPos(PropertyPosReqVO createReqVO) { - // 插入 + /* 1.设置当前登录用户所属部门Id、企业Id */ + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + if(StringUtils.isEmpty(loginUser.getInfo().get("deptId"))){ + //当前登录用户没有部门,不能新增 + throw exception(PROPERTY_NO_DEPT); + } + Long deptId = Long.valueOf(loginUser.getInfo().get("deptId")); + createReqVO.setDeptId(deptId); + DeptRespDTO deptRespDTO = deptApi.getDept(deptId); + if(StringUtils.isEmpty(deptRespDTO.getCorpId()) && StringUtils.isEmpty(createReqVO.getCorpId())){ + //当前登录用户非企业人员,且没有手动选择所属企业的话,不能添加 + throw exception(PROPERTY_NO_CORP); + } + if(StringUtils.isEmpty(createReqVO.getCorpId())){ + createReqVO.setCorpId(deptRespDTO.getCorpId()); + } + /* 2.插入数据并反回Id*/ PropertyPosDO propertyPos = BeanUtils.toBean(createReqVO, PropertyPosDO.class); baseMapper.insert(propertyPos); // 返回 diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java index 3770dedd..4431254e 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java @@ -40,6 +40,7 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_STAFF; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; /** @@ -105,6 +106,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl