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 a6d3b365..2b07c5f4 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 07a123b0..ed8df974 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.time.ZoneId; import java.util.List; import java.util.stream.Collectors; +import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_STAFF; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; /** @@ -112,6 +113,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl