Search in sources :

Example 1 with SysDictEntity

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

Example 2 with SysDictEntity

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

Example 3 with SysDictEntity

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

Example 4 with SysDictEntity

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

Example 5 with SysDictEntity

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

Aggregations

SysDictEntity (com.company.project.entity.SysDictEntity)5 ApiOperation (io.swagger.annotations.ApiOperation)3 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)3 SysDictDetailEntity (com.company.project.entity.SysDictDetailEntity)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.company.project.common.exception.BusinessException)1