use of com.company.project.entity.SysDictEntity in project springboot-manager by aitangbao.
the class SysDictController method update.
@ApiOperation(value = "更新")
@PutMapping("/update")
@RequiresPermissions("sysDict:update")
public DataResult update(@RequestBody SysDictEntity sysDict) {
if (StringUtils.isEmpty(sysDict.getName())) {
return DataResult.fail("字典名称不能为空");
}
SysDictEntity q = sysDictService.getOne(Wrappers.<SysDictEntity>lambdaQuery().eq(SysDictEntity::getName, sysDict.getName()));
if (q != null && !q.getId().equals(sysDict.getId())) {
return DataResult.fail("字典名称已存在");
}
sysDictService.updateById(sysDict);
return DataResult.success();
}
use of com.company.project.entity.SysDictEntity in project springboot-manager by aitangbao.
the class SysDictController method findListByPage.
@ApiOperation(value = "查询分页数据")
@PostMapping("/listByPage")
@RequiresPermissions("sysDict:list")
public DataResult findListByPage(@RequestBody SysDictEntity sysDict) {
Page page = new Page(sysDict.getPage(), sysDict.getLimit());
LambdaQueryWrapper<SysDictEntity> queryWrapper = Wrappers.lambdaQuery();
// 查询条件示例
if (!StringUtils.isEmpty(sysDict.getName())) {
queryWrapper.like(SysDictEntity::getName, sysDict.getName());
queryWrapper.or();
queryWrapper.like(SysDictEntity::getRemark, sysDict.getName());
}
queryWrapper.orderByAsc(SysDictEntity::getName);
IPage<SysDictEntity> iPage = sysDictService.page(page, queryWrapper);
return DataResult.success(iPage);
}
use of com.company.project.entity.SysDictEntity in project springboot-manager by aitangbao.
the class SysDictController method add.
@ApiOperation(value = "新增")
@PostMapping("/add")
@RequiresPermissions("sysDict:add")
public DataResult add(@RequestBody SysDictEntity sysDict) {
if (StringUtils.isEmpty(sysDict.getName())) {
return DataResult.fail("字典名称不能为空");
}
SysDictEntity q = sysDictService.getOne(Wrappers.<SysDictEntity>lambdaQuery().eq(SysDictEntity::getName, sysDict.getName()));
if (q != null) {
return DataResult.fail("字典名称已存在");
}
sysDictService.save(sysDict);
return DataResult.success();
}
use of com.company.project.entity.SysDictEntity in project springboot-manager by aitangbao.
the class SysDictDetailServiceImpl method listByPage.
@Override
public IPage<SysDictDetailEntity> listByPage(Page<SysDictDetailEntity> page, String dictId) {
SysDictEntity sysDictEntity = sysDictMapper.selectById(dictId);
if (sysDictEntity == null) {
throw new BusinessException("获取字典数据失败!");
}
LambdaQueryWrapper<SysDictDetailEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(SysDictDetailEntity::getDictId, dictId);
wrapper.orderByAsc(SysDictDetailEntity::getSort);
IPage<SysDictDetailEntity> result = sysDictDetailMapper.selectPage(page, wrapper);
if (!CollectionUtils.isEmpty(result.getRecords())) {
result.getRecords().parallelStream().forEach(entity -> entity.setDictName(sysDictEntity.getName()));
}
return result;
}
use of com.company.project.entity.SysDictEntity in project springboot-manager by aitangbao.
the class SysDictServiceImpl method getType.
/**
* 根据字典类型查询字典数据信息
*
* @param name 字典名称
* @return 参数键值
*/
public JSONArray getType(String name) {
if (StringUtils.isEmpty(name)) {
return new JSONArray();
}
// 根据名称获取字典
SysDictEntity dict = this.getOne(Wrappers.<SysDictEntity>lambdaQuery().eq(SysDictEntity::getName, name));
if (dict == null || dict.getId() == null) {
return new JSONArray();
}
// 获取明细
List<SysDictDetailEntity> list = sysDictDetailMapper.selectList(Wrappers.<SysDictDetailEntity>lambdaQuery().eq(SysDictDetailEntity::getDictId, dict.getId()));
return JSONArray.parseArray(JSON.toJSONString(list));
}
Aggregations