feat:通用认证
This commit is contained in:
1 parent
5e3e866239
commit
1d630d6d81
11 files changed
+464
-22
No files matched your search
@@ -73,24 +73,24 @@ CREATE TABLE `member_view_record`
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '用户查看记录表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for member_auth
|
||||
-- Table structure for member_com_auth
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `member_auth`;
|
||||
CREATE TABLE `member_auth`
|
||||
DROP TABLE IF EXISTS `member_com_auth`;
|
||||
CREATE TABLE `member_com_auth`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '认证编号',
|
||||
`biz_type` varchar(32) NOT NULL COMMENT '认证类型',
|
||||
`biz_id` bigint NOT NULL COMMENT '认证类型编号',
|
||||
`auth_pic` bigint NOT NULL COMMENT '认证图片或视频',
|
||||
`auth_extra` varchar(256) NOT NULL COMMENT '认证额外消息',
|
||||
`auth_time` datetime NOT NULL COMMENT '认证时间',
|
||||
`auth_member_id` bigint NOT NULL COMMENT '认证人编号(-1为系统认证)',
|
||||
`auth_status` varchar(32) NOT NULL COMMENT '认证状态',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '认证编号',
|
||||
`biz_type` varchar(32) NOT NULL COMMENT '认证类型',
|
||||
`biz_id` bigint NOT NULL COMMENT '认证类型编号',
|
||||
`auth_pic` bigint NOT NULL COMMENT '认证图片或视频',
|
||||
`auth_extra_json` varchar(1024) NOT NULL COMMENT '认证额外信息(json)',
|
||||
`auth_time` datetime NOT NULL COMMENT '认证时间',
|
||||
`auth_member_id` bigint NOT NULL COMMENT '认证人编号(-1为系统认证)',
|
||||
`auth_status` varchar(32) NOT NULL COMMENT '认证状态',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '用户认证';
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '用户通用认证';
|
||||
+1
@@ -59,4 +59,5 @@ public interface MemberErrorCode {
|
||||
ErrorCode REPORT_TYPE_NOT_NULL = new ErrorCode(2_001_000_002, "举报类型不能为空");
|
||||
ErrorCode RATING_SCORE_NOT_NULL = new ErrorCode(2_001_000_003, "评价分数不能为空");
|
||||
ErrorCode VIEW_RECORD_NOT_EXISTS = new ErrorCode(2_001_000_004, "用户查看记录不存在");
|
||||
ErrorCode COM_AUTH_NOT_EXISTS = new ErrorCode(2_001_000_005, "通用认证不存在");
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.comauth;
|
||||
|
||||
import cn.iocoder.yudao.module.member.service.comauth.ComAuthService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.comauth.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.comauth.ComAuthDO;
|
||||
|
||||
@Tag(name = "管理后台 - 用户认证")
|
||||
@RestController
|
||||
@RequestMapping("/member/com-auth")
|
||||
@Validated
|
||||
public class ComAuthController {
|
||||
|
||||
@Resource
|
||||
private ComAuthService authService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建用户认证")
|
||||
@PreAuthorize("@ss.hasPermission('member:auth:create')")
|
||||
public CommonResult<Long> createAuth(@Valid @RequestBody ComAuthSaveReqVO createReqVO) {
|
||||
return success(authService.createAuth(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新用户认证")
|
||||
@PreAuthorize("@ss.hasPermission('member:auth:update')")
|
||||
public CommonResult<Boolean> updateAuth(@Valid @RequestBody ComAuthSaveReqVO updateReqVO) {
|
||||
authService.updateAuth(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除用户认证")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('member:auth:delete')")
|
||||
public CommonResult<Boolean> deleteAuth(@RequestParam("id") Long id) {
|
||||
authService.deleteAuth(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得用户认证")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('member:auth:query')")
|
||||
public CommonResult<ComAuthRespVO> getAuth(@RequestParam("id") Long id) {
|
||||
ComAuthDO auth = authService.getAuth(id);
|
||||
return success(BeanUtils.toBean(auth, ComAuthRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得用户认证分页")
|
||||
@PreAuthorize("@ss.hasPermission('member:auth:query')")
|
||||
public CommonResult<PageResult<ComAuthRespVO>> getAuthPage(@Valid ComAuthPageReqVO pageReqVO) {
|
||||
PageResult<ComAuthDO> pageResult = authService.getAuthPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ComAuthRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出用户认证 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('member:auth:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportAuthExcel(@Valid ComAuthPageReqVO pageReqVO, HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ComAuthDO> list = authService.getAuthPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "用户认证.xls", "数据", ComAuthRespVO.class, BeanUtils.toBean(list, ComAuthRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.comauth.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 用户认证分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ComAuthPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "认证类型", example = "2")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "认证类型编号", example = "31110")
|
||||
private Long bizId;
|
||||
|
||||
@Schema(description = "认证图片或视频")
|
||||
private Long authPic;
|
||||
|
||||
@Schema(description = "认证额外信息(json)")
|
||||
private String authExtraJson;
|
||||
|
||||
@Schema(description = "认证时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] authTime;
|
||||
|
||||
@Schema(description = "认证人编号(-1为系统认证)", example = "22515")
|
||||
private Long authMemberId;
|
||||
|
||||
@Schema(description = "认证状态", example = "2")
|
||||
private String authStatus;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.comauth.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 用户认证 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ComAuthRespVO {
|
||||
|
||||
@Schema(description = "认证编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8878")
|
||||
@ExcelProperty("认证编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "认证类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("认证类型")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "认证类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31110")
|
||||
@ExcelProperty("认证类型编号")
|
||||
private Long bizId;
|
||||
|
||||
@Schema(description = "认证图片或视频", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("认证图片或视频")
|
||||
private Long authPic;
|
||||
|
||||
@Schema(description = "认证额外信息(json)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("认证额外信息(json)")
|
||||
private String authExtraJson;
|
||||
|
||||
@Schema(description = "认证时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("认证时间")
|
||||
private LocalDateTime authTime;
|
||||
|
||||
@Schema(description = "认证人编号(-1为系统认证)", requiredMode = Schema.RequiredMode.REQUIRED, example = "22515")
|
||||
@ExcelProperty("认证人编号(-1为系统认证)")
|
||||
private Long authMemberId;
|
||||
|
||||
@Schema(description = "认证状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("认证状态")
|
||||
private String authStatus;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.comauth.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 用户认证新增/修改 Request VO")
|
||||
@Data
|
||||
public class ComAuthSaveReqVO {
|
||||
|
||||
@Schema(description = "认证编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8878")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "认证类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotEmpty(message = "认证类型不能为空")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "认证类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31110")
|
||||
@NotNull(message = "认证类型编号不能为空")
|
||||
private Long bizId;
|
||||
|
||||
@Schema(description = "认证图片或视频", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "认证图片或视频不能为空")
|
||||
private Long authPic;
|
||||
|
||||
@Schema(description = "认证额外信息(json)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "认证额外信息(json)不能为空")
|
||||
private String authExtraJson;
|
||||
|
||||
@Schema(description = "认证时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "认证时间不能为空")
|
||||
private LocalDateTime authTime;
|
||||
|
||||
@Schema(description = "认证人编号(-1为系统认证)", requiredMode = Schema.RequiredMode.REQUIRED, example = "22515")
|
||||
@NotNull(message = "认证人编号(-1为系统认证)不能为空")
|
||||
private Long authMemberId;
|
||||
|
||||
@Schema(description = "认证状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotEmpty(message = "认证状态不能为空")
|
||||
private String authStatus;
|
||||
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package cn.iocoder.yudao.module.member.dal.dataobject.comauth;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 用户认证 DO
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@TableName("member_com_auth")
|
||||
@KeySequence("member_com_auth_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ComAuthDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 认证编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 认证类型
|
||||
*/
|
||||
private String bizType;
|
||||
|
||||
/**
|
||||
* 认证类型编号
|
||||
*/
|
||||
private Long bizId;
|
||||
|
||||
/**
|
||||
* 认证图片或视频
|
||||
*/
|
||||
private Long authPic;
|
||||
|
||||
/**
|
||||
* 认证额外信息(json)
|
||||
*/
|
||||
private String authExtraJson;
|
||||
|
||||
/**
|
||||
* 认证时间
|
||||
*/
|
||||
private LocalDateTime authTime;
|
||||
|
||||
/**
|
||||
* 认证人编号(-1为系统认证)
|
||||
*/
|
||||
private Long authMemberId;
|
||||
|
||||
/**
|
||||
* 认证状态
|
||||
*/
|
||||
private String authStatus;
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.member.dal.mysql.comauth;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.comauth.ComAuthDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.comauth.vo.*;
|
||||
|
||||
/**
|
||||
* 用户认证 Mapper
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@Mapper
|
||||
public interface ComAuthMapper extends BaseMapperX<ComAuthDO> {
|
||||
|
||||
default PageResult<ComAuthDO> selectPage(ComAuthPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ComAuthDO>()
|
||||
.eqIfPresent(ComAuthDO::getBizType, reqVO.getBizType())
|
||||
.eqIfPresent(ComAuthDO::getBizId, reqVO.getBizId())
|
||||
.eqIfPresent(ComAuthDO::getAuthPic, reqVO.getAuthPic())
|
||||
.eqIfPresent(ComAuthDO::getAuthExtraJson, reqVO.getAuthExtraJson())
|
||||
.betweenIfPresent(ComAuthDO::getAuthTime, reqVO.getAuthTime())
|
||||
.eqIfPresent(ComAuthDO::getAuthMemberId, reqVO.getAuthMemberId())
|
||||
.eqIfPresent(ComAuthDO::getAuthStatus, reqVO.getAuthStatus())
|
||||
.betweenIfPresent(ComAuthDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ComAuthDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
-4
@@ -6,10 +6,6 @@ import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 会员的认证 Service 接口
|
||||
*
|
||||
* 提供用户的账号密码登录、token 的校验等认证相关的功能
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface MemberAuthService {
|
||||
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.member.service.comauth;
|
||||
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.comauth.vo.ComAuthPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.comauth.vo.ComAuthSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.comauth.ComAuthDO;
|
||||
|
||||
/**
|
||||
* 用户通用认证 Service 接口
|
||||
*/
|
||||
public interface ComAuthService {
|
||||
|
||||
/**
|
||||
* 创建用户认证
|
||||
*/
|
||||
Long createAuth(@Valid ComAuthSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新用户认证
|
||||
*/
|
||||
void updateAuth(@Valid ComAuthSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除用户认证
|
||||
*/
|
||||
void deleteAuth(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户认证
|
||||
*/
|
||||
ComAuthDO getAuth(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户认证分页
|
||||
*/
|
||||
PageResult<ComAuthDO> getAuthPage(ComAuthPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package cn.iocoder.yudao.module.member.service.comauth;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.comauth.vo.ComAuthPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.comauth.vo.ComAuthSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.comauth.ComAuthDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.comauth.ComAuthMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.MemberErrorCode;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 用户认证 Service 实现类
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ComAuthServiceImpl implements ComAuthService {
|
||||
|
||||
@Resource
|
||||
private ComAuthMapper authMapper;
|
||||
|
||||
@Override
|
||||
public Long createAuth(ComAuthSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ComAuthDO auth = BeanUtils.toBean(createReqVO, ComAuthDO.class);
|
||||
authMapper.insert(auth);
|
||||
// 返回
|
||||
return auth.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAuth(ComAuthSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateAuthExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ComAuthDO updateObj = BeanUtils.toBean(updateReqVO, ComAuthDO.class);
|
||||
authMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAuth(Long id) {
|
||||
// 校验存在
|
||||
validateAuthExists(id);
|
||||
// 删除
|
||||
authMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComAuthDO getAuth(Long id) {
|
||||
return authMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ComAuthDO> getAuthPage(ComAuthPageReqVO pageReqVO) {
|
||||
return authMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
private void validateAuthExists(Long id) {
|
||||
if (authMapper.selectById(id) == null) {
|
||||
throw exception(MemberErrorCode.COM_AUTH_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user