dev:app相关接口
parent
973b93d749
commit
ce6f71a9ac
|
|
@ -0,0 +1,74 @@
|
|||
package com.zcloud.basic.info.app;
|
||||
|
||||
|
||||
import com.alibaba.cola.dto.MultiResponse;
|
||||
import com.alibaba.cola.dto.PageResponse;
|
||||
import com.alibaba.cola.dto.Response;
|
||||
import com.alibaba.cola.dto.SingleResponse;
|
||||
import com.jjb.saas.framework.auth.model.SSOUser;
|
||||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||
import com.zcloud.basic.info.api.UserServiceI;
|
||||
import com.zcloud.basic.info.dto.*;
|
||||
import com.zcloud.basic.info.dto.clientobject.UserCO;
|
||||
import com.zcloud.basic.info.dto.clientobject.UserXmfCO;
|
||||
import com.zcloud.basic.info.plan.DockingRZUserPlanJob;
|
||||
import com.zcloud.gbscommon.translateaop.TranslateField;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* web-adapter
|
||||
*
|
||||
* @Author zhangyue
|
||||
* @Date 2025-11-04 14:07:33
|
||||
*/
|
||||
@Api(tags = "APP端用户")
|
||||
@RequestMapping("/${application.gateway}/appuser")
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class AppUserController {
|
||||
private final UserServiceI userService;
|
||||
private final TranslateField translateField;
|
||||
|
||||
@ApiOperation("验证手机号是否已注册")
|
||||
@PostMapping("/verifyPhone")
|
||||
public Response verifyPhone(@Validated @RequestBody UserVerifyPhoneCmd cmd) {
|
||||
return userService.verifyPhone(cmd);
|
||||
}
|
||||
|
||||
@ApiOperation("发送验证码")
|
||||
@PostMapping("/sendPhoneCode")
|
||||
public Response sendPhoneCode(@Validated @RequestBody UserVerifyPhoneCmd cmd) {
|
||||
return userService.sendPhoneCode(cmd);
|
||||
}
|
||||
|
||||
@ApiOperation("注册用户")
|
||||
@PostMapping("/register")
|
||||
public SingleResponse<UserCO> register(@Validated @RequestBody AppUserAddCmd cmd) {
|
||||
return userService.register(cmd);
|
||||
}
|
||||
|
||||
@ApiOperation("完善个人信息(不包括企业,部门,岗位)")
|
||||
@PostMapping("/perfectUserInfo")
|
||||
public SingleResponse<UserCO> perfectUserInfo(@Validated @RequestBody AppUserAddCmd cmd) {
|
||||
return userService.register(cmd);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("上传人脸识别图片")
|
||||
@PostMapping("/updateUserFaceUrl")
|
||||
public Response updateUserFaceUrl(@Validated @RequestBody UserUpdateFaceUrlCmd cmd){
|
||||
userService.updateUserFaceUrl(cmd);
|
||||
return SingleResponse.buildSuccess();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -144,12 +144,7 @@ public class UserController {
|
|||
return userService.getEncryInfo(userCheckPassWordCmd);
|
||||
}
|
||||
|
||||
@ApiOperation("上传人脸识别图片")
|
||||
@PostMapping("/updateUserFaceUrl")
|
||||
public Response updateUserFaceUrl(@Validated @RequestBody UserUpdateFaceUrlCmd cmd){
|
||||
userService.updateUserFaceUrl(cmd);
|
||||
return SingleResponse.buildSuccess();
|
||||
}
|
||||
|
||||
|
||||
private final DockingRZUserPlanJob dockingRZPlanJob;
|
||||
@ApiOperation("手动调用获取人资人员信息定时")
|
||||
|
|
|
|||
|
|
@ -2,25 +2,30 @@ package com.zcloud.basic.info.command;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.cola.dto.SingleResponse;
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jjb.saas.config.client.dicttree.facade.ConfDictTreeFacade;
|
||||
import com.jjb.saas.config.client.dicttree.response.ConfDictTreeCO;
|
||||
import com.jjb.saas.framework.auth.model.SSOUser;
|
||||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||
import com.jjb.saas.message.client.message.facede.MessageFacade;
|
||||
import com.jjb.saas.message.client.message.request.MessageSendCmd;
|
||||
import com.jjb.saas.message.client.message.request.MessageTargetCmd;
|
||||
import com.jjb.saas.system.client.role.response.RoleCO;
|
||||
import com.zcloud.basic.info.command.convertor.UserCoConvertor;
|
||||
import com.zcloud.basic.info.command.query.CorpInfoQueryExe;
|
||||
import com.zcloud.basic.info.domain.enums.UserFlowFlagEnum;
|
||||
import com.zcloud.basic.info.domain.gateway.*;
|
||||
import com.zcloud.basic.info.domain.model.*;
|
||||
import com.zcloud.basic.info.dto.CorpInfoAddCmd;
|
||||
import com.zcloud.basic.info.dto.UserAddCmd;
|
||||
import com.zcloud.basic.info.dto.UserXgfAddCmd;
|
||||
import com.zcloud.basic.info.dto.*;
|
||||
import com.zcloud.basic.info.persistence.dataobject.*;
|
||||
import com.zcloud.basic.info.persistence.repository.*;
|
||||
import com.zcloud.gbscommon.excelEntity.UserExcelImportEntity;
|
||||
import com.zcloud.gbscommon.utils.Tools;
|
||||
import com.zcloud.gbscommon.utils.UuidUtil;
|
||||
import com.zcloud.gbscommon.utils.ZcloudRedisUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
|
@ -100,6 +105,57 @@ public class UserAddExe {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(AppUserAddCmd cmd) {
|
||||
|
||||
UserE userE = new UserE();
|
||||
userE.checkPassword(cmd.getPassword(), cmd.getConfirmPassword());
|
||||
// 获取redis所有有效验证码
|
||||
// 如果不能对上, 提示验证码已过期或错误
|
||||
|
||||
// CorpInfoDO corpInfoDO = corpInfoRepository.getCorpInfoByCorpName("相关方通用租户");
|
||||
// if(corpInfoDO == null){
|
||||
// throw new BizException("未创建相关方通用租户");
|
||||
// }
|
||||
BeanUtils.copyProperties(cmd, userE);
|
||||
userGateway.register(userE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@DubboReference
|
||||
private final MessageFacade messageFacade;
|
||||
|
||||
// private ZcloudRedisUtil zcloudRedisUtil;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean executeSendPhoneCode(UserVerifyPhoneCmd cmd) {
|
||||
// 生成6位验证码
|
||||
String s = RandomUtil.randomString(6);
|
||||
// 放入到redis里
|
||||
// 每天每个手机号只能发20次
|
||||
|
||||
|
||||
// MessageSendCmd messageSendCmd = new MessageSendCmd();
|
||||
// messageSendCmd.setBusinessId(UuidUtil.get32UUID());
|
||||
// MessageTargetCmd messageTargetCmd = new MessageTargetCmd();
|
||||
// messageTargetCmd.setMobile("18603366337");
|
||||
// messageSendCmd.setTargetCmd(messageTargetCmd);
|
||||
// messageSendCmd.setSourceCode("MS000070");
|
||||
// Map<String, Object> sendParams = new HashMap<String, Object>();
|
||||
// sendParams.put("code", "77777");
|
||||
// messageSendCmd.setParams(sendParams);
|
||||
// SingleResponse<Boolean> d = messageFacade.send(messageSendCmd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 组装发送短信
|
||||
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean executeXgf(UserXgfAddCmd cmd) {
|
||||
SSOUser ssoUser = AuthContext.getCurrentUser();
|
||||
|
|
|
|||
|
|
@ -5,16 +5,14 @@ import com.alibaba.cola.dto.MultiResponse;
|
|||
import com.alibaba.cola.dto.PageResponse;
|
||||
import com.alibaba.cola.dto.Response;
|
||||
import com.alibaba.cola.dto.SingleResponse;
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jjb.saas.framework.auth.model.SSOUser;
|
||||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||
import com.zcloud.basic.info.command.convertor.UserCoConvertor;
|
||||
import com.zcloud.basic.info.domain.gateway.UserGateway;
|
||||
import com.zcloud.basic.info.domain.model.UserE;
|
||||
import com.zcloud.basic.info.dto.UserCheckPassWordCmd;
|
||||
import com.zcloud.basic.info.dto.UserPageQry;
|
||||
import com.zcloud.basic.info.dto.UserQryCmd;
|
||||
import com.zcloud.basic.info.dto.UserVerifyQryCmd;
|
||||
import com.zcloud.basic.info.dto.*;
|
||||
import com.zcloud.basic.info.dto.clientobject.UserCO;
|
||||
import com.zcloud.basic.info.dto.clientobject.UserXmfCO;
|
||||
import com.zcloud.basic.info.persistence.dataobject.UserCorpDO;
|
||||
|
|
@ -122,6 +120,18 @@ public class UserQueryExe {
|
|||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证手机号是否存在
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void executeVerifyPhone(UserVerifyPhoneCmd cmd) {
|
||||
List<UserDO> userDOS = userRepository.listByPhone(cmd.getPhone());
|
||||
if(CollUtil.isNotEmpty(userDOS)){
|
||||
throw new BizException("手机号已被注册。");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<UserCO> listByUserIds(Collection<Long> collection) {
|
||||
QueryWrapper<UserDO> userDOQueryWrapper = new QueryWrapper<>();
|
||||
|
|
|
|||
|
|
@ -49,6 +49,24 @@ public class UserServiceImpl implements UserServiceI {
|
|||
return SingleResponse.buildSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleResponse<UserCO> register(AppUserAddCmd cmd) {
|
||||
userAddExe.execute(cmd);
|
||||
return SingleResponse.buildSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleResponse<UserCO> verifyPhone(UserVerifyPhoneCmd cmd) {
|
||||
userQueryExe.executeVerifyPhone(cmd);
|
||||
return SingleResponse.buildSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleResponse<UserCO> sendPhoneCode(UserVerifyPhoneCmd cmd) {
|
||||
userAddExe.executeSendPhoneCode(cmd);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SingleResponse addXgf(UserXgfAddCmd cmd) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ public interface UserServiceI {
|
|||
|
||||
SingleResponse<UserCO> add(UserAddCmd cmd);
|
||||
|
||||
SingleResponse<UserCO> register(AppUserAddCmd cmd);
|
||||
|
||||
SingleResponse<UserCO> verifyPhone(UserVerifyPhoneCmd cmd);
|
||||
|
||||
SingleResponse<UserCO> sendPhoneCode(UserVerifyPhoneCmd cmd);
|
||||
|
||||
SingleResponse<UserCO> addXgf(UserXgfAddCmd cmd);
|
||||
|
||||
void edit(UserUpdateCmd cmd);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package com.zcloud.basic.info.dto;
|
||||
|
||||
import com.alibaba.cola.dto.Command;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* web-client
|
||||
*
|
||||
* @Author zhangyue
|
||||
* @Date 2025-11-04 14:07:12
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AppUserAddCmd extends Command {
|
||||
|
||||
@ApiModelProperty(value = "手机号", name = "phone")
|
||||
@NotEmpty(message = "手机号不能为空")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "密码", name = "password")
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "确认密码", name = "confirmPassword")
|
||||
@NotEmpty(message = "确认密码不能为空")
|
||||
private String confirmPassword;
|
||||
|
||||
@ApiModelProperty(value = "验证码", name = "phoneCode")
|
||||
@NotEmpty(message = "验证码不能为空")
|
||||
private String phoneCode;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.zcloud.basic.info.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
|
||||
/**
|
||||
* web-client
|
||||
*
|
||||
* @Author zhangyue
|
||||
* @Date 2025-11-04 14:07:36
|
||||
*/
|
||||
@Data
|
||||
public class UserVerifyPhoneCmd {
|
||||
|
||||
@ApiModelProperty(value = "手机号", name = "phone", required = true)
|
||||
@NotEmpty
|
||||
private String phone;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -19,6 +19,8 @@ public interface UserGateway {
|
|||
*/
|
||||
Boolean add(UserE userE);
|
||||
|
||||
Boolean register(UserE userE);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -163,6 +163,36 @@ public class UserE extends BaseE {
|
|||
userE.setPassword(defaultPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验密码是否相同, 并且是否符合规范
|
||||
*/
|
||||
public void checkPassword(String password, String confirmPassword) {
|
||||
if (!password.equals(confirmPassword)) {
|
||||
throw new BizException("两次输入的密码不一致");
|
||||
}
|
||||
if (password.length() < 8 || password.length() > 32) {
|
||||
throw new BizException("密码长度必须在8到32个字符之间");
|
||||
}
|
||||
if (!password.matches("^[A-Za-z\\d!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>/?]{8,32}$")) {
|
||||
throw new BizException("密码必须包含大小写字母和数字,且长度大于8");
|
||||
}
|
||||
|
||||
// 检查至少包含两种类型
|
||||
int typeCount = 0;
|
||||
if (password.matches(".*[A-Za-z].*")) typeCount++; // 包含字母
|
||||
if (password.matches(".*\\d.*")) typeCount++; // 包含数字
|
||||
if (password.matches(".*[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>/?].*")) typeCount++; // 包含符号
|
||||
|
||||
if (typeCount < 2) {
|
||||
throw new BizException("密码必须包含两种以上的字符类型");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*/
|
||||
|
||||
/**
|
||||
* 人员修改过程中,是否存在转岗、入职离职
|
||||
*
|
||||
|
|
|
|||
|
|
@ -34,6 +34,15 @@ public class UserGatewayImpl implements UserGateway {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean register(UserE userE) {
|
||||
UserDO d = new UserDO();
|
||||
BeanUtils.copyProperties(userE, d);
|
||||
userRepository.saveRegisterUser(d);
|
||||
userE.setId(d.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addXgf(UserE userE) {
|
||||
UserDO d = new UserDO();
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ public class UserDO extends BaseDO {
|
|||
@ApiModelProperty(value = "是否流动人员,1-流动,0-固定人员")
|
||||
private Integer flowFlag;
|
||||
//用户所属企业id
|
||||
@TableField(exist = false)
|
||||
private String userCorpId;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,5 +31,7 @@ public interface CorpInfoRepository extends BaseRepository<CorpInfoDO> {
|
|||
Long checkCorpName(Map<String, Object> parmas);
|
||||
|
||||
PageResponse<CorpInfoDO> corpUserMiddlePage(Map<String, Object> parmas);
|
||||
|
||||
CorpInfoDO getCorpInfoByCorpName(String corpName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ public interface UserRepository extends BaseRepository<UserDO> {
|
|||
|
||||
void saveUser(UserDO userDO);
|
||||
|
||||
void saveRegisterUser(UserDO userDO);
|
||||
|
||||
void updateInfoById(UserDO userDO);
|
||||
|
||||
void deleteUserById(Long id);
|
||||
|
|
@ -64,6 +66,8 @@ public interface UserRepository extends BaseRepository<UserDO> {
|
|||
|
||||
Boolean updateFaceUrl(UserDO userDO);
|
||||
|
||||
List<UserDO> listByPhone(String phone);
|
||||
|
||||
UserDO getEncryInfo(UserE userE);
|
||||
|
||||
void saveUserXgf(UserDO d);
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public class CorpInfoRepositoryImpl extends BaseRepositoryImpl<CorpInfoMapper, C
|
|||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
save(corpInfoDO);
|
||||
|
||||
}
|
||||
|
|
@ -186,5 +186,12 @@ public class CorpInfoRepositoryImpl extends BaseRepositoryImpl<CorpInfoMapper, C
|
|||
IPage<CorpInfoDO> result = corpInfoMapper.corpUserMiddlePage(iPage,params);
|
||||
return PageHelper.pageToResponse(result, result.getRecords());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CorpInfoDO getCorpInfoByCorpName(String corpName) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("corp_name", corpName);
|
||||
return corpInfoMapper.selectOne(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -216,6 +216,32 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
|||
save(userDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveRegisterUser(UserDO userDO) {
|
||||
if(StringUtils.isEmpty(userDO.getUsername())){
|
||||
userDO.setUsername(userDO.getPhone());
|
||||
}
|
||||
UserAddCmd userAddCmd = new UserAddCmd();
|
||||
userAddCmd.setAccount(userDO.getPhone());
|
||||
userAddCmd.setMobile(userDO.getPhone());
|
||||
RoleDeptAddCmd roleDeptAddCmd = new RoleDeptAddCmd();
|
||||
roleDeptAddCmd.setRoleId(0L);
|
||||
roleDeptAddCmd.setDeptId(0L);
|
||||
List<RoleDeptAddCmd> roleDeptAddCmdList = Collections.singletonList(roleDeptAddCmd);
|
||||
userAddCmd.setRoleDepts(roleDeptAddCmdList);
|
||||
|
||||
SingleResponse<Long> gbsResult = userFacade.add(userAddCmd);
|
||||
userDO.setId(gbsResult.getData());
|
||||
if(userDO.getSort() == null){
|
||||
userDO.setSort(9999);
|
||||
}
|
||||
// 新增用户默认入职待审核
|
||||
userDO.setEmploymentFlag(11);
|
||||
// 默认不是主账号
|
||||
userDO.setMainCorpFlag(0);
|
||||
save(userDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveUserXgf(UserDO userDO) {
|
||||
if(StringUtils.isEmpty(userDO.getUsername())){
|
||||
|
|
@ -354,6 +380,13 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
|||
return updateById(userDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDO> listByPhone(String phone) {
|
||||
QueryWrapper<UserDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("phone", phone);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDO getEncryInfo(UserE userE) {
|
||||
// 验证老密码是否正确
|
||||
|
|
|
|||
Loading…
Reference in New Issue