Merge branch 'master' of http://122.51.230.86:3000/dianliang/lanan-system
Conflicts: dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java
This commit is contained in:
commit
b5d140498f
@ -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<CompanyMapper, Company> impl
|
||||
userDTO.setDeptId(deptId);
|
||||
userDTO.setPassword(companyRespVO.getPassword());
|
||||
userDTO.setMobile(companyRespVO.getMobilePhone());
|
||||
userDTO.setUserType(USER_TYPE_STAFF);
|
||||
Long userId = adminUserApi.createUser(userDTO);
|
||||
Set<String> roleCodes = new HashSet<>(Arrays.asList(companyRespVO.getServiceCodes().split(StrUtil.COMMA)));
|
||||
permissionApi.assignUserRole(userId, roleCodes);
|
||||
|
@ -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<CustomerMainMapper, Cus
|
||||
//默认密码
|
||||
user.setPassword(PASSWORD_DEFAULT);
|
||||
user.setMobile(saveReqVO.getPhoneNumber());
|
||||
user.setUserType(USER_TYPE_CUS);
|
||||
//该用户未注册情况下,如果是政企客户,需要在部门表中创建部门,并给用户绑定
|
||||
if (CUS_TYPE_CORP.equals(main.getTypeCode())) {
|
||||
//查询当前登录用户所属租户的政企客户部门id(父级部门)
|
||||
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.common;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
|
||||
/**
|
||||
* company 错误码枚举类
|
||||
*
|
||||
* company 系统,使用 1-099-000-000 段
|
||||
*/
|
||||
public interface ErrorCodeConstants {
|
||||
// ========== 员工管理 1-099-000-000 ==========
|
||||
|
||||
// ========== 资产管理模块 1-099-001-000 ==========
|
||||
ErrorCode PROPERTY_NO_DEPT = new ErrorCode(1_099_001_000, "当前登录用户没有所属部门");
|
||||
ErrorCode PROPERTY_NO_CORP = new ErrorCode(1_099_001_000, "请选择企业");
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,16 +1,28 @@
|
||||
package cn.iocoder.yudao.module.property.service.impl;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.property.entity.PropertyPosDO;
|
||||
import cn.iocoder.yudao.module.property.mapper.PropertyPosMapper;
|
||||
import cn.iocoder.yudao.module.property.service.PropertyPosService;
|
||||
import cn.iocoder.yudao.module.property.vo.PropertyPosReqVO;
|
||||
import cn.iocoder.yudao.module.property.vo.PropertyPosRespVO;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.common.ErrorCodeConstants.PROPERTY_NO_CORP;
|
||||
import static cn.iocoder.yudao.common.ErrorCodeConstants.PROPERTY_NO_DEPT;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_COUNT_MAX;
|
||||
|
||||
/**
|
||||
* 企业管理-资产存放位置 Service 实现类
|
||||
*
|
||||
@ -19,10 +31,28 @@ import org.springframework.validation.annotation.Validated;
|
||||
@Service
|
||||
@Validated
|
||||
public class PropertyPosServiceImpl extends ServiceImpl<PropertyPosMapper, PropertyPosDO> 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);
|
||||
// 返回
|
||||
|
@ -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<CompanyStaffMapper, Com
|
||||
userDTO.setDeptId(loginUser.getDeptId());
|
||||
userDTO.setMobile(staffRespVO.getTel());
|
||||
userDTO.setSex(staffRespVO.getSex());
|
||||
userDTO.setUserType(USER_TYPE_STAFF);
|
||||
// 获取sys_users中刚插入记录ID给准备添加的员工
|
||||
Long userId = adminUserApi.createUser(userDTO);
|
||||
staffRespVO.setUserId(userId);
|
||||
|
@ -10,4 +10,8 @@ public interface CommonStr {
|
||||
Long TENANT_ID=1L;
|
||||
/** 默认超级管理员id --1 */
|
||||
Long SUPER_ADMIN_ID=1L;
|
||||
/** 用户类型-员工 --1 */
|
||||
String USER_TYPE_STAFF="01";
|
||||
/** 用户类型-客户 --1 */
|
||||
String USER_TYPE_CUS="02";
|
||||
}
|
||||
|
@ -21,6 +21,11 @@ public class AdminUserRespDTO {
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private String userType;
|
||||
/**
|
||||
* 帐号状态
|
||||
*
|
||||
|
@ -16,6 +16,10 @@ public class UserDTO {
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickname;
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private String userType;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -28,6 +28,9 @@ public class UserRespVO{
|
||||
@ExcelProperty("用户昵称")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "用户类型", example = "芋艿")
|
||||
private String userType;
|
||||
|
||||
@Schema(description = "备注", example = "我是一个用户")
|
||||
private String remark;
|
||||
|
||||
|
@ -33,6 +33,10 @@ public class UserSaveReqVO {
|
||||
@DiffLogField(name = "用户昵称")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "用户类型", example = "芋艿")
|
||||
@DiffLogField(name = "用户类型")
|
||||
private String userType;
|
||||
|
||||
@Schema(description = "备注", example = "我是一个用户")
|
||||
@DiffLogField(name = "备注")
|
||||
private String remark;
|
||||
|
@ -43,6 +43,10 @@ public class AdminUserDO extends TenantBaseDO {
|
||||
* 因为目前使用 {@link BCryptPasswordEncoder} 加密器,所以无需自己处理 salt 盐
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 用户类型(数据字典system_user_type:01 员工 | 02 客户)
|
||||
*/
|
||||
private String userType;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
|
@ -32,6 +32,7 @@ import com.mzt.logapi.context.LogRecordContext;
|
||||
import com.mzt.logapi.service.impl.DiffParseFunction;
|
||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -42,6 +43,7 @@ import java.io.InputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
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.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
@ -101,6 +103,10 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class);
|
||||
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
||||
user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码
|
||||
if(StringUtils.isEmpty(user.getUserType())){
|
||||
//没传用户类型。默认员工
|
||||
user.setUserType(USER_TYPE_STAFF);
|
||||
}
|
||||
userMapper.insert(user);
|
||||
// 2.2 插入关联岗位
|
||||
if (CollectionUtil.isNotEmpty(user.getPostIds())) {
|
||||
|
Loading…
Reference in New Issue
Block a user