对比新文件 |
| | |
| | | package com.gk.firework.Controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.gk.firework.Domain.*; |
| | | import com.gk.firework.Domain.Utils.*; |
| | | import com.gk.firework.Service.*; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStream; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | @Api(tags = "数据字典接口") |
| | | @RestController |
| | | public class DictionaryController { |
| | | @Autowired |
| | | DictionaryTypeService dictionaryTypeService; |
| | | @Autowired |
| | | DictionaryItemService dictionaryItemService; |
| | | |
| | | |
| | | @Autowired |
| | | UserService userService; |
| | | @Autowired |
| | | RoleService roleService; |
| | | @Autowired |
| | | UserRolesService userRolesService; |
| | | @Autowired |
| | | RolePermissionsService rolePermissionsService; |
| | | @Autowired |
| | | ExcelExportService excelExportService; |
| | | @Autowired |
| | | DistrictService districtService; |
| | | @Autowired |
| | | UserRolesService userRolesInfoService; |
| | | |
| | | @GetMapping("/dictionary-types") |
| | | @ApiOperation(value = "获取数据字典类型",response = Msg.class) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageIndex",value = "当前页码"), |
| | | @ApiImplicitParam(name = "pageSize",value = "每页行数"), |
| | | @ApiImplicitParam(name = "name",value = "名称"), |
| | | }) |
| | | public Msg getDictionaryTypeInfo(@RequestParam(defaultValue = "0") Integer pageIndex, @RequestParam(defaultValue = "10") Integer pageSize, String name){ |
| | | Msg msg = new Msg(); |
| | | msg.setCode("200"); |
| | | msg.setMessage("success"); |
| | | |
| | | PageInfo pageInfo = new PageInfo(pageIndex, pageSize); |
| | | HashMap<String, Object> condition = new HashMap<String, Object>(); |
| | | |
| | | if (StringUtils.isNotBlank(name)) { |
| | | condition.put("name", name.trim()); |
| | | } |
| | | |
| | | pageInfo.setCondition(condition); |
| | | dictionaryTypeService.selectDataGrid(pageInfo); |
| | | msg.setResult(pageInfo); |
| | | return msg; |
| | | } |
| | | |
| | | @PostMapping("/adddictionary-types") |
| | | @ApiOperation(value = "添加数据字典类型",response = Msg.class) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "code",value = "编码",required = true), |
| | | @ApiImplicitParam(name = "text",value = "名称",required = true), |
| | | @ApiImplicitParam(name = "description",value = "备注"), |
| | | @ApiImplicitParam(name = "operator",value = "操作人"), |
| | | }) |
| | | public Msg addDiactionaryTypeInfo(@RequestBody JSONObject jsonObject){ |
| | | Msg msg = new Msg(); |
| | | msg.setCode("200"); |
| | | msg.setMessage("success"); |
| | | String code = jsonObject.getString("code"); |
| | | String text = jsonObject.getString("text"); |
| | | String operator = jsonObject.getString("operator"); |
| | | DictionaryTypeInfo dictionaryExistCode = dictionaryTypeService.selctByCode(code); |
| | | if (dictionaryExistCode != null){ |
| | | msg.setCode("999"); |
| | | msg.setMessage("编码已存在"); |
| | | return msg; |
| | | } |
| | | DictionaryTypeInfo dictionaryExistText = dictionaryTypeService.selctByText(text); |
| | | if (dictionaryExistText != null){ |
| | | msg.setCode("999"); |
| | | msg.setMessage("名称已存在"); |
| | | return msg; |
| | | } |
| | | DictionaryTypeInfo dictionaryTypeInfo = new DictionaryTypeInfo(); |
| | | dictionaryTypeInfo.setCode(code); |
| | | dictionaryTypeInfo.setStatus((byte)1); |
| | | dictionaryTypeInfo.setText(text); |
| | | dictionaryTypeInfo.setCreatedby(operator); |
| | | dictionaryTypeInfo.setCreateddate(new Date()); |
| | | dictionaryTypeInfo.setModifiedby(operator); |
| | | dictionaryTypeInfo.setModifieddate(new Date()); |
| | | dictionaryTypeInfo.setDescription(jsonObject.getString("description")); |
| | | dictionaryTypeService.save(dictionaryTypeInfo); |
| | | return msg; |
| | | } |
| | | |
| | | @PostMapping("/putdictionary-types") |
| | | @ApiOperation(value = "修改字典类型",response = Msg.class) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id",value = "id",required = true), |
| | | @ApiImplicitParam(name = "code",value = "编码",required = true), |
| | | @ApiImplicitParam(name = "text",value = "名称",required = true), |
| | | @ApiImplicitParam(name = "description",value = "备注"), |
| | | @ApiImplicitParam(name = "operator",value = "操作人"), |
| | | }) |
| | | public Msg putDiactionaryTypefo(@RequestBody JSONObject jsonObject){ |
| | | Msg msg = new Msg(); |
| | | msg.setCode("200"); |
| | | msg.setMessage("success"); |
| | | Long id = jsonObject.getLong("id"); |
| | | String code = jsonObject.getString("code"); |
| | | String text = jsonObject.getString("text"); |
| | | String operator = jsonObject.getString("operator"); |
| | | List<DictionaryTypeInfo> dictionaryTypes = dictionaryTypeService.selectExistInfo(id,code,null); |
| | | if (dictionaryTypes.size() > 0){ |
| | | msg.setCode("999"); |
| | | msg.setMessage("编码重复"); |
| | | return msg; |
| | | } |
| | | List<DictionaryTypeInfo> dictionaryTypeInfoList = dictionaryTypeService.selectExistInfo(id,null,text); |
| | | if (dictionaryTypeInfoList.size() > 0){ |
| | | msg.setCode("999"); |
| | | msg.setMessage("名称重复"); |
| | | return msg; |
| | | } |
| | | DictionaryTypeInfo dictionaryTypeInfo = new DictionaryTypeInfo(); |
| | | dictionaryTypeInfo.setId(jsonObject.getLong("id")); |
| | | dictionaryTypeInfo.setCode(code); |
| | | dictionaryTypeInfo.setText(text); |
| | | dictionaryTypeInfo.setModifiedby(operator); |
| | | dictionaryTypeInfo.setModifieddate(new Date()); |
| | | dictionaryTypeInfo.setDescription(jsonObject.getString("description")); |
| | | dictionaryTypeService.updateById(dictionaryTypeInfo); |
| | | return msg; |
| | | |
| | | } |
| | | |
| | | @PostMapping("/deldictionary-types") |
| | | @ApiOperation(value = "删除字典类型", notes = "删除字典类型", response = Msg.class) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType="query",name = "id",value = "id",required = true), |
| | | @ApiImplicitParam(paramType="body",name = "lastmodifiedby",value = "更新人"), |
| | | |
| | | }) |
| | | public Msg delDiactionaryTypeInfo(@ApiParam(value = "id,lastmodifiedby") |
| | | @RequestBody JSONObject jsonObject){ |
| | | Msg msg = new Msg(); |
| | | msg.setCode("200"); |
| | | msg.setMessage("success"); |
| | | DictionaryTypeInfo dictionaryTypeInfo = new DictionaryTypeInfo(); |
| | | dictionaryTypeInfo.setId(jsonObject.getLong("id")); |
| | | dictionaryTypeInfo.setModifiedby(jsonObject.getString("lastmodifiedby")); |
| | | dictionaryTypeInfo.setModifieddate(new Date()); |
| | | dictionaryTypeInfo.setStatus((byte)0); |
| | | dictionaryTypeService.updateById(dictionaryTypeInfo); |
| | | return msg; |
| | | } |
| | | |
| | | @GetMapping("/dictionary-items") |
| | | @ApiOperation(value = "获取数据字典详情",response = Msg.class) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageIndex",value = "当前页码"), |
| | | @ApiImplicitParam(name = "pageSize",value = "每页行数"), |
| | | @ApiImplicitParam(name = "name",value = "名称"), |
| | | @ApiImplicitParam(name = "dictionaryTypeId",value = "字典类型id"), |
| | | }) |
| | | public Msg getDiactionaryItemInfo(@RequestParam(defaultValue = "0") Integer pageIndex, @RequestParam(defaultValue = "10") Integer pageSize, |
| | | String name,Long dictionaryTypeId){ |
| | | Msg msg = new Msg(); |
| | | msg.setCode("200"); |
| | | msg.setMessage("success"); |
| | | |
| | | PageInfo pageInfo = new PageInfo(pageIndex, pageSize); |
| | | HashMap<String, Object> condition = new HashMap<String, Object>(); |
| | | |
| | | if (StringUtils.isNotBlank(name)) { |
| | | condition.put("name", name.trim()); |
| | | } |
| | | |
| | | if (dictionaryTypeId != null){ |
| | | condition.put("dictionaryTypeId",dictionaryTypeId); |
| | | } |
| | | |
| | | pageInfo.setCondition(condition); |
| | | dictionaryItemService.selectDataGrid(pageInfo); |
| | | msg.setResult(pageInfo); |
| | | return msg; |
| | | } |
| | | |
| | | @GetMapping("/dictionaryAllItems") |
| | | @ApiOperation(value = "获取数据字典详情",response = Msg.class) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "dictionaryType",value = "字典类型名称"), |
| | | }) |
| | | public Msg getDiactionaryItemInfo(String dictionaryType){ |
| | | Msg msg = new Msg(); |
| | | msg.setCode("200"); |
| | | msg.setMessage("success"); |
| | | |
| | | List<DictionaryItemInfo> dictionaryItems = dictionaryItemService.selectByType(dictionaryType); |
| | | msg.setResult(dictionaryItems); |
| | | return msg; |
| | | } |
| | | |
| | | @PostMapping("/adddictionary-items") |
| | | @ApiOperation(value = "添加数据字典详情",response = Msg.class) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "text",value = "字典标签",required = true), |
| | | @ApiImplicitParam(name = "value",value = "字典值",required = true), |
| | | @ApiImplicitParam(name = "description",value = "备注"), |
| | | @ApiImplicitParam(name = "dictionaryTypeId",value = "类型id"), |
| | | @ApiImplicitParam(name = "operator",value = "操作人"), |
| | | @ApiImplicitParam(name = "sort",value = "序号"), |
| | | @ApiImplicitParam(name = "status",value = "状态"), |
| | | }) |
| | | public Msg addDiactionaryItemInfo(@RequestBody JSONObject jsonObject){ |
| | | Msg msg = new Msg(); |
| | | msg.setCode("200"); |
| | | msg.setMessage("success"); |
| | | String value = jsonObject.getString("value"); |
| | | String text = jsonObject.getString("text"); |
| | | String operator = jsonObject.getString("operator"); |
| | | Long typeid = jsonObject.getLong("dictionaryTypeId"); |
| | | if (typeid == null){ |
| | | msg.setCode("999"); |
| | | msg.setMessage("未选择字典类型"); |
| | | return msg; |
| | | } |
| | | DictionaryItemInfo dictionaryExistCode = dictionaryItemService.selctByText(text); |
| | | if (dictionaryExistCode != null){ |
| | | msg.setCode("999"); |
| | | msg.setMessage("字典标签已存在"); |
| | | return msg; |
| | | } |
| | | DictionaryItemInfo dictionaryExistText = dictionaryItemService.selctByValue(value); |
| | | if (dictionaryExistText != null){ |
| | | msg.setCode("999"); |
| | | msg.setMessage("字典值已存在"); |
| | | return msg; |
| | | } |
| | | DictionaryItemInfo dictionaryItemInfo = new DictionaryItemInfo(); |
| | | dictionaryItemInfo.setTypeid(typeid); |
| | | dictionaryItemInfo.setValue(value); |
| | | dictionaryItemInfo.setStatus(jsonObject.getByte("status")); |
| | | dictionaryItemInfo.setText(text); |
| | | dictionaryItemInfo.setSort(jsonObject.getInteger("sort")); |
| | | dictionaryItemInfo.setCreatedby(operator); |
| | | dictionaryItemInfo.setCreateddate(new Date()); |
| | | dictionaryItemInfo.setModifiedby(operator); |
| | | dictionaryItemInfo.setModifieddate(new Date()); |
| | | dictionaryItemInfo.setDescription(jsonObject.getString("description")); |
| | | dictionaryItemService.save(dictionaryItemInfo); |
| | | return msg; |
| | | } |
| | | |
| | | @PostMapping("/putdictionary-items") |
| | | @ApiOperation(value = "修改字典详情",response = Msg.class) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id",value = "id",required = true), |
| | | @ApiImplicitParam(name = "text",value = "字典标签",required = true), |
| | | @ApiImplicitParam(name = "value",value = "字典值",required = true), |
| | | @ApiImplicitParam(name = "description",value = "备注"), |
| | | @ApiImplicitParam(name = "operator",value = "操作人"), |
| | | @ApiImplicitParam(name = "sort",value = "序号"), |
| | | @ApiImplicitParam(name = "status",value = "状态"), |
| | | }) |
| | | public Msg putDiactionaryItemfo(@RequestBody JSONObject jsonObject){ |
| | | Msg msg = new Msg(); |
| | | msg.setCode("200"); |
| | | msg.setMessage("success"); |
| | | Long id = jsonObject.getLong("id"); |
| | | |
| | | String value = jsonObject.getString("value"); |
| | | String text = jsonObject.getString("text"); |
| | | String operator = jsonObject.getString("operator"); |
| | | |
| | | List<DictionaryTypeInfo> dictionaryTypes = dictionaryItemService.selectExistInfo(id,value,null); |
| | | if (dictionaryTypes.size() > 0){ |
| | | msg.setCode("999"); |
| | | msg.setMessage("字典值重复"); |
| | | return msg; |
| | | } |
| | | List<DictionaryTypeInfo> dictionaryTypeInfoList = dictionaryItemService.selectExistInfo(id,null,text); |
| | | if (dictionaryTypeInfoList.size() > 0){ |
| | | msg.setCode("999"); |
| | | msg.setMessage("字典标签重复"); |
| | | return msg; |
| | | } |
| | | |
| | | DictionaryItemInfo dictionaryItemInfo = new DictionaryItemInfo(); |
| | | dictionaryItemInfo.setId(id); |
| | | dictionaryItemInfo.setValue(value); |
| | | dictionaryItemInfo.setStatus(jsonObject.getByte("status")); |
| | | dictionaryItemInfo.setText(text); |
| | | dictionaryItemInfo.setSort(jsonObject.getInteger("sort")); |
| | | dictionaryItemInfo.setModifiedby(operator); |
| | | dictionaryItemInfo.setModifieddate(new Date()); |
| | | dictionaryItemInfo.setDescription(jsonObject.getString("description")); |
| | | dictionaryItemService.updateById(dictionaryItemInfo); |
| | | return msg; |
| | | } |
| | | |
| | | @PostMapping("/deldictionary-items") |
| | | @ApiOperation(value = "删除字典详情", notes = "删除字典详情", response = Msg.class) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType="query",name = "id",value = "id",required = true), |
| | | @ApiImplicitParam(paramType="body",name = "lastmodifiedby",value = "更新人"), |
| | | |
| | | }) |
| | | public Msg delDiactionaryItemInfo(@ApiParam(value = "id,lastmodifiedby") |
| | | @RequestBody JSONObject jsonObject){ |
| | | Msg msg = new Msg(); |
| | | msg.setCode("200"); |
| | | msg.setMessage("success"); |
| | | DictionaryItemInfo dictionaryTypeInfo = new DictionaryItemInfo(); |
| | | dictionaryTypeInfo.setId(jsonObject.getLong("id")); |
| | | dictionaryItemService.removeById(dictionaryTypeInfo); |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | } |