feat: update

This commit is contained in:
zlg
2024-05-26 17:17:49 +08:00
parent c3a29cedca
commit 1154a53e9f
34 changed files with 956 additions and 223 deletions

View File

@@ -1,11 +1,14 @@
package com.schisandra.auth.application.config;
import cn.dev33.satoken.interceptor.SaInterceptor;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import java.util.List;
@@ -21,6 +24,7 @@ import java.util.List;
*/
@Configuration
public class GlobalConfig extends WebMvcConfigurationSupport {
@Override
protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
super.configureMessageConverters(converters);

View File

@@ -5,9 +5,11 @@ 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;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -15,16 +17,20 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* controller
*
* @author landaiqing
* @since 2024-05-23 20:00:28
* @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
*/
@RestController
@RequestMapping("/auth/")
@Slf4j
public class SchisandraAuthUserController {
@Resource
RedisUtil redisUtil;
@Resource
private SchisandraAuthUserDomainService schisandraAuthUserDomainService;
@@ -33,44 +39,48 @@ public class SchisandraAuthUserController {
*/
@RequestMapping("add")
public Result<Boolean> add(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SchisandraAuthUserController.add.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
}
Preconditions.checkNotNull(schisandraAuthUserDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUserName(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getNickName(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getEmail(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getPhone(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getPassword(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getGender(), "不能为空");
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) {
log.error("SchisandraAuthUserController.register.error:{}", e.getMessage(), e);
return Result.fail("新增失败");
}
return Result.ok();
}
@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.getActiveCode()) {
return Result.fail("验证码错误,请重新验证");
}
} else {
return Result.fail("验证码错误,请重新验证");
}
try {
SchisandraAuthUserBO authUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
if (schisandraAuthUserDomainService.register(authUserBO)) {
return Result.fail("注册用户成功");
} else {
return Result.fail("注册用户失败");
}
} catch (Exception e) {
return Result.fail("注册用户失败");
}
}
@PostMapping("login")
public Result login(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
String EmailType = "^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.[a-zA-Z0-9]{2,6}$";
Boolean s = EmailType.matches(schisandraAuthUserDTO.getEmail());
// return Result.ok(schisandraAuthUserDomainService.login(SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO)));
// return null;
return Result.ok(s);
}
/**
* 修改
*/
@RequestMapping("update")
public Result<Boolean> update(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
public Result update(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
try {
if (log.isInfoEnabled()) {
@@ -134,7 +144,8 @@ public class SchisandraAuthUserController {
Preconditions.checkNotNull(schisandraAuthUserDTO.getLocation(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCompany(), "不能为空");
SchisandraAuthUserBO schisandraAuthUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
return Result.ok(schisandraAuthUserDomainService.delete(schisandraAuthUserBO));
//
return Result.ok();
} catch (Exception e) {
log.error("SchisandraAuthUserController.delete.error:{}", e.getMessage(), e);
return Result.fail("删除信息失败");

View File

@@ -0,0 +1,23 @@
package com.schisandra.auth.application.convert;
import com.schisandra.auth.application.dto.SchisandraAuthUserRoleDTO;
import com.schisandra.auth.domain.bo.SchisandraAuthUserRoleBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* dto转换器
*
* @author zlg
* @since 2024-05-25 18:05:40
*/
@Mapper
public interface SchisandraAuthUserRoleDTOConverter {
SchisandraAuthUserRoleDTOConverter INSTANCE = Mappers.getMapper(SchisandraAuthUserRoleDTOConverter.class);
SchisandraAuthUserRoleBO convertDTOToBO(SchisandraAuthUserRoleDTO schisandraAuthUserRoleDTO);
SchisandraAuthUserRoleDTO convertBOToDTO(SchisandraAuthUserRoleBO schisandraAuthUserRoleBO);
}

View File

@@ -109,5 +109,7 @@ public class SchisandraAuthUserDTO implements Serializable {
*/
private String company;
private String activeCode;
}

View File

@@ -0,0 +1,58 @@
package com.schisandra.auth.application.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* dto
*
* @author zlg
* @since 2024-05-25 18:05:40
*/
@Data
public class SchisandraAuthUserRoleDTO implements Serializable {
/**
*
*/
private Long id;
/**
*
*/
private Long userId;
/**
*
*/
private Long roleId;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
/**
*
*/
private Integer isDeleted;
}

View File

@@ -0,0 +1,58 @@
package com.schisandra.auth.domain.bo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* bo
*
* @author zlg
* @since 2024-05-25 18:05:40
*/
@Data
public class SchisandraAuthUserRoleBO implements Serializable {
/**
*
*/
private Long id;
/**
*
*/
private Long userId;
/**
*
*/
private Long roleId;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
/**
*
*/
private Integer isDeleted;
}

View File

@@ -19,4 +19,6 @@ public interface SchisandraAuthUserBOConverter {
SchisandraAuthUser convertBOToEntity(SchisandraAuthUserBO schisandraAuthUserBO);
SchisandraAuthUserBO convertEntityToBO(SchisandraAuthUser schisandraAuthUser);
}

View File

@@ -0,0 +1,25 @@
package com.schisandra.auth.domain.convert;
import com.schisandra.auth.domain.bo.SchisandraAuthUserRoleBO;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUserRole;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* bo转换器
*
* @author zlg
* @since 2024-05-25 18:05:40
*/
@Mapper
public interface SchisandraAuthUserRoleBOConverter {
SchisandraAuthUserRoleBOConverter INSTANCE = Mappers.getMapper(SchisandraAuthUserRoleBOConverter.class);
SchisandraAuthUserRole convertBOToEntity(SchisandraAuthUserRoleBO schisandraAuthUserRoleBO);
SchisandraAuthUserRoleBO convertEntityToBO(SchisandraAuthUserRole schisandraAuthUserRole);
}

View File

@@ -1,28 +1,57 @@
package com.schisandra.auth.domain.service;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
/**
* 领域service
* 用户领域service
*
* @author landaiqing
* @since 2024-05-23 20:00:28
* @author schisandra
* @date 2024/3/21
*/
public interface SchisandraAuthUserDomainService {
/**
* 添加 信息
*/
Boolean add(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* 更新 信息
* @description 用户注册
* @param schisandraAuthUserBO
* @return java.lang.Boolean
* @author zlg
* @date 2024/3/21 23:14
*/
Boolean update(SchisandraAuthUserBO schisandraAuthUserBO);
Boolean register(SchisandraAuthUserBO schisandraAuthUserBO);
SchisandraAuthUserBO login(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* 删除 信息
* @description 更新用户信息
* @param schisandraAuthUserBO
* @return java.lang.Object
* @author schisandra
* @date 2024/3/21 23:14
*/
Boolean delete(SchisandraAuthUserBO schisandraAuthUserBO);
Object 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);
}

View File

@@ -0,0 +1,30 @@
package com.schisandra.auth.domain.service;
import com.schisandra.auth.domain.bo.SchisandraAuthUserRoleBO;
/**
* 领域service
*
* @author zlg
* @since 2024-05-25 18:05:40
*/
public interface SchisandraAuthUserRoleDomainService {
/**
* 添加 信息
*/
Boolean add(SchisandraAuthUserRoleBO schisandraAuthUserRoleBO);
/**
* 更新 信息
*/
Boolean update(SchisandraAuthUserRoleBO schisandraAuthUserRoleBO);
/**
* 删除 信息
*/
Boolean delete(SchisandraAuthUserRoleBO schisandraAuthUserRoleBO);
}

View File

@@ -1,49 +1,110 @@
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.bo.SchisandraAuthUserRoleBO;
import com.schisandra.auth.domain.convert.SchisandraAuthUserBOConverter;
import com.schisandra.auth.domain.convert.SchisandraAuthUserRoleBOConverter;
import com.schisandra.auth.domain.service.SchisandraAuthUserDomainService;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import com.schisandra.auth.infra.basic.service.SchisandraAuthUserRoleService;
import com.schisandra.auth.infra.basic.service.SchisandraAuthUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 领域service实现了
*
* @author landaiqing
* @since 2024-05-23 20:00:28
*/
@Service
@Slf4j
public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDomainService {
@Resource
private SchisandraAuthUserService schisandraAuthUserService;
@Resource
private SchisandraAuthUserRoleService schisandraAuthUserRoleService;
/**
* @description: 注册用户
* @param: [schisandraAuthUserBO]
* @return: com.schisandra.auth.domain.bo.SchisandraAuthUserBO
* @author zlg
* @date: 2024/5/14 20:59
*/
@Override
public Boolean register(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = schisandraAuthUserService.queryByPhone(schisandraAuthUserBO.getPhone());
if (schisandraAuthUser != null) {
return false;
} else {
SchisandraAuthUser schisandraAuthUser1 = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO);
if (schisandraAuthUserService.insert(schisandraAuthUser1)){
SchisandraAuthUserRoleBO schisandraAuthUserRoleBO = new SchisandraAuthUserRoleBO();
schisandraAuthUserRoleBO.setUserId(schisandraAuthUserService.queryByPhone(schisandraAuthUserBO.getPhone()).getId());
schisandraAuthUserRoleBO.setRoleId(1L);
return schisandraAuthUserRoleService.insert(SchisandraAuthUserRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserRoleBO))>1;
}else {
return false;
}
}
}
@Override
public Boolean add(SchisandraAuthUserBO schisandraAuthUserBO) {
public SchisandraAuthUserBO login(SchisandraAuthUserBO schisandraAuthUserBO) {
return null;
}
/**
* @param schisandraAuthUserBO
* @return java.lang.Object
* @description 更新用户信息
* @author schisandra
* @date 2024/3/21 23:14
*/
@Override
public Object update(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO);
schisandraAuthUser.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
return schisandraAuthUserService.insert(schisandraAuthUser) > 0;
Integer count = schisandraAuthUserService.update(schisandraAuthUser);
return count > 0;
}
/**
* @param schisandraAuthUserBO
* @return
* @description 查询用户信息
* @author msz
* @date 2024/4/3 22:10
*/
@Override
public Boolean update(SchisandraAuthUserBO schisandraAuthUserBO) {
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) {
SchisandraAuthUser schisandraAuthUser = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO);
return schisandraAuthUserService.update(schisandraAuthUser) > 0;
return schisandraAuthUserService.insert(schisandraAuthUser);
}
/**
* @param id
* @return java.lang.Object
* @description 添加用户信息
* @author msz
* @date 2024/4/3 22:30
*/
@Override
public Boolean delete(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = new SchisandraAuthUser();
schisandraAuthUser.setId(schisandraAuthUserBO.getId());
schisandraAuthUser.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
return schisandraAuthUserService.update(schisandraAuthUser) > 0;
public Object deleteById(Long id) {
boolean flag = schisandraAuthUserService.deleteById(id);
return flag;
}
}

View File

@@ -0,0 +1,48 @@
package com.schisandra.auth.domain.service.impl;
import com.schisandra.auth.common.enums.IsDeletedFlagEnum;
import com.schisandra.auth.domain.bo.SchisandraAuthUserRoleBO;
import com.schisandra.auth.domain.convert.SchisandraAuthUserRoleBOConverter;
import com.schisandra.auth.domain.service.SchisandraAuthUserRoleDomainService;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUserRole;
import com.schisandra.auth.infra.basic.service.SchisandraAuthUserRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 领域service实现了
*
* @author zlg
* @since 2024-05-25 18:05:40
*/
@Service
@Slf4j
public class SchisandraAuthUserRoleDomainServiceImpl implements SchisandraAuthUserRoleDomainService {
@Resource
private SchisandraAuthUserRoleService schisandraAuthUserRoleService;
@Override
public Boolean add(SchisandraAuthUserRoleBO schisandraAuthUserRoleBO) {
SchisandraAuthUserRole schisandraAuthUserRole = SchisandraAuthUserRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserRoleBO);
schisandraAuthUserRole.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
return schisandraAuthUserRoleService.insert(schisandraAuthUserRole) > 0;
}
@Override
public Boolean update(SchisandraAuthUserRoleBO schisandraAuthUserRoleBO) {
SchisandraAuthUserRole schisandraAuthUserRole = SchisandraAuthUserRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserRoleBO);
return schisandraAuthUserRoleService.update(schisandraAuthUserRole) > 0;
}
@Override
public Boolean delete(SchisandraAuthUserRoleBO schisandraAuthUserRoleBO) {
SchisandraAuthUserRole schisandraAuthUserRole = new SchisandraAuthUserRole();
schisandraAuthUserRole.setId(schisandraAuthUserRoleBO.getId());
schisandraAuthUserRole.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
return schisandraAuthUserRoleService.update(schisandraAuthUserRole) > 0;
}
}

View File

@@ -0,0 +1,17 @@
package com.schisandra.auth.infra.basic.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUserRole;
import org.springframework.stereotype.Repository;
/**
* 表数据库访问层
*
* @author zlg
* @since 2024-05-25 18:05:40
*/
@Repository
public interface SchisandraAuthUserRoleDao extends BaseMapper<SchisandraAuthUserRole> {
}

View File

@@ -0,0 +1,71 @@
package com.schisandra.auth.infra.basic.entity;
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 lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 实体类
*
* @author zlg
* @since 2024-05-25 18:05:40
*/
@Data
@TableName("schisandra_auth_user_role")
public class SchisandraAuthUserRole implements Serializable {
/**
*
*/
@TableId(value = "`id`", type = IdType.AUTO)
private Long id;
/**
*
*/
@TableField("`user_id`")
private Long userId;
/**
*
*/
@TableField("`role_id`")
private Long roleId;
/**
* 创建人
*/
@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;
}

View File

@@ -0,0 +1,50 @@
package com.schisandra.auth.infra.basic.service;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUserRole;
/**
* 表服务接口
*
* @author zlg
* @since 2024-05-25 18:05:40
*/
public interface SchisandraAuthUserRoleService {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
SchisandraAuthUserRole queryById(Long id);
/**
* 新增数据
*
* @param schisandraAuthUserRole 实例对象
* @return 实例对象
*/
int insert(SchisandraAuthUserRole schisandraAuthUserRole);
/**
* 修改数据
*
* @param schisandraAuthUserRole 实例对象
* @return 实例对象
*/
int update(SchisandraAuthUserRole schisandraAuthUserRole);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
boolean deleteById(Long id);
/**
* 根据条件查询角色
*/
SchisandraAuthUserRole queryByCondition(SchisandraAuthUserRole schisandraAuthUserRole);
}

View File

@@ -3,13 +3,15 @@ package com.schisandra.auth.infra.basic.service;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
/**
* 表服务接口
* (SchisandraAuthUser)表服务接口
*
* @author landaiqing
* @since 2024-05-23 20:00:28
* @author schisandra
* @since 2024-03-21 20:15:44
*/
public interface SchisandraAuthUserService {
SchisandraAuthUser queryByPhone(String phone);
/**
* 通过ID查询单条数据
*
@@ -24,7 +26,7 @@ public interface SchisandraAuthUserService {
* @param schisandraAuthUser 实例对象
* @return 实例对象
*/
int insert(SchisandraAuthUser schisandraAuthUser);
Boolean insert(SchisandraAuthUser schisandraAuthUser);
/**
* 修改数据

View File

@@ -0,0 +1,93 @@
package com.schisandra.auth.infra.basic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.schisandra.auth.infra.basic.dao.SchisandraAuthUserRoleDao;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUserRole;
import com.schisandra.auth.infra.basic.service.SchisandraAuthUserRoleService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Objects;
/**
* 表服务实现类
*
* @author zlg
* @since 2024-05-25 18:05:40
*/
@Service("SchisandraAuthUserRoleService")
public class SchisandraAuthUserRoleServiceImpl implements SchisandraAuthUserRoleService {
@Resource
private SchisandraAuthUserRoleDao schisandraAuthUserRoleDao;
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
@Override
public SchisandraAuthUserRole queryById(Long id) {
return this.schisandraAuthUserRoleDao.selectById(id);
}
/**
* 新增数据
*
* @param schisandraAuthUserRole 实例对象
* @return 实例对象
*/
@Override
public int insert(SchisandraAuthUserRole schisandraAuthUserRole) {
return this.schisandraAuthUserRoleDao.insert(schisandraAuthUserRole);
}
/**
* 修改数据
*
* @param schisandraAuthUserRole 实例对象
* @return 实例对象
*/
@Override
public int update(SchisandraAuthUserRole schisandraAuthUserRole) {
return this.schisandraAuthUserRoleDao.updateById(schisandraAuthUserRole);
}
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Long id) {
return this.schisandraAuthUserRoleDao.deleteById(id) > 0;
}
/**
* 条件查询
*
* @param schisandraAuthUserRole 条件
* @return 实例对象
*/
@Override
public SchisandraAuthUserRole queryByCondition(SchisandraAuthUserRole schisandraAuthUserRole) {
LambdaQueryWrapper<SchisandraAuthUserRole> queryWrapper = Wrappers.<SchisandraAuthUserRole>lambdaQuery()
.eq(Objects.nonNull(schisandraAuthUserRole.getId()), SchisandraAuthUserRole::getId, schisandraAuthUserRole.getId())
.eq(Objects.nonNull(schisandraAuthUserRole.getUserId()), SchisandraAuthUserRole::getUserId, schisandraAuthUserRole.getUserId())
.eq(Objects.nonNull(schisandraAuthUserRole.getRoleId()), SchisandraAuthUserRole::getRoleId, schisandraAuthUserRole.getRoleId())
.eq(Objects.nonNull(schisandraAuthUserRole.getCreatedBy()), SchisandraAuthUserRole::getCreatedBy, schisandraAuthUserRole.getCreatedBy())
.eq(Objects.nonNull(schisandraAuthUserRole.getCreatedTime()), SchisandraAuthUserRole::getCreatedTime, schisandraAuthUserRole.getCreatedTime())
.eq(Objects.nonNull(schisandraAuthUserRole.getUpdateBy()), SchisandraAuthUserRole::getUpdateBy, schisandraAuthUserRole.getUpdateBy())
.eq(Objects.nonNull(schisandraAuthUserRole.getUpdateTime()), SchisandraAuthUserRole::getUpdateTime, schisandraAuthUserRole.getUpdateTime())
.eq(Objects.nonNull(schisandraAuthUserRole.getIsDeleted()), SchisandraAuthUserRole::getIsDeleted, schisandraAuthUserRole.getIsDeleted())
;
return schisandraAuthUserRoleDao.selectOne(queryWrapper);
}
}

View File

@@ -1,6 +1,5 @@
package com.schisandra.auth.infra.basic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.schisandra.auth.infra.basic.dao.SchisandraAuthUserDao;
@@ -12,10 +11,10 @@ import javax.annotation.Resource;
import java.util.Objects;
/**
* 表服务实现类
* (SchisandraAuthUser)表服务实现类
*
* @author landaiqing
* @since 2024-05-23 20:00:28
* @author schisandra
* @since 2024-03-21 20:15:44
*/
@Service("SchisandraAuthUserService")
public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService {
@@ -23,6 +22,11 @@ public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService
@Resource
private SchisandraAuthUserDao schisandraAuthUserDao;
@Override
public SchisandraAuthUser queryByPhone(String phone) {
return null;
}
/**
* 通过ID查询单条数据
*
@@ -41,8 +45,9 @@ public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService
* @return 实例对象
*/
@Override
public int insert(SchisandraAuthUser schisandraAuthUser) {
return this.schisandraAuthUserDao.insert(schisandraAuthUser);
public Boolean insert(SchisandraAuthUser schisandraAuthUser) {
return this.schisandraAuthUserDao.insert(schisandraAuthUser)>0;
}
/**

View File

@@ -0,0 +1,16 @@
<?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.SchisandraAuthUserRoleDao">
<resultMap id="BaseResultMap" type="com.schisandra.auth.infra.basic.entity.SchisandraAuthUserRole">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="user_id" jdbcType="BIGINT" property="userId"/>
<result column="role_id" jdbcType="BIGINT" property="roleId"/>
<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"/>
</resultMap>
</mapper>