zhou zhou
1 天以前 1dcfa3702505f0c431757312b5304531029f90f6
rsf-server/src/main/java/com/vincent/rsf/server/system/controller/DictTypeController.java
@@ -16,8 +16,9 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.vincent.rsf.server.manager.utils.buildPageRowsUtils;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;
import java.util.*;
@RestController
@@ -31,25 +32,25 @@
    public R page(@RequestBody Map<String, Object> map) {
        BaseParam baseParam = buildParam(map, BaseParam.class);
        PageParam<DictType, BaseParam> pageParam = new PageParam<>(baseParam, DictType.class);
        return R.ok().add(dictTypeService.page(pageParam, pageParam.buildWrapper(true)));
        return R.ok().add(buildPageRowsUtils.rowsMap(dictTypeService.page(pageParam, pageParam.buildWrapper(true))));
    }
    @PreAuthorize("hasAuthority('system:dictType:list')")
    @PostMapping("/dictType/list")
    public R list(@RequestBody Map<String, Object> map) {
        return R.ok().add(dictTypeService.list());
        return R.ok().add(buildPageRowsUtils.rowsMap(dictTypeService.list()));
    }
    @PreAuthorize("hasAuthority('system:dictType:list')")
    @PostMapping({"/dictType/many/{ids}", "/dictTypes/many/{ids}"})
    public R many(@PathVariable Long[] ids) {
        return R.ok().add(dictTypeService.listByIds(Arrays.asList(ids)));
        return R.ok().add(buildPageRowsUtils.rowsMap(dictTypeService.listByIds(Arrays.asList(ids))));
    }
    @PreAuthorize("hasAuthority('system:dictType:list')")
    @GetMapping("/dictType/{id}")
    public R get(@PathVariable("id") Long id) {
        return R.ok().add(dictTypeService.getById(id));
        return R.ok().add(buildPageRowsUtils.rowsMap(dictTypeService.getById(id)));
    }
    @PreAuthorize("hasAuthority('system:dictType:save')")
@@ -61,29 +62,33 @@
        if (Objects.isNull(dictType.getName())) {
            throw new CoolException("字典名称不能为空!!");
        }
        if (Objects.isNull(dictType.getDescription())) {
            throw new CoolException("字典描述不能为空!!");
        }
        if (Objects.isNull(dictType.getCode())) {
            throw new CoolException("字典编码不能为空!!");
        }
        if (!dictTypeService.list(new LambdaQueryWrapper<DictType>().eq(DictType::getCode, dictType.getCode())).isEmpty()) {
            throw new CoolException("编码不能重复!!");
        }
        if (!dictTypeService.list(new LambdaQueryWrapper<DictType>().eq(DictType::getName, dictType.getName())).isEmpty()) {
            throw new CoolException("名称不能重复!!");
        }
        if (!dictTypeService.save(dictType)) {
            return R.error("Save Fail");
        }
        return R.ok("Save Success").add(dictType);
        return R.ok("Save Success").add(buildPageRowsUtils.rowsMap(dictType));
    }
    @PreAuthorize("hasAuthority('system:dictType:update')")
    @OperationLog("Update 数据字典")
    @PostMapping("/dictType/update")
    public R update(@RequestBody DictType dictType) {
        if (Objects.isNull(dictType)) {
            throw new CoolException("参数不能为空!!");
        }
        dictType.setUpdateBy(getLoginUserId());
        dictType.setUpdateTime(new Date());
        if (!dictTypeService.updateById(dictType)) {
            return R.error("Update Fail");
        }
        return R.ok("Update Success").add(dictType);
        return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(dictType));
    }
    @PreAuthorize("hasAuthority('system:dictType:remove')")
@@ -93,7 +98,7 @@
        if (!dictTypeService.removeByIds(Arrays.asList(ids))) {
            return R.error("Delete Fail");
        }
        return R.ok("Delete Success").add(ids);
        return R.ok("Delete Success").add(buildPageRowsUtils.rowsMap(ids));
    }
    @PreAuthorize("hasAuthority('system:dictType:list')")
@@ -107,13 +112,14 @@
        dictTypeService.page(new Page<>(1, 30), wrapper).getRecords().forEach(
                item -> vos.add(new KeyValVo(item.getId(), item.getName()))
        );
        return R.ok().add(vos);
        return R.ok().add(buildPageRowsUtils.rowsMap(vos));
    }
    @PreAuthorize("hasAuthority('system:dictType:list')")
    @PostMapping("/dictType/export")
    public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
        ExcelUtil.build(ExcelUtil.create(dictTypeService.list(), DictType.class), response);
        ExcelUtil.build(ExcelUtil.create(buildPageRowsUtils.rowsMap(dictTypeService.list()), DictType.class), response);
    }
}