feat(warning-message): 新增用户注销提示信息管理功能
新增 Controller/Service/Mapper/DO/VO 等全套后端模块,支持分页、增删改查及状态切换;补充对应错误码常量。
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
package com.yolo.keyboard.controller.admin.warningmessage;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.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 jakarta.validation.constraints.*;
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.yolo.keyboard.framework.common.pojo.PageParam;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||
import com.yolo.keyboard.framework.common.pojo.CommonResult;
|
||||
import com.yolo.keyboard.framework.common.util.object.BeanUtils;
|
||||
import static com.yolo.keyboard.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import com.yolo.keyboard.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.yolo.keyboard.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static com.yolo.keyboard.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import com.yolo.keyboard.controller.admin.warningmessage.vo.*;
|
||||
import com.yolo.keyboard.dal.dataobject.warningmessage.KeyboardWarningMessageDO;
|
||||
import com.yolo.keyboard.service.warningmessage.KeyboardWarningMessageService;
|
||||
|
||||
@Tag(name = "管理后台 - 用户注销提示信息")
|
||||
@RestController
|
||||
@RequestMapping("/keyboard/warning-message")
|
||||
@Validated
|
||||
public class KeyboardWarningMessageController {
|
||||
|
||||
@Resource
|
||||
private KeyboardWarningMessageService warningMessageService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建用户注销提示信息")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:warning-message:create')")
|
||||
public CommonResult<Long> createWarningMessage(@Valid @RequestBody KeyboardWarningMessageSaveReqVO createReqVO) {
|
||||
return success(warningMessageService.createWarningMessage(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新用户注销提示信息")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:warning-message:update')")
|
||||
public CommonResult<Boolean> updateWarningMessage(@Valid @RequestBody KeyboardWarningMessageSaveReqVO updateReqVO) {
|
||||
warningMessageService.updateWarningMessage(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除用户注销提示信息")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:warning-message:delete')")
|
||||
public CommonResult<Boolean> deleteWarningMessage(@RequestParam("id") Long id) {
|
||||
warningMessageService.deleteWarningMessage(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除用户注销提示信息")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:warning-message:delete')")
|
||||
public CommonResult<Boolean> deleteWarningMessageList(@RequestParam("ids") List<Long> ids) {
|
||||
warningMessageService.deleteWarningMessageListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得用户注销提示信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:warning-message:query')")
|
||||
public CommonResult<KeyboardWarningMessageRespVO> getWarningMessage(@RequestParam("id") Long id) {
|
||||
KeyboardWarningMessageDO warningMessage = warningMessageService.getWarningMessage(id);
|
||||
return success(BeanUtils.toBean(warningMessage, KeyboardWarningMessageRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得用户注销提示信息分页")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:warning-message:query')")
|
||||
public CommonResult<PageResult<KeyboardWarningMessageRespVO>> getWarningMessagePage(@Valid KeyboardWarningMessagePageReqVO pageReqVO) {
|
||||
PageResult<KeyboardWarningMessageDO> pageResult = warningMessageService.getWarningMessagePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, KeyboardWarningMessageRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出用户注销提示信息 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:warning-message:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportWarningMessageExcel(@Valid KeyboardWarningMessagePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<KeyboardWarningMessageDO> list = warningMessageService.getWarningMessagePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "用户注销提示信息.xls", "数据", KeyboardWarningMessageRespVO.class,
|
||||
BeanUtils.toBean(list, KeyboardWarningMessageRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yolo.keyboard.controller.admin.warningmessage.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.yolo.keyboard.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 用户注销提示信息分页 Request VO")
|
||||
@Data
|
||||
public class KeyboardWarningMessagePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "地区")
|
||||
private String locale;
|
||||
|
||||
@Schema(description = "正文")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime created;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.yolo.keyboard.controller.admin.warningmessage.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import cn.idev.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 用户注销提示信息 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class KeyboardWarningMessageRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "7770")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "地区")
|
||||
@ExcelProperty("地区")
|
||||
private String locale;
|
||||
|
||||
@Schema(description = "正文")
|
||||
@ExcelProperty("正文")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@ExcelProperty("更新时间")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime created;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yolo.keyboard.controller.admin.warningmessage.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 用户注销提示信息新增/修改 Request VO")
|
||||
@Data
|
||||
public class KeyboardWarningMessageSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "7770")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "地区")
|
||||
private String locale;
|
||||
|
||||
@Schema(description = "正文")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime created;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.yolo.keyboard.dal.dataobject.warningmessage;
|
||||
|
||||
import com.yolo.keyboard.framework.tenant.core.aop.TenantIgnore;import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.yolo.keyboard.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 用户注销提示信息 DO
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@TableName("keyboard_warning_message")
|
||||
@KeySequence("keyboard_warning_message_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TenantIgnore
|
||||
public class KeyboardWarningMessageDO{
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 地区
|
||||
*/
|
||||
private String locale;
|
||||
/**
|
||||
* 正文
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updatedAt;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime created;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yolo.keyboard.dal.mysql.warningmessage;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||
import com.yolo.keyboard.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.yolo.keyboard.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.yolo.keyboard.dal.dataobject.warningmessage.KeyboardWarningMessageDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.yolo.keyboard.controller.admin.warningmessage.vo.*;
|
||||
|
||||
/**
|
||||
* 用户注销提示信息 Mapper
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@Mapper
|
||||
public interface KeyboardWarningMessageMapper extends BaseMapperX<KeyboardWarningMessageDO> {
|
||||
|
||||
default PageResult<KeyboardWarningMessageDO> selectPage(KeyboardWarningMessagePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<KeyboardWarningMessageDO>()
|
||||
.eqIfPresent(KeyboardWarningMessageDO::getLocale, reqVO.getLocale())
|
||||
.eqIfPresent(KeyboardWarningMessageDO::getContent, reqVO.getContent())
|
||||
.eqIfPresent(KeyboardWarningMessageDO::getUpdatedAt, reqVO.getUpdatedAt())
|
||||
.eqIfPresent(KeyboardWarningMessageDO::getCreated, reqVO.getCreated())
|
||||
.orderByDesc(KeyboardWarningMessageDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.yolo.keyboard.service.warningmessage;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import com.yolo.keyboard.controller.admin.warningmessage.vo.*;
|
||||
import com.yolo.keyboard.dal.dataobject.warningmessage.KeyboardWarningMessageDO;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 用户注销提示信息 Service 接口
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
public interface KeyboardWarningMessageService {
|
||||
|
||||
/**
|
||||
* 创建用户注销提示信息
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createWarningMessage(@Valid KeyboardWarningMessageSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新用户注销提示信息
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateWarningMessage(@Valid KeyboardWarningMessageSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除用户注销提示信息
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteWarningMessage(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除用户注销提示信息
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteWarningMessageListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得用户注销提示信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 用户注销提示信息
|
||||
*/
|
||||
KeyboardWarningMessageDO getWarningMessage(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户注销提示信息分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 用户注销提示信息分页
|
||||
*/
|
||||
PageResult<KeyboardWarningMessageDO> getWarningMessagePage(KeyboardWarningMessagePageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.yolo.keyboard.service.warningmessage;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import com.yolo.keyboard.controller.admin.warningmessage.vo.*;
|
||||
import com.yolo.keyboard.dal.dataobject.warningmessage.KeyboardWarningMessageDO;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||
|
||||
import com.yolo.keyboard.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.yolo.keyboard.dal.mysql.warningmessage.KeyboardWarningMessageMapper;
|
||||
|
||||
import static com.yolo.keyboard.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.yolo.keyboard.module.infra.enums.ErrorCodeConstants.WARNING_MESSAGE_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 用户注销提示信息 Service 实现类
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class KeyboardWarningMessageServiceImpl implements KeyboardWarningMessageService {
|
||||
|
||||
@Resource
|
||||
private KeyboardWarningMessageMapper warningMessageMapper;
|
||||
|
||||
@Override
|
||||
public Long createWarningMessage(KeyboardWarningMessageSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
KeyboardWarningMessageDO warningMessage = BeanUtils.toBean(createReqVO, KeyboardWarningMessageDO.class);
|
||||
warningMessageMapper.insert(warningMessage);
|
||||
|
||||
// 返回
|
||||
return warningMessage.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWarningMessage(KeyboardWarningMessageSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateWarningMessageExists(updateReqVO.getId());
|
||||
// 更新
|
||||
KeyboardWarningMessageDO updateObj = BeanUtils.toBean(updateReqVO, KeyboardWarningMessageDO.class);
|
||||
warningMessageMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteWarningMessage(Long id) {
|
||||
// 校验存在
|
||||
validateWarningMessageExists(id);
|
||||
// 删除
|
||||
warningMessageMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteWarningMessageListByIds(List<Long> ids) {
|
||||
// 删除
|
||||
warningMessageMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
private void validateWarningMessageExists(Long id) {
|
||||
if (warningMessageMapper.selectById(id) == null) {
|
||||
throw exception(WARNING_MESSAGE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyboardWarningMessageDO getWarningMessage(Long id) {
|
||||
return warningMessageMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<KeyboardWarningMessageDO> getWarningMessagePage(KeyboardWarningMessagePageReqVO pageReqVO) {
|
||||
return warningMessageMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?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.yolo.keyboard.module.keyboard.dal.mysql.warningmessage.KeyboardWarningMessageMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
@@ -95,5 +95,5 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode USER_INVITES_NOT_EXISTS = new ErrorCode(1_001_202_021, "用户邀请关系绑定台账表,记录新用户最终归属的邀请人不存在");
|
||||
ErrorCode TENANT_COMMISSION_NOT_EXISTS = new ErrorCode(1_001_202_022, "租户内购分成记录不存在");
|
||||
ErrorCode AI_COMPANION_NOT_EXISTS = new ErrorCode(1_001_202_023, "AI陪聊角色表,用于定义恋爱/陪伴型虚拟角色的基础信息与人设不存在");
|
||||
|
||||
ErrorCode WARNING_MESSAGE_NOT_EXISTS = new ErrorCode(1_001_202_024, "用户注销提示信息不存在");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user