New file |
| | |
| | | package com.panzhihua.community_backstage.api; |
| | | |
| | | import com.panzhihua.common.model.vos.BcDictionaryItemVO; |
| | | import com.panzhihua.common.model.vos.BcDictionaryVO; |
| | | import com.panzhihua.common.model.vos.DictionaryVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典 |
| | | * |
| | | * @author manailin |
| | | * @date 2021/8/4 17:00 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/dictionary") |
| | | public class DictionaryApi { |
| | | |
| | | @Resource |
| | | private CommunityService communityService; |
| | | |
| | | /** |
| | | * 插入字典 |
| | | * |
| | | * @param dictionaryVO 字典数据 |
| | | * @return Boolean 是否保存成功 |
| | | * @author manailin |
| | | * @date 2021/6/10 17:00 |
| | | */ |
| | | @PostMapping("/insertDiction") |
| | | R insertDiction(@RequestBody @Valid DictionaryVO dictionaryVO, @ApiIgnore BindingResult results) { |
| | | if (results.hasErrors()) { |
| | | return R.fail(results.getFieldError().getDefaultMessage()); |
| | | } |
| | | return communityService.insertDiction(dictionaryVO); |
| | | } |
| | | |
| | | /** |
| | | * 插入字典项 |
| | | * |
| | | * @param dictionaryVO 字典数据 |
| | | * @return Boolean 是否保存成功 |
| | | * @author manailin |
| | | * @date 2021/6/10 17:00 |
| | | */ |
| | | @PostMapping("/insertDictionItem") |
| | | R insertDictionItem(@RequestBody @Valid BcDictionaryVO dictionaryVO, @ApiIgnore BindingResult results) { |
| | | if (results.hasErrors()) { |
| | | return R.fail(results.getFieldError().getDefaultMessage()); |
| | | } |
| | | return communityService.insertDictionItem(dictionaryVO); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典key查询自典项 |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | @GetMapping("/listDictionaryByKey") |
| | | R<List<BcDictionaryVO>> listDictionaryByKey(@RequestParam("key") String key) { |
| | | |
| | | return communityService.listDictionaryByKey(key); |
| | | } |
| | | |
| | | /** |
| | | * description 根据字典code查询自典项 |
| | | * |
| | | * @param code 入参参数 |
| | | * @return BcDictionaryVO 字典 |
| | | * @author manailin |
| | | * @date 2021/6/10 17:00 |
| | | */ |
| | | @GetMapping("/getByCode") |
| | | BcDictionaryItemVO getByCode(@RequestParam("dictId") String dictId, @RequestParam("code") String code) { |
| | | return communityService.getByCode(dictId, code); |
| | | } |
| | | } |