From 9b3676f8d31907d1b87719bb049f993b0552fb34 Mon Sep 17 00:00:00 2001
From: liuxm <liuxm_a@163.com>
Date: 星期一, 03 六月 2024 10:58:13 +0800
Subject: [PATCH] product 疑似与nginx冲突,所以修改为production
---
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java | 104 +++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 87 insertions(+), 17 deletions(-)
diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java
index 40ae28b..e081b49 100644
--- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java
@@ -1,5 +1,6 @@
package com.dy.pmsPlatform.station;
+import com.alibaba.excel.converters.Converter;
import com.alibaba.fastjson2.JSON;
import com.dy.common.aop.SsoPowerAop;
import com.dy.common.webUtil.BaseResponse;
@@ -7,12 +8,17 @@
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.aop.Log;
import com.dy.pmsGlobal.pojoPlt.PltStation;
+import com.dy.pmsGlobal.util.QrCodeUtil;
+import com.google.zxing.WriterException;
+import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -24,6 +30,9 @@
@RequestMapping(path="station")
@SuppressWarnings("unchecked")
public class StationCtrl {
+ private static final String fileName = "宸ョ珯淇℃伅" ;
+ private static final String sheetName = "宸ョ珯淇℃伅" ;
+ private static final String stationPrefix = "103" ;
private StationSv sv;
@Autowired
public StationCtrl(StationSv sv){
@@ -37,18 +46,25 @@
* @return
*/
@PostMapping(path="save")
- @SsoPowerAop(power = "10300001")
+ @SsoPowerAop(power = "10300007")
@Log("淇濆瓨宸ョ珯")
- public BaseResponse<PltStation> save(@RequestBody @Valid PltStation station,BindingResult bindingResult){
+ public BaseResponse<Boolean> save(@RequestBody @Valid PltStation station,BindingResult bindingResult){
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ int count;
try {
- if (bindingResult != null && bindingResult.hasErrors()) {
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
- }
station.deleted = false;
- return BaseResponseUtils.buildSuccess(sv.save(station));
+ count = sv.save(station);
}catch (Exception e){
log.error("淇濆瓨宸ョ珯寮傚父", e);
return BaseResponseUtils.buildException(e.getMessage());
+ }
+
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
}
}
@@ -60,17 +76,23 @@
* @return
*/
@PostMapping(path="update")
- @SsoPowerAop(power = "10300001")
+ @SsoPowerAop(power = "10300007")
@Log("鏇存柊宸ョ珯")
- public BaseResponse<PltStation> update(@RequestBody @Valid PltStation station,BindingResult bindingResult){
+ public BaseResponse<Boolean> update(@RequestBody @Valid PltStation station,BindingResult bindingResult){
+ int count;
try {
if (bindingResult != null && bindingResult.hasErrors()) {
return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
- return BaseResponseUtils.buildSuccess(sv.update(station));
+ count = sv.update(station);
}catch (Exception e){
log.error("鏇存柊宸ョ珯寮傚父", e);
return BaseResponseUtils.buildException(e.getMessage());
+ }
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
}
}
@@ -80,25 +102,28 @@
* @return
*/
@GetMapping(path="delete")
- @SsoPowerAop(power = "10300001")
+ @SsoPowerAop(power = "10300007")
@Log("鍒犻櫎宸ョ珯")
- public BaseResponse<PltStation> delete(String id){
+ public BaseResponse<Boolean> delete(String id){
+ int count;
try {
- return BaseResponseUtils.buildSuccess(sv.delete(Long.parseLong(id)));
+ count = sv.delete(Long.parseLong(id));
}catch (Exception e){
log.error("鍒犻櫎宸ョ珯寮傚父", e);
return BaseResponseUtils.buildException(e.getMessage());
}
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
}
-
-
-
/**
* 鏍规嵁ID鏌ヨ
* @return
*/
@GetMapping(path="one")
- @SsoPowerAop(power = "10300000") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @SsoPowerAop(power = "10300006") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
@Log("鏍规嵁ID鏌ヨ宸ョ珯")
public BaseResponse<PltStation> one(String id){
try{
@@ -116,7 +141,7 @@
* @return
*/
@PostMapping(path="some")
- @SsoPowerAop(power = "10300000")
+ @SsoPowerAop(power = "10300006")
@Log("鍒嗛〉鏌ヨ宸ョ珯")
public BaseResponse<QueryResultVo<List<PltStation>>> some(@RequestBody QueryVo vo){
try {
@@ -128,5 +153,50 @@
}
}
+ @PostMapping(path="disabled")
+ @SsoPowerAop(power = "10100011")
+ @Log("绂佺敤鎴栧惎鐢ㄥ伐绔�")
+ public BaseResponse<Boolean> disabled(@RequestBody PltStation station){
+ int count;
+ try {
+ count = sv.disabled(station.id,station.disabled);
+ }catch (Exception e){
+ log.error("绂佺敤鎴栧惎鐢ㄥ伐绔欏紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
+ }
+ @PostMapping(path="export")
+ @SsoPowerAop(power = "10300000")
+ @Log("瀵煎嚭宸ョ珯淇℃伅")
+ public void export(HttpServletResponse response){
+ try{
+ List<Converter> list = new ArrayList<>() ;
+
+ List<PltStation> stations = sv.selectAll();
+ // 浣跨敤骞惰娴佹彁楂樻�ц兘
+ stations.parallelStream().forEach(station -> {
+ ExcelVo vo = new ExcelVo();
+ vo.name = station.name;
+// vo.code = "103"+station.id;
+ vo.lineName = station.lineName;
+ try {
+ vo.qrCode = QrCodeUtil.genQrCode(stationPrefix+station.id);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (WriterException e) {
+ e.printStackTrace();
+ }
+ list.add(vo);
+ });
+ QrCodeUtil.downloadExcel(response, fileName,sheetName,list);
+ }catch (Exception e){
+ log.error("瀵煎嚭浜у搧淇℃伅寮傚父", e);
+ }
+ }
}
--
Gitblit v1.8.0