mirror of
https://github.com/suyiiyii/SIMS.git
synced 2025-05-30 11:06:11 +08:00
奖惩类型实现分页查询
This commit is contained in:
parent
efc2aa97cb
commit
b04a347c33
@ -0,0 +1,24 @@
|
||||
package top.suyiiyii.sims.common;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@MapperScan("top.suyiiyii.sims.mapper")
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 添加分页插件
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // 如果配置多个插件, 切记分页最后添加
|
||||
// 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType
|
||||
return interceptor;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package top.suyiiyii.sims.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
import top.suyiiyii.sims.common.AuthAccess;
|
||||
import top.suyiiyii.sims.common.Result;
|
||||
import top.suyiiyii.sims.entity.RewardPunishmentCategory;
|
||||
import top.suyiiyii.sims.service.CategoryService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController()
|
||||
@RequestMapping("/category")
|
||||
public class CategoryController {
|
||||
|
||||
@Autowired
|
||||
CategoryService categoryService;
|
||||
@GetMapping("")
|
||||
@Operation(summary = "获取所有类别信息,支持分页")
|
||||
@AuthAccess(allowRoles = {"admin"})
|
||||
public Result<List<RewardPunishmentCategory>> getAllCategory(
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "size", defaultValue = "10") Integer size
|
||||
) {
|
||||
Page<RewardPunishmentCategory> pageObj = new Page<>(page, size);
|
||||
return Result.success(categoryService.getCateGory(pageObj));
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,9 @@ package top.suyiiyii.sims.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.tangzc.mpe.autotable.annotation.Column;
|
||||
import com.tangzc.autotable.annotation.ColumnNotNull;
|
||||
import com.tangzc.mpe.autotable.annotation.Table;
|
||||
import com.tangzc.mpe.autotable.annotation.UniqueIndex;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -23,15 +24,22 @@ import java.util.Objects;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class RewardPunishmentCategory {
|
||||
@TableId(type= IdType.AUTO)
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer categoryId;
|
||||
// 类别名称
|
||||
@ColumnNotNull
|
||||
private String categoryName;
|
||||
@ColumnNotNull
|
||||
@UniqueIndex
|
||||
private String subCategoryName;
|
||||
// 类别说明
|
||||
private String description;
|
||||
|
||||
// 类别状态
|
||||
private String status;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -0,0 +1,7 @@
|
||||
package top.suyiiyii.sims.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import top.suyiiyii.sims.entity.RewardPunishmentCategory;
|
||||
|
||||
public interface MpCategoryMapper extends BaseMapper<RewardPunishmentCategory> {
|
||||
}
|
@ -1,8 +1,12 @@
|
||||
package top.suyiiyii.sims.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.suyiiyii.sims.entity.RewardPunishmentCategory;
|
||||
import top.suyiiyii.sims.mapper.CategoryMapper;
|
||||
import top.suyiiyii.sims.mapper.MpCategoryMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -19,6 +23,9 @@ public class CategoryService {
|
||||
@Autowired
|
||||
CategoryMapper categoryMapper;
|
||||
|
||||
@Autowired
|
||||
MpCategoryMapper mpCategoryMapper;
|
||||
|
||||
|
||||
public String getCategoryName(Integer id) {
|
||||
return categoryMapper.getCategoryName(id);
|
||||
@ -29,12 +36,13 @@ public class CategoryService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Integer> getIdByCategoryName(String categoryName) {
|
||||
return categoryMapper.getIdByCategoryName(categoryName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<RewardPunishmentCategory> getCateGory(Page pageObj) {
|
||||
mpCategoryMapper.selectPage(pageObj, new LambdaQueryWrapper<>());
|
||||
return pageObj.getRecords();
|
||||
}
|
||||
}
|
||||
|
14
设计文档/奖惩类别的增删改查.md
Normal file
14
设计文档/奖惩类别的增删改查.md
Normal file
@ -0,0 +1,14 @@
|
||||
# 奖惩类别的增删改查
|
||||
## 需求
|
||||
1. 管理员可以查看奖惩类别的数据,可以按奖惩类型查看(类别名称,奖惩类型,是否启用,类别说明,操作),需分页展示
|
||||
2. 管理员可以启用或禁用某个奖惩类别,禁用后在添加奖惩记录的页面中不显示该奖惩类别 ,启动后恢复
|
||||
3. 管理员可以删除某个奖惩类别,但需要为已有该奖惩类别的奖惩记录选择一个替代的奖惩类别,替换后相应的奖惩记录也会同步更新
|
||||
|
||||
### 需求1
|
||||
基础增删改查,支持分页
|
||||
|
||||
### 需求2
|
||||
先使用已有接口进行查询,然后再查询已有数据的类型有没有被禁用,过滤即可
|
||||
|
||||
### 需求3
|
||||
全表替换
|
Loading…
x
Reference in New Issue
Block a user