Compare commits
2 Commits
3d559e8903
...
506e1e0192
| Author | SHA1 | Date | |
|---|---|---|---|
| 506e1e0192 | |||
| e2fdd1637f |
@@ -0,0 +1,38 @@
|
||||
package com.yolo.keyborad.controller;
|
||||
|
||||
import com.yolo.keyborad.common.BaseResponse;
|
||||
import com.yolo.keyborad.common.ResultUtils;
|
||||
import com.yolo.keyborad.model.vo.warning.KeyboardWarningMessageRespVO;
|
||||
import com.yolo.keyborad.service.KeyboardWarningMessageService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2026/2/28
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/keyboardWarningMessage")
|
||||
@Tag(name = "注销提示信息")
|
||||
public class KeyboardWarningMessageController {
|
||||
|
||||
private final KeyboardWarningMessageService keyboardWarningMessageService;
|
||||
|
||||
public KeyboardWarningMessageController(KeyboardWarningMessageService keyboardWarningMessageService) {
|
||||
this.keyboardWarningMessageService = keyboardWarningMessageService;
|
||||
}
|
||||
|
||||
@GetMapping("/byLocale")
|
||||
@Operation(summary = "按 locale 查询提示信息", description = "根据 locale 查询用户注销提示信息")
|
||||
public BaseResponse<KeyboardWarningMessageRespVO> getByLocale(
|
||||
@Parameter(description = "地区/语言标识,例如:zh-CN、en-US", required = true)
|
||||
@RequestParam("locale") String locale
|
||||
) {
|
||||
return ResultUtils.success(keyboardWarningMessageService.getByLocale(locale));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yolo.keyborad.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yolo.keyborad.model.entity.KeyboardWarningMessage;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2026/2/28 13:39
|
||||
*/
|
||||
|
||||
public interface KeyboardWarningMessageMapper extends BaseMapper<KeyboardWarningMessage> {
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.yolo.keyborad.model.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 io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2026/2/28 13:39
|
||||
*/
|
||||
|
||||
/**
|
||||
* 用户注销提示信息表
|
||||
*/
|
||||
@Schema(description="用户注销提示信息表")
|
||||
@Data
|
||||
@TableName(value = "keyboard_warning_message")
|
||||
public class KeyboardWarningMessage {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@Schema(description="主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 地区
|
||||
*/
|
||||
@TableField(value = "\"locale\"")
|
||||
@Schema(description="地区")
|
||||
private String locale;
|
||||
|
||||
/**
|
||||
* 正文
|
||||
*/
|
||||
@TableField(value = "content")
|
||||
@Schema(description="正文")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "updated_at")
|
||||
@Schema(description="更新时间")
|
||||
private Date updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yolo.keyborad.model.vo.warning;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "用户注销提示信息返回")
|
||||
@Data
|
||||
public class KeyboardWarningMessageRespVO {
|
||||
|
||||
@Schema(description = "地区")
|
||||
private String locale;
|
||||
|
||||
@Schema(description = "正文")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private Date updatedAt;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yolo.keyborad.service;
|
||||
|
||||
import com.yolo.keyborad.model.entity.KeyboardWarningMessage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yolo.keyborad.model.vo.warning.KeyboardWarningMessageRespVO;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2026/2/28 13:39
|
||||
*/
|
||||
|
||||
public interface KeyboardWarningMessageService extends IService<KeyboardWarningMessage>{
|
||||
|
||||
KeyboardWarningMessageRespVO getByLocale(String locale);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.yolo.keyborad.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yolo.keyborad.common.ErrorCode;
|
||||
import com.yolo.keyborad.exception.BusinessException;
|
||||
import com.yolo.keyborad.mapper.KeyboardWarningMessageMapper;
|
||||
import com.yolo.keyborad.model.entity.KeyboardWarningMessage;
|
||||
import com.yolo.keyborad.model.vo.warning.KeyboardWarningMessageRespVO;
|
||||
import com.yolo.keyborad.service.KeyboardWarningMessageService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2026/2/28 13:39
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class KeyboardWarningMessageServiceImpl extends ServiceImpl<KeyboardWarningMessageMapper, KeyboardWarningMessage> implements KeyboardWarningMessageService{
|
||||
|
||||
@Override
|
||||
public KeyboardWarningMessageRespVO getByLocale(String locale) {
|
||||
final String normalizedLocale = locale == null ? null : locale.trim();
|
||||
if (!StringUtils.hasText(normalizedLocale)) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
|
||||
final LambdaQueryWrapper<KeyboardWarningMessage> queryWrapper = new LambdaQueryWrapper<KeyboardWarningMessage>()
|
||||
.eq(KeyboardWarningMessage::getLocale, normalizedLocale);
|
||||
final KeyboardWarningMessage warningMessage = this.getOne(queryWrapper);
|
||||
if (warningMessage == null) {
|
||||
throw new BusinessException(ErrorCode.NOT_FOUND_ERROR);
|
||||
}
|
||||
|
||||
final KeyboardWarningMessageRespVO respVO = new KeyboardWarningMessageRespVO();
|
||||
respVO.setLocale(warningMessage.getLocale());
|
||||
respVO.setContent(warningMessage.getContent());
|
||||
respVO.setUpdatedAt(warningMessage.getUpdatedAt());
|
||||
return respVO;
|
||||
}
|
||||
}
|
||||
16
src/main/resources/mapper/KeyboardWarningMessageMapper.xml
Normal file
16
src/main/resources/mapper/KeyboardWarningMessageMapper.xml
Normal 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.yolo.keyborad.mapper.KeyboardWarningMessageMapper">
|
||||
<resultMap id="BaseResultMap" type="com.yolo.keyborad.model.entity.KeyboardWarningMessage">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table keyboard_warning_message-->
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="locale" jdbcType="VARCHAR" property="locale" />
|
||||
<result column="content" jdbcType="VARCHAR" property="content" />
|
||||
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, "locale", content, updated_at
|
||||
</sql>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user