From b253ddd53f9073f944983dff1e6800abff1413e2 Mon Sep 17 00:00:00 2001
From: Fancy <Fancy.fx@outlook.com>
Date: 星期三, 03 七月 2024 11:24:35 +0800
Subject: [PATCH] some debug
---
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserSv.java | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserSv.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserSv.java
index 753a880..3c041a8 100644
--- a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserSv.java
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserSv.java
@@ -1,17 +1,24 @@
package com.dy.pmsBase.user;
+import cn.hutool.core.codec.Base64;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.daoBa.BaUserMapper;
import com.dy.pmsGlobal.daoBa.BaUserRoleMapper;
import com.dy.pmsGlobal.pojoBa.BaUser;
import com.dy.pmsGlobal.pojoBa.BaUserRole;
+import com.dy.pmsGlobal.util.QrCodeUtil;
+import com.google.zxing.WriterException;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.*;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
@Slf4j
@Service
@@ -20,6 +27,7 @@
private BaUserMapper dao;
@Autowired
private BaUserRoleMapper urDao;
+ private static final String stationPrefix = "101" ;
/**
* 鐢熸垚鎸囧畾浣嶆暟闅忔満鏁板瓧瀵嗙爜
@@ -68,6 +76,16 @@
//鏌ヨ绗﹀悎鏉′欢鐨勮褰�
rsVo.obj = this.dao.selectSome(params) ;
+ rsVo.obj.parallelStream().forEach(item->{
+ try {
+ byte[] codes = QrCodeUtil.genQrCode(stationPrefix+item.id);
+ item.qrCode = "data:image/jpeg;base64," + Base64.encode(codes);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (WriterException e) {
+ e.printStackTrace();
+ }
+ });
return rsVo ;
}
@@ -79,7 +97,12 @@
*/
@Transactional
public Long save(BaUser po){
- this.dao.insertSelective(po) ;
+ try{
+ dao.insertSelective(po) ;
+ }catch(DuplicateKeyException e){
+ log.error(e.getMessage());
+ throw new RuntimeException("鎵嬫満鍙风爜閲嶅");
+ }
Long id = po.getId();
this.saveUserRoles(id, po.roleIds) ;
return id ;
@@ -92,12 +115,32 @@
*/
@Transactional
public int update(BaUser po) {
- int count = this.dao.updateByPrimaryKeySelective(po);
+ int count=0;
+ try{
+ count = this.dao.updateByPrimaryKeySelective(po);
+ }catch(DuplicateKeyException e){
+ log.error(e.getMessage());
+ throw new RuntimeException("鎵嬫満鍙风爜閲嶅");
+ }
this.saveUserRoles(po.id, po.roleIds) ;
return count ;
}
/**
+ * 绂佺敤鎴栧惎鐢ㄧ敤鎴蜂俊鎭�
+ * @param id
+ * @param disabled
+ * @return
+ */
+ @Transactional
+ public int disabled(Long id,Boolean disabled) {
+ BaUser user=new BaUser();
+ user.id=id;
+ user.disabled=disabled;
+ return dao.updateByPrimaryKeySelective(user);
+ }
+
+ /**
* 淇敼瀵嗙爜
*
* @param id 鐢ㄦ埛ID
--
Gitblit v1.8.0