| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.oying.modules.system.domain.DictDetail; |
| | | import com.oying.utils.R; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author Z |
| | | * @date 2019-04-10 |
| | | */ |
| | | * @author Z |
| | | * @date 2019-04-10 |
| | | */ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "系统:字典详情管理") |
| | |
| | | |
| | | @ApiOperation("查询字典详情") |
| | | @GetMapping |
| | | public ResponseEntity<PageResult<DictDetail>> queryDictDetail(DictDetailQueryCriteria criteria){ |
| | | public ResponseEntity<Object> queryDictDetail(DictDetailQueryCriteria criteria) { |
| | | Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize()); |
| | | return new ResponseEntity<>(dictDetailService.queryAll(criteria, page),HttpStatus.OK); |
| | | return new ResponseEntity<>(R.success(dictDetailService.queryAll(criteria, page)), HttpStatus.OK); |
| | | } |
| | | |
| | | @ApiOperation("查询多个字典详情") |
| | | @GetMapping(value = "/map") |
| | | public ResponseEntity<Object> getDictDetailMaps(@RequestParam String dictName){ |
| | | public ResponseEntity<Object> getDictDetailMaps(@RequestParam String dictName) { |
| | | String[] names = dictName.split("[,,]"); |
| | | Map<String, List<DictDetail>> dictMap = new HashMap<>(16); |
| | | for (String name : names) { |
| | | dictMap.put(name, dictDetailService.getDictByName(name)); |
| | | } |
| | | return new ResponseEntity<>(dictMap, HttpStatus.OK); |
| | | return new ResponseEntity<>(R.success(dictMap), HttpStatus.OK); |
| | | } |
| | | |
| | | @Log("新增字典详情") |
| | | @ApiOperation("新增字典详情") |
| | | @PostMapping |
| | | @PreAuthorize("@el.check('dict:add')") |
| | | public ResponseEntity<Object> createDictDetail(@Validated @RequestBody DictDetail resources){ |
| | | public ResponseEntity<Object> createDictDetail(@Validated @RequestBody DictDetail resources) { |
| | | if (resources.getId() != null) { |
| | | throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); |
| | | throw new BadRequestException("A new " + ENTITY_NAME + " cannot already have an ID"); |
| | | } |
| | | dictDetailService.create(resources); |
| | | return new ResponseEntity<>(HttpStatus.CREATED); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.CREATED); |
| | | } |
| | | |
| | | @Log("修改字典详情") |
| | | @ApiOperation("修改字典详情") |
| | | @PutMapping |
| | | @PreAuthorize("@el.check('dict:edit')") |
| | | public ResponseEntity<Object> updateDictDetail(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources){ |
| | | public ResponseEntity<Object> updateDictDetail(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources) { |
| | | dictDetailService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @Log("删除字典详情") |
| | | @ApiOperation("删除字典详情") |
| | | @DeleteMapping(value = "/{id}") |
| | | @PreAuthorize("@el.check('dict:del')") |
| | | public ResponseEntity<Object> deleteDictDetail(@PathVariable Long id){ |
| | | public ResponseEntity<Object> deleteDictDetail(@PathVariable Long id) { |
| | | dictDetailService.delete(id); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.OK); |
| | | } |
| | | } |