1
This commit is contained in:
parent
7ae2ba0ce1
commit
555d9a0db6
@ -92,6 +92,10 @@ public class BaseCategoryController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody BaseCategory baseCategory)
|
||||
{
|
||||
List<BaseCategory> 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<String> 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<BaseCategory> list = baseCategoryService.selectByCode(code);
|
||||
if(list.isEmpty()){
|
||||
return error("未查询到该字典项!");
|
||||
}
|
||||
LambdaQueryWrapper<BaseCategory> 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));
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,13 @@ import com.ruoyi.base.domain.BaseCategory;
|
||||
public interface IBaseCategoryService extends IService<BaseCategory>
|
||||
{
|
||||
IPage<BaseCategory> queryListPage(BaseCategory pageReqVO, Page<BaseCategory> page);
|
||||
|
||||
/**
|
||||
* 根据code查询字典
|
||||
* @author vinjor-M
|
||||
* @date 11:32 2025/3/18
|
||||
* @param code
|
||||
* @return java.util.List<com.ruoyi.base.domain.BaseCategory>
|
||||
**/
|
||||
List<BaseCategory> selectByCode(String code);
|
||||
}
|
||||
|
@ -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<BaseCategoryMapper,Base
|
||||
public IPage<BaseCategory> queryListPage(BaseCategory pageReqVO, Page<BaseCategory> page) {
|
||||
return baseCategoryMapper.queryListPage(pageReqVO, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code查询字典
|
||||
*
|
||||
* @param code
|
||||
* @return java.util.List<com.ruoyi.base.domain.BaseCategory>
|
||||
* @author vinjor-M
|
||||
* @date 11:32 2025/3/18
|
||||
**/
|
||||
@Override
|
||||
public List<BaseCategory> selectByCode(String code) {
|
||||
return this.list(new LambdaQueryWrapper<BaseCategory>().eq(BaseCategory::getCode,code));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user