This commit is contained in:
淋雨一直走YH
2023-09-28 15:38:29 +08:00
commit 7bc57c75dc
1480 changed files with 144393 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
package mjkf.xinke.client.core.config;
import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMethod;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import mjkf.xinke.common.pojo.CommonResult;
import javax.annotation.Resource;
/**
* C端相关配置
*
*
* @date 2022/7/7 16:18
**/
@Configuration
public class ClientConfigure {
@Resource
private OpenApiExtensionResolver openApiExtensionResolver;
/**
* API文档分组配置
*
*
* @date 2022/7/7 16:18
**/
@Bean(value = "clientDocApi")
public Docket clientDocApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder()
.title("C端功能CLIENT")
.description("C端功能CLIENT")
.termsOfServiceUrl("https://www.xiaonuo.vip")
.contact(new Contact("SNOWY_TEAM","https://www.xiaonuo.vip", "xuyuxiang29@foxmail.com"))
.version("2.0.0")
.build())
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET, CommonResult.responseList())
.globalResponseMessage(RequestMethod.POST, CommonResult.responseList())
.groupName("C端功能CLIENT")
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.apis(RequestHandlerSelectors.basePackage("mjkf.xinke.client"))
.paths(PathSelectors.any())
.build().extensions(openApiExtensionResolver.buildExtensions("C端功能CLIENT"));
}
}

View File

@@ -0,0 +1,36 @@
package mjkf.xinke.client.modular.relation.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
/**
* C端关系实体
*
*
* @date 2022/4/21 16:13
**/
@Getter
@Setter
@TableName("CLIENT_RELATION")
public class ClientRelation {
/** id */
private String id;
/** 租户id */
private String tenantId;
/** 对象id */
private String objectId;
/** 目标id */
private String targetId;
/** 分类 */
private String category;
/** 扩展信息 */
private String extJson;
}

View File

@@ -0,0 +1,25 @@
package mjkf.xinke.client.modular.relation.enums;
import lombok.Getter;
/**
* C端关系分类枚举
*
*
* @date 2022/4/21 19:56
**/
@Getter
public enum ClientRelationCategoryEnum {
/* ====C端用户与其他关系==== */
/** 测试关系 */
USER_TEST("USER_TEST");
private final String value;
ClientRelationCategoryEnum(String value) {
this.value = value;
}
}

View File

