From 65b9ae05594a82e9d13f5226dad7204ffedf022c Mon Sep 17 00:00:00 2001
From: liuxm <liuxm@fescotech.com>
Date: 星期二, 21 五月 2024 10:42:41 +0800
Subject: [PATCH] 文件id返回时设置为String,以防丢失精度
---
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java | 132 ++++++++++++++++++++++++++++++-------------
1 files changed, 92 insertions(+), 40 deletions(-)
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java
index 2c16460..eae9aeb 100644
--- a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java
@@ -6,6 +6,8 @@
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.aop.Log;
+import com.dy.pmsGlobal.pojoBa.BaRole;
import com.dy.pmsGlobal.pojoBa.BaUser;
import com.dy.pmsGlobal.util.Constant;
import com.mysql.cj.util.StringUtils;
@@ -59,7 +61,8 @@
*/
@PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE)
//@SsoAop() //鍙湁鐧诲綍楠岃瘉锛屾病鏈夋潈闄愰獙璇�
- @SsoPowerAop(power = "10100010") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @SsoPowerAop(power = "10100000") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @Log("鏌ヨ鐢ㄦ埛")
public BaseResponse<QueryResultVo<List<BaUser>>> some(@RequestBody QueryVo vo) {
try {
QueryResultVo<List<BaUser>> res = this.sv.selectSome(vo);
@@ -77,7 +80,8 @@
//@GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE)//鎸囧墠绔悜鍚庝紶鐨勫弬鏁扮被鍨�
@GetMapping(path = "one")
//@SsoAop() //鍙湁鐧诲綍楠岃瘉锛屾病鏈夋潈闄愰獙璇�
- @SsoPowerAop(power = "10100010") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @SsoPowerAop(power = "10100000") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @Log("鏌ヨ鍗曚釜鐢ㄦ埛")
public BaseResponse<BaUser> one(String id) {
try {
return BaseResponseUtils.buildSuccess(this.sv.selectById(Long.parseLong(id)));
@@ -95,7 +99,8 @@
*/
@PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE)
//@SsoAop() //鍙湁鐧诲綍楠岃瘉锛屾病鏈夋潈闄愰獙璇�
- @SsoPowerAop(power = "10100011") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @SsoPowerAop(power = "10100001") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @Log("淇濆瓨鐢ㄦ埛淇℃伅")
public BaseResponse<Boolean> save(@RequestBody @Valid BaUser po, BindingResult bindingResult) {
if (bindingResult != null && bindingResult.hasErrors()) {
return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
@@ -104,7 +109,7 @@
Long id;
try {
po.supperAdmin = Constant.no.byteValue() ;
- po.disabled = false ;//榛樿涓嶇鐢�
+// po.disabled = false ;//榛樿涓嶇鐢�
po.deleted = false;//榛樿涓嶅垹闄�
if (!StringUtils.isNullOrEmpty(po.password)) {
/*
@@ -135,22 +140,66 @@
*/
@PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
//@SsoAop() //鍙湁鐧诲綍楠岃瘉锛屾病鏈夋潈闄愰獙璇�
- @SsoPowerAop(power = "10100011") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @SsoPowerAop(power = "10100001") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @Log("鏇存柊鐢ㄦ埛淇℃伅")
public BaseResponse<Boolean> update(@RequestBody @Validated BaUser po, BindingResult bindingResult) {
- if (bindingResult != null && bindingResult.hasErrors()) {
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
- }
- if (po.id == null) {
- return BaseResponseUtils.buildFail("鏃犳暟鎹疄浣揑D");
- }
int count;
try {
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ if (po.id == null) {
+ return BaseResponseUtils.buildFail("鏃犳暟鎹疄浣揑D");
+ }
po.password = null;//璁剧疆涓簄ull锛屼笉鍋氭洿鏂�
po.supperAdmin = null;//璁剧疆涓簄ull锛屼笉鍋氭洿鏂�
po.deleted = null;//璁剧疆涓簄ull锛屼笉鍋氭洿鏂�
count = this.sv.update(po);
} catch (Exception e) {
log.error("淇敼鐢ㄦ埛寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
+ }
+
+ /**
+ * 绂佺敤鎴栧惎鐢ㄧ敤鎴蜂俊鎭�
+ * @param po
+ * @return
+ */
+ @PostMapping(path="disabled")
+ @SsoPowerAop(power = "10100001")
+ @Log("绂佺敤鎴栧惎鐢ㄧ敤鎴蜂俊鎭�")
+ public BaseResponse<BaRole> disabled(@RequestBody BaUser po){
+ try {
+ return BaseResponseUtils.buildSuccess(sv.disabled(po.id,po.disabled));
+ }catch (Exception e){
+ log.error("绂佺敤鎴栧惎鐢ㄧ敤鎴蜂俊鎭紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鍒犻櫎鐢ㄦ埛淇℃伅
+ * @param id
+ * @return
+ */
+ @GetMapping(path = "delete")
+ @SsoPowerAop(power = "10100001") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @Log("鍒犻櫎鐢ㄦ埛")
+ public BaseResponse<Boolean> delete(Long id) {
+ int count;
+ try {
+ BaUser po = new BaUser();
+ po.id = id;
+ po.deleted = true;
+ count = this.sv.update(po);
+ } catch (Exception e) {
+ log.error("鍒犻櫎鐢ㄦ埛寮傚父", e);
return BaseResponseUtils.buildException(e.getMessage());
}
if (count <= 0) {
@@ -168,27 +217,29 @@
//@GetMapping(path = "changePassword", consumes = MediaType.TEXT_PLAIN_VALUE)
@GetMapping(path = "changePassword")
@SsoAop()
- public BaseResponse<Boolean> changePassword(String id, String oldPassword, String newPassword) throws Exception {
- if (id == null) {
- return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖");
- }
- if (StringUtils.isNullOrEmpty(oldPassword)) {
- return BaseResponseUtils.buildFail("鏃у瘑鐮佷笉鑳戒负绌�");
- }
- if (StringUtils.isNullOrEmpty(newPassword)) {
- return BaseResponseUtils.buildFail("鏂板瘑鐮佷笉鑳戒负绌�");
- }
- /*
- 濡傛灉鍓嶇杩涜浜哹ase64鍔犲瘑
- oldPassword = new String(Base64.getDecoder().decode(oldPassword)) ;
- newPassword = new String(Base64.getDecoder().decode(newPassword)) ;
- */
- oldPassword = MD5.encrypt(oldPassword);//杩涜鍔犲瘑鐮�
- newPassword = MD5.encrypt(newPassword);//杩涜鍔犲瘑鐮�
-
- Long idLg = Long.parseLong(id);
+ @Log("淇敼瀵嗙爜")
+ public BaseResponse<Boolean> changePassword(String id, String oldPassword, String newPassword) {
int count;
try {
+ if (id == null) {
+ return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖");
+ }
+ if (StringUtils.isNullOrEmpty(oldPassword)) {
+ return BaseResponseUtils.buildFail("鏃у瘑鐮佷笉鑳戒负绌�");
+ }
+ if (StringUtils.isNullOrEmpty(newPassword)) {
+ return BaseResponseUtils.buildFail("鏂板瘑鐮佷笉鑳戒负绌�");
+ }
+ /*
+ 濡傛灉鍓嶇杩涜浜哹ase64鍔犲瘑
+ oldPassword = new String(Base64.getDecoder().decode(oldPassword)) ;
+ newPassword = new String(Base64.getDecoder().decode(newPassword)) ;
+ */
+ oldPassword = MD5.encrypt(oldPassword);//杩涜鍔犲瘑鐮�
+ newPassword = MD5.encrypt(newPassword);//杩涜鍔犲瘑鐮�
+
+ Long idLg = Long.parseLong(id) ;
+
BaUser po = this.sv.selectById(idLg);
if (Objects.isNull(po)) {
return BaseResponseUtils.buildFail("鏈緱鍒扮敤鎴凤紝璇锋眰澶辫触");
@@ -200,7 +251,7 @@
}
}
} catch (Exception e) {
- log.error("淇濆瓨鐢ㄦ埛寮傚父", e);
+ log.error("淇敼瀵嗙爜寮傚父", e);
return BaseResponseUtils.buildException(e.getMessage());
}
if (count <= 0) {
@@ -218,16 +269,17 @@
*/
@PostMapping(path = "resetPassword", consumes = MediaType.APPLICATION_JSON_VALUE)
//@SsoAop() //鍙湁鐧诲綍楠岃瘉锛屾病鏈夋潈闄愰獙璇�
- @SsoPowerAop(power = "10100011") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
- public BaseResponse<Boolean> resetPassword(@RequestBody @Validated ResetPasswordVo vo, BindingResult bindingResult) throws Exception {
- if (bindingResult != null && bindingResult.hasErrors()) {
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
- }
- String password = MD5.encrypt(vo.password);//杩涜鍔犲瘑鐮�
- Long idLg = Long.parseLong(vo.id);
+ @SsoPowerAop(power = "10100001") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @Log("閲嶇疆瀵嗙爜")
+ public BaseResponse<Boolean> resetPassword(@RequestBody @Validated ResetPasswordVo vo, BindingResult bindingResult) {
int count;
try {
- BaUser po = this.sv.selectById(idLg);
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ String password = MD5.encrypt(vo.password);//杩涜鍔犲瘑鐮�
+ Long idLg = Long.parseLong(vo.id);
+ BaUser po = this.sv.selectById(idLg);
if (Objects.isNull(po)) {
return BaseResponseUtils.buildFail("鏈緱鍒扮敤鎴凤紝璇锋眰澶辫触");
} else {
@@ -240,7 +292,7 @@
if (count <= 0) {
return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
} else {
- return BaseResponseUtils.buildSuccess("淇敼瀵嗙爜鎴愬姛");
+ return BaseResponseUtils.buildSuccess("閲嶇疆瀵嗙爜鎴愬姛");
}
}
--
Gitblit v1.8.0