|
@@ -1,16 +1,20 @@
|
|
|
package cn.iocoder.yudao.module.system.controller.admin.dict;
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
|
|
-import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.*;
|
|
|
-import cn.iocoder.yudao.module.system.convert.dict.DictTypeConvert;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypePageReqVO;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeRespVO;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeSimpleRespVO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO;
|
|
|
import cn.iocoder.yudao.module.system.service.dict.DictTypeService;
|
|
|
-import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
-import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -36,16 +40,16 @@ public class DictTypeController {
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建字典类型")
|
|
|
@PreAuthorize("@ss.hasPermission('system:dict:create')")
|
|
|
- public CommonResult<Long> createDictType(@Valid @RequestBody DictTypeCreateReqVO reqVO) {
|
|
|
- Long dictTypeId = dictTypeService.createDictType(reqVO);
|
|
|
+ public CommonResult<Long> createDictType(@Valid @RequestBody DictTypeSaveReqVO createReqVO) {
|
|
|
+ Long dictTypeId = dictTypeService.createDictType(createReqVO);
|
|
|
return success(dictTypeId);
|
|
|
}
|
|
|
|
|
|
@PutMapping("/update")
|
|
|
@Operation(summary = "修改字典类型")
|
|
|
@PreAuthorize("@ss.hasPermission('system:dict:update')")
|
|
|
- public CommonResult<Boolean> updateDictType(@Valid @RequestBody DictTypeUpdateReqVO reqVO) {
|
|
|
- dictTypeService.updateDictType(reqVO);
|
|
|
+ public CommonResult<Boolean> updateDictType(@Valid @RequestBody DictTypeSaveReqVO updateReqVO) {
|
|
|
+ dictTypeService.updateDictType(updateReqVO);
|
|
|
return success(true);
|
|
|
}
|
|
|
|
|
@@ -58,11 +62,12 @@ public class DictTypeController {
|
|
|
return success(true);
|
|
|
}
|
|
|
|
|
|
- @Operation(summary = "/获得字典类型的分页列表")
|
|
|
@GetMapping("/page")
|
|
|
+ @Operation(summary = "获得字典类型的分页列表")
|
|
|
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
|
|
- public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(@Valid DictTypePageReqVO reqVO) {
|
|
|
- return success(DictTypeConvert.INSTANCE.convertPage(dictTypeService.getDictTypePage(reqVO)));
|
|
|
+ public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(@Valid DictTypePageReqVO pageReqVO) {
|
|
|
+ PageResult<DictTypeDO> pageResult = dictTypeService.getDictTypePage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, DictTypeRespVO.class));
|
|
|
}
|
|
|
|
|
|
@Operation(summary = "/查询字典类型详细")
|
|
@@ -70,26 +75,28 @@ public class DictTypeController {
|
|
|
@GetMapping(value = "/get")
|
|
|
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
|
|
public CommonResult<DictTypeRespVO> getDictType(@RequestParam("id") Long id) {
|
|
|
- return success(DictTypeConvert.INSTANCE.convert(dictTypeService.getDictType(id)));
|
|
|
+ DictTypeDO dictType = dictTypeService.getDictType(id);
|
|
|
+ return success(BeanUtils.toBean(dictType, DictTypeRespVO.class));
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/list-all-simple")
|
|
|
+ @GetMapping(value = {"/list-all-simple", "simple-list"})
|
|
|
@Operation(summary = "获得全部字典类型列表", description = "包括开启 + 禁用的字典类型,主要用于前端的下拉选项")
|
|
|
// 无需添加权限认证,因为前端全局都需要
|
|
|
public CommonResult<List<DictTypeSimpleRespVO>> getSimpleDictTypeList() {
|
|
|
List<DictTypeDO> list = dictTypeService.getDictTypeList();
|
|
|
- return success(DictTypeConvert.INSTANCE.convertList(list));
|
|
|
+ return success(BeanUtils.toBean(list, DictTypeSimpleRespVO.class));
|
|
|
}
|
|
|
|
|
|
@Operation(summary = "导出数据类型")
|
|
|
@GetMapping("/export")
|
|
|
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
|
|
@OperateLog(type = EXPORT)
|
|
|
- public void export(HttpServletResponse response, @Valid DictTypeExportReqVO reqVO) throws IOException {
|
|
|
- List<DictTypeDO> list = dictTypeService.getDictTypeList(reqVO);
|
|
|
- List<DictTypeExcelVO> data = DictTypeConvert.INSTANCE.convertList02(list);
|
|
|
- // 输出
|
|
|
- ExcelUtils.write(response, "字典类型.xls", "类型列表", DictTypeExcelVO.class, data);
|
|
|
+ public void export(HttpServletResponse response, @Valid DictTypePageReqVO exportReqVO) throws IOException {
|
|
|
+ exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<DictTypeDO> list = dictTypeService.getDictTypePage(exportReqVO).getList();
|
|
|
+ // 导出
|
|
|
+ ExcelUtils.write(response, "字典类型.xls", "数据", DictTypeRespVO.class,
|
|
|
+ BeanUtils.toBean(list, DictTypeRespVO.class));
|
|
|
}
|
|
|
|
|
|
}
|