@@ -0,0 +1,14 @@
package mjkf.xinke.client.modular.relation.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import mjkf.xinke.client.modular.relation.entity.ClientRelation;
/**
* C端关系Mapper接口
*
*
* @date 2022/4/21 18:37
**/
public interface ClientRelationMapper extends BaseMapper<ClientRelation> {
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="mjkf.xinke.client.modular.relation.mapper.ClientRelationMapper">
</mapper>

View File

@@ -0,0 +1,208 @@
package mjkf.xinke.client.modular.relation.service;
import com.baomidou.mybatisplus.extension.service.IService;
import mjkf.xinke.client.modular.relation.entity.ClientRelation;
import java.util.List;
/**
* C端关系Service接口
*
*
* @date 2022/4/21 18:35
**/
public interface ClientRelationService extends IService<ClientRelation> {
/**
* 追加关系
*
*
* @date 2022/4/24 22:29
*/
void saveRelationWithAppend(String objectId, String targetId, String category);
/**
* 追加关系
*
*
* @date 2022/4/24 22:29
*/
void saveRelationWithAppend(String objectId, String targetId, String category, String extJson);
/**
* 批量追加关系
*
*
* @date 2022/4/24 22:29
*/
void saveRelationBatchWithAppend(String objectId, List<String> targetIdList, String category);
/**
* 批量追加关系
*
*
* @date 2022/4/24 22:29
*/
void saveRelationBatchWithAppend(String objectId, List<String> targetIdList, String category, List<String> extJsonList);
/**
* 清空原关系并保存关系
*
*
* @date 2022/4/24 22:29
*/
void saveRelationWithClear(String objectId, String targetId, String category);
/**
* 清空原关系并保存关系
*
*
* @date 2022/4/24 22:29
*/
void saveRelationWithClear(String objectId, String targetId, String category, String extJson);
/**
* 清空原关系并批量保存关系
*
*
* @date 2022/4/24 22:29
*/
void saveRelationBatchWithClear(String objectId, List<String> targetIdList, String category);
/**
* 清空原关系并批量保存关系
*
*
* @date 2022/4/24 22:29
*/
void saveRelationBatchWithClear(String objectId, List<String> targetIdList, String category, List<String> extJsonList);
/**
* 根据对象id获取关系列表
*
*
* @date 2022/4/27 22:06
*/
List<ClientRelation> getRelationListByObjectId(String objectId);
/**
* 根据对象id集合获取关系列表
*
*
* @date 2022/4/27 22:06
*/
List<ClientRelation> getRelationListByObjectIdList(List<String> objectIdList);
/**
* 根据对象id和关系分类获取关系列表
*
*
* @date 2022/4/27 22:06
*/
List<ClientRelation> getRelationListByObjectIdAndCategory(String objectId, String category);
/**
* 根据对象id集合和关系分类获取关系列表
*
*
* @date 2022/4/27 22:06
*/
List<ClientRelation> getRelationListByObjectIdListAndCategory(List<String> objectIdList, String category);
/**
* 根据目标id获取关系列表
*
*
* @date 2022/4/27 22:06
*/
List<ClientRelation> getRelationListByTargetId(String targetId);
/**
* 根据目标id集合获取关系列表
*
*
* @date 2022/4/27 22:06
*/
List<ClientRelation> getRelationListByTargetIdList(List<String> targetIdList);
/**
* 根据目标id和关系分类获取关系列表
*
*
* @date 2022/4/27 22:06
*/
List<ClientRelation> getRelationListByTargetIdAndCategory(String targetId, String category);
/**
* 根据目标id集合和关系分类获取关系列表
*
*
* @date 2022/4/27 22:06
*/
List<ClientRelation> getRelationListByTargetIdListAndCategory(List<String> targetIdList, String category);
/**
* 根据对象id获取目标id列表
*
*
* @date 2022/4/27 22:07
*/
List<String> getRelationTargetIdListByObjectId(String objectId);
/**
* 根据对象id集合获取目标id列表
*
*
* @date 2022/4/27 22:07
*/
List<String> getRelationTargetIdListByObjectIdList(List<String> objectIdList);
/**
* 根据对象id和关系分类获取目标id列表
*
*
* @date 2022/4/27 22:07
*/
List<String> getRelationTargetIdListByObjectIdAndCategory(String objectId, String category);
/**
* 根据对象id集合和关系分类获取目标id列表
*
*
* @date 2022/4/27 22:07
*/
List<String> getRelationTargetIdListByObjectIdListAndCategory(List<String> objectIdList, String category);
/**
* 根据目标id获取对象id列表
*
*
* @date 2022/4/27 22:07
*/
List<String> getRelationObjectIdListByTargetId(String targetId);
/**
* 根据目标id集合获取对象id列表
*
*
* @date 2022/4/27 22:07
*/
List<String> getRelationObjectIdListByTargetIdList(List<String> targetIdList);
/**
* 根据目标id和关系分类获取对象id列表
*
*
* @date 2022/4/27 22:08
*/
List<String> getRelationObjectIdListByTargetIdAndCategory(String targetId, String category);
/**
* 根据目标id集合和关系分类获取对象id列表
*
*
* @date 2022/4/27 22:08
*/
List<String> getRelationObjectIdListByTargetIdListAndCategory(List<String> targetIdList, String category);
}

View File

@@ -0,0 +1,207 @@
package mjkf.xinke.client.modular.relation.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import mjkf.xinke.client.modular.relation.entity.ClientRelation;
import mjkf.xinke.client.modular.relation.mapper.ClientRelationMapper;
import mjkf.xinke.client.modular.relation.service.ClientRelationService;
import java.util.List;
import java.util.stream.Collectors;
/**
* C端关系Service接口实现类
*
*
* @date 2022/2/23 18:43
**/
@Service
public class ClientRelationServiceImpl extends ServiceImpl<ClientRelationMapper, ClientRelation> implements ClientRelationService {
@Transactional(rollbackFor = Exception.class)
public void saveRelation(String objectId, String targetId, String category, String extJson, boolean clear) {
// 是否需要先删除关系
if(clear) {
this.remove(new LambdaQueryWrapper<ClientRelation>().eq(ClientRelation::getObjectId, objectId)
.eq(ClientRelation::getCategory, category));
}
ClientRelation clientRelation = new ClientRelation();
clientRelation.setObjectId(objectId);
clientRelation.setTargetId(targetId);
clientRelation.setCategory(category);
clientRelation.setExtJson(extJson);
this.save(clientRelation);
}
@Transactional(rollbackFor = Exception.class)
public void saveRelationBatch(String objectId, List<String> targetIdList, String category, List<String> extJsonList, boolean clear) {
// 是否需要先删除关系
if(clear) {
this.remove(new LambdaQueryWrapper<ClientRelation>().eq(ClientRelation::getObjectId, objectId)
.eq(ClientRelation::getCategory, category));
}
List<ClientRelation> clientRelationList = CollectionUtil.newArrayList();
for(int i = 0; i < targetIdList.size(); i++) {
ClientRelation clientRelation = new ClientRelation();
clientRelation.setObjectId(objectId);
clientRelation.setTargetId(targetIdList.get(i));
clientRelation.setCategory(category);
if(ObjectUtil.isNotEmpty(extJsonList)) {
clientRelation.setExtJson(extJsonList.get(i));
}
clientRelationList.add(clientRelation);
}
if(ObjectUtil.isNotEmpty(clientRelationList)) {
this.saveBatch(clientRelationList);
}
}
@Override
public void saveRelationWithAppend(String objectId, String targetId, String category) {
this.saveRelation(objectId, targetId, category, null, false);
}
@Override
public void saveRelationWithAppend(String objectId, String targetId, String category, String extJson) {
this.saveRelation(objectId, targetId, category, extJson, false);
}
@Override
public void saveRelationBatchWithAppend(String objectId, List<String> targetIdList, String category) {
this.saveRelationBatch(objectId, targetIdList, category, null, false);
}
@Override
public void saveRelationBatchWithAppend(String objectId, List<String> targetIdList, String category, List<String> extJsonList) {
this.saveRelationBatch(objectId, targetIdList, category, extJsonList, false);
}
@Override
public void saveRelationWithClear(String objectId, String targetId, String category) {
this.saveRelation(objectId, targetId, category, null, true);
}
@Override
public void saveRelationWithClear(String objectId, String targetId, String category, String extJson) {
this.saveRelation(objectId, targetId, category, extJson, true);
}
@Override
public void saveRelationBatchWithClear(String objectId, List<String> targetIdList, String category) {
this.saveRelationBatch(objectId, targetIdList, category, null, true);
}
@Override
public void saveRelationBatchWithClear(String objectId, List<String> targetIdList, String category, List<String> extJsonList) {
this.saveRelationBatch(objectId, targetIdList, category, extJsonList, true);
}
@Override
public List<ClientRelation> getRelationListByObjectId(String objectId) {
return this.getRelationListByObjectIdAndCategory(objectId, null);
}
@Override
public List<ClientRelation> getRelationListByObjectIdList(List<String> objectIdList) {
return this.getRelationListByObjectIdListAndCategory(objectIdList, null);
}
@Override
public List<ClientRelation> getRelationListByObjectIdAndCategory(String objectId, String category) {
LambdaQueryWrapper<ClientRelation> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ClientRelation::getObjectId, objectId);
if(ObjectUtil.isNotEmpty(category)) {
lambdaQueryWrapper.eq(ClientRelation::getCategory, category);
}
return this.list(lambdaQueryWrapper);
}
@Override
public List<ClientRelation> getRelationListByObjectIdListAndCategory(List<String> objectIdList, String category) {
LambdaQueryWrapper<ClientRelation> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(ClientRelation::getObjectId, objectIdList);
if(ObjectUtil.isNotEmpty(category)) {
lambdaQueryWrapper.eq(ClientRelation::getCategory, category);
}
return this.list(lambdaQueryWrapper);
}
@Override
public List<ClientRelation> getRelationListByTargetId(String targetId) {
return this.getRelationListByTargetIdAndCategory(targetId, null);
}
@Override
public List<ClientRelation> getRelationListByTargetIdList(List<String> targetIdList) {
return this.getRelationListByTargetIdListAndCategory(targetIdList, null);
}
@Override
public List<ClientRelation> getRelationListByTargetIdAndCategory(String targetId, String category) {
LambdaQueryWrapper<ClientRelation> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ClientRelation::getTargetId, targetId);
if(ObjectUtil.isNotEmpty(category)) {
lambdaQueryWrapper.eq(ClientRelation::getCategory, category);
}
return this.list(lambdaQueryWrapper);
}
@Override
public List<ClientRelation> getRelationListByTargetIdListAndCategory(List<String> targetIdList, String category) {
LambdaQueryWrapper<ClientRelation> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(ClientRelation::getTargetId, targetIdList);
if(ObjectUtil.isNotEmpty(category)) {
lambdaQueryWrapper.eq(ClientRelation::getCategory, category);
}
return this.list(lambdaQueryWrapper);
}
@Override
public List<String> getRelationTargetIdListByObjectId(String objectId) {
return this.getRelationTargetIdListByObjectIdAndCategory(objectId, null);
}
@Override
public List<String> getRelationTargetIdListByObjectIdList(List<String> objectIdList) {
return this.getRelationTargetIdListByObjectIdListAndCategory(objectIdList, null);
}
@Override
public List<String> getRelationTargetIdListByObjectIdAndCategory(String objectId, String category) {
return this.getRelationListByObjectIdAndCategory(objectId, category).stream()
.map(ClientRelation::getTargetId).collect(Collectors.toList());
}
@Override
public List<String> getRelationTargetIdListByObjectIdListAndCategory(List<String> objectIdList, String category) {
return this.getRelationListByObjectIdListAndCategory(objectIdList, category).stream()
.map(ClientRelation::getTargetId).collect(Collectors.toList());
}
@Override
public List<String> getRelationObjectIdListByTargetId(String targetId) {
return this.getRelationObjectIdListByTargetIdAndCategory(targetId, null);
}
@Override
public List<String> getRelationObjectIdListByTargetIdList(List<String> targetIdList) {
return this.getRelationObjectIdListByTargetIdListAndCategory(targetIdList, null);
}
@Override
public List<String> getRelationObjectIdListByTargetIdAndCategory(String targetId, String category) {
return this.getRelationListByTargetIdAndCategory(targetId, category).stream()
.map(ClientRelation::getObjectId).collect(Collectors.toList());
}
@Override
public List<String> getRelationObjectIdListByTargetIdListAndCategory(List<String> targetIdList, String category) {
return this.getRelationListByTargetIdListAndCategory(targetIdList, category).stream()
.map(ClientRelation::getObjectId).collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,114 @@
package mjkf.xinke.client.modular.user.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import mjkf.xinke.client.modular.user.entity.ClientUser;
import mjkf.xinke.client.modular.user.param.ClientUserAddParam;
import mjkf.xinke.client.modular.user.param.ClientUserEditParam;
import mjkf.xinke.client.modular.user.param.ClientUserIdParam;
import mjkf.xinke.client.modular.user.param.ClientUserPageParam;
import mjkf.xinke.client.modular.user.service.ClientUserService;
import mjkf.xinke.common.annotation.CommonLog;
import mjkf.xinke.common.pojo.CommonResult;
import mjkf.xinke.common.pojo.CommonValidList;
import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
/**
* C端用户控制器
*
*
* @date 2022/4/22 9:34
**/
@Api(tags = "C端用户控制器")
@ApiSupport(author = "SNOWY_TEAM", order = 1)
@RestController
@Validated
public class ClientUserController {
@Resource
private ClientUserService clientUserService;
/**
* 获取C端用户分页
*
*
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 1)
@ApiOperation("获取C端用户分页")
@GetMapping("/client/user/page")
public CommonResult<Page<ClientUser>> page(ClientUserPageParam clientUserPageParam) {
return CommonResult.data(clientUserService.page(clientUserPageParam));
}
/**
* 添加C端用户
*
*
* @date 2022/4/24 20:47
*/
@ApiOperationSupport(order = 2)
@ApiOperation("添加C端用户")
@CommonLog("添加C端用户")
@PostMapping("/client/user/add")
public CommonResult<String> add(@RequestBody @Valid ClientUserAddParam clientUserAddParam) {
clientUserService.add(clientUserAddParam);
return CommonResult.ok();
}
/**
* 编辑C端用户
*
*
* @date 2022/4/24 20:47
*/
@ApiOperationSupport(order = 3)
@ApiOperation("编辑C端用户")
@CommonLog("编辑C端用户")
@PostMapping("/client/user/edit")
public CommonResult<String> edit(@RequestBody @Valid ClientUserEditParam clientUserEditParam) {
clientUserService.edit(clientUserEditParam);
return CommonResult.ok();
}
/**
* 删除C端用户
*
*
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 4)
@ApiOperation("删除C端用户")
@CommonLog("删除C端用户")
@PostMapping("/client/user/delete")
public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
CommonValidList<ClientUserIdParam> clientUserIdParamList) {
clientUserService.delete(clientUserIdParamList);
return CommonResult.ok();
}
/**
* 获取C端用户详情
*
*
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 5)
@ApiOperation("获取C端用户详情")
@GetMapping("/client/user/detail")
public CommonResult<ClientUser> detail(@Valid ClientUserIdParam clientUserIdParam) {
return CommonResult.data(clientUserService.detail(clientUserIdParam));
}
}

View File

@@ -0,0 +1,219 @@
package mjkf.xinke.client.modular.user.entity;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fhs.core.trans.anno.Trans;
import com.fhs.core.trans.constant.TransType;
import com.fhs.core.trans.vo.TransPojo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import mjkf.xinke.common.handler.CommonSm4CbcTypeHandler;
import mjkf.xinke.common.pojo.CommonEntity;
import java.util.Date;
/**
* C端用户实体
*
*
* @date 2022/4/21 16:13
**/
@Getter
@Setter
@TableName(value = "CLIENT_USER", autoResultMap = true)
public class ClientUser extends CommonEntity implements TransPojo {
/** id */
@ApiModelProperty(value = "id", position = 1)
private String id;
/** 租户id */
@ApiModelProperty(value = "租户id", position = 2)
private String tenantId;
/** 头像 */
@ApiModelProperty(value = "头像图片base64", position = 3)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String avatar;
/** 签名 */
@ApiModelProperty(value = "签名图片base64", position = 4)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String signature;
/** 账号 */
@ApiModelProperty(value = "账号", position = 5)
private String account;
/** 密码 */
@ApiModelProperty(value = "密码", position = 6)
private String password;
/** 姓名 */
@ApiModelProperty(value = "姓名", position = 7)
private String name;
/** 昵称 */
@ApiModelProperty(value = "昵称", position = 8)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String nickname;
/** 性别 */
@ApiModelProperty(value = "性别", position = 9)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
@Trans(type = TransType.DICTIONARY, key = "GENDER")
private String gender;
/** 年龄 */
@ApiModelProperty(value = "年龄", position = 10)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String age;
/** 出生日期 */
@ApiModelProperty(value = "出生日期", position = 11)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String birthday;
/** 民族 */
@ApiModelProperty(value = "民族", position = 12)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String nation;
/** 籍贯 */
@ApiModelProperty(value = "籍贯", position = 13)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String nativePlace;
/** 家庭住址 */
@ApiModelProperty(value = "家庭住址", position = 14)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String homeAddress;
/** 通信地址 */
@ApiModelProperty(value = "通信地址", position = 15)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String mailingAddress;
/** 证件类型 */
@ApiModelProperty(value = "证件类型", position = 16)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String idCardType;
/** 证件号码 */
@ApiModelProperty(value = "证件号码", position = 17)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED, typeHandler = CommonSm4CbcTypeHandler.class)
private String idCardNumber;
/** 文化程度 */
@ApiModelProperty(value = "文化程度", position = 18)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String cultureLevel;
/** 政治面貌 */
@ApiModelProperty(value = "政治面貌", position = 19)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String politicalOutlook;
/** 毕业院校 */
@ApiModelProperty(value = "毕业院校", position = 20)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String college;
/** 学历 */
@ApiModelProperty(value = "学历", position = 21)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String education;
/** 学制 */
@ApiModelProperty(value = "学制", position = 22)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String eduLength;
/** 学位 */
@ApiModelProperty(value = "学位", position = 23)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String degree;
/** 手机 */
@ApiModelProperty(value = "手机", position = 24)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED, typeHandler = CommonSm4CbcTypeHandler.class)
private String phone;
/** 邮箱 */
@ApiModelProperty(value = "邮箱", position = 25)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String email;
/** 家庭电话 */
@ApiModelProperty(value = "家庭电话", position = 26)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String homeTel;
/** 办公电话 */
@ApiModelProperty(value = "办公电话", position = 27)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String officeTel;
/** 紧急联系人 */
@ApiModelProperty(value = "紧急联系人", position = 28)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String emergencyContact;
/** 紧急联系人电话 */
@ApiModelProperty(value = "紧急联系人电话", position = 29)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED, typeHandler = CommonSm4CbcTypeHandler.class)
private String emergencyPhone;
/** 紧急联系人地址 */
@ApiModelProperty(value = "紧急联系人地址", position = 30)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String emergencyAddress;
/** 上次登录ip */
@ApiModelProperty(value = "上次登录ip", position = 31)
private String lastLoginIp;
/** 上次登录地点 */
@ApiModelProperty(value = "上次登录地点", position = 32)
private String lastLoginAddress;
/** 上次登录时间 */
@ApiModelProperty(value = "上次登录时间", position = 33)
private Date lastLoginTime;
/** 上次登录设备 */
@ApiModelProperty(value = "上次登录设备", position = 34)
private String lastLoginDevice;
/** 最新登录ip */
@ApiModelProperty(value = "最新登录ip", position = 35)
private String latestLoginIp;
/** 最新登录地点 */
@ApiModelProperty(value = "最新登录地点", position = 36)
private String latestLoginAddress;
/** 最新登录时间 */
@ApiModelProperty(value = "最新登录时间", position = 37)
private Date latestLoginTime;
/** 最新登录设备 */
@ApiModelProperty(value = "最新登录设备", position = 38)
private String latestLoginDevice;
/** 用户状态 */
@ApiModelProperty(value = "用户状态", position = 39)
private String userStatus;
/** 排序码 */
@ApiModelProperty(value = "排序码", position = 40)
private Integer sortCode;
/** 扩展信息 */
@ApiModelProperty(value = "扩展信息", position = 41)
@TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
private String extJson;
}

