package com.gkhy.exam.admin.system; import com.gkhy.exam.common.annotation.Log; import com.gkhy.exam.common.api.CommonResult; import com.gkhy.exam.common.domain.entity.SysDictType; import com.gkhy.exam.common.enums.BusinessType; import com.gkhy.exam.system.service.SysDictTypeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; @Api(tags = "数据字典类型前端控制器") @RestController @RequestMapping("/system/dict/type") public class SysDictTypeController { @Autowired private SysDictTypeService dictTypeService; @ApiOperation(value = "字典类型分页") @GetMapping(value = "/list") public CommonResult list(SysDictType dictType){ return CommonResult.success(dictTypeService.selectDictTypeList(dictType)); } @ApiOperation(value = "根据id获取字典类型详情") @GetMapping(value = "/{dictId}") public CommonResult getInfo(@PathVariable(name = "dictId")Long dictId){ return CommonResult.success(dictTypeService.selectDictTypeById(dictId)); } @PreAuthorize("hasAnyAuthority('train:exam:system')") @Log(title = "字典类型", businessType = BusinessType.INSERT) @ApiOperation(value = "新增字典类型") @PostMapping public CommonResult add(@Validated @RequestBody SysDictType dictType){ return CommonResult.success(dictTypeService.insertDictType(dictType)); } @PreAuthorize("hasAnyAuthority('train:exam:system')") @Log(title = "字典类型", businessType = BusinessType.UPDATE) @ApiOperation(value = "编辑字典类型") @PutMapping public CommonResult edit(@Validated @RequestBody SysDictType dictType){ return CommonResult.success(dictTypeService.updateDictType(dictType)); } @PreAuthorize("hasAnyAuthority('train:exam:system')") @Log(title = "字典类型", businessType = BusinessType.DELETE) @ApiOperation(value = "删除字典类型") @DeleteMapping(value = "/{dictIds}") public CommonResult remove(@PathVariable Long[] dictIds){ dictTypeService.deleteDictTypeByIds(dictIds); return CommonResult.success(); } @Log(title = "字典类型", businessType = BusinessType.CLEAN) @ApiOperation(value = "刷新缓存") @DeleteMapping("/refreshCache") public CommonResult refreshCache(){ dictTypeService.resetDictCache(); return CommonResult.success(); } @ApiOperation(value = "获取字典选择框列表") @GetMapping("/optionselect") public CommonResult optionselect() { List dictTypes = dictTypeService.selectDictTypeAll(); return CommonResult.success(dictTypes); } }