| package com.mzl.flower.web.system; | 
|   | 
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
| import com.mzl.flower.base.BaseController; | 
| import com.mzl.flower.base.R; | 
| import com.mzl.flower.base.ReturnDataDTO; | 
| import com.mzl.flower.dto.request.system.*; | 
| import com.mzl.flower.dto.response.system.CodeTypeDTO; | 
| import com.mzl.flower.dto.response.system.CodeValueDTO; | 
| import com.mzl.flower.service.system.CodeService; | 
| import io.swagger.annotations.Api; | 
| import io.swagger.annotations.ApiImplicitParam; | 
| import io.swagger.annotations.ApiImplicitParams; | 
| import io.swagger.annotations.ApiOperation; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.http.ResponseEntity; | 
| import org.springframework.validation.annotation.Validated; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import java.util.List; | 
|   | 
| @RestController | 
| @RequestMapping("/api/code") | 
| @Api(value = "字典管理", tags = "字典管理") | 
| @Validated | 
| public class CodeController extends BaseController { | 
|     @Autowired | 
|     private CodeService codeService; | 
|   | 
|     @GetMapping("/value") | 
|     @ApiOperation(value = "获取字典值") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "type", value = "类型码", required = true, dataType = "String", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<List<CodeValueDTO>>> searchValue(String type){ | 
|         return returnData(R.SUCCESS.getCode(), codeService.searchValue(type)); | 
|     } | 
|   | 
|     @GetMapping("/multiple") | 
|     @ApiOperation(value = "获取多个字典值") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "type", value = "类型码,逗号隔开", required = true, dataType = "String", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO> searchMultipleValue(String type){ | 
|         return returnData(R.SUCCESS.getCode(), codeService.searchMultipleValue(type)); | 
|     } | 
|   | 
|     @PostMapping("/type/add") | 
|     @ApiOperation(value = "新增字典类型") | 
|     public ResponseEntity<ReturnDataDTO> addType(@RequestBody CreateCodeTypeDTO dto){ | 
|         codeService.addType(dto); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @PostMapping("/type/edit") | 
|     @ApiOperation(value = "编辑字典类型") | 
|     public ResponseEntity<ReturnDataDTO> updateType(@RequestBody UpdateCodeTypeDTO dto){ | 
|         codeService.updateType(dto); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @GetMapping("/type/list") | 
|     @ApiOperation(value = "获取字典类型") | 
|     public ResponseEntity<ReturnDataDTO<Page<CodeTypeDTO>>> searchCodeType(Page page, QueryCodeTypeDTO dto){ | 
|         return returnData(R.SUCCESS.getCode(), codeService.searchCodeType(page, dto)); | 
|     } | 
|   | 
|     @GetMapping("/type/delete") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "字典类型id", required = true, dataType = "String", paramType = "query") | 
|     }) | 
|     @ApiOperation(value = "删除字典类型") | 
|     public ResponseEntity<ReturnDataDTO> deleteDictType(String id) { | 
|         codeService.deleteCodeType(id); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @PostMapping("/value/add") | 
|     @ApiOperation(value = "新增字典值") | 
|     public ResponseEntity<ReturnDataDTO> addCodeValue(@RequestBody CreateCodeValueDTO dto){ | 
|         codeService.addCodeValue(dto); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @PostMapping("/value/edit") | 
|     @ApiOperation(value = "编辑字典值") | 
|     public ResponseEntity<ReturnDataDTO> updateValue(@RequestBody UpdateCodeValueDTO dto){ | 
|         codeService.updateValue(dto); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @GetMapping("/value/delete") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "字典值id", required = true, dataType = "String", paramType = "query") | 
|     }) | 
|     @ApiOperation(value = "删除字典值") | 
|     public ResponseEntity<ReturnDataDTO> deleteCodeValue(String id) { | 
|         codeService.deleteCodeValue(id); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
| } |