From f5b8e3c5955e21a3ec9c38bc5cbd6f3927861ea3 Mon Sep 17 00:00:00 2001 From: qdxkrs <39894542+qdxkrs@users.noreply.github.com> Date: Wed, 22 Jun 2022 18:11:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tool/controller/AppManageController.java | 101 --------- .../tool/controller/CacheController.java | 38 ---- .../CropClassifyRecordController.java | 109 ---------- .../DicBusinessServiceController.java | 61 ------ .../controller/FarmingInfoController.java | 108 ---------- .../controller/FileDocumentController.java | 82 -------- .../tool/controller/FileServerController.java | 119 ----------- .../tool/controller/HelloController.java | 34 --- .../HydrologicalStationController.java | 74 ------- .../IndependentCheckController.java | 87 -------- .../controller/IrrigationCheckController.java | 117 ----------- .../IrrigationRecordController.java | 109 ---------- .../IrrigationSarRecordController.java | 123 ----------- .../tool/controller/ShpAdmController.java | 93 --------- .../tool/controller/SysManageController.java | 56 ----- .../tool/controller/SysUserController.java | 195 ------------------ .../controller/TeaGardenPlotController.java | 69 ------- .../tool/controller/TifProductController.java | 110 ---------- .../controller/TypicalFarmerController.java | 128 ------------ .../controller/TypicalPlotController.java | 139 ------------- .../TypicalPlotIrrigationController.java | 131 ------------ .../tool/controller/WcsRecordController.java | 111 ---------- .../tool/controller/WeatherController.java | 92 --------- .../controller/WeatherStationController.java | 53 ----- 24 files changed, 2339 deletions(-) delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/AppManageController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/CacheController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/CropClassifyRecordController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/DicBusinessServiceController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/FarmingInfoController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/FileDocumentController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/FileServerController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/HelloController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/HydrologicalStationController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/IndependentCheckController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/IrrigationCheckController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/IrrigationRecordController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/IrrigationSarRecordController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/ShpAdmController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/SysManageController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/SysUserController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/TeaGardenPlotController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/TifProductController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/TypicalFarmerController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/TypicalPlotController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/TypicalPlotIrrigationController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/WcsRecordController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/WeatherController.java delete mode 100644 src/main/java/com/xkrs/microservice/common/tool/controller/WeatherStationController.java diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/AppManageController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/AppManageController.java deleted file mode 100644 index 3ac9ed8..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/AppManageController.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.FileAppEntity; -import com.xkrs.microservice.model.qo.AppFileQo; -import com.xkrs.microservice.model.validation.AppFileQoInsert; -import com.xkrs.microservice.model.vo.FileServerResultVo; -import com.xkrs.microservice.service.AppManageService; -import com.xkrs.microservice.service.FileServerService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Locale; -import java.util.Optional; -import java.util.regex.Pattern; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; - -/** - * App 管理服务 - * @author tajochen - */ -@RestController -@RequestMapping("/api/app-file") -public class AppManageController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private AppManageService appManageService; - - @Resource - private FileServerService fileServerService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - public String getAllAppFiles() { - Iterable list = appManageService.getAllFile(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/new-version",method = RequestMethod.GET) - @CrossOrigin - public String appFileGetNew(@RequestParam("versionNumber") String versionNumber){ - String pattern = "^([1-9]\\d|[1-9])(.([1-9]\\d|\\d)){2}$"; - boolean isMatch = Pattern.matches(pattern, versionNumber); - if(!isMatch){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"版本号错误",locale); - } - Iterable list = appManageService.checkLastVersionNumber(versionNumber); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/add",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") - @CrossOrigin - public String appFileAdd(@Validated({AppFileQoInsert.class}) @RequestBody AppFileQo appFileQo, - BindingResult bindingResult,@RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 检查版本号是否存在 - Iterable appFileEntityIterable = appManageService.getByVersionNumber(appFileQo.getVersionNumber()); - for (FileAppEntity o : appFileEntityIterable) { - if(o!=null){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"重复的版本号",locale); - } - } - // 获取当前用户名 - String userName = getTokenUserName(token); - appManageService.add(appFileQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public String appFileDelete(@RequestParam("id") Integer id) { - Optional sf = appManageService.getById(id); - if(sf.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"指定id文件不存在",locale); - } - try { - FileServerResultVo fileServerResultVo = fileServerService.deleteFile(sf.get().getMd5(),""); - appManageService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,fileServerResultVo,locale); - } catch (Exception e) { - e.printStackTrace(); - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"文件服务器出错",locale); - } - } -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/CacheController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/CacheController.java deleted file mode 100644 index 4824257..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/CacheController.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.service.CacheService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Locale; - - -/** - * 缓存测试服务 - * @author tajochen - */ -@RestController -@RequestMapping("/api/cache") -public class CacheController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private CacheService cacheService; - - @GetMapping("/get/test-name") - public String findByNickName(@RequestParam(value="testName", required=false) String testName) - { - return cacheService.findByTestName(testName); - } - - @GetMapping("/set/test-name") - public String setNickName(@RequestParam(value="testName", required=false) String testName) - { - return cacheService.setTestName(testName); - } -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/CropClassifyRecordController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/CropClassifyRecordController.java deleted file mode 100644 index 74cbf82..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/CropClassifyRecordController.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.CropClassifyRecordEntity; -import com.xkrs.microservice.model.qo.CropClassifyRecordQo; -import com.xkrs.microservice.model.validation.CropClassifyRecordQoInsert; -import com.xkrs.microservice.service.CropClassifyRecordService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.time.LocalDate; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; -import static com.xkrs.microservice.util.DateTimeUtil.timeMillisToDate; - -/** - * 作物种植记录数据服务 - * @author tajochen - */ -@RestController -@RequestMapping("/api/crop-classify-record") -public class CropClassifyRecordController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private CropClassifyRecordService cropClassifyRecordService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - @CrossOrigin - public String getCropClassifyAllRecord() { - Iterable list = cropClassifyRecordService.getAllRecord(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/admcode",method = RequestMethod.GET) - @CrossOrigin - public String getCropClassifyByAdmCode(@RequestParam("admCode") Integer admCode) { - Iterable list = cropClassifyRecordService.getByAdmCode(admCode); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/towncode/date",method = RequestMethod.GET) - @CrossOrigin - public String getCropClassifyByTownCode(@RequestParam("townCode") String townCode, - @RequestParam("startDateTs") Long startDateTs, - @RequestParam("endDateTs") Long endDateTs) { - if(startDateTs > endDateTs){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - LocalDate sTime = timeMillisToDate(startDateTs); - LocalDate eTime = timeMillisToDate(endDateTs); - Iterable list = cropClassifyRecordService.getByTownCodeAndDate(townCode,sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/admcode/date",method = RequestMethod.GET) - @CrossOrigin - public String getCropClassifyByAdmCodeAndDate(@RequestParam("admCode") Integer admCode, - @RequestParam("startDateTs") Long startDateTs, - @RequestParam("endDateTs") Long endDateTs) { - if(startDateTs > endDateTs){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - LocalDate sTime = timeMillisToDate(startDateTs); - LocalDate eTime = timeMillisToDate(endDateTs); - Iterable list = cropClassifyRecordService.getByAdmCodeAndDateTime(admCode,sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/add",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") - @CrossOrigin - public String cropClassifyAdd(@Validated({CropClassifyRecordQoInsert.class}) @RequestBody CropClassifyRecordQo cropClassifyRecordQo, - BindingResult bindingResult, @RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - cropClassifyRecordService.add(cropClassifyRecordQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public String cropClassifyDelete(@RequestParam("id") Integer id) { - Optional cropClassifyRecordEntity = cropClassifyRecordService.getById(id); - if(cropClassifyRecordEntity.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); - } - cropClassifyRecordService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/DicBusinessServiceController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/DicBusinessServiceController.java deleted file mode 100644 index 3df002b..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/DicBusinessServiceController.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.*; -import com.xkrs.microservice.service.DicBusinessService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Locale; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - - -/** - * 系统用户Controller - * @author tajocehn - */ -@RestController -@RequestMapping(value = "/api/data") -public class DicBusinessServiceController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private DicBusinessService dicBusinessService; - - @RequestMapping(value="/get/soil-classify/all", method = RequestMethod.GET) - public String getAllSoilClassify(){ - Iterable res = dicBusinessService.getAllSoilClassify(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale); - } - - @RequestMapping(value="/get/crop-classify/all", method = RequestMethod.GET) - public String getAllCropClassify(){ - Iterable res = dicBusinessService.getAllCropClassify(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale); - } - - @RequestMapping(value="/get/drought-classify/all", method = RequestMethod.GET) - public String getAllDroughtClassify(){ - Iterable res = dicBusinessService.getAllDroughtClassify(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale); - } - - @RequestMapping(value="/get/land-classify/all", method = RequestMethod.GET) - public String getAllLandClassify(){ - Iterable res = dicBusinessService.getAllLandClassify(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale); - } - - @RequestMapping(value="/get/product/all", method = RequestMethod.GET) - public String getAllProduct(){ - Iterable res = dicBusinessService.getAllProduct(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/FarmingInfoController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/FarmingInfoController.java deleted file mode 100644 index 9bfd662..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/FarmingInfoController.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.FarmingInfoEntity; -import com.xkrs.microservice.model.qo.FarmingInfoQo; -import com.xkrs.microservice.model.validation.FarmingInfoQoInsert; -import com.xkrs.microservice.service.FarmingInfoService; - -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; - -/** - * 农情信息表管理 - * @author tajochen - */ -@RestController -@RequestMapping("/api/farming-info") -public class FarmingInfoController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private FarmingInfoService farmingInfoService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - @CrossOrigin - public String getAllRecord() { - Iterable list = farmingInfoService.getAllRecord(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/dkbh",method = RequestMethod.GET) - @CrossOrigin - public String getByDkbh(@RequestParam("dkbh") String dkbh) { - Iterable list = farmingInfoService.getByDkbh(dkbh); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/qxbh",method = RequestMethod.GET) - @CrossOrigin - public String getByQxbh(@RequestParam("qxbh") Integer qxbh) { - Iterable list = farmingInfoService.getByQxbh(qxbh); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/zwdm",method = RequestMethod.GET) - @CrossOrigin - public String getByQxbhAndZwdm(@RequestParam("qxbh") Integer qxbh,@RequestParam("zwdm") Integer zwdm) { - Iterable list = farmingInfoService.getByZwdmAndQxbh(zwdm,qxbh); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/new",method = RequestMethod.GET) - @CrossOrigin - public String getNewByQxbh(@RequestParam("qxbh") Integer qxbh) { - Iterable list = farmingInfoService.getNewByQxbh(qxbh); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/user-name",method = RequestMethod.GET) - @CrossOrigin - public String getByUserName(@RequestParam("userName") String userName) { - Iterable list = farmingInfoService.getByUserName(userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/add",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor','auth_farm_user')") - @CrossOrigin - public String dataAdd(@Validated({FarmingInfoQoInsert.class}) @RequestBody FarmingInfoQo farmingInfoQo, - BindingResult bindingResult,@RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - farmingInfoService.add(farmingInfoQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public String dataDelete(@RequestParam("id") Integer id) { - Optional typicalPlotEntity = farmingInfoService.getById(id); - if(typicalPlotEntity.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); - } - farmingInfoService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/FileDocumentController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/FileDocumentController.java deleted file mode 100644 index 4d47c64..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/FileDocumentController.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.FileDocumentEntity; -import com.xkrs.microservice.model.qo.FileDocumentQo; -import com.xkrs.microservice.model.validation.FileDocumentQoInsert; -import com.xkrs.microservice.model.vo.FileServerResultVo; -import com.xkrs.microservice.service.FileDocumentService; -import com.xkrs.microservice.service.FileServerService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; -import static com.xkrs.microservice.util.NumberUtil.isStrNumeric; - -/** - * 文档管理服务 - * @author tajochen - */ -@RestController -@RequestMapping("/api/document") -public class FileDocumentController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private FileDocumentService fileDocumentService; - - @Resource - private FileServerService fileServerService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - public String getAllFiles() { - Iterable list = fileDocumentService.getAllFile(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/add",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") - @CrossOrigin - public String fileUpload(@Validated({FileDocumentQoInsert.class}) @RequestBody FileDocumentQo fileDocumentQo, - BindingResult bindingResult,@RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - fileDocumentService.add(fileDocumentQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public String fileDelete(@RequestParam("id") Integer id) { - Optional sf = fileDocumentService.getById(id); - if(sf.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"指定id文件不存在",locale); - } - try { - FileServerResultVo fileServerResultVo = fileServerService.deleteFile(sf.get().getMd5(),""); - fileDocumentService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,fileServerResultVo,locale); - } catch (Exception e) { - e.printStackTrace(); - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"文件服务器出错",locale); - } - } -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/FileServerController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/FileServerController.java deleted file mode 100644 index 18fd5c5..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/FileServerController.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.model.vo.FileServerResultVo; -import com.xkrs.microservice.service.FileServerService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Locale; - -/** - * 文件服务器管理服务 - * @author tajochen - */ -@RestController -@RequestMapping("/api/file") -public class FileServerController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private FileServerService fileServerService; - - /** - * 文件统计 - * @return - */ - @RequestMapping(value="/stat",method = RequestMethod.GET) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public FileServerResultVo getFileStat() { - return fileServerService.getFileStat(); - } - - /** - * 文件删除 - * @param md5 信息摘要 - * @param path 路径 - * @return - */ - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')") - @CrossOrigin - public FileServerResultVo deleteFile(@RequestParam(value = "md5",required = false) String md5, - @RequestParam(value = "path",required = false) String path) { - FileServerResultVo fileServerResultVo = new FileServerResultVo(); - boolean existed = (md5==null||md5.isEmpty())&&(path==null||path.isEmpty()); - if(existed){ - fileServerResultVo.setStatus("fail"); - fileServerResultVo.setData(""); - fileServerResultVo.setMessage("参数为空"); - return fileServerResultVo; - } - return fileServerService.deleteFile(md5,path); - } - - /** - * 获取文件信息 - * @param md5 信息摘要 - * @param path 路径 - * @return - */ - @RequestMapping(value="/get/info",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')") - @CrossOrigin - public FileServerResultVo getFileInfo(@RequestParam(value = "md5",required = false) String md5, - @RequestParam(value = "path",required = false) String path) { - boolean existed = (md5==null||md5.isEmpty())&&(path==null||path.isEmpty()); - if(existed){ - FileServerResultVo fileServerResultVo = new FileServerResultVo<>(); - fileServerResultVo.setStatus("fail"); - fileServerResultVo.setData(""); - fileServerResultVo.setMessage("参数为空"); - return fileServerResultVo; - } - return fileServerService.getFileInfo(md5,path); - } - - /** - * 获取文件列表 - * @param dir 文件夹 - * @return - */ - @RequestMapping(value="/get/list",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')") - @CrossOrigin - public FileServerResultVo getFileList(@RequestParam(value = "dir") String dir) { - return fileServerService.getFileList(dir); - } - - /** - * 修复统计信息 - * @param date 要修复的日期,格式如:20190725 - * @return - */ - @RequestMapping(value="/get/repair-stat",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')") - @CrossOrigin - public FileServerResultVo getFileRepairStat(@RequestParam(value = "date") String date) { - return fileServerService.getFileRepairStat(date); - } - - /** - * 同步失败修复 - * @param force 是否强行修复(0|1) - * @return - */ - @RequestMapping(value="/get/repair",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')") - @CrossOrigin - public FileServerResultVo getFileRepair(@RequestParam(value = "force") String force) { - return fileServerService.getFileRepair(force); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/HelloController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/HelloController.java deleted file mode 100644 index 2643e3b..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/HelloController.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; - -import java.util.Locale; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -/** - * HelloController - * @author tajochen - */ -@RestController -public class HelloController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - /** - * 返回类型为Mono - * @return - */ - @GetMapping("/hello") - public Mono hello() { - // 【改】使用Mono.just生成响应式数据 - return Mono.just(outputEncapsulationObject(PromptMessageEnum.SUCCESS,"Welcome to reactive world ~",locale)); - } -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/HydrologicalStationController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/HydrologicalStationController.java deleted file mode 100644 index 0b0900b..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/HydrologicalStationController.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.HydrologicalStationEntity; -import com.xkrs.microservice.model.qo.HydrologicalStationQo; -import com.xkrs.microservice.model.validation.HydrologicalStationQoInsert; -import com.xkrs.microservice.service.HydrologicalStationService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Locale; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.util.DateTimeUtil.timeMillisToTime; - -/** - * 水文站点数据服务管理 - * @author tajochen - */ -@RestController -@RequestMapping("/api/hydrological-station") -public class HydrologicalStationController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private HydrologicalStationService hydrologicalStationService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - public String getAllFiles() { - Iterable list = hydrologicalStationService.getAllRecord(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/time",method = RequestMethod.GET) - public String getByTime(@RequestParam("sTimeTs") Long sTimeTs,@RequestParam("eTimeTs") Long eTimeTs) { - LocalDateTime sTime = timeMillisToTime(sTimeTs); - LocalDateTime eTime = timeMillisToTime(eTimeTs); - Iterable list = hydrologicalStationService.getByTime(sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/add",method = RequestMethod.POST) - @CrossOrigin - public String addRecord(@Validated({HydrologicalStationQoInsert.class}) @RequestBody HydrologicalStationQo hydrologicalStationQo, - BindingResult bindingResult) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - hydrologicalStationService.add(hydrologicalStationQo); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") - @CrossOrigin - public String deleteRecord(@RequestParam("id") Integer id) { - int res = hydrologicalStationService.delete(id); - if(res!=0){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"id 不存在",locale); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/IndependentCheckController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/IndependentCheckController.java deleted file mode 100644 index b923653..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/IndependentCheckController.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.IndependentCheckEntity; -import com.xkrs.microservice.model.qo.IndependentCheckQo; -import com.xkrs.microservice.model.validation.IndependentCheckQoInsert; -import com.xkrs.microservice.service.IndependentCheckService; - -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; - -/** - * 自主核查表管理 - * @author tajochen - */ -@RestController -@RequestMapping("/api/independent-check") -public class IndependentCheckController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private IndependentCheckService independentCheckService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - @CrossOrigin - public String getAllRecord() { - Iterable list = independentCheckService.getAllRecord(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/qxdm",method = RequestMethod.GET) - @CrossOrigin - public String getByCountyCode(@RequestParam("qxdm") Integer qxdm) { - Iterable list = independentCheckService.getByCountyCode(qxdm); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/user-name",method = RequestMethod.GET) - @CrossOrigin - public String getByUserName(@RequestParam("userName") String userName) { - Iterable list = independentCheckService.getByUserName(userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/add",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") - @CrossOrigin - public String dataAdd(@Validated({IndependentCheckQoInsert.class}) @RequestBody IndependentCheckQo independentCheckQo, - BindingResult bindingResult,@RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - independentCheckService.add(independentCheckQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public String dataDelete(@RequestParam("id") Integer id) { - Optional independentCheckEntity = independentCheckService.getById(id); - if(independentCheckEntity.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); - } - independentCheckService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/IrrigationCheckController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/IrrigationCheckController.java deleted file mode 100644 index 7144ad1..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/IrrigationCheckController.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.IrrigationCheckEntity; -import com.xkrs.microservice.model.qo.IrrigationCheckQo; -import com.xkrs.microservice.model.validation.IrrigationCheckQoInsert; -import com.xkrs.microservice.service.IrrigationCheckService; - -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; -import static com.xkrs.microservice.util.DateTimeUtil.timeMillisToDate; -import static com.xkrs.microservice.util.DateTimeUtil.timeMillisToTime; - -/** - * 灌溉核查表管理 - * @author tajochen - */ -@RestController -@RequestMapping("/api/irrigation-check") -public class IrrigationCheckController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private IrrigationCheckService irrigationCheckService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - @CrossOrigin - public String getAllRecord() { - Iterable list = irrigationCheckService.getAllRecord(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/ggbh",method = RequestMethod.GET) - @CrossOrigin - public String getByGgbh(@RequestParam("ggbh") String ggbh) { - Optional list = irrigationCheckService.getByGgbh(ggbh); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/qxbh",method = RequestMethod.GET) - @CrossOrigin - public String getQxbh(@RequestParam("qxbh") Integer qxbh) { - Iterable list = irrigationCheckService.getByQxbh(qxbh); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/dkbh",method = RequestMethod.GET) - @CrossOrigin - public String getByDkbh(@RequestParam("dkbh") String dkbh) { - Iterable list = irrigationCheckService.getByDkbh(dkbh); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/time",method = RequestMethod.GET) - @CrossOrigin - public String getByQxbhAndCreateTimeBetween(@RequestParam("qxdm") Integer qxdm,@RequestParam("sTimeTs") Long sTimeTs,@RequestParam("eTimeTs") Long eTimeTs) { - if(sTimeTs > eTimeTs){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - LocalDateTime sTime = timeMillisToTime(sTimeTs); - LocalDateTime eTime = timeMillisToTime(eTimeTs); - Iterable list = irrigationCheckService.getByQxbhAndCreateTimeBetween(qxdm,sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/user-name",method = RequestMethod.GET) - @CrossOrigin - public String getByUserName(@RequestParam("userName") String userName) { - Iterable list = irrigationCheckService.getByUserName(userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/add",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") - @CrossOrigin - public String dataAdd(@Validated({IrrigationCheckQoInsert.class}) @RequestBody IrrigationCheckQo irrigationCheckQo, - BindingResult bindingResult,@RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - irrigationCheckService.add(irrigationCheckQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public String dataDelete(@RequestParam("id") Integer id) { - Optional typicalPlotIrrigationEntity = irrigationCheckService.getById(id); - if(typicalPlotIrrigationEntity.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); - } - irrigationCheckService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/IrrigationRecordController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/IrrigationRecordController.java deleted file mode 100644 index 69ed770..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/IrrigationRecordController.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.IrrigationRecordEntity; -import com.xkrs.microservice.model.qo.IrrigationRecordQo; -import com.xkrs.microservice.model.validation.IrrigationRecordQoInsert; -import com.xkrs.microservice.service.IrrigationRecordService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.time.LocalDate; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; -import static com.xkrs.microservice.util.DateTimeUtil.timeMillisToDate; - -/** - * 灌溉记录数据服务 - * @author tajochen - */ -@RestController -@RequestMapping("/api/irrigation-record") -public class IrrigationRecordController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private IrrigationRecordService irrigationRecordService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - @CrossOrigin - public String getIrrigationAllRecord() { - Iterable list = irrigationRecordService.getAllRecord(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/admcode",method = RequestMethod.GET) - @CrossOrigin - public String getIrrigationByAdmCode(@RequestParam("admCode") Integer admCode) { - Iterable list = irrigationRecordService.getByAdmCode(admCode); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/towncode/date",method = RequestMethod.GET) - @CrossOrigin - public String getIrrigationByTownCode(@RequestParam("townCode") String townCode, - @RequestParam("startDateTs") Long startDateTs, - @RequestParam("endDateTs") Long endDateTs) { - if(startDateTs > endDateTs){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - LocalDate sTime = timeMillisToDate(startDateTs); - LocalDate eTime = timeMillisToDate(endDateTs); - Iterable list = irrigationRecordService.getByTownCodeAndDate(townCode,sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/admcode/date",method = RequestMethod.GET) - @CrossOrigin - public String getIrrigationByAdmCodeAndDate(@RequestParam("admCode") Integer admCode, - @RequestParam("startDateTs") Long startDateTs, - @RequestParam("endDateTs") Long endDateTs) { - if(startDateTs > endDateTs){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - LocalDate sTime = timeMillisToDate(startDateTs); - LocalDate eTime = timeMillisToDate(endDateTs); - Iterable list = irrigationRecordService.getByAdmCodeAndDateTime(admCode,sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/add",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") - @CrossOrigin - public String irrigationAdd(@Validated({IrrigationRecordQoInsert.class}) @RequestBody IrrigationRecordQo irrigationRecordQo, - BindingResult bindingResult,@RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - irrigationRecordService.add(irrigationRecordQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public String irrigationDelete(@RequestParam("id") Integer id) { - Optional irrigationRecordEntity = irrigationRecordService.getById(id); - if(irrigationRecordEntity.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); - } - irrigationRecordService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/IrrigationSarRecordController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/IrrigationSarRecordController.java deleted file mode 100644 index 1d32499..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/IrrigationSarRecordController.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.IrrigationSarRecordEntity; -import com.xkrs.microservice.model.qo.IrrigationSarRecordQo; -import com.xkrs.microservice.model.validation.IrrigationSarRecordQoInsert; -import com.xkrs.microservice.service.IrrigationSarRecordService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.time.LocalDate; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; -import static com.xkrs.microservice.util.DateTimeUtil.timeMillisToDate; - -/** - * 灌溉Sar记录数据服务 - * @author tajochen - */ -@RestController -@RequestMapping("/api/irrigation-sar-record") -public class IrrigationSarRecordController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private IrrigationSarRecordService irrigationSarRecordService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - @CrossOrigin - public String getIrrigationAllRecord() { - Iterable list = irrigationSarRecordService.getAllRecord(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/admcode",method = RequestMethod.GET) - @CrossOrigin - public String getIrrigationByAdmCode(@RequestParam("admCode") Integer admCode) { - Iterable list = irrigationSarRecordService.getByAdmCode(admCode); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/towncode/date",method = RequestMethod.GET) - @CrossOrigin - public String getIrrigationByTownCode(@RequestParam("townCode") String townCode, - @RequestParam("startDateTs") Long startDateTs, - @RequestParam("endDateTs") Long endDateTs) { - if(startDateTs > endDateTs){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - LocalDate sTime = timeMillisToDate(startDateTs); - LocalDate eTime = timeMillisToDate(endDateTs); - Iterable list = irrigationSarRecordService.getByTownCodeAndDate(townCode,sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/condition",method = RequestMethod.GET) - @CrossOrigin - public String getCondition(@RequestParam("townCode") String townCode, - @RequestParam("startDateTs") Long startDateTs, - @RequestParam("endDateTs") Long endDateTs) { - if(startDateTs > endDateTs){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - LocalDate sTime = timeMillisToDate(startDateTs); - LocalDate eTime = timeMillisToDate(endDateTs); - Iterable list = irrigationSarRecordService.geAllByCondition(townCode,sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/admcode/date",method = RequestMethod.GET) - @CrossOrigin - public String getIrrigationByAdmCodeAndDate(@RequestParam("admCode") Integer admCode, - @RequestParam("startDateTs") Long startDateTs, - @RequestParam("endDateTs") Long endDateTs) { - if(startDateTs > endDateTs){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - LocalDate sTime = timeMillisToDate(startDateTs); - LocalDate eTime = timeMillisToDate(endDateTs); - Iterable list = irrigationSarRecordService.getByAdmCodeAndDateTime(admCode,sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/add",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") - @CrossOrigin - public String irrigationAdd(@Validated({IrrigationSarRecordQoInsert.class}) @RequestBody IrrigationSarRecordQo irrigationSarRecordQo, - BindingResult bindingResult,@RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - irrigationSarRecordService.add(irrigationSarRecordQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public String irrigationDelete(@RequestParam("id") Integer id) { - Optional irrigationRecordEntity = irrigationSarRecordService.getById(id); - if(irrigationRecordEntity.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); - } - irrigationSarRecordService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/ShpAdmController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/ShpAdmController.java deleted file mode 100644 index be1e4aa..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/ShpAdmController.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.vo.ShpCityVo; -import com.xkrs.microservice.model.vo.ShpCountyVo; -import com.xkrs.microservice.service.AdministrativeDivisionService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Locale; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.util.NumberUtil.isStrAdmCode; - -/** - * 行政区划服务 - * @author tajochen - */ -@RestController -@RequestMapping("/api/adm") -public class ShpAdmController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private AdministrativeDivisionService administrativeDivisionService; - - @RequestMapping(value="/city/get/all",method = RequestMethod.GET) - public String getAllCity() { - Iterable list = administrativeDivisionService.getAllCity(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/city/get/province-code",method = RequestMethod.GET) - public String getAllCityByProvinceCode(@RequestParam(value="provinceCode") String provinceCode) { - if(!isStrAdmCode(provinceCode)){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - Iterable list = administrativeDivisionService.getAllCityByProvinceCode(Integer.valueOf(provinceCode)); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/city/get/city-code",method = RequestMethod.GET) - public String getAllCityCityCode(@RequestParam(value="cityCode") String cityCode) { - if(!isStrAdmCode(cityCode)){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - ShpCityVo res = administrativeDivisionService.getCityByCityCode(Integer.valueOf(cityCode)); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale); - } - - @RequestMapping(value="/county/get/all",method = RequestMethod.GET) - public String getAllCounty() { - Iterable list = administrativeDivisionService.getAllCounty(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/county/get/province-code",method = RequestMethod.GET) - public String getAllCountyByProvinceCode(@RequestParam(value="provinceCode") String provinceCode) { - if(!isStrAdmCode(provinceCode)){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - Iterable list = administrativeDivisionService.getAllCountyByProvinceCode( - Integer.valueOf(provinceCode)); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/county/get/city-code",method = RequestMethod.GET) - public String getAllCountyByCityCode(@RequestParam(value="cityCode") String cityCode) { - if(!isStrAdmCode(cityCode)){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - Iterable list = administrativeDivisionService.getAllCountyByCityCode(Integer.valueOf(cityCode)); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/county/get/county-code",method = RequestMethod.GET) - public String getAllCountyByCountyCode(@RequestParam(value="countyCode") String countyCode) { - if(!isStrAdmCode(countyCode)){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - ShpCountyVo res = administrativeDivisionService.getCountyByCountyCode(Integer.valueOf(countyCode)); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/SysManageController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/SysManageController.java deleted file mode 100644 index 9ff14f4..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/SysManageController.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import nl.basjes.parse.useragent.UserAgent; -import nl.basjes.parse.useragent.UserAgentAnalyzer; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import java.util.Locale; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -/** - * 系统管理测试服务 - * @author tajochen - */ -@RestController -@RequestMapping(value = "/api") -public class SysManageController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @RequestMapping(value="/hello/role",method = RequestMethod.GET) - @PreAuthorize("hasAnyRole('role_administor','role_system_manager')") - public String hello() { - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"hello vip",locale); - } - - @RequestMapping(value="/hello/auth",method = RequestMethod.GET) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user')") - public String world() { - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"world",locale); - } - - @RequestMapping(value="/greeting",method = RequestMethod.GET) - public String greeting(@RequestParam(required=false, defaultValue="World") String name, - @RequestHeader(value="User-Agent") String userAgent) { - System.out.println("==== in greeting ===="); - System.out.println(userAgent); - UserAgentAnalyzer uaa = UserAgentAnalyzer - .newBuilder() - .hideMatcherLoadStats() - .withCache(10000) - .build(); - - UserAgent agent = uaa.parse(userAgent); - for (String fieldName: agent.getAvailableFieldNamesSorted()) { - System.out.println(fieldName + " = " + agent.getValue(fieldName)); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,name,locale); - } -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/SysUserController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/SysUserController.java deleted file mode 100644 index 144ac50..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/SysUserController.java +++ /dev/null @@ -1,195 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.SysRoleEntity; -import com.xkrs.microservice.model.qo.SysUserQo; -import com.xkrs.microservice.model.validation.SysUserQoInsert; -import com.xkrs.microservice.model.vo.SysUserVo; -import com.xkrs.microservice.service.SysRoleService; -import com.xkrs.microservice.service.SysUserService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; - -import java.util.List; -import java.util.Locale; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; -import static com.xkrs.microservice.util.NumberUtil.isStrNumeric; - -/** - * 系统用户Controller - * @author tajocehn - */ -@RestController -@RequestMapping(value = "/api/user") -public class SysUserController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private SysUserService sysUserService; - - @Resource - private SysRoleService sysRoleService; - - /** - * 登录用户Token验证 - * @return - */ - @RequestMapping(value = "/logged/check",method = RequestMethod.POST) - public String loginUserTokenCheck(){ - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value = "/check/duplicate", method = RequestMethod.GET) - public String checkDuplicate(@RequestParam(value="userName", required=false) String userName){ - // 验证用户名是否重复 - if(!sysUserService.checkUserName(userName)){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale); - } - - @RequestMapping(value = "/add", method = RequestMethod.POST) - public String addUser(@Validated({SysUserQoInsert.class}) @RequestBody SysUserQo userQo, - BindingResult bindingResult){ - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 验证用户名是否重复 - if(!sysUserService.checkUserName(userQo.getUserName())){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - // 添加新用户 - sysUserService.addUser(userQo); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale); - } - - @RequestMapping(value="/get/all", method = RequestMethod.GET) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - public String getAllSysUser(){ - Iterable sysUserDtoList = sysUserService.getAllSysUser(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,sysUserDtoList,locale); - } - - /** - * 软删除指定id的普通用户 - * @param id - * @return - */ - @RequestMapping(value = "/general/delete", method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user')") - public String deleteCustomUser(@RequestParam(value="userId", required=false) int id){ - // 验证数据合法性 - int res = sysUserService.softDeleteGeneralUser(id); - if(res==1){ - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"",locale); - } else { - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - } - -// @RequestMapping(value = "/update", method = RequestMethod.POST) -// @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") -// public String updateUser(@Validated({SysUserQoUpdate.class}) @RequestBody SysUserQo userQo, -// BindingResult bindingResult){ -// // 验证数据合法性 -// if(bindingResult.hasErrors()){ -// return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); -// } -// // 修改用户 -// sysUserService.updateSysUser(userQo); -// return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale); -// } - - @RequestMapping(value = "/update/portrait", method = RequestMethod.POST) - public String updateUserPortrait(@RequestParam(value="portraitId") String portraitId, - @RequestHeader(value="Authorization") String token){ - - if(!isStrNumeric(portraitId)){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - // 头像是否正确 - int res = sysUserService.updateSysUserPortrait(userName, Integer.valueOf(portraitId)); - if(res==1){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"",locale); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale); - } - - @RequestMapping(value = "/update/password", method = RequestMethod.POST) - public String updateUserPassword(@RequestParam(value="oldPassword") String oldPassword, - @RequestParam(value="newPassword") String newPassword, - @RequestHeader(value="Authorization") String token){ - // 获取当前用户名 - String userName = getTokenUserName(token); - int res = sysUserService.updateSysUserPassword(userName,oldPassword,newPassword); - final int r1 = 1; - final int r2 = 2; - final int r3 = 3; - if(res==r1){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"未知错误",locale); - } else if(res==r2){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"旧密码错误",locale); - } else if(res==r3){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"新密码不符合规则",locale); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale); - } - - @RequestMapping(value = "/get/info", method = RequestMethod.GET) - public String getUserInfo(@RequestHeader(value="Authorization") String token){ - // 获取当前用户名 - String userName = getTokenUserName(token); - SysUserVo sysUserVo = sysUserService.getSysUserVoByUserName(userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,sysUserVo,locale); - } - - @RequestMapping(value="/set/forbidden",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - public String setUserForbidden(@RequestParam(value="userName", required=true) String userName) { - String generalRole = "role_general_user"; - String farmerRole = "role_farm_user"; - if(sysUserService.checkUserName(userName)){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"userName 错误",locale); - } - List list1 = sysRoleService.getSysRoleListByUserName(userName); - SysRoleEntity sysRoleEntity = list1.get(0); - if(generalRole.equals(sysRoleEntity.getRoleName()) || farmerRole.equals(sysRoleEntity.getRoleName())){ - sysUserService.disableSysUser(userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - return outputEncapsulationObject(PromptMessageEnum.USER_NO_PERMISSION,"",locale); - } - - @RequestMapping(value="/set/enable",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - public String setUserEnable(@RequestParam(value="userName", required=true) String userName) { - String generalRole = "role_general_user"; - String farmerRole = "role_farm_user"; - if(sysUserService.checkUserName(userName)){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"userName 错误",locale); - } - List list1 = sysRoleService.getSysRoleListByUserName(userName); - SysRoleEntity sysRoleEntity = list1.get(0); - if(generalRole.equals(sysRoleEntity.getRoleName()) || farmerRole.equals(sysRoleEntity.getRoleName())){ - sysUserService.enableSysUser(userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - return outputEncapsulationObject(PromptMessageEnum.USER_NO_PERMISSION,"",locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/TeaGardenPlotController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/TeaGardenPlotController.java deleted file mode 100644 index c0a93e7..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/TeaGardenPlotController.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.TeaGardenPlotEntity; -import com.xkrs.microservice.model.qo.TeaGardenPlotQo; -import com.xkrs.microservice.service.TeaGardenPlotService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Locale; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -/** - * 茶园地块管理 - * @author tajochen - */ -@RestController -@RequestMapping("/api/tea-garden-plot") -public class TeaGardenPlotController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private TeaGardenPlotService teaGardenPlotService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - @CrossOrigin - public String getAllRecord() { - Iterable list = teaGardenPlotService.getAllRecord(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/update",method = RequestMethod.POST) -// @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") - @CrossOrigin - public String dataUpdate(@RequestBody TeaGardenPlotQo teaGardenPlotQo) { - teaGardenPlotService.update(teaGardenPlotQo); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/add",method = RequestMethod.POST) -// @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor','auth_farm_user')") - @CrossOrigin - public String dataAdd(@RequestBody TeaGardenPlotQo teaGardenPlotQo) { - // 监测地块编号是否存在 - TeaGardenPlotEntity teaGardenPlotEntity = teaGardenPlotService.getAllRecordByDkbh(teaGardenPlotQo.getDkbh()); - if(teaGardenPlotEntity!=null){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"地块编号已存在",locale); - } - teaGardenPlotService.add(teaGardenPlotQo); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) -// @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor','auth_farm_user')") - @CrossOrigin - public String dataDelete(@RequestParam("id") Integer id) { - int res = teaGardenPlotService.delete(id); - if(res == 1){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/TifProductController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/TifProductController.java deleted file mode 100644 index 4255581..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/TifProductController.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.TifProductEntity; -import com.xkrs.microservice.model.qo.TifProductQo; -import com.xkrs.microservice.model.validation.TifProductQoInsert; -import com.xkrs.microservice.service.TifProductService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.time.LocalDate; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; -import static com.xkrs.microservice.util.DateTimeUtil.timeMillisToDate; - -/** - * 栅格产品管理服务 - * @author tajochen - */ -@RestController -@RequestMapping("/api/tif-product") -public class TifProductController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private TifProductService tifProductService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - public String getAllFiles() { - Iterable list = tifProductService.getAllFile(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/product-code",method = RequestMethod.GET) - public String getByProductCode(@RequestParam("productCode") String productCode) { - TifProductEntity res = tifProductService.getByProductCode(productCode); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale); - } - - @RequestMapping(value="/get/product-type",method = RequestMethod.GET) - public String getByProductType(@RequestParam("productType") String productType) { - Iterable list = tifProductService.getByProductType(productType); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/admcode/product-type",method = RequestMethod.GET) - public String getByAdmCodeAndProductType(@RequestParam("admCode") Integer admCode, - @RequestParam("productType") String productType) { - Iterable list = tifProductService.getByAdmCodeAndProductType(admCode,productType); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/admcode/product-type/date",method = RequestMethod.GET) - public String getByAdmCodeAndProductTypeAndDate(@RequestParam("admCode") Integer admCode, - @RequestParam("productType") String productType, - @RequestParam("startDateTs") Long startDateTs, - @RequestParam("endDateTs") Long endDateTs) { - if(startDateTs > endDateTs){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - LocalDate sTime = timeMillisToDate(startDateTs); - LocalDate eTime = timeMillisToDate(endDateTs); - Iterable list = tifProductService.getByAdmCodeAndProductTypeAndDate(admCode,productType,sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - - @RequestMapping(value="/add",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") - @CrossOrigin - public String fileAdd(@Validated({TifProductQoInsert.class}) @RequestBody TifProductQo tifProductQo, - BindingResult bindingResult,@RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 验证数据是否存在 - if(tifProductService.getByProductCode(tifProductQo.getProductCode())!=null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_REPEAT,"数据已存在",locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - tifProductService.add(tifProductQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public String fileDelete(@RequestParam("id") Integer id) { - Optional tifProductEntity = tifProductService.getById(id); - if(tifProductEntity.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); - } - tifProductService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/TypicalFarmerController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/TypicalFarmerController.java deleted file mode 100644 index 406a042..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/TypicalFarmerController.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.TypicalFarmerEntity; -import com.xkrs.microservice.model.qo.TypicalFarmerQo; -import com.xkrs.microservice.model.validation.TypicalFarmerQoInsert; -import com.xkrs.microservice.model.validation.TypicalFarmerQoUpdate; -import com.xkrs.microservice.service.SysUserService; -import com.xkrs.microservice.service.TypicalFarmerService; - -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -/** - * 典型区农户表管理 - * @author tajochen - */ -@RestController -@RequestMapping("/api/typical-farmer") -public class TypicalFarmerController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private TypicalFarmerService typicalFarmerService; - - @Resource - private SysUserService sysUserService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - @CrossOrigin - public String getAllRecord() { - Iterable list = typicalFarmerService.getAllRecord(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/xzdm",method = RequestMethod.GET) - @CrossOrigin - public String getByTownCode(@RequestParam("xzdm") String xzdm) { - Iterable list = typicalFarmerService.getByTownCode(xzdm); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/qxdm",method = RequestMethod.GET) - @CrossOrigin - public String getByCountyCode(@RequestParam("qxdm") Integer qxdm) { - Iterable list = typicalFarmerService.getByCountyCode(qxdm); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/lxr",method = RequestMethod.GET) - @CrossOrigin - public String getByLxr(@RequestParam("lxr") String lxr) { - Iterable list = typicalFarmerService.getByLxr(lxr); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/user-name",method = RequestMethod.GET) - @CrossOrigin - public String getByUserName(@RequestParam("userName") String userName) { - Optional obj = typicalFarmerService.getByTel(userName); - if(obj.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } else { - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,obj.get(),locale); - } - } - - @RequestMapping(value="/add",method = RequestMethod.POST) - @CrossOrigin - public String dataAdd(@Validated({TypicalFarmerQoInsert.class}) @RequestBody TypicalFarmerQo typicalFarmerQo, - BindingResult bindingResult) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 验证用户名是否重复 - if(!sysUserService.checkUserName(typicalFarmerQo.getTel())){ - return outputEncapsulationObject(PromptMessageEnum.USER_ALREADY_EXIST,"用户名已存在!",locale); - } - // 添加新用户 - typicalFarmerService.add(typicalFarmerQo,typicalFarmerQo.getTel()); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/update",method = RequestMethod.POST) - @CrossOrigin - public String dataUpdate(@Validated({TypicalFarmerQoUpdate.class}) @RequestBody TypicalFarmerQo typicalFarmerQo, - BindingResult bindingResult) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 验证用户名是否存在 - if(sysUserService.checkUserName(typicalFarmerQo.getTel())){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"用户名不存在!",locale); - } - // 添加新用户 - typicalFarmerService.update(typicalFarmerQo); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public String dataDelete(@RequestParam("id") Integer id) { - Optional typicalPlotEntity = typicalFarmerService.getById(id); - if(typicalPlotEntity.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); - } - typicalFarmerService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/TypicalPlotController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/TypicalPlotController.java deleted file mode 100644 index cefb367..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/TypicalPlotController.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.TypicalPlotEntity; -import com.xkrs.microservice.model.qo.TypicalPlotQo; -import com.xkrs.microservice.model.validation.TypicalPlotQoInsert; -import com.xkrs.microservice.model.validation.TypicalPlotQoUpdate; -import com.xkrs.microservice.service.TypicalPlotService; - -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; - -/** - * 典型区地块管理 - * @author tajochen - */ -@RestController -@RequestMapping("/api/typical-plot") -public class TypicalPlotController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private TypicalPlotService typicalPlotService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - @CrossOrigin - public String getAllRecord() { - Iterable list = typicalPlotService.getAllRecord(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/qxdm",method = RequestMethod.GET) - @CrossOrigin - public String getByCountyCode(@RequestParam("qxdm") Integer qxdm) { - Iterable list = typicalPlotService.getByCountyCode(qxdm); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/xzdm",method = RequestMethod.GET) - @CrossOrigin - public String getByTownCode(@RequestParam("xzdm") String xzdm) { - Iterable list = typicalPlotService.getByTownCode(xzdm); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/dkbh",method = RequestMethod.GET) - @CrossOrigin - public String getByDkbh(@RequestParam("dkbh") String dkbh) { - Optional res = typicalPlotService.getByDkbh(dkbh); - if(res.isPresent()){ - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res.get(),locale); - } - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"dkbh 不存在",locale); - } - - @RequestMapping(value="/get/lxr",method = RequestMethod.GET) - @CrossOrigin - public String getByLxr(@RequestParam("lxr") String lxr) { - Iterable list = typicalPlotService.getByLxr(lxr); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/tel",method = RequestMethod.GET) - @CrossOrigin - public String getByTel(@RequestParam("tel") String tel) { - Iterable list = typicalPlotService.getByTel(tel); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/user-name",method = RequestMethod.GET) - @CrossOrigin - public String getByUserName(@RequestParam("userName") String userName) { - Iterable list = typicalPlotService.getByTel(userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/update",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") - @CrossOrigin - public String dataUpdate(@Validated({TypicalPlotQoUpdate.class}) @RequestBody TypicalPlotQo typicalPlotQo, - BindingResult bindingResult,@RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - typicalPlotService.update(typicalPlotQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/add",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor','auth_farm_user')") - @CrossOrigin - public String dataAdd(@Validated({TypicalPlotQoInsert.class}) @RequestBody TypicalPlotQo typicalPlotQo, - BindingResult bindingResult,@RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 监测地块编号是否存在 - Optional typicalPlotEntity = typicalPlotService.getByDkbh(typicalPlotQo.getDkbh()); - if(typicalPlotEntity.isPresent()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"地块编号已存在",locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - typicalPlotService.add(typicalPlotQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor','auth_farm_user')") - @CrossOrigin - public String dataDelete(@RequestParam("id") Integer id) { - Optional typicalPlotEntity = typicalPlotService.getById(id); - if(typicalPlotEntity.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); - } - typicalPlotService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/TypicalPlotIrrigationController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/TypicalPlotIrrigationController.java deleted file mode 100644 index 197be34..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/TypicalPlotIrrigationController.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.TypicalPlotIrrigationEntity; -import com.xkrs.microservice.model.qo.TypicalPlotIrrigationQo; -import com.xkrs.microservice.model.validation.TypicalPlotIrrigationQoInsert; -import com.xkrs.microservice.service.TypicalPlotIrrigationService; - -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; -import static com.xkrs.microservice.util.DateTimeUtil.timeMillisToTime; - -/** - * 灌溉信息表管理 - * @author tajochen - */ -@RestController -@RequestMapping("/api/typical-plot-irrigation") -public class TypicalPlotIrrigationController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private TypicalPlotIrrigationService typicalPlotIrrigationService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - @CrossOrigin - public String getAllRecord() { - Iterable list = typicalPlotIrrigationService.getAllRecord(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/ggbh",method = RequestMethod.GET) - @CrossOrigin - public String getByGgbh(@RequestParam("ggbh") String ggbh) { - Optional list = typicalPlotIrrigationService.getByGgbh(ggbh); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/qxbh",method = RequestMethod.GET) - @CrossOrigin - public String getByQxbh(@RequestParam("qxbh") Integer qxbh) { - Iterable list = typicalPlotIrrigationService.getByQxbh(qxbh); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/dkbh",method = RequestMethod.GET) - @CrossOrigin - public String getByDkbh(@RequestParam("dkbh") String dkbh) { - Iterable list = typicalPlotIrrigationService.getByDkbh(dkbh); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/user-name",method = RequestMethod.GET) - @CrossOrigin - public String getByUserName(@RequestParam("userName") String userName) { - Iterable list = typicalPlotIrrigationService.getByUserName(userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/condition",method = RequestMethod.GET) - @CrossOrigin - public String getByCondition(@RequestParam("xzbh") String xzbh, - @RequestParam("cropCode") Integer cropCode, - @RequestParam("sTimeTs") Long sTime, - @RequestParam("eTimeTs") Long eTime) { - List list = typicalPlotIrrigationService.getAllByCondition(xzbh,cropCode,sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/time",method = RequestMethod.GET) - @CrossOrigin - public String getByQxbhAndCreateTimeBetween(@RequestParam("qxdm") Integer qxdm,@RequestParam("sTimeTs") Long sTimeTs,@RequestParam("eTimeTs") Long eTimeTs) { - if(sTimeTs > eTimeTs){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - LocalDateTime sTime = timeMillisToTime(sTimeTs); - LocalDateTime eTime = timeMillisToTime(eTimeTs); - Iterable list = typicalPlotIrrigationService.findAllByQxbhAndStrtimeBetween(qxdm,sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/add",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor','auth_farm_user')") - @CrossOrigin - public String dataAdd(@Validated({TypicalPlotIrrigationQoInsert.class}) @RequestBody TypicalPlotIrrigationQo typicalPlotIrrigationQo, - BindingResult bindingResult,@RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 验证灌溉编号是否存在 - Optional typicalPlotIrrigationEntity = typicalPlotIrrigationService.getByGgbh(typicalPlotIrrigationQo.getGgbh()); - if(typicalPlotIrrigationEntity.isPresent()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"灌溉编号重复!",locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - typicalPlotIrrigationService.add(typicalPlotIrrigationQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public String dataDelete(@RequestParam("id") Integer id) { - Optional typicalPlotIrrigationEntity = typicalPlotIrrigationService.getById(id); - if(typicalPlotIrrigationEntity.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); - } - typicalPlotIrrigationService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/WcsRecordController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/WcsRecordController.java deleted file mode 100644 index 66eb6ca..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/WcsRecordController.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.entity.WcsRecordEntity; -import com.xkrs.microservice.model.qo.WcsRecordQo; -import com.xkrs.microservice.model.validation.WcsRecordQoInsert; -import com.xkrs.microservice.service.WcsRecordService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.BindingResult; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.time.LocalDate; -import java.util.Locale; -import java.util.Optional; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName; -import static com.xkrs.microservice.util.DateTimeUtil.timeMillisToDate; - -/** - * 栅格服务管理 - * @author tajochen - */ -@RestController -@RequestMapping("/api/wcs-record") -public class WcsRecordController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private WcsRecordService wcsRecordService; - - @RequestMapping(value="/get/all",method = RequestMethod.GET) - public String getAllFiles() { - Iterable list = wcsRecordService.getAllService(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/service-code",method = RequestMethod.GET) - public String getByProductCode(@RequestParam("serviceCode") String serviceCode) { - WcsRecordEntity res = wcsRecordService.getByServiceCode(serviceCode); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale); - } - - @RequestMapping(value="/get/product-type",method = RequestMethod.GET) - public String getByProductType(@RequestParam("productType") String productType) { - Iterable list = wcsRecordService.getByProductType(productType); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - @RequestMapping(value="/get/admcode/product-type",method = RequestMethod.GET) - public String getByAdmCodeAndProductTypeAndDate(@RequestParam("admCode") Integer admCode, - @RequestParam("productType") String productType) { - Iterable list = wcsRecordService.getByAdmCodeAndProductType(admCode,productType); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - - @RequestMapping(value="/get/admcode/product-type/date",method = RequestMethod.GET) - public String getByAdmCodeAndProductTypeAndDate(@RequestParam("admCode") Integer admCode, - @RequestParam("productType") String productType, - @RequestParam("startDateTs") Long startDateTs, - @RequestParam("endDateTs") Long endDateTs) { - if(startDateTs > endDateTs){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - LocalDate sTime = timeMillisToDate(startDateTs); - LocalDate eTime = timeMillisToDate(endDateTs); - Iterable list = wcsRecordService.getByAdmCodeAndProductTypeAndDate(admCode,productType,sTime,eTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); - } - - - @RequestMapping(value="/add",method = RequestMethod.POST) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") - @CrossOrigin - public String fileAdd(@Validated({WcsRecordQoInsert.class}) @RequestBody WcsRecordQo wcsRecordQo, - BindingResult bindingResult,@RequestHeader(value="Authorization") String token) { - // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); - } - // 验证数据是否存在 - if(wcsRecordService.getByServiceCode(wcsRecordQo.getServiceCode())!=null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_REPEAT,"数据已存在",locale); - } - // 获取当前用户名 - String userName = getTokenUserName(token); - wcsRecordService.add(wcsRecordQo,userName); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } - - @RequestMapping(value="/delete",method = RequestMethod.DELETE) - @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - @CrossOrigin - public String fileDelete(@RequestParam("id") Integer id) { - Optional wcsRecordEntity = wcsRecordService.getById(id); - if(wcsRecordEntity.isEmpty()){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); - } - wcsRecordService.delete(id); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); - } -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/WeatherController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/WeatherController.java deleted file mode 100644 index 79c6456..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/WeatherController.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.common.tool.PageBean; -import com.xkrs.microservice.common.tool.WeatherGet; -import com.xkrs.microservice.dao.WeatherDao; -import com.xkrs.microservice.model.entity.WeatherEntity; -import com.xkrs.microservice.service.WeatherService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -/** - * @author XinYiSong - */ -@RestController -@RequestMapping("/api/weather-station") -public class WeatherController { - - @Resource - private WeatherGet weatherGet; - - @Resource - private WeatherService weatherService; - - @Resource - private WeatherDao weatherDao; - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - /** - * 测试 - * @return - */ - @PostMapping("/insertWeather") - public void insertWeather(){ - weatherGet.findWeather(); - } - - /** - * 查询相关的天气和气候 - * @param map - * @return - */ - @PostMapping("/queryWeather") - public String queryWeather(@RequestBody Map map){ - Integer pageNo = (Integer) map.get("pageNo"); - String addTimeStart = (String) map.get("addTimeStart"); - String addTimeEnd = (String) map.get("addTimeEnd"); - PageBean pageBean = weatherService.queryWeather(pageNo, addTimeStart, addTimeEnd); - if(pageBean.getList() == null || pageBean.getList().size() == 0){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有相关数据",locale); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,pageBean,locale); - } - - /** - * 查询气候最新的一条信息 - * @return - */ - @GetMapping("/selectNewest") - public String selectNewest(){ - WeatherEntity weatherEntity = weatherDao.selectNewest(); - if(weatherEntity == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有相关数据",locale); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,weatherEntity,locale); - } - - /** - * 根据时间查询气象信息 - * 修改 - * @param map - * @return - */ - @PostMapping("/selectWeather") - public String selectWeather(@RequestBody Map map){ - String addTimeStart = (String) map.get("addTimeStart"); - String addTimeEnd = (String) map.get("addTimeEnd"); - List weatherEntities = weatherService.selectWeather(addTimeStart, addTimeEnd); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,weatherEntities,locale); - } -} diff --git a/src/main/java/com/xkrs/microservice/common/tool/controller/WeatherStationController.java b/src/main/java/com/xkrs/microservice/common/tool/controller/WeatherStationController.java deleted file mode 100644 index 0ef1cc5..0000000 --- a/src/main/java/com/xkrs/microservice/common/tool/controller/WeatherStationController.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.xkrs.microservice.common.tool.controller; - -import com.xkrs.microservice.common.encapsulation.PromptMessageEnum; -import com.xkrs.microservice.model.vo.ForecastWeather7DayVo; -import com.xkrs.microservice.model.vo.RealTimeWeatherVo; -import com.xkrs.microservice.service.MeteorologicalService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Locale; - -import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; -import static com.xkrs.microservice.util.NumberUtil.isStrAdmCode; - -/** - * 行政区划气象站点服务 - * @author tajochen - */ -@RestController -@RequestMapping("/api/weather") -public class WeatherStationController { - - /** - * 获取区域信息 - */ - Locale locale = LocaleContextHolder.getLocale(); - - @Resource - private MeteorologicalService meteorologicalService; - - @RequestMapping(value="/get/now",method = RequestMethod.GET) - public String getWeatherNowByAdmCode(@RequestParam(value="admCode") String admCode) { - if(!isStrAdmCode(admCode)){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - RealTimeWeatherVo res = meteorologicalService.getWeatherNowByAdmCode(Integer.valueOf(admCode)); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale); - } - - @RequestMapping(value="/get/forecast",method = RequestMethod.GET) - public String getWeatherForecastByAdmCode(@RequestParam(value="admCode") String admCode) { - if(!isStrAdmCode(admCode)){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); - } - ForecastWeather7DayVo res = meteorologicalService.getWeatherForecastByAdmCode(Integer.valueOf(admCode)); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale); - } - -}