diff --git a/ruoyi-admin/src/main/java/com/ruoyi/base/controller/BaseCategoryController.java b/ruoyi-admin/src/main/java/com/ruoyi/base/controller/BaseCategoryController.java index 83221b1..089915c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/base/controller/BaseCategoryController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/base/controller/BaseCategoryController.java @@ -92,6 +92,10 @@ public class BaseCategoryController extends BaseController @PostMapping public AjaxResult add(@RequestBody BaseCategory baseCategory) { + List list = baseCategoryService.selectByCode(baseCategory.getCode()); + if(!list.isEmpty()){ + return error("唯一编码重复!"); + } return toAjax(baseCategoryService.save(baseCategory)); } @@ -117,4 +121,29 @@ public class BaseCategoryController extends BaseController List list = new ArrayList<>(Arrays.asList(ids)); return toAjax(baseCategoryService.removeByIds(list)); } + + /** + * 根据code查分类字典,list + * @author vinjor-M + * @date 11:31 2025/3/18 + * @param code code + * @param isSystem 是否系统级 + * @return com.ruoyi.common.core.domain.AjaxResult + **/ + @GetMapping("/listByCode") + public AjaxResult listByCode(@RequestParam(value = "code") String code, + @RequestParam(value = "isSystem",required = false) Integer isSystem) + { + List list = baseCategoryService.selectByCode(code); + if(list.isEmpty()){ + return error("未查询到该字典项!"); + } + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(BaseCategory::getPid,list.get(0).getId()); + if(null!=isSystem){ + queryWrapper.eq(BaseCategory::getIsSystem,isSystem); + } + queryWrapper.orderByAsc(BaseCategory::getSort); + return success(baseCategoryService.list(queryWrapper)); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/base/controller/BaseConfigController.java b/ruoyi-admin/src/main/java/com/ruoyi/base/controller/BaseConfigController.java index d090869..1afdfd4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/base/controller/BaseConfigController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/base/controller/BaseConfigController.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.security.access.prepost.PreAuthorize; @@ -109,4 +111,18 @@ public class BaseConfigController extends BaseController List list = new ArrayList<>(Arrays.asList(ids)); return toAjax(baseConfigService.removeByIds(list)); } + /** + * 获取基础配置-账户配置、小程序配置的内容详细信息-根据code获取 + */ + @GetMapping(value = "/getConfigByCode") + public AjaxResult getConfigByCode(String code) + { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper().eq(BaseConfig::getCode,code); + List list = baseConfigService.list(queryWrapper); + if(list.isEmpty()){ + error("未查询到相关配置!"); + } + return success(list.get(0)); + } + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/base/service/IBaseCategoryService.java b/ruoyi-admin/src/main/java/com/ruoyi/base/service/IBaseCategoryService.java index 7f156f2..a610624 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/base/service/IBaseCategoryService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/base/service/IBaseCategoryService.java @@ -15,4 +15,13 @@ import com.ruoyi.base.domain.BaseCategory; public interface IBaseCategoryService extends IService { IPage queryListPage(BaseCategory pageReqVO, Page page); + + /** + * 根据code查询字典 + * @author vinjor-M + * @date 11:32 2025/3/18 + * @param code + * @return java.util.List + **/ + List selectByCode(String code); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/base/service/impl/BaseCategoryServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/base/service/impl/BaseCategoryServiceImpl.java index ea94465..e1aa107 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/base/service/impl/BaseCategoryServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/base/service/impl/BaseCategoryServiceImpl.java @@ -1,6 +1,8 @@ package com.ruoyi.base.service.impl; import java.util.List; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.utils.DateUtils; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -27,4 +29,17 @@ public class BaseCategoryServiceImpl extends ServiceImpl queryListPage(BaseCategory pageReqVO, Page page) { return baseCategoryMapper.queryListPage(pageReqVO, page); } + + /** + * 根据code查询字典 + * + * @param code + * @return java.util.List + * @author vinjor-M + * @date 11:32 2025/3/18 + **/ + @Override + public List selectByCode(String code) { + return this.list(new LambdaQueryWrapper().eq(BaseCategory::getCode,code)); + } } diff --git a/ruoyi-admin/src/main/resources/mapper/base/BaseConfigMapper.xml b/ruoyi-admin/src/main/resources/mapper/base/BaseConfigMapper.xml index 414033b..0cdcf99 100644 --- a/ruoyi-admin/src/main/resources/mapper/base/BaseConfigMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/base/BaseConfigMapper.xml @@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +del_flag=0 and user_type = #{entity.userType} and code = #{entity.code} and name like concat('%', #{entity.name}, '%') and rights_type = #{entity.rightsType} and rights_cycle = #{entity.rightsCycle} + order by user_type,sort asc,create_time asc \ No newline at end of file diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisAutoConfiguration.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisAutoConfiguration.java index b6a027a..a29bf30 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisAutoConfiguration.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisAutoConfiguration.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.incrementer.H2KeyGenerator; import com.baomidou.mybatisplus.extension.incrementer.KingbaseKeyGenerator; import com.baomidou.mybatisplus.extension.incrementer.OracleKeyGenerator; import com.baomidou.mybatisplus.extension.incrementer.PostgreKeyGenerator; +import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; import com.ruoyi.framework.handler.DefaultDBFieldHandler; import org.apache.ibatis.annotations.Mapper; import org.mybatis.spring.annotation.MapperScan; @@ -33,4 +34,15 @@ public class MybatisAutoConfiguration { return new DefaultDBFieldHandler(); // 自动填充参数类 } + /** Mybatis plus 分页插件 **/ + @Bean + public PaginationInterceptor paginationInterceptor() { + PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); + // 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false + // paginationInterceptor.setOverflow(false); + // 设置最大单页限制数量,默认 500 条,-1 不受限制 + paginationInterceptor.setLimit(-1); + return paginationInterceptor; + } + }