feat(keyboard): 新增键盘用户管理模块
新增 keyboard-server 子模块,含用户 DO/Mapper/Service/Controller 全套代码; 补充错误码 KEYBOARD_USER_NOT_EXISTS; 主工程引入 keyboard-server 依赖并扩展包扫描路径。
This commit is contained in:
56
keyboard-server/pom.xml
Normal file
56
keyboard-server/pom.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.yolo</groupId>
|
||||
<artifactId>yolo</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging> <!-- 2. 新增 packaging 为 jar -->
|
||||
<artifactId>keyboard-server</artifactId>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<description> <!-- 4. 新增 description 为该模块的描述 -->
|
||||
键盘后台服务
|
||||
</description>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>com.yolo</groupId>
|
||||
<artifactId>yolo-spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.yolo</groupId>
|
||||
<artifactId>yolo-spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- DB 相关 -->
|
||||
<dependency>
|
||||
<groupId>com.yolo</groupId>
|
||||
<artifactId>yolo-spring-boot-starter-mybatis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yolo</groupId>
|
||||
<artifactId>yolo-spring-boot-starter-excel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yolo</groupId>
|
||||
<artifactId>yolo-module-infra</artifactId>
|
||||
<version>2025.11-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.yolo.keyboard.controller.admin.user;
|
||||
|
||||
import com.yolo.keyboard.dal.dataobject.user.KeyboardUserDO;
|
||||
import com.yolo.keyboard.controller.admin.user.vo.KeyboardUserPageReqVO;
|
||||
import com.yolo.keyboard.controller.admin.user.vo.KeyboardUserRespVO;
|
||||
import com.yolo.keyboard.controller.admin.user.vo.KeyboardUserSaveReqVO;
|
||||
import com.yolo.keyboard.service.user.KeyboardUserService;
|
||||
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.*;
|
||||
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.*;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 键盘用户")
|
||||
@RestController
|
||||
@RequestMapping("/keyboard-server/keyboard-user")
|
||||
@Validated
|
||||
public class KeyboardUserController {
|
||||
|
||||
@Resource
|
||||
private KeyboardUserService keyboardUserService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建键盘用户")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard-server:keyboard-user:create')")
|
||||
public CommonResult<Long> createKeyboardUser(@Valid @RequestBody KeyboardUserSaveReqVO createReqVO) {
|
||||
return success(keyboardUserService.createKeyboardUser(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新键盘用户")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard-server:keyboard-user:update')")
|
||||
public CommonResult<Boolean> updateKeyboardUser(@Valid @RequestBody KeyboardUserSaveReqVO updateReqVO) {
|
||||
keyboardUserService.updateKeyboardUser(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除键盘用户")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('keyboard-server:keyboard-user:delete')")
|
||||
public CommonResult<Boolean> deleteKeyboardUser(@RequestParam("id") Long id) {
|
||||
keyboardUserService.deleteKeyboardUser(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除键盘用户")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard-server:keyboard-user:delete')")
|
||||
public CommonResult<Boolean> deleteKeyboardUserList(@RequestParam("ids") List<Long> ids) {
|
||||
keyboardUserService.deleteKeyboardUserListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得键盘用户")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard-server:keyboard-user:query')")
|
||||
public CommonResult<KeyboardUserRespVO> getKeyboardUser(@RequestParam("id") Long id) {
|
||||
KeyboardUserDO keyboardUser = keyboardUserService.getKeyboardUser(id);
|
||||
return success(BeanUtils.toBean(keyboardUser, KeyboardUserRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得键盘用户分页")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard-server:keyboard-user:query')")
|
||||
public CommonResult<PageResult<KeyboardUserRespVO>> getKeyboardUserPage(@Valid KeyboardUserPageReqVO pageReqVO) {
|
||||
PageResult<KeyboardUserDO> pageResult = keyboardUserService.getKeyboardUserPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, KeyboardUserRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出键盘用户 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard-server:keyboard-user:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportKeyboardUserExcel(@Valid KeyboardUserPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<KeyboardUserDO> list = keyboardUserService.getKeyboardUserPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "键盘用户.xls", "数据", KeyboardUserRespVO.class,
|
||||
BeanUtils.toBean(list, KeyboardUserRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.yolo.keyboard.controller.admin.user.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 KeyboardUserPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "用户 Id", example = "16033")
|
||||
private Long uid;
|
||||
|
||||
@Schema(description = "用户昵称", example = "张三")
|
||||
private String nickName;
|
||||
|
||||
@Schema(description = "性别")
|
||||
private Integer gender;
|
||||
|
||||
@Schema(description = "头像地址", example = "https://www.iocoder.cn")
|
||||
private String avatarUrl;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Schema(description = "邮箱地址")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "是否禁用", example = "1")
|
||||
private Boolean status;
|
||||
|
||||
@Schema(description = "密码")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "苹果登录subjectId", example = "12266")
|
||||
private String subjectId;
|
||||
|
||||
@Schema(description = "邮箱是否验证")
|
||||
private Boolean emailVerified;
|
||||
|
||||
@Schema(description = "是否是 VIP")
|
||||
private Boolean isVip;
|
||||
|
||||
@Schema(description = "VIP 过期时间")
|
||||
private LocalDateTime vipExpiry;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.yolo.keyboard.controller.admin.user.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 KeyboardUserRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "22036")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户 Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16033")
|
||||
@ExcelProperty("用户 Id")
|
||||
private Long uid;
|
||||
|
||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@ExcelProperty("用户昵称")
|
||||
private String nickName;
|
||||
|
||||
@Schema(description = "性别")
|
||||
@ExcelProperty("性别")
|
||||
private Integer gender;
|
||||
|
||||
@Schema(description = "头像地址", example = "https://www.iocoder.cn")
|
||||
@ExcelProperty("头像地址")
|
||||
private String avatarUrl;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@ExcelProperty("更新时间")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Schema(description = "邮箱地址")
|
||||
@ExcelProperty("邮箱地址")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "是否禁用", example = "1")
|
||||
@ExcelProperty("是否禁用")
|
||||
private Boolean status;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "苹果登录subjectId", example = "12266")
|
||||
@ExcelProperty("苹果登录subjectId")
|
||||
private String subjectId;
|
||||
|
||||
@Schema(description = "邮箱是否验证")
|
||||
@ExcelProperty("邮箱是否验证")
|
||||
private Boolean emailVerified;
|
||||
|
||||
@Schema(description = "是否是 VIP")
|
||||
@ExcelProperty("是否是 VIP")
|
||||
private Boolean isVip;
|
||||
|
||||
@Schema(description = "VIP 过期时间")
|
||||
@ExcelProperty("VIP 过期时间")
|
||||
private LocalDateTime vipExpiry;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.yolo.keyboard.controller.admin.user.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 KeyboardUserSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "22036")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户 Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16033")
|
||||
@NotNull(message = "用户 Id不能为空")
|
||||
private Long uid;
|
||||
|
||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@NotEmpty(message = "用户昵称不能为空")
|
||||
private String nickName;
|
||||
|
||||
@Schema(description = "性别")
|
||||
private Integer gender;
|
||||
|
||||
@Schema(description = "头像地址", example = "https://www.iocoder.cn")
|
||||
private String avatarUrl;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Schema(description = "邮箱地址")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "是否禁用", example = "1")
|
||||
private Boolean status;
|
||||
|
||||
@Schema(description = "密码")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "苹果登录subjectId", example = "12266")
|
||||
private String subjectId;
|
||||
|
||||
@Schema(description = "邮箱是否验证")
|
||||
private Boolean emailVerified;
|
||||
|
||||
@Schema(description = "是否是 VIP")
|
||||
private Boolean isVip;
|
||||
|
||||
@Schema(description = "VIP 过期时间")
|
||||
private LocalDateTime vipExpiry;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.yolo.keyboard.dal.dataobject.user;
|
||||
|
||||
|
||||
import com.yolo.keyboard.framework.tenant.core.aop.TenantIgnore;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
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_user")
|
||||
@KeySequence("keyboard_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TenantIgnore
|
||||
public class KeyboardUserDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 用户 Id
|
||||
*/
|
||||
private Long uid;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickName;
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private Integer gender;
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
private String avatarUrl;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createdAt;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updatedAt;
|
||||
/**
|
||||
* 邮箱地址
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 是否禁用
|
||||
*/
|
||||
private Boolean status;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 苹果登录subjectId
|
||||
*/
|
||||
private String subjectId;
|
||||
/**
|
||||
* 邮箱是否验证
|
||||
*/
|
||||
private Boolean emailVerified;
|
||||
/**
|
||||
* 是否是 VIP
|
||||
*/
|
||||
private Boolean isVip;
|
||||
/**
|
||||
* VIP 过期时间
|
||||
*/
|
||||
private LocalDateTime vipExpiry;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.yolo.keyboard.dal.mysql.user;
|
||||
|
||||
|
||||
|
||||
import com.yolo.keyboard.dal.dataobject.user.KeyboardUserDO;
|
||||
import com.yolo.keyboard.controller.admin.user.vo.KeyboardUserPageReqVO;
|
||||
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 org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 键盘用户 Mapper
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@Mapper
|
||||
public interface KeyboardUserMapper extends BaseMapperX<KeyboardUserDO> {
|
||||
|
||||
default PageResult<KeyboardUserDO> selectPage(KeyboardUserPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<KeyboardUserDO>()
|
||||
.eqIfPresent(KeyboardUserDO::getUid, reqVO.getUid())
|
||||
.likeIfPresent(KeyboardUserDO::getNickName, reqVO.getNickName())
|
||||
.eqIfPresent(KeyboardUserDO::getGender, reqVO.getGender())
|
||||
.eqIfPresent(KeyboardUserDO::getAvatarUrl, reqVO.getAvatarUrl())
|
||||
.eqIfPresent(KeyboardUserDO::getCreatedAt, reqVO.getCreatedAt())
|
||||
.eqIfPresent(KeyboardUserDO::getUpdatedAt, reqVO.getUpdatedAt())
|
||||
.eqIfPresent(KeyboardUserDO::getEmail, reqVO.getEmail())
|
||||
.eqIfPresent(KeyboardUserDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(KeyboardUserDO::getPassword, reqVO.getPassword())
|
||||
.eqIfPresent(KeyboardUserDO::getSubjectId, reqVO.getSubjectId())
|
||||
.eqIfPresent(KeyboardUserDO::getEmailVerified, reqVO.getEmailVerified())
|
||||
.eqIfPresent(KeyboardUserDO::getIsVip, reqVO.getIsVip())
|
||||
.eqIfPresent(KeyboardUserDO::getVipExpiry, reqVO.getVipExpiry())
|
||||
.orderByDesc(KeyboardUserDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.yolo.keyboard.service.user;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.yolo.keyboard.dal.dataobject.user.KeyboardUserDO;
|
||||
import com.yolo.keyboard.controller.admin.user.vo.KeyboardUserPageReqVO;
|
||||
import com.yolo.keyboard.controller.admin.user.vo.KeyboardUserSaveReqVO;
|
||||
import jakarta.validation.*;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 键盘用户 Service 接口
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
public interface KeyboardUserService {
|
||||
|
||||
/**
|
||||
* 创建键盘用户
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createKeyboardUser(@Valid KeyboardUserSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新键盘用户
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateKeyboardUser(@Valid KeyboardUserSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除键盘用户
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteKeyboardUser(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除键盘用户
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteKeyboardUserListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得键盘用户
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 键盘用户
|
||||
*/
|
||||
KeyboardUserDO getKeyboardUser(Long id);
|
||||
|
||||
/**
|
||||
* 获得键盘用户分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 键盘用户分页
|
||||
*/
|
||||
PageResult<KeyboardUserDO> getKeyboardUserPage(KeyboardUserPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.yolo.keyboard.service.user;
|
||||
|
||||
|
||||
import com.yolo.keyboard.dal.dataobject.user.KeyboardUserDO;
|
||||
import com.yolo.keyboard.dal.mysql.user.KeyboardUserMapper;
|
||||
import com.yolo.keyboard.controller.admin.user.vo.KeyboardUserPageReqVO;
|
||||
import com.yolo.keyboard.controller.admin.user.vo.KeyboardUserSaveReqVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||
import com.yolo.keyboard.framework.common.util.object.BeanUtils;
|
||||
|
||||
|
||||
import static com.yolo.keyboard.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.yolo.keyboard.module.infra.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 键盘用户 Service 实现类
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class KeyboardUserServiceImpl implements KeyboardUserService {
|
||||
|
||||
@Resource
|
||||
private KeyboardUserMapper keyboardUserMapper;
|
||||
|
||||
@Override
|
||||
public Long createKeyboardUser(KeyboardUserSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
KeyboardUserDO keyboardUser = BeanUtils.toBean(createReqVO, KeyboardUserDO.class);
|
||||
keyboardUserMapper.insert(keyboardUser);
|
||||
|
||||
// 返回
|
||||
return keyboardUser.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateKeyboardUser(KeyboardUserSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateKeyboardUserExists(updateReqVO.getId());
|
||||
// 更新
|
||||
KeyboardUserDO updateObj = BeanUtils.toBean(updateReqVO, KeyboardUserDO.class);
|
||||
keyboardUserMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteKeyboardUser(Long id) {
|
||||
// 校验存在
|
||||
validateKeyboardUserExists(id);
|
||||
// 删除
|
||||
keyboardUserMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteKeyboardUserListByIds(List<Long> ids) {
|
||||
// 删除
|
||||
keyboardUserMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
private void validateKeyboardUserExists(Long id) {
|
||||
if (keyboardUserMapper.selectById(id) == null) {
|
||||
throw exception(KEYBOARD_USER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyboardUserDO getKeyboardUser(Long id) {
|
||||
return keyboardUserMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<KeyboardUserDO> getKeyboardUserPage(KeyboardUserPageReqVO pageReqVO) {
|
||||
return keyboardUserMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
3
pom.xml
3
pom.xml
@@ -15,7 +15,8 @@
|
||||
<!-- 各种 module 拓展 -->
|
||||
<module>yolo-module-system</module>
|
||||
<module>yolo-module-infra</module>
|
||||
<!-- <module>yolo-module-member</module>-->
|
||||
<module>keyboard-server</module>
|
||||
<!-- <module>yolo-module-member</module>-->
|
||||
<!-- <module>yolo-module-bpm</module>-->
|
||||
<!-- <module>yolo-module-report</module>-->
|
||||
<!-- <module>yolo-module-mp</module>-->
|
||||
|
||||
@@ -69,4 +69,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode DEMO03_GRADE_NOT_EXISTS = new ErrorCode(1_001_201_009, "学生班级不存在");
|
||||
ErrorCode DEMO03_GRADE_EXISTS = new ErrorCode(1_001_201_010, "学生班级已存在");
|
||||
|
||||
|
||||
// ========== 键盘用户 1-001-202-000 ==========
|
||||
ErrorCode KEYBOARD_USER_NOT_EXISTS = new ErrorCode(1_001_202_000, "键盘用户不存在");
|
||||
}
|
||||
|
||||
@@ -31,7 +31,11 @@
|
||||
<artifactId>yolo-module-infra</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.yolo</groupId>
|
||||
<artifactId>keyboard-server</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- spring boot 配置所需依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yolo.info.base-package}
|
||||
@SpringBootApplication(scanBasePackages = {"${yolo.info.base-package}.server", "${yolo.info.base-package}.module"})
|
||||
@SpringBootApplication(scanBasePackages = {"${yolo.info.base-package}.server", "${yolo.info.base-package}.module", "com.yolo.keyboard"})
|
||||
public class YoloServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 48080
|
||||
port: 48081
|
||||
|
||||
--- #################### 数据库相关配置 ####################
|
||||
|
||||
@@ -50,11 +50,11 @@ spring:
|
||||
url: jdbc:postgresql://localhost:5432/keyborad_db?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||
username: root
|
||||
password: 123asd
|
||||
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||
lazy: true # 开启懒加载,保证启动速度
|
||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||
username: root
|
||||
password: 123456
|
||||
# slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||
# lazy: true # 开启懒加载,保证启动速度
|
||||
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||
# username: root
|
||||
# password: 123456
|
||||
|
||||
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
||||
data:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 48080
|
||||
port: 48081
|
||||
|
||||
--- #################### 数据库相关配置 ####################
|
||||
spring:
|
||||
@@ -232,3 +232,22 @@ justauth:
|
||||
type: REDIS
|
||||
prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE::
|
||||
timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟
|
||||
|
||||
--- #################### 微信公众号相关配置 ####################
|
||||
wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档
|
||||
mp:
|
||||
# 公众号配置(必填)
|
||||
app-id: wx041349c6f39b268b
|
||||
secret: 5abee519483bc9f8cb37ce280e814bd0
|
||||
# 存储配置,解决 AccessToken 的跨节点的共享
|
||||
config-storage:
|
||||
type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取
|
||||
key-prefix: wx # Redis Key 的前缀
|
||||
http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台
|
||||
miniapp: # 小程序配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-miniapp-spring-boot-starter/README.md 文档
|
||||
appid: wx63c280fe3248a3e7
|
||||
secret: 6f270509224a7ae1296bbf1c8cb97aed
|
||||
config-storage:
|
||||
type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取
|
||||
key-prefix: wa # Redis Key 的前缀
|
||||
http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台
|
||||
@@ -58,12 +58,12 @@ mybatis-plus:
|
||||
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。
|
||||
id-type: NONE # "智能"模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。
|
||||
# id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库
|
||||
# id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库
|
||||
# id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解
|
||||
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
|
||||
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
|
||||
logic-delete-value: 1 # 逻辑已删除值
|
||||
logic-not-delete-value: 0 # 逻辑未删除值
|
||||
banner: false # 关闭控制台的 Banner 打印
|
||||
type-aliases-package: ${yolo.info.base-package}.module.*.dal.dataobject
|
||||
encryptor:
|
||||
|
||||
Reference in New Issue
Block a user