删除多余controller
This commit is contained in:
parent
7ba1d7c66b
commit
f5b8e3c595
@ -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<FileAppEntity> 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<FileAppEntity> 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<FileAppEntity> 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 <FileAppEntity> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<CropClassifyRecordEntity> 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<CropClassifyRecordEntity> 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<CropClassifyRecordEntity> 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<CropClassifyRecordEntity> 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> cropClassifyRecordEntity = cropClassifyRecordService.getById(id);
|
|
||||||
if(cropClassifyRecordEntity.isEmpty()){
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
|
|
||||||
}
|
|
||||||
cropClassifyRecordService.delete(id);
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<DicSoilClassifyEntity> res = dicBusinessService.getAllSoilClassify();
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value="/get/crop-classify/all", method = RequestMethod.GET)
|
|
||||||
public String getAllCropClassify(){
|
|
||||||
Iterable<DicCropClassifyEntity> res = dicBusinessService.getAllCropClassify();
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value="/get/drought-classify/all", method = RequestMethod.GET)
|
|
||||||
public String getAllDroughtClassify(){
|
|
||||||
Iterable<DicDroughtClassifyEntity> res = dicBusinessService.getAllDroughtClassify();
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value="/get/land-classify/all", method = RequestMethod.GET)
|
|
||||||
public String getAllLandClassify(){
|
|
||||||
Iterable<DicLandClassifyEntity> res = dicBusinessService.getAllLandClassify();
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value="/get/product/all", method = RequestMethod.GET)
|
|
||||||
public String getAllProduct(){
|
|
||||||
Iterable<DicProductEntity> res = dicBusinessService.getAllProduct();
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,res,locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<FarmingInfoEntity> 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<FarmingInfoEntity> 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<FarmingInfoEntity> 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<FarmingInfoEntity> 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<FarmingInfoEntity> 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<FarmingInfoEntity> 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<FarmingInfoEntity> typicalPlotEntity = farmingInfoService.getById(id);
|
|
||||||
if(typicalPlotEntity.isEmpty()){
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
|
|
||||||
}
|
|
||||||
farmingInfoService.delete(id);
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<FileDocumentEntity> 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 <FileDocumentEntity> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String>
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/hello")
|
|
||||||
public Mono<String> hello() {
|
|
||||||
// 【改】使用Mono.just生成响应式数据
|
|
||||||
return Mono.just(outputEncapsulationObject(PromptMessageEnum.SUCCESS,"Welcome to reactive world ~",locale));
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<HydrologicalStationEntity> 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<HydrologicalStationEntity> 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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<IndependentCheckEntity> 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<IndependentCheckEntity> 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<IndependentCheckEntity> 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> independentCheckEntity = independentCheckService.getById(id);
|
|
||||||
if(independentCheckEntity.isEmpty()){
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
|
|
||||||
}
|
|
||||||
independentCheckService.delete(id);
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<IrrigationCheckEntity> 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<IrrigationCheckEntity> 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<IrrigationCheckEntity> 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<IrrigationCheckEntity> 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<IrrigationCheckEntity> 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<IrrigationCheckEntity> 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<IrrigationCheckEntity> typicalPlotIrrigationEntity = irrigationCheckService.getById(id);
|
|
||||||
if(typicalPlotIrrigationEntity.isEmpty()){
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
|
|
||||||
}
|
|
||||||
irrigationCheckService.delete(id);
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<IrrigationRecordEntity> 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<IrrigationRecordEntity> 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<IrrigationRecordEntity> 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<IrrigationRecordEntity> 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> irrigationRecordEntity = irrigationRecordService.getById(id);
|
|
||||||
if(irrigationRecordEntity.isEmpty()){
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
|
|
||||||
}
|
|
||||||
irrigationRecordService.delete(id);
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<IrrigationSarRecordEntity> 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<IrrigationSarRecordEntity> 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<IrrigationSarRecordEntity> 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<IrrigationSarRecordEntity> 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<IrrigationSarRecordEntity> 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<IrrigationSarRecordEntity> irrigationRecordEntity = irrigationSarRecordService.getById(id);
|
|
||||||
if(irrigationRecordEntity.isEmpty()){
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
|
|
||||||
}
|
|
||||||
irrigationSarRecordService.delete(id);
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<ShpCityVo> 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<ShpCityVo> 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<ShpCountyVo> 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<ShpCountyVo> 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<ShpCountyVo> 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<SysUserVo> 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<SysRoleEntity> 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<SysRoleEntity> 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<TeaGardenPlotEntity> 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<TifProductEntity> 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<TifProductEntity> 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<TifProductEntity> 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<TifProductEntity> 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> tifProductEntity = tifProductService.getById(id);
|
|
||||||
if(tifProductEntity.isEmpty()){
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
|
|
||||||
}
|
|
||||||
tifProductService.delete(id);
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<TypicalFarmerEntity> 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<TypicalFarmerEntity> 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<TypicalFarmerEntity> 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<TypicalFarmerEntity> 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<TypicalFarmerEntity> 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<TypicalFarmerEntity> typicalPlotEntity = typicalFarmerService.getById(id);
|
|
||||||
if(typicalPlotEntity.isEmpty()){
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
|
|
||||||
}
|
|
||||||
typicalFarmerService.delete(id);
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<TypicalPlotEntity> 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<TypicalPlotEntity> 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<TypicalPlotEntity> 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<TypicalPlotEntity> 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<TypicalPlotEntity> 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<TypicalPlotEntity> 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<TypicalPlotEntity> 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> 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> typicalPlotEntity = typicalPlotService.getById(id);
|
|
||||||
if(typicalPlotEntity.isEmpty()){
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
|
|
||||||
}
|
|
||||||
typicalPlotService.delete(id);
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<TypicalPlotIrrigationEntity> 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<TypicalPlotIrrigationEntity> 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<TypicalPlotIrrigationEntity> 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<TypicalPlotIrrigationEntity> 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<TypicalPlotIrrigationEntity> 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<TypicalPlotIrrigationEntity> 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<TypicalPlotIrrigationEntity> 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> 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> typicalPlotIrrigationEntity = typicalPlotIrrigationService.getById(id);
|
|
||||||
if(typicalPlotIrrigationEntity.isEmpty()){
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
|
|
||||||
}
|
|
||||||
typicalPlotIrrigationService.delete(id);
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<WcsRecordEntity> 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<WcsRecordEntity> 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<WcsRecordEntity> 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<WcsRecordEntity> 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> wcsRecordEntity = wcsRecordService.getById(id);
|
|
||||||
if(wcsRecordEntity.isEmpty()){
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
|
|
||||||
}
|
|
||||||
wcsRecordService.delete(id);
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<WeatherEntity> weatherEntities = weatherService.selectWeather(addTimeStart, addTimeEnd);
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,weatherEntities,locale);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user