Search in sources :

Example 1 with SysDictDetailEntity

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();
}
Also used : SysDictDetailEntity(com.jun.plugin.system.entity.SysDictDetailEntity) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with SysDictDetailEntity

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);
}
Also used : SysDictDetailEntity(com.jun.plugin.system.entity.SysDictDetailEntity) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with SysDictDetailEntity

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;
}
Also used : BusinessException(com.jun.plugin.system.common.exception.BusinessException) SysDictDetailEntity(com.jun.plugin.system.entity.SysDictDetailEntity) SysDictEntity(com.jun.plugin.system.entity.SysDictEntity)

Example 4 with SysDictDetailEntity

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));
}
Also used : SysDictDetailEntity(com.jun.plugin.system.entity.SysDictDetailEntity) JSONArray(com.alibaba.fastjson.JSONArray) SysDictEntity(com.jun.plugin.system.entity.SysDictEntity)

Example 5 with SysDictDetailEntity

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();
}
Also used : SysDictDetailEntity(com.jun.plugin.system.entity.SysDictDetailEntity) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

SysDictDetailEntity (com.jun.plugin.system.entity.SysDictDetailEntity)5 ApiOperation (io.swagger.annotations.ApiOperation)3 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)3 SysDictEntity (com.jun.plugin.system.entity.SysDictEntity)2 JSONArray (com.alibaba.fastjson.JSONArray)1 IPage (com.baomidou.mybatisplus.core.metadata.IPage)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 BusinessException (com.jun.plugin.system.common.exception.BusinessException)1