View File

@@ -0,0 +1,38 @@
package mjkf.xinke.client.modular.user.enums;
import lombok.Getter;
import mjkf.xinke.common.exception.CommonException;
/**
* C端用户状态枚举
*
*
* @date 2022/4/27 21:47
*/
@Getter
public enum ClientUserStatusEnum {
/**
* 正常
*/
ENABLE("ENABLE"),
/**
* 停用
*/
DISABLED("DISABLED");
private final String value;
ClientUserStatusEnum(String value) {
this.value = value;
}
public static void validate(String value) {
boolean flag = ENABLE.getValue().equals(value) || DISABLED.getValue().equals(value);
if(!flag) {
throw new CommonException("不支持的C端用户状态{}", value);
}
}
}

View File

@@ -0,0 +1,14 @@
package mjkf.xinke.client.modular.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import mjkf.xinke.client.modular.user.entity.ClientUser;
/**
* C端用户Mapper接口
*
*
* @date 2022/4/21 18:37
**/
public interface ClientUserMapper extends BaseMapper<ClientUser> {
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="mjkf.xinke.client.modular.user.mapper.ClientUserMapper">
</mapper>

View File

@@ -0,0 +1,137 @@
package mjkf.xinke.client.modular.user.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
/**
* C端用户添加参数
*
*
* @date 2022/4/21 16:13
**/
@Getter
@Setter
public class ClientUserAddParam {
/** 账号 */
@ApiModelProperty(value = "账号", required = true, position = 1)
@NotBlank(message = "account不能为空")
private String account;
/** 姓名 */
@ApiModelProperty(value = "姓名", required = true, position = 2)
@NotBlank(message = "name不能为空")
private String name;
/** 头像 */
@ApiModelProperty(value = "头像图片base64", position = 3)
private String avatar;
/** 签名 */
@ApiModelProperty(value = "签名图片base64", position = 4)
private String signature;
/** 昵称 */
@ApiModelProperty(value = "昵称", position = 7)
private String nickname;
/** 性别 */
@ApiModelProperty(value = "性别", position = 8)
private String gender;
/** 年龄 */
@ApiModelProperty(value = "年龄", position = 9)
private String age;
/** 出生日期 */
@ApiModelProperty(value = "出生日期", position = 10)
private String birthday;
/** 民族 */
@ApiModelProperty(value = "民族", position = 11)
private String nation;
/** 籍贯 */
@ApiModelProperty(value = "籍贯", position = 12)
private String nativePlace;
/** 家庭住址 */
@ApiModelProperty(value = "家庭住址", position = 13)
private String homeAddress;
/** 通信地址 */
@ApiModelProperty(value = "通信地址", position = 14)
private String mailingAddress;
/** 证件类型 */
@ApiModelProperty(value = "证件类型", position = 15)
private String idCardType;
/** 证件号码 */
@ApiModelProperty(value = "证件号码", position = 16)
private String idCardNumber;
/** 文化程度 */
@ApiModelProperty(value = "文化程度", position = 17)
private String cultureLevel;
/** 政治面貌 */
@ApiModelProperty(value = "政治面貌", position = 18)
private String politicalOutlook;
/** 毕业院校 */
@ApiModelProperty(value = "毕业院校", position = 19)
private String college;
/** 学历 */
@ApiModelProperty(value = "学历", position = 20)
private String education;
/** 学制 */
@ApiModelProperty(value = "学制", position = 21)
private String eduLength;
/** 学位 */
@ApiModelProperty(value = "学位", position = 22)
private String degree;
/** 手机 */
@ApiModelProperty(value = "手机", position = 23)
private String phone;
/** 邮箱 */
@ApiModelProperty(value = "邮箱", position = 24)
private String email;
/** 家庭电话 */
@ApiModelProperty(value = "家庭电话", position = 25)
private String homeTel;
/** 办公电话 */
@ApiModelProperty(value = "办公电话", position = 26)
private String officeTel;
/** 紧急联系人 */
@ApiModelProperty(value = "紧急联系人", position = 27)
private String emergencyContact;
/** 紧急联系人电话 */
@ApiModelProperty(value = "紧急联系人电话", position = 28)
private String emergencyPhone;
/** 紧急联系人地址 */
@ApiModelProperty(value = "紧急联系人地址", position = 29)
private String emergencyAddress;
/** 排序码 */
@ApiModelProperty(value = "排序码", position = 30)
private Integer sortCode;
/** 扩展信息 */
@ApiModelProperty(value = "扩展信息", position = 31)
private String extJson;
}

View File

@@ -0,0 +1,142 @@
package mjkf.xinke.client.modular.user.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
/**
* C端用户参数
*
*
* @date 2022/4/21 16:13
**/
@Getter
@Setter
public class ClientUserEditParam {
/** id */
@ApiModelProperty(value = "id", required = true, position = 1)
@NotBlank(message = "id不能为空")
private String id;
/** 账号 */
@ApiModelProperty(value = "账号", required = true, position = 2)
@NotBlank(message = "account不能为空")
private String account;
/** 姓名 */
@ApiModelProperty(value = "姓名", required = true, position = 3)
@NotBlank(message = "name不能为空")
private String name;
/** 头像 */
@ApiModelProperty(value = "头像图片base64", position = 4)
private String avatar;
/** 签名 */
@ApiModelProperty(value = "签名图片base64", position = 5)
private String signature;
/** 昵称 */
@ApiModelProperty(value = "昵称", position = 7)
private String nickname;
/** 性别 */
@ApiModelProperty(value = "性别", position = 8)
private String gender;
/** 年龄 */
@ApiModelProperty(value = "年龄", position = 9)
private String age;
/** 出生日期 */
@ApiModelProperty(value = "出生日期", position = 10)
private String birthday;
/** 民族 */
@ApiModelProperty(value = "民族", position = 11)
private String nation;
/** 籍贯 */
@ApiModelProperty(value = "籍贯", position = 12)
private String nativePlace;
/** 家庭住址 */
@ApiModelProperty(value = "家庭住址", position = 13)
private String homeAddress;
/** 通信地址 */
@ApiModelProperty(value = "通信地址", position = 14)
private String mailingAddress;
/** 证件类型 */
@ApiModelProperty(value = "证件类型", position = 15)
private String idCardType;
/** 证件号码 */
@ApiModelProperty(value = "证件号码", position = 16)
private String idCardNumber;
/** 文化程度 */
@ApiModelProperty(value = "文化程度", position = 17)
private String cultureLevel;
/** 政治面貌 */
@ApiModelProperty(value = "政治面貌", position = 18)
private String politicalOutlook;
/** 毕业院校 */
@ApiModelProperty(value = "毕业院校", position = 19)
private String college;
/** 学历 */
@ApiModelProperty(value = "学历", position = 20)
private String education;
/** 学制 */
@ApiModelProperty(value = "学制", position = 21)
private String eduLength;
/** 学位 */
@ApiModelProperty(value = "学位", position = 22)
private String degree;
/** 手机 */
@ApiModelProperty(value = "手机", position = 23)
private String phone;
/** 邮箱 */
@ApiModelProperty(value = "邮箱", position = 24)
private String email;
/** 家庭电话 */
@ApiModelProperty(value = "家庭电话", position = 25)
private String homeTel;
/** 办公电话 */
@ApiModelProperty(value = "办公电话", position = 26)
private String officeTel;
/** 紧急联系人 */
@ApiModelProperty(value = "紧急联系人", position = 27)
private String emergencyContact;
/** 紧急联系人电话 */
@ApiModelProperty(value = "紧急联系人电话", position = 28)
private String emergencyPhone;
/** 紧急联系人地址 */
@ApiModelProperty(value = "紧急联系人地址", position = 29)
private String emergencyAddress;
/** 排序码 */
@ApiModelProperty(value = "排序码", position = 30)
private Integer sortCode;
/** 扩展信息 */
@ApiModelProperty(value = "扩展信息", position = 31)
private String extJson;
}

View File

@@ -0,0 +1,24 @@
package mjkf.xinke.client.modular.user.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
/**
* C端用户Id参数
*
*
* @date 2022/4/21 16:13
**/
@Getter
@Setter
public class ClientUserIdParam {
/** id */
@ApiModelProperty(value = "id", required = true)
@NotBlank(message = "id不能为空")
private String id;
}

View File

@@ -0,0 +1,37 @@
package mjkf.xinke.client.modular.user.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* C端用户参数
*
*
* @date 2022/4/21 16:13
**/
@Getter
@Setter
public class ClientUserPageParam {
/** 当前页 */
@ApiModelProperty(value = "当前页码")
private Integer current;
/** 每页条数 */
@ApiModelProperty(value = "每页条数")
private Integer size;
/** 排序字段 */
@ApiModelProperty(value = "排序字段字段驼峰名称userName")
private String sortField;
/** 排序方式 */
@ApiModelProperty(value = "排序方式升序ASCEND降序DESCEND")
private String sortOrder;
/** 账号、姓名关键词 */
@ApiModelProperty(value = "账号、姓名关键词")
private String searchKey;
}

View File

@@ -0,0 +1,165 @@
package mjkf.xinke.client.modular.user.provider;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.springframework.stereotype.Service;
import mjkf.xinke.auth.api.SaBaseLoginUserApi;
import mjkf.xinke.auth.core.pojo.SaBaseClientLoginUser;
import mjkf.xinke.auth.core.pojo.SaBaseLoginUser;
import mjkf.xinke.client.modular.user.result.ClientLoginUser;
import mjkf.xinke.client.modular.user.service.ClientUserService;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
* C端登录用户API接口实现类
*
*
* @date 2022/4/29 13:36
**/
@Service("clientLoginUserApi")
public class ClientLoginUserApiProvider implements SaBaseLoginUserApi {
@Resource
private ClientUserService clientUserService;
/**
* 不实现B端用户信息
*
*
* @date 2022/7/8 10:36
**/
@Override
public SaBaseLoginUser getUserById(String id) {
return null;
}
/**
* 根据id获取C端用户信息查不到则返回null
*
*
* @date 2021/12/28 15:35
**/
@Override
public SaBaseClientLoginUser getClientUserById(String id) {
return clientUserService.getUserById(id);
}
/**
* 不实现B端用户信息
*
*
* @date 2022/7/8 10:36
**/
@Override
public SaBaseLoginUser getUserByAccount(String account) {
return null;
}
/**
* 根据账号获取C端用户信息查不到则返回null
*
*
* @date 2021/12/28 15:35
**/
@Override
public ClientLoginUser getClientUserByAccount(String account) {
return clientUserService.getUserByAccount(account);
}
/**
* 不实现B端用户信息
*
*
* @date 2022/8/25 14:08
**/
@Override
public SaBaseLoginUser getUserByPhone(String phone) {
return null;
}
/**
* 根据手机号获取C端用户信息查不到则返回null
*
*
* @date 2022/8/25 14:08
**/
@Override
public SaBaseClientLoginUser getClientUserByPhone(String phone) {
return clientUserService.getUserByPhone(phone);
}
/**
* 根据用户id获取用户集合
*
*
* @date 2022/4/27 22:53
*/
@Override
public List<JSONObject> listUserByUserIdList(List<String> userIdList) {
return clientUserService.listByIds(userIdList).stream().map(JSONUtil::parseObj).collect(Collectors.toList());
}
/**
* 根据用户id获取角色集合
*
*
* @date 2022/4/27 22:53
*/
@Override
public List<JSONObject> getRoleListByUserId(String userId) {
// TODO C端用户暂无角色
return CollectionUtil.newArrayList();
}
/**
* 根据角色id和用户id集合获取按钮码集合
*
*
* @date 2022/4/27 22:54
*/
@Override
public List<String> getButtonCodeListListByUserAndRoleIdList(List<String> userAndRoleIdList) {
// TODO C端用户暂无按钮码
return CollectionUtil.newArrayList();
}
/**
* 根据角色id和用户id集合获取移动端按钮码集合
*
*
* @date 2022/4/27 22:54
*/
@Override
public List<String> getMobileButtonCodeListListByUserIdAndRoleIdList(List<String> userAndRoleIdList) {
// TODO C端用户暂无移动端按钮码
return CollectionUtil.newArrayList();
}
/**
* 根据角色id和用户id集合获取权限集合
*
*
* @date 2022/4/27 22:54
*/
@Override
public List<JSONObject> getPermissionListByUserIdAndRoleIdList(List<String> userAndRoleIdList, String orgId) {
// TODO C端用户暂无权限码
return CollectionUtil.newArrayList();
}
/**
* 更新用户的登录时间和登录ip等信息
*
*
* @date 2022/4/27 22:57
*/
@Override
public void updateUserLoginInfo(String userId, String device) {
clientUserService.updateUserLoginInfo(userId, device);
}
}

View File

@@ -0,0 +1,26 @@
package mjkf.xinke.client.modular.user.result;
import mjkf.xinke.auth.core.pojo.SaBaseClientLoginUser;
import mjkf.xinke.client.modular.user.enums.ClientUserStatusEnum;
/**
* C端登录用户对象
*
*
* @date 2022/4/21 19:33
**/
public class ClientLoginUser extends SaBaseClientLoginUser {
/**
* 实现是否可以登录
*
*
* @date 2022/8/15 15:27
**/
@Override
public Boolean getEnabled() {
// 仅判断状态是否正常,可自行扩展
return this.getUserStatus().equals(ClientUserStatusEnum.ENABLE.getValue());
}
}

View File

@@ -0,0 +1,110 @@
package mjkf.xinke.client.modular.user.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import mjkf.xinke.client.modular.user.entity.ClientUser;
import mjkf.xinke.client.modular.user.param.ClientUserAddParam;
import mjkf.xinke.client.modular.user.param.ClientUserEditParam;
import mjkf.xinke.client.modular.user.param.ClientUserIdParam;
import mjkf.xinke.client.modular.user.param.ClientUserPageParam;
import mjkf.xinke.client.modular.user.result.ClientLoginUser;
import java.util.List;
/**
* C端用户Service接口
*
*
* @date 2022/4/21 18:35
**/
public interface ClientUserService extends IService<ClientUser> {
/**
* 根据id获取用户信息查不到则返回null
*
*
* @date 2022/4/27 21:38
*/
ClientLoginUser getUserById(String id);
/**
* 根据账户获取用户信息查不到则返回null
*
*
* @date 2022/4/27 21:38
*/
ClientLoginUser getUserByAccount(String account);
/**
* 根据手机号获取用户信息查不到则返回null
*
*
* @date 2022/4/27 21:38
*/
ClientLoginUser getUserByPhone(String phone);
/**
* 根据邮箱获取用户信息查不到则返回null
*
*
* @date 2022/4/27 21:38
*/
ClientLoginUser getUserByEmail(String email);
/**
* 获取C端用户分页
*
*
* @date 2022/4/24 20:08
*/
Page<ClientUser> page(ClientUserPageParam clientUserPageParam);
/**
* 添加C端用户
*
*
* @date 2022/4/24 20:48
*/
void add(ClientUserAddParam clientUserAddParam);
/**
* 编辑C端用户
*
*
* @date 2022/4/24 21:13
*/
void edit(ClientUserEditParam clientUserEditParam);
/**
* 删除C端用户
*
*
* @date 2022/4/24 21:18
*/
void delete(List<ClientUserIdParam> clientUserIdParamList);
/**
* 获取C端用户详情
*
*
* @date 2022/4/24 21:18
*/
ClientUser detail(ClientUserIdParam clientUserIdParam);
/**
* 更新C端用户的登录时间和登录ip等信息
*
*
* @date 2022/4/27 22:58
*/
void updateUserLoginInfo(String userId, String device);
/**
* 获取C端用户详情
*
*
* @date 2022/4/24 21:18
*/
ClientUser queryEntity(String id);
}

View File

@@ -0,0 +1,224 @@
package mjkf.xinke.client.modular.user.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollStreamUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.PhoneUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fhs.trans.service.impl.TransService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import mjkf.xinke.client.modular.relation.service.ClientRelationService;
import mjkf.xinke.client.modular.user.entity.ClientUser;
import mjkf.xinke.client.modular.user.enums.ClientUserStatusEnum;
import mjkf.xinke.client.modular.user.mapper.ClientUserMapper;
import mjkf.xinke.client.modular.user.param.ClientUserAddParam;
import mjkf.xinke.client.modular.user.param.ClientUserEditParam;
import mjkf.xinke.client.modular.user.param.ClientUserIdParam;
import mjkf.xinke.client.modular.user.param.ClientUserPageParam;
import mjkf.xinke.client.modular.user.result.ClientLoginUser;
import mjkf.xinke.client.modular.user.service.ClientUserService;
import mjkf.xinke.common.enums.CommonSortOrderEnum;
import mjkf.xinke.common.exception.CommonException;
import mjkf.xinke.common.page.CommonPageRequest;
import mjkf.xinke.common.util.*;
import mjkf.xinke.dev.api.DevConfigApi;
import javax.annotation.Resource;
import java.util.List;
/**
* C端用户Service接口实现类
*
*
* @date 2022/2/23 18:43
**/
@Service
public class ClientUserServiceImpl extends ServiceImpl<ClientUserMapper, ClientUser> implements ClientUserService {
private static final String SNOWY_SYS_DEFAULT_PASSWORD_KEY = "SNOWY_SYS_DEFAULT_PASSWORD";
@Resource
private DevConfigApi devConfigApi;
@Resource
private TransService transService;
@Resource
private ClientRelationService clientRelationService;
@Override
public ClientLoginUser getUserById(String id) {
ClientUser clientUser = this.getById(id);
if(ObjectUtil.isNotEmpty(clientUser)) {
transService.transOne(clientUser);
return BeanUtil.copyProperties(clientUser, ClientLoginUser.class);
}
return null;
}
@Override
public ClientLoginUser getUserByAccount(String account) {
ClientUser clientUser = this.getOne(new LambdaQueryWrapper<ClientUser>().eq(ClientUser::getAccount, account));
if(ObjectUtil.isNotEmpty(clientUser)) {
transService.transOne(clientUser);
return BeanUtil.copyProperties(clientUser, ClientLoginUser.class);
}
return null;
}
@Override
public ClientLoginUser getUserByPhone(String phone) {
ClientUser clientUser = this.getOne(new LambdaQueryWrapper<ClientUser>().eq(ClientUser::getPhone, CommonCryptogramUtil.doSm4CbcEncrypt(phone)));
if(ObjectUtil.isNotEmpty(clientUser)) {
transService.transOne(clientUser);
return BeanUtil.copyProperties(clientUser, ClientLoginUser.class);
}
return null;
}
@Override
public ClientLoginUser getUserByEmail(String email) {
ClientUser clientUser = this.getOne(new LambdaQueryWrapper<ClientUser>().eq(ClientUser::getEmail, email));
if(ObjectUtil.isNotEmpty(clientUser)) {
transService.transOne(clientUser);
return BeanUtil.copyProperties(clientUser, ClientLoginUser.class);
}
return null;
}
@Override
public Page<ClientUser> page(ClientUserPageParam clientUserPageParam) {
QueryWrapper<ClientUser> queryWrapper = new QueryWrapper<>();
if(ObjectUtil.isNotEmpty(clientUserPageParam.getSearchKey())) {
queryWrapper.lambda().and(q -> q.like(ClientUser::getName, clientUserPageParam.getSearchKey())
.or().like(ClientUser::getAccount, clientUserPageParam.getSearchKey()));
}
if(ObjectUtil.isAllNotEmpty(clientUserPageParam.getSortField(), clientUserPageParam.getSortOrder())) {
CommonSortOrderEnum.validate(clientUserPageParam.getSortOrder());
queryWrapper.orderBy(true, clientUserPageParam.getSortOrder().equals(CommonSortOrderEnum.ASC.getValue()),
StrUtil.toUnderlineCase(clientUserPageParam.getSortField()));
} else {
queryWrapper.lambda().orderByAsc(ClientUser::getSortCode);
}
return this.page(CommonPageRequest.defaultPage(), queryWrapper);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void add(ClientUserAddParam clientUserAddParam) {
checkParam(clientUserAddParam);
ClientUser clientUser = BeanUtil.toBean(clientUserAddParam, ClientUser.class);
if(ObjectUtil.isEmpty(clientUser.getAvatar())) {
// 设置默认头像
clientUser.setAvatar(CommonAvatarUtil.generateImg(clientUser.getName()));
}
// 设置默认密码
clientUser.setPassword(CommonCryptogramUtil.doHashValue(devConfigApi.getValueByKey(SNOWY_SYS_DEFAULT_PASSWORD_KEY)));
// 设置状态
clientUser.setUserStatus(ClientUserStatusEnum.ENABLE.getValue());
this.save(clientUser);
}
private void checkParam(ClientUserAddParam clientUserAddParam) {
if (this.count(new LambdaQueryWrapper<ClientUser>()
.eq(ClientUser::getAccount, clientUserAddParam.getAccount())) > 0) {
throw new CommonException("存在重复的账号,账号为:{}", clientUserAddParam.getAccount());
}
if(ObjectUtil.isNotEmpty(clientUserAddParam.getPhone())) {
if(!PhoneUtil.isMobile(clientUserAddParam.getPhone())) {
throw new CommonException("手机号码:{}格式错误", clientUserAddParam.getPhone());
}
if (this.count(new LambdaQueryWrapper<ClientUser>()
.eq(ClientUser::getPhone, CommonCryptogramUtil.doSm4CbcEncrypt(clientUserAddParam.getPhone()))) > 0) {
throw new CommonException("存在重复的手机号,手机号为:{}", clientUserAddParam.getPhone());
}
}
if(ObjectUtil.isNotEmpty(clientUserAddParam.getEmail())) {
if(!CommonEmailUtil.isEmail(clientUserAddParam.getEmail())) {
throw new CommonException("邮箱:{}格式错误", clientUserAddParam.getEmail());
}
if (this.count(new LambdaQueryWrapper<ClientUser>()
.eq(ClientUser::getEmail, clientUserAddParam.getEmail())) > 0) {
throw new CommonException("存在重复的邮箱,邮箱为:{}", clientUserAddParam.getEmail());
}
}
}
@Override
public void edit(ClientUserEditParam clientUserEditParam) {
ClientUser clientUser = this.queryEntity(clientUserEditParam.getId());
checkParam(clientUserEditParam);
BeanUtil.copyProperties(clientUserEditParam, clientUser);
this.updateById(clientUser);
}
private void checkParam(ClientUserEditParam clientUserEditParam) {
if (this.count(new LambdaQueryWrapper<ClientUser>()
.eq(ClientUser::getAccount, clientUserEditParam.getAccount())
.ne(ClientUser::getId, clientUserEditParam.getId())) > 0) {
throw new CommonException("存在重复的账号,账号为:{}", clientUserEditParam.getAccount());
}
if(ObjectUtil.isNotEmpty(clientUserEditParam.getPhone())) {
if(!PhoneUtil.isMobile(clientUserEditParam.getPhone())) {
throw new CommonException("手机号码:{}格式错误", clientUserEditParam.getPhone());
}
if (this.count(new LambdaQueryWrapper<ClientUser>()
.eq(ClientUser::getPhone, CommonCryptogramUtil.doSm4CbcEncrypt(clientUserEditParam.getPhone()))
.ne(ClientUser::getId, clientUserEditParam.getId())) > 0) {
throw new CommonException("存在重复的手机号,手机号为:{}", clientUserEditParam.getPhone());
}
}
if(ObjectUtil.isNotEmpty(clientUserEditParam.getEmail())) {
if(!CommonEmailUtil.isEmail(clientUserEditParam.getEmail())) {
throw new CommonException("邮箱:{}格式错误", clientUserEditParam.getEmail());
}
if (this.count(new LambdaQueryWrapper<ClientUser>()
.eq(ClientUser::getEmail, clientUserEditParam.getEmail())
.ne(ClientUser::getId, clientUserEditParam.getId())) > 0) {
throw new CommonException("存在重复的邮箱,邮箱为:{}", clientUserEditParam.getEmail());
}
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public void delete(List<ClientUserIdParam> clientUserIdParamList) {
this.removeByIds(CollStreamUtil.toList(clientUserIdParamList, ClientUserIdParam::getId));
}
@Override
public ClientUser detail(ClientUserIdParam clientUserIdParam) {
return this.queryEntity(clientUserIdParam.getId());
}
@Override
public void updateUserLoginInfo(String userId, String device) {
ClientUser clientUser = this.queryEntity(userId);
clientUser.setLastLoginTime(clientUser.getLatestLoginTime());
clientUser.setLastLoginIp(clientUser.getLatestLoginIp());
clientUser.setLastLoginAddress(clientUser.getLatestLoginAddress());
clientUser.setLastLoginDevice(clientUser.getLatestLoginDevice());
clientUser.setLatestLoginTime(DateTime.now());
String ip = CommonIpAddressUtil.getIp(CommonServletUtil.getRequest());
clientUser.setLatestLoginIp(ip);
clientUser.setLatestLoginAddress(CommonIpAddressUtil.getCityInfo(ip));
clientUser.setLatestLoginDevice(device);
this.updateById(clientUser);
}
@Override
public ClientUser queryEntity(String id) {
ClientUser clientUser = this.getById(id);
if(ObjectUtil.isEmpty(clientUser)) {
throw new CommonException("用户不存在id值为{}", id);
}
return clientUser;
}
}