|
@@ -0,0 +1,131 @@
|
|
|
+package com.huaxu.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.huaxu.entity.Dict;
|
|
|
+import com.huaxu.model.AjaxMessage;
|
|
|
+import com.huaxu.model.Pagination;
|
|
|
+import com.huaxu.model.ResultStatus;
|
|
|
+import com.huaxu.service.DictService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 数据字典(Dict)控制层
|
|
|
+ *
|
|
|
+ * @author yjy
|
|
|
+ * @since 2020-10-26
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/dict")
|
|
|
+@Api(tags = "")
|
|
|
+public class DictController {
|
|
|
+ /**
|
|
|
+ * 服务对象
|
|
|
+ */
|
|
|
+ @Autowired
|
|
|
+ private DictService dictService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过主键查询单条数据
|
|
|
+ *
|
|
|
+ * @param dict 参数对象
|
|
|
+ * @return 单条数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "get", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "查询数据字典配置列表")
|
|
|
+ public AjaxMessage<Dict> selectOne(
|
|
|
+ @ApiParam(value = "数据字典配置", required = true) @RequestBody Dict dict) {
|
|
|
+ Dict result = dictService.selectById(dict.getId());
|
|
|
+
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增一条数据
|
|
|
+ *
|
|
|
+ * @param dict 实体类
|
|
|
+ * @return Response对象
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "insert", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "插入数据字典配置列表")
|
|
|
+ public AjaxMessage<Integer> insert(@ApiParam(value = "数据字典配置", required = true) @RequestBody Dict dict) {
|
|
|
+ int result = dictService.insert(dict);
|
|
|
+
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改一条数据
|
|
|
+ *
|
|
|
+ * @param dict 实体类
|
|
|
+ * @return Response对象
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "update", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "修改数据字典配置列表")
|
|
|
+ public AjaxMessage<Integer> update(@ApiParam(value = "数据字典配置", required = true) @RequestBody Dict dict) {
|
|
|
+ int result = dictService.update(dict);
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除一条数据
|
|
|
+ *
|
|
|
+ * @param ids 主键,以逗号隔开
|
|
|
+ * @return Response对象
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "delete", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "删除数据字典配置列表")
|
|
|
+ public AjaxMessage<Integer> delete(String ids) {
|
|
|
+ String[] arrayIds = ids.split(",");
|
|
|
+ List<String> idList = Arrays.asList(arrayIds);
|
|
|
+ int result = dictService.deleteById(idList);
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询
|
|
|
+ *
|
|
|
+ * @param pageNum 偏移
|
|
|
+ * @param pageSize 条数
|
|
|
+ * @return Response对象
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "selectPage", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "查询数据字典配置列表")
|
|
|
+ public AjaxMessage<Pagination<Dict>> selectPage(Integer pageNum, Integer pageSize,String keyWords) {
|
|
|
+ Dict dict = new Dict();
|
|
|
+ dict.setDictName(keyWords);
|
|
|
+ dict.setDictCode(keyWords);
|
|
|
+ IPage<Dict> iPage = new Page<>(pageNum, pageSize);
|
|
|
+ iPage = dictService.selectPage(dict, iPage);
|
|
|
+ Pagination<Dict> pages = new Pagination<>(iPage);
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, pages);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过父配置id查询数据
|
|
|
+ *
|
|
|
+ * @param dict 参数对象
|
|
|
+ * @return 数据列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "selectList", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "查询父配置字典数据")
|
|
|
+ public AjaxMessage<List<Dict>> selectList(
|
|
|
+ @ApiParam(value = "数据字典配置", required = true) @RequestBody Dict dict) {
|
|
|
+ List<Dict> result = dictService.selectList(dict);
|
|
|
+
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|