use of com.jun.plugin.system.entity.SysDictDetailEntity in project jun_springboot_api_service by wujun728.
the class SysDictDetailController method add.
@ApiOperation(value = "新增")
@PostMapping("/add")
@RequiresPermissions("sysDict:add")
public DataResult add(@RequestBody SysDictDetailEntity sysDictDetail) {
if (StringUtils.isEmpty(sysDictDetail.getValue())) {
return DataResult.fail("字典值不能为空");
}
LambdaQueryWrapper<SysDictDetailEntity> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SysDictDetailEntity::getValue, sysDictDetail.getValue());
queryWrapper.eq(SysDictDetailEntity::getDictId, sysDictDetail.getDictId());
SysDictDetailEntity q = sysDictDetailService.getOne(queryWrapper);
if (q != null) {
return DataResult.fail("字典名称-字典值已存在");
}
sysDictDetailService.save(sysDictDetail);
return DataResult.success();
}
use of com.jun.plugin.system.entity.SysDictDetailEntity in project jun_springboot_api_service by wujun728.
the class SysDictDetailController method findListByPage.
@ApiOperation(value = "查询列表数据")
@PostMapping("/listByPage")
@RequiresPermissions("sysDict:list")
public DataResult findListByPage(@RequestBody SysDictDetailEntity sysDictDetail) {
Page page = new Page(sysDictDetail.getPage(), sysDictDetail.getLimit());
if (StringUtils.isEmpty(sysDictDetail.getDictId())) {
return DataResult.success();
}
IPage<SysDictDetailEntity> iPage = sysDictDetailService.listByPage(page, sysDictDetail.getDictId());
return DataResult.success(iPage);
}
use of com.jun.plugin.system.entity.SysDictDetailEntity in project jun_springboot_api_service by wujun728.
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.jun.plugin.system.entity.SysDictDetailEntity in project jun_springboot_api_service by wujun728.
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));
}
use of com.jun.plugin.system.entity.SysDictDetailEntity in project jun_springboot_api_service by wujun728.
the class SysDictDetailController method update.
@ApiOperation(value = "更新")
@PutMapping("/update")
@RequiresPermissions("sysDict:update")
public DataResult update(@RequestBody SysDictDetailEntity sysDictDetail) {
if (StringUtils.isEmpty(sysDictDetail.getValue())) {
return DataResult.fail("字典值不能为空");
}
LambdaQueryWrapper<SysDictDetailEntity> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SysDictDetailEntity::getValue, sysDictDetail.getValue());
queryWrapper.eq(SysDictDetailEntity::getDictId, sysDictDetail.getDictId());
SysDictDetailEntity q = sysDictDetailService.getOne(queryWrapper);
if (q != null && !q.getId().equals(sysDictDetail.getId())) {
return DataResult.fail("字典名称-字典值已存在");
}
sysDictDetailService.updateById(sysDictDetail);
return DataResult.success();
}
Aggregations