feat: update

This commit is contained in:
landaiqing
2024-05-23 13:12:42 +08:00
parent 047c019151
commit a44576e5ff
23 changed files with 567 additions and 674 deletions

View File

@@ -1,10 +1,10 @@
package com.schisandra.auth.application.controller;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Preconditions;
import com.schisandra.auth.application.convert.SchisandraAuthUserDTOConverter;
import com.schisandra.auth.application.dto.SchisandraAuthUserDTO;
import com.schisandra.auth.common.entity.Result;
import com.schisandra.auth.common.redis.RedisUtil;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import com.schisandra.auth.domain.service.SchisandraAuthUserDomainService;
import lombok.extern.slf4j.Slf4j;
@@ -13,144 +13,134 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @Classname SchisandraAuthUserController
* @BelongsProject: schisandra-cloud-storage
* @BelongsPackage: com.schisandra.auth.application.controller
* @Author: schisandra
* @CreateTime: 2024-03-21 22:48
* @Description: AuthUserController层
* @Version: 1.0
* controller
*
* @author landaiqing
* @since 2024-05-23 12:55:58
*/
@RestController
@RequestMapping("/user/")
@RequestMapping("/auth/")
@Slf4j
public class SchisandraAuthUserController {
@Resource
private SchisandraAuthUserDomainService schisandraAuthUserDomainService;
@Resource
private RedisUtil redisUtil;
/**
* @param schisandraAuthUserDTO
* @return com.schisandra.auth.common.entity.Result<java.lang.Boolean>
* @description 更新用户信息
* @author schisandra
* @date 2024/3/21 23:06
*/
@PostMapping("register")
public Result register(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
if (log.isInfoEnabled()) {
log.info("UserController.register.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
}
if (redisUtil.exist("auth.phone."+schisandraAuthUserDTO.getPhone())){
if (redisUtil.get("auth.phone."+schisandraAuthUserDTO.getPhone())!=schisandraAuthUserDTO.getAvatar()){
return Result.fail("验证码错误,请重新验证");
}
}else {
return Result.fail("验证码错误,请重新验证");
}
/**
* 新增
*/
@PostMapping("add")
public Result<Boolean> add(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
try {
checkUserInfo(schisandraAuthUserDTO);
SchisandraAuthUserBO authUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
if (schisandraAuthUserDomainService.register(authUserBO)==1){
return Result.fail("注册用户成功");
}else {
return Result.fail("注册用户失败");
if (log.isInfoEnabled()) {
log.info("SchisandraAuthUserController.add.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
}
Preconditions.checkNotNull(schisandraAuthUserDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUuid(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUserName(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getNickName(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getEmail(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getPhone(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getPassword(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getSex(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getAvatar(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getStatus(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getIntroduce(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getExtJson(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getIsDeleted(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getBlog(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getLocation(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCompany(), "不能为空");
SchisandraAuthUserBO SchisandraAuthUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
return Result.ok(schisandraAuthUserDomainService.add(SchisandraAuthUserBO));
} catch (Exception e) {
return Result.fail("注册用户失败");
log.error("SchisandraAuthUserController.register.error:{}", e.getMessage(), e);
return Result.fail("新增失败");
}
}
/**
* 修改
*/
@PostMapping("update")
public Result update(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
public Result<Boolean> update(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
try {
if (log.isInfoEnabled()) {
log.info("UserController.update.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
log.info("SchisandraAuthUserController.update.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
}
checkUserInfo(schisandraAuthUserDTO);
SchisandraAuthUserBO authUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
return Result.ok(schisandraAuthUserDomainService.update(authUserBO));
Preconditions.checkNotNull(schisandraAuthUserDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUuid(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUserName(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getNickName(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getEmail(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getPhone(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getPassword(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getSex(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getAvatar(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getStatus(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getIntroduce(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getExtJson(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getIsDeleted(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getBlog(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getLocation(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCompany(), "不能为空");
SchisandraAuthUserBO schisandraAuthUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
return Result.ok(schisandraAuthUserDomainService.update(schisandraAuthUserBO));
} catch (Exception e) {
log.error("UserController.update.error:{}", e.getMessage(), e);
return Result.fail("更新用户信息失败");
log.error("SchisandraAuthUserController.update.error:{}", e.getMessage(), e);
return Result.fail("更新信息失败");
}
}
/**
* @param schisandraAuthUserDTO
* @return
* @description 查询用户信息
* @author msz
* @date 2024/4/3 22:05
* 删除
*/
@PostMapping("/query")
public Result query(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
@DeleteMapping("delete")
public Result<Boolean> delete(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
try {
if (log.isInfoEnabled()) {
log.info("UserController.select.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
log.info("SchisandraAuthUserController.delete.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
}
checkUserInfo(schisandraAuthUserDTO);
SchisandraAuthUserBO authUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
return Result.ok(schisandraAuthUserDomainService.queryById(authUserBO));
Preconditions.checkNotNull(schisandraAuthUserDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUuid(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUserName(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getNickName(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getEmail(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getPhone(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getPassword(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getSex(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getAvatar(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getStatus(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getIntroduce(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getExtJson(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getIsDeleted(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getBlog(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getLocation(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCompany(), "不能为空");
SchisandraAuthUserBO schisandraAuthUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
return Result.ok(schisandraAuthUserDomainService.delete(schisandraAuthUserBO));
} catch (Exception e) {
log.error("UserController.select.error:{}", e.getMessage(), e);
return Result.fail("查询用户信息失败");
log.error("SchisandraAuthUserController.delete.error:{}", e.getMessage(), e);
return Result.fail("删除信息失败");
}
}
/**
* @param schisandraAuthUserDTO
* @return
* @description 添加用户信息
* @author msz
* @date 2024/4/3 22:12
*/
@PostMapping("/insert")
public Result insert(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
try {
if (log.isInfoEnabled()) {
log.info("UserController.insert.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
}
checkUserInfo(schisandraAuthUserDTO);
SchisandraAuthUserBO authUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
return Result.ok(schisandraAuthUserDomainService.update(authUserBO));
} catch (Exception e) {
log.error("UserController.insert.error:{}", e.getMessage(), e);
return Result.fail("添加用户信息失败");
}
}
/**
* @param id
* @return
* @description 删除用户信息
* @author msz
* @date 2024/4/3 22:12
*/
@GetMapping("/delete/{id}")
public Result delete(@PathVariable Long id) {
try {
if (log.isInfoEnabled()) {
log.info("UserController.insert.dto:{}", id);
}
return Result.ok(schisandraAuthUserDomainService.deleteById(id));
} catch (Exception e) {
log.error("UserController.insert.error:{}", e.getMessage(), e);
return Result.fail("删除用户信息失败");
}
}
/**
* @param schisandraAuthUserDTO
* @return void
* @description 用户信息断言校验
* @author schisandra
* @date 2024/3/21 23:09
*/
private void checkUserInfo(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
// Preconditions.checkArgument(!StringUtils.isBlank(schisandraAuthUserDTO.getUserName()), "用户名不能为空");
// Preconditions.checkArgument(!StringUtils.isBlank(schisandraAuthUserDTO.getEmail()), "邮箱不能为空");
// Preconditions.checkArgument(!StringUtils.isBlank(schisandraAuthUserDTO.getPassword()), "密码不能为空");
}
}

View File

@@ -1,37 +1,22 @@
package com.schisandra.auth.application.convert;
import com.schisandra.auth.application.dto.SchisandraAuthUserDTO;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 用户dto转换器
* dto转换器
*
* @author schisandra
* @author landaiqing
* @since 2024-05-23 12:55:58
*/
@Mapper(componentModel = "spring")
@Mapper
public interface SchisandraAuthUserDTOConverter {
SchisandraAuthUserDTOConverter INSTANCE = Mappers.getMapper(SchisandraAuthUserDTOConverter.class);
/**
* @param authUserDTO
* @return com.schisandra.auth.domain.bo.SchisandraAuthUserBO
* @description DTO转BO
* @author schisandra
* @date 2024/3/21 23:11
*/
SchisandraAuthUserBO convertDTOToBO(SchisandraAuthUserDTO authUserDTO);
/**
* @description: BO转DTO
* @param: [authUserBO]
* @return: com.schisandra.auth.application.dto.SchisandraAuthUserDTO
* @author: schisandra
* @date: 2024/3/21 23:26
*/
SchisandraAuthUserDTO convertBOToDTO(SchisandraAuthUserBO authUserBO);
SchisandraAuthUserBO convertDTOToBO(SchisandraAuthUserDTO schisandraAuthUserDTO);
}

View File

@@ -1,78 +1,118 @@
package com.schisandra.auth.application.dto;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* (SchisandraAuthUserDTO)实体类
* dto
*
* @author labdaiqing
* @since 2024-03-21 20:15:43
* @author landaiqing
* @since 2024-05-23 12:55:58
*/
@Data
//@Builder
public class SchisandraAuthUserDTO implements Serializable {
/**
* id主键
*
*/
private Long id;
/**
* 用户名
*
*/
private String uuid;
/**
*
*/
private String userName;
/**
* 昵称
*
*/
private String nickName;
/**
* 邮箱
*
*/
private String email;
/**
* 手机号
*
*/
private String phone;
/**
* 密码
*
*/
private String password;
/**
* 性别
*
*/
private Integer sex;
/**
* 头像
*
*/
private String avatar;
/**
* 状态
*
*/
private Integer status;
/**
* 介绍
*
*/
private String introduce;
/**
* 额外字段
*
*/
private String extJson;
/**
* 是否删除
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
/**
*
*/
private Integer isDeleted;
/**
*
*/
private String blog;
/**
*
*/
private String location;
/**
*
*/
private String company;
}

View File

@@ -1,79 +1,118 @@
package com.schisandra.auth.domain.bo;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* (SchisandraAuthUserBO)实体类
* bo
*
* @author labdaiqing
* @since 2024-03-21 20:15:43
* @author landaiqing
* @since 2024-05-23 12:55:58
*/
@Data
//@Builder
public class SchisandraAuthUserBO implements Serializable {
/**
* id主键
*
*/
private Long id;
/**
* 用户名
*
*/
private String uuid;
/**
*
*/
private String userName;
/**
* 昵称
*
*/
private String nickName;
/**
* 邮箱
*
*/
private String email;
/**
* 手机号
*
*/
private String phone;
/**
* 密码
*
*/
private String password;
/**
* 性别
*
*/
private Integer sex;
/**
* 头像
*
*/
private String avatar;
/**
* 状态
*
*/
private Integer status;
/**
* 介绍
*
*/
private String introduce;
/**
* 额外字段
*
*/
private String extJson;
/**
* 是否删除
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
/**
*
*/
private Integer isDeleted;
/**
*
*/
private String blog;
/**
*
*/
private String location;
/**
*
*/
private String company;
}

View File

@@ -1,37 +1,22 @@
package com.schisandra.auth.domain.convert;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 用户bo转换器
* bo转换器
*
* @author schisandra
* @date 2024/3/21
* @author landaiqing
* @since 2024-05-23 12:55:58
*/
@Mapper(componentModel = "spring")
@Mapper
public interface SchisandraAuthUserBOConverter {
SchisandraAuthUserBOConverter INSTANCE = Mappers.getMapper(SchisandraAuthUserBOConverter.class);
/**
* @description 将bo转换为实体
* @param schisandraAuthUserBO
* @return com.schisandra.auth.infra.basic.entity.SchisandraAuthUser
* @author schisandra
* @date 2024/3/21 23:13
*/
SchisandraAuthUser convertBOToEntity(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 将实体转换为bo
* @param schisandraAuthUser
* @return com.schisandra.auth.domain.bo.SchisandraAuthUserBO
* @author schisandra
* @date 2024/3/21 23:13
*/
SchisandraAuthUserBO convertEntityToBO(SchisandraAuthUser schisandraAuthUser);
}

View File

@@ -1,49 +1,28 @@
package com.schisandra.auth.domain.service;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
/**
* 用户领域service
* 领域service
*
* @author schisandra
* @date 2024/3/21
* @author landaiqing
* @since 2024-05-23 12:55:58
*/
public interface SchisandraAuthUserDomainService {
int register(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* 添加 信息
*/
Boolean add(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 更新用户信息
* @param schisandraAuthUserBO
* @return java.lang.Object
* @author schisandra
* @date 2024/3/21 23:14
* 更新 信息
*/
Object update(SchisandraAuthUserBO schisandraAuthUserBO);
Boolean update(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 查询用户信息
* @param schisandraAuthUserBO
* @author msz
* @return com.schisandra.auth.infra.basic.entity.SchisandraAuthUser
* 删除 信息
*/
SchisandraAuthUserBO queryById(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 添加用户信息
* @param schisandraAuthUserBO
* @author msz
* @return java.lang.object
*/
Object insert(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 删除用户(物理)
* @param id
* @author msz
* @return java.lang.object
*/
Object deleteById(Long id);
Boolean delete(SchisandraAuthUserBO schisandraAuthUserBO);
}

View File

@@ -1,5 +1,7 @@
package com.schisandra.auth.domain.service.impl;
import com.schisandra.auth.common.enums.IsDeletedFlagEnum;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import com.schisandra.auth.domain.convert.SchisandraAuthUserBOConverter;
import com.schisandra.auth.domain.service.SchisandraAuthUserDomainService;
@@ -10,87 +12,38 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 领域service实现了
*
* @author landaiqing
* @since 2024-05-23 12:55:58
*/
@Service
@Slf4j
public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDomainService {
@Resource
private SchisandraAuthUserService schisandraAuthUserService;
/**
* @description: 注册用户
* @param: [schisandraAuthUserBO]
* @return: com.schisandra.auth.domain.bo.SchisandraAuthUserBO
* @author zlg
* @date: 2024/5/14 20:59
*/
@Override
public int register(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = schisandraAuthUserService.queryByPhone(schisandraAuthUserBO.getPhone());
if (schisandraAuthUser != null) {
return 0;
} else {
SchisandraAuthUser schisandraAuthUser1 = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO);
if (schisandraAuthUserService.insert(schisandraAuthUser1)==null) {
return 0;
}else {
return 1;
}
}
}
/**
* @param schisandraAuthUserBO
* @return java.lang.Object
* @description 更新用户信息
* @author schisandra
* @date 2024/3/21 23:14
*/
@Override
public Object update(SchisandraAuthUserBO schisandraAuthUserBO) {
public Boolean add(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO);
Integer count = schisandraAuthUserService.update(schisandraAuthUser);
return count > 0;
schisandraAuthUser.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
return schisandraAuthUserService.insert(schisandraAuthUser) > 0;
}
/**
* @param schisandraAuthUserBO
* @return
* @description 查询用户信息
* @author msz
* @date 2024/4/3 22:10
*/
@Override
public SchisandraAuthUserBO queryById(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = schisandraAuthUserService.queryById(schisandraAuthUserBO.getId());
SchisandraAuthUserBO schisandraAuthUserBO1 = SchisandraAuthUserBOConverter.INSTANCE.convertEntityToBO(schisandraAuthUser);
return schisandraAuthUserBO1;
}
/**
* @param schisandraAuthUserBO
* @return java.lang.Object
* @description 添加用户信息
* @author msz
* @date 2024/4/3 22:17
*/
@Override
public Object insert(SchisandraAuthUserBO schisandraAuthUserBO) {
public Boolean update(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO);
SchisandraAuthUser user = schisandraAuthUserService.insert(schisandraAuthUser);
return user != null;
return schisandraAuthUserService.update(schisandraAuthUser) > 0;
}
/**
* @param id
* @return java.lang.Object
* @description 添加用户信息
* @author msz
* @date 2024/4/3 22:30
*/
@Override
public Object deleteById(Long id) {
boolean flag = schisandraAuthUserService.deleteById(id);
return flag;
public Boolean delete(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = new SchisandraAuthUser();
schisandraAuthUser.setId(schisandraAuthUserBO.getId());
schisandraAuthUser.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
return schisandraAuthUserService.update(schisandraAuthUser) > 0;
}
}

View File

@@ -1,85 +1,17 @@
package com.schisandra.auth.infra.basic.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
import org.springframework.stereotype.Repository;
/**
* (SchisandraAuthUser)表数据库访问层
* 表数据库访问层
*
* @author schisandra
* @since 2024-03-21 20:15:43
* @author landaiqing
* @since 2024-05-23 12:55:58
*/
public interface SchisandraAuthUserDao {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
SchisandraAuthUser queryById(Long id);
/**
* 查询指定行数据
*
* @param schisandraAuthUser 查询条件
* @param pageable 分页对象
* @return 对象列表
*/
List<SchisandraAuthUser> queryAllByLimit(SchisandraAuthUser schisandraAuthUser, @Param("pageable") Pageable pageable);
/**
* 统计总行数
*
* @param schisandraAuthUser 查询条件
* @return 总行数
*/
long count(SchisandraAuthUser schisandraAuthUser);
/**
* 新增数据
*
* @return 影响行数
*/
int insert(SchisandraAuthUser schisandraAuthUser);
/**
* 批量新增数据MyBatis原生foreach方法
*
* @param entities List<SchisandraAuthUser> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<SchisandraAuthUser> entities);
/**
* 批量新增或按主键更新数据MyBatis原生foreach方法
*
* @param entities List<SchisandraAuthUser> 实例对象列表
* @return 影响行数
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常请自行校验入参
*/
int insertOrUpdateBatch(@Param("entities") List<SchisandraAuthUser> entities);
/**
* 修改数据
*
* @param schisandraAuthUser 实例对象
* @return 影响行数
*/
int update(SchisandraAuthUser schisandraAuthUser);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Long id);
SchisandraAuthUser queryByPhone(String phone);
@Repository
public interface SchisandraAuthUserDao extends BaseMapper<SchisandraAuthUser> {
}

View File

@@ -1,97 +1,143 @@
package com.schisandra.auth.infra.basic.entity;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
import java.io.Serializable;
import java.util.Date;
/**
* (SchisandraAuthUser)实体类
* 实体类
*
* @author labdaiqing
* @since 2024-03-21 20:15:43
* @author landaiqing
* @since 2024-05-23 12:55:58
*/
@Data
@TableName("schisandra_auth_user")
public class SchisandraAuthUser implements Serializable {
/**
* id主键
*
*/
@TableId(value = "`id`", type = IdType.AUTO)
private Long id;
/**
* 用户名
*
*/
@TableField("`uuid`")
private String uuid;
/**
*
*/
@TableField("`user_name`")
private String userName;
/**
* 昵称
*
*/
@TableField("`nick_name`")
private String nickName;
/**
* 邮箱
*
*/
@TableField("`email`")
private String email;
/**
* 手机号
*
*/
@TableField("`phone`")
private String phone;
/**
* 密码
*
*/
@TableField("`password`")
private String password;
/**
* 性别
*
*/
@TableField("`sex`")
private Integer sex;
/**
* 头像
*
*/
@TableField("`avatar`")
private String avatar;
/**
* 状态
*
*/
@TableField("`status`")
private Integer status;
/**
* 介绍
*
*/
@TableField("`introduce`")
private String introduce;
/**
* 额外字段
*
*/
@TableField("`ext_json`")
private String extJson;
/**
* 创建人
*/
@TableField("`created_by`")
private String createdBy;
/**
* 创建时间
*/
@TableField("`created_time`")
private Date createdTime;
/**
* 更新人
*/
@TableField("`update_by`")
private String updateBy;
/**
* 更新时间
*/
@TableField("`update_time`")
private Date updateTime;
/**
* 是否删除
*
*/
@TableField("`is_deleted`")
private Integer isDeleted;
/**
*
*/
@TableField("`blog`")
private String blog;
/**
*
*/
@TableField("`location`")
private String location;
/**
*
*/
@TableField("`company`")
private String company;
}

View File

@@ -1,14 +1,12 @@
package com.schisandra.auth.infra.basic.service;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
/**
* (SchisandraAuthUser)表服务接口
* 表服务接口
*
* @author schisandra
* @since 2024-03-21 20:15:44
* @author landaiqing
* @since 2024-05-23 12:55:58
*/
public interface SchisandraAuthUserService {
@@ -20,22 +18,13 @@ public interface SchisandraAuthUserService {
*/
SchisandraAuthUser queryById(Long id);
/**
* 分页查询
*
* @param schisandraAuthUser 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
Page<SchisandraAuthUser> queryByPage(SchisandraAuthUser schisandraAuthUser, PageRequest pageRequest);
/**
* 新增数据
*
* @param schisandraAuthUser 实例对象
* @return 实例对象
*/
SchisandraAuthUser insert(SchisandraAuthUser schisandraAuthUser);
int insert(SchisandraAuthUser schisandraAuthUser);
/**
* 修改数据
@@ -43,7 +32,7 @@ public interface SchisandraAuthUserService {
* @param schisandraAuthUser 实例对象
* @return 实例对象
*/
Integer update(SchisandraAuthUser schisandraAuthUser);
int update(SchisandraAuthUser schisandraAuthUser);
/**
* 通过主键删除数据
@@ -53,6 +42,9 @@ public interface SchisandraAuthUserService {
*/
boolean deleteById(Long id);
SchisandraAuthUser queryByPhone(String phone);
/**
* 根据条件查询角色
*/
SchisandraAuthUser queryByCondition(SchisandraAuthUser schisandraAuthUser);
}

View File

@@ -1,23 +1,25 @@
package com.schisandra.auth.infra.basic.service.impl;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.schisandra.auth.infra.basic.dao.SchisandraAuthUserDao;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import com.schisandra.auth.infra.basic.service.SchisandraAuthUserService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import javax.annotation.Resource;
import java.util.Objects;
/**
* (SchisandraAuthUser)表服务实现类
* 表服务实现类
*
* @author schisandra
* @since 2024-03-21 20:15:44
* @author landaiqing
* @since 2024-05-23 12:55:58
*/
@Service("schisandraAuthUserService")
@Service("SchisandraAuthUserService")
public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService {
@Resource
private SchisandraAuthUserDao schisandraAuthUserDao;
@@ -29,20 +31,7 @@ public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService
*/
@Override
public SchisandraAuthUser queryById(Long id) {
return this.schisandraAuthUserDao.queryById(id);
}
/**
* 分页查询
*
* @param schisandraAuthUser 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
@Override
public Page<SchisandraAuthUser> queryByPage(SchisandraAuthUser schisandraAuthUser, PageRequest pageRequest) {
long total = this.schisandraAuthUserDao.count(schisandraAuthUser);
return new PageImpl<>(this.schisandraAuthUserDao.queryAllByLimit(schisandraAuthUser, pageRequest), pageRequest, total);
return this.schisandraAuthUserDao.selectById(id);
}
/**
@@ -52,9 +41,8 @@ public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService
* @return 实例对象
*/
@Override
public SchisandraAuthUser insert(SchisandraAuthUser schisandraAuthUser) {
this.schisandraAuthUserDao.insert(schisandraAuthUser);
return schisandraAuthUser;
public int insert(SchisandraAuthUser schisandraAuthUser) {
return this.schisandraAuthUserDao.insert(schisandraAuthUser);
}
/**
@@ -64,9 +52,8 @@ public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService
* @return 实例对象
*/
@Override
public Integer update(SchisandraAuthUser schisandraAuthUser) {
return this.schisandraAuthUserDao.update(schisandraAuthUser);
public int update(SchisandraAuthUser schisandraAuthUser) {
return this.schisandraAuthUserDao.updateById(schisandraAuthUser);
}
/**
@@ -80,8 +67,39 @@ public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService
return this.schisandraAuthUserDao.deleteById(id) > 0;
}
/**
* 条件查询
*
* @param schisandraAuthUser 条件
* @return 实例对象
*/
@Override
public SchisandraAuthUser queryByPhone(String phone) {
return this.schisandraAuthUserDao.queryByPhone(phone);
public SchisandraAuthUser queryByCondition(SchisandraAuthUser schisandraAuthUser) {
LambdaQueryWrapper<SchisandraAuthUser> queryWrapper = Wrappers.<SchisandraAuthUser>lambdaQuery()
.eq(Objects.nonNull(schisandraAuthUser.getId()), SchisandraAuthUser::getId, schisandraAuthUser.getId())
.eq(Objects.nonNull(schisandraAuthUser.getUuid()), SchisandraAuthUser::getUuid, schisandraAuthUser.getUuid())
.eq(Objects.nonNull(schisandraAuthUser.getUserName()), SchisandraAuthUser::getUserName, schisandraAuthUser.getUserName())
.eq(Objects.nonNull(schisandraAuthUser.getNickName()), SchisandraAuthUser::getNickName, schisandraAuthUser.getNickName())
.eq(Objects.nonNull(schisandraAuthUser.getEmail()), SchisandraAuthUser::getEmail, schisandraAuthUser.getEmail())
.eq(Objects.nonNull(schisandraAuthUser.getPhone()), SchisandraAuthUser::getPhone, schisandraAuthUser.getPhone())
.eq(Objects.nonNull(schisandraAuthUser.getPassword()), SchisandraAuthUser::getPassword, schisandraAuthUser.getPassword())
.eq(Objects.nonNull(schisandraAuthUser.getSex()), SchisandraAuthUser::getSex, schisandraAuthUser.getSex())
.eq(Objects.nonNull(schisandraAuthUser.getAvatar()), SchisandraAuthUser::getAvatar, schisandraAuthUser.getAvatar())
.eq(Objects.nonNull(schisandraAuthUser.getStatus()), SchisandraAuthUser::getStatus, schisandraAuthUser.getStatus())
.eq(Objects.nonNull(schisandraAuthUser.getIntroduce()), SchisandraAuthUser::getIntroduce, schisandraAuthUser.getIntroduce())
.eq(Objects.nonNull(schisandraAuthUser.getExtJson()), SchisandraAuthUser::getExtJson, schisandraAuthUser.getExtJson())
.eq(Objects.nonNull(schisandraAuthUser.getCreatedBy()), SchisandraAuthUser::getCreatedBy, schisandraAuthUser.getCreatedBy())
.eq(Objects.nonNull(schisandraAuthUser.getCreatedTime()), SchisandraAuthUser::getCreatedTime, schisandraAuthUser.getCreatedTime())
.eq(Objects.nonNull(schisandraAuthUser.getUpdateBy()), SchisandraAuthUser::getUpdateBy, schisandraAuthUser.getUpdateBy())
.eq(Objects.nonNull(schisandraAuthUser.getUpdateTime()), SchisandraAuthUser::getUpdateTime, schisandraAuthUser.getUpdateTime())
.eq(Objects.nonNull(schisandraAuthUser.getIsDeleted()), SchisandraAuthUser::getIsDeleted, schisandraAuthUser.getIsDeleted())
.eq(Objects.nonNull(schisandraAuthUser.getBlog()), SchisandraAuthUser::getBlog, schisandraAuthUser.getBlog())
.eq(Objects.nonNull(schisandraAuthUser.getLocation()), SchisandraAuthUser::getLocation, schisandraAuthUser.getLocation())
.eq(Objects.nonNull(schisandraAuthUser.getCompany()), SchisandraAuthUser::getCompany, schisandraAuthUser.getCompany())
;
return schisandraAuthUserDao.selectOne(queryWrapper);
}
}

View File

@@ -1,242 +1,28 @@
<?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="com.schisandra.auth.infra.basic.dao.SchisandraAuthUserDao">
<mapper namespace="com.schisandra.auth.infra.basic.mapper.SchisandraAuthUserDao">
<resultMap type="com.schisandra.auth.infra.basic.entity.SchisandraAuthUser" id="SchisandraAuthUserMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
<result property="nickName" column="nick_name" jdbcType="VARCHAR"/>
<result property="email" column="email" jdbcType="VARCHAR"/>
<result property="phone" column="phone" jdbcType="VARCHAR"/>
<result property="password" column="password" jdbcType="VARCHAR"/>
<result property="sex" column="sex" jdbcType="INTEGER"/>
<result property="avatar" column="avatar" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="introduce" column="introduce" jdbcType="VARCHAR"/>
<result property="extJson" column="ext_json" jdbcType="VARCHAR"/>
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
<resultMap id="BaseResultMap" type="com.schisandra.auth.infra.basic.entity.SchisandraAuthUser">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="uuid" jdbcType="VARCHAR" property="uuid"/>
<result column="user_name" jdbcType="VARCHAR" property="userName"/>
<result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
<result column="email" jdbcType="VARCHAR" property="email"/>
<result column="phone" jdbcType="VARCHAR" property="phone"/>
<result column="password" jdbcType="VARCHAR" property="password"/>
<result column="sex" jdbcType="TINYINT" property="sex"/>
<result column="avatar" jdbcType="VARCHAR" property="avatar"/>
<result column="status" jdbcType="TINYINT" property="status"/>
<result column="introduce" jdbcType="VARCHAR" property="introduce"/>
<result column="ext_json" jdbcType="VARCHAR" property="extJson"/>
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
<result column="blog" jdbcType="VARCHAR" property="blog"/>
<result column="location" jdbcType="VARCHAR" property="location"/>
<result column="company" jdbcType="VARCHAR" property="company"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="SchisandraAuthUserMap">
select id,user_name,nick_name,email,phone,password,sex,avatar,status,introduce,ext_json,created_by,created_time,update_by,update_time,is_deleted
from schisandra_auth_user
where id = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="SchisandraAuthUserMap">
select
id,user_name,nick_name,email,phone,password,sex,avatar,status,introduce,ext_json,created_by,created_time,update_by,update_time,is_deleted
from schisandra_auth_user
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="userName != null and userName != ''">
and user_name = #{userName}
</if>
<if test="nickName != null and nickName != ''">
and nick_name = #{nickName}
</if>
<if test="email != null and email != ''">
and email = #{email}
</if>
<if test="phone != null and phone != ''">
and phone = #{phone}
</if>
<if test="password != null and password != ''">
and password = #{password}
</if>
<if test="sex != null">
and sex = #{sex}
</if>
<if test="avatar != null and avatar != ''">
and avatar = #{avatar}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="introduce != null and introduce != ''">
and introduce = #{introduce}
</if>
<if test="extJson != null and extJson != ''">
and ext_json = #{extJson}
</if>
<if test="createdBy != null and createdBy != ''">
and created_by = #{createdBy}
</if>
<if test="createdTime != null">
and created_time = #{createdTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="isDeleted != null">
and is_deleted = #{isDeleted}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from schisandra_auth_user
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="userName != null and userName != ''">
and user_name = #{userName}
</if>
<if test="nickName != null and nickName != ''">
and nick_name = #{nickName}
</if>
<if test="email != null and email != ''">
and email = #{email}
</if>
<if test="phone != null and phone != ''">
and phone = #{phone}
</if>
<if test="password != null and password != ''">
and password = #{password}
</if>
<if test="sex != null">
and sex = #{sex}
</if>
<if test="avatar != null and avatar != ''">
and avatar = #{avatar}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="introduce != null and introduce != ''">
and introduce = #{introduce}
</if>
<if test="extJson != null and extJson != ''">
and ext_json = #{extJson}
</if>
<if test="createdBy != null and createdBy != ''">
and created_by = #{createdBy}
</if>
<if test="createdTime != null">
and created_time = #{createdTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="isDeleted != null">
and is_deleted = #{isDeleted}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into schisandra_auth_user(user_name,nick_name,email,phone,password,sex,avatar,status,introduce,ext_json,created_by,created_time,update_by,update_time,is_deleted)
values (#{userName},#{nickName},#{email},#{phone},#{password},#{sex},#{avatar},#{status},#{introduce},#{extJson},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into
schisandra_auth_user(user_name,nick_name,email,phone,password,sex,avatar,status,introduce,ext_json,created_by,created_time,update_by,update_time,is_deleted)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.userName},#{entity.nickName},#{entity.email},#{entity.phone},#{entity.password},#{entity.sex},#{entity.avatar},#{entity.status},#{entity.introduce},#{entity.extJson},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into
schisandra_auth_user(user_name,nick_name,email,phone,password,sex,avatar,status,introduce,ext_json,created_by,created_time,update_by,update_time,is_deleted)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.userName},#{entity.nickName},#{entity.email},#{entity.phone},#{entity.password},#{entity.sex},#{entity.avatar},#{entity.status},#{entity.introduce},#{entity.extJson},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
</foreach>
on duplicate key update
user_name = values(user_name)nick_name = values(nick_name)email = values(email)phone = values(phone)password =
values(password)sex = values(sex)avatar = values(avatar)status = values(status)introduce =
values(introduce)ext_json = values(ext_json)created_by = values(created_by)created_time =
values(created_time)update_by = values(update_by)update_time = values(update_time)is_deleted =
values(is_deleted)
</insert>
<!--通过主键修改数据-->
<update id="update">
update schisandra_auth_user
<set>
<if test="userName != null and userName != ''">
user_name = #{userName},
</if>
<if test="nickName != null and nickName != ''">
nick_name = #{nickName},
</if>
<if test="email != null and email != ''">
email = #{email},
</if>
<if test="phone != null and phone != ''">
phone = #{phone},
</if>
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="sex != null">
sex = #{sex},
</if>
<if test="avatar != null and avatar != ''">
avatar = #{avatar},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="introduce != null and introduce != ''">
introduce = #{introduce},
</if>
<if test="extJson != null and extJson != ''">
ext_json = #{extJson},
</if>
<if test="createdBy != null and createdBy != ''">
created_by = #{createdBy},
</if>
<if test="createdTime != null">
created_time = #{createdTime},
</if>
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="isDeleted != null">
is_deleted = #{isDeleted},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from schisandra_auth_user
where id = #{id}
</delete>
<select id="queryByPhone" resultMap="SchisandraAuthUserMap">
select id,user_name,nick_name,email,phone,password,sex,avatar,status,introduce,ext_json,created_by,created_time,update_by,update_time,is_deleted
from schisandra_auth_user
where phone = #{phone}
</select>
</mapper>