From 86e5bb4399d25e0a4ffa5188d6c0a5cc727efef1 Mon Sep 17 00:00:00 2001
From: Administrator <zhubaomin>
Date: 星期四, 21 十二月 2023 15:52:31 +0800
Subject: [PATCH] 2023-12-21 朱宝民 分水房导出
---
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java | 132 +++++++++++++++++++++++++++++++++++---------
1 files changed, 105 insertions(+), 27 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
index 9eee7c2..ebe2415 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
@@ -3,54 +3,65 @@
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoBa.BaUserMapper;
+import com.dy.pipIrrGlobal.daoBa.BaUserRoleMapper;
import com.dy.pipIrrGlobal.pojoBa.BaUser;
+import com.dy.pipIrrGlobal.pojoBa.BaUserRole;
+import com.dy.pipIrrGlobal.voBa.VoUserInfo;
import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
-
-import org.apache.dubbo.common.utils.PojoUtils ;
-import org.springframework.transaction.annotation.Transactional;
+import java.util.Random;
@Slf4j
@Service
public class UserSv {
private BaUserMapper dao;
+ private BaUserRoleMapper urDao;
@Autowired
- private void setDao(BaUserMapper dao){
+ private void setDao(BaUserMapper dao) {
this.dao = dao;
}
- /**
- * 寰楀埌涓�涓敤鎴�
- * @param id 鐢ㄦ埛ID
- * @return 鐢ㄦ埛瀹炰綋
- */
- public BaUser selectById(Long id){
- return this.dao.selectById(id) ;
+ @Autowired
+ private void setDao(BaUserRoleMapper dao) {
+ this.urDao = dao;
}
/**
* 寰楀埌涓�涓敤鎴�
+ *
+ * @param id 鐢ㄦ埛ID
+ * @return 鐢ㄦ埛瀹炰綋
+ */
+ public BaUser selectById(Long id) {
+ return this.dao.selectById(id);
+ }
+
+ /**
+ * 寰楀埌涓�涓敤鎴�
+ *
* @param vo 鏌ヨ鏉′欢鍊煎璞�
* @return 鐢ㄦ埛瀹炰綋
*/
@SuppressWarnings("unchecked")
- public QueryResultVo<List<BaUser>> selectSome(QueryVo vo){
- Map<String, Object> params = (Map<String, Object>)PojoUtils.generalize(vo) ;
- Long itemTotal = this.dao.selectTotal(params) ;
+ public QueryResultVo<List<BaUser>> selectSome(QueryVo vo) {
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo);
+ Long itemTotal = this.dao.selectTotal(params);
- QueryResultVo<List<BaUser>> rsVo = new QueryResultVo<>() ;
- rsVo.pageSize = vo.pageSize ;
- rsVo.pageCurr = vo.pageCurr ;
+ QueryResultVo<List<BaUser>> rsVo = new QueryResultVo<>();
+ rsVo.pageSize = vo.pageSize;
+ rsVo.pageCurr = vo.pageCurr;
rsVo.calculateAndSet(itemTotal, params);
- rsVo.obj = this.dao.selectSome(params) ;
+ rsVo.obj = this.dao.selectSome(params);
- return rsVo ;
+ return rsVo;
}
/**
@@ -60,7 +71,7 @@
*/
@Transactional
public int save(BaUser po){
- return this.dao.insert(po) ;
+ return this.dao.putin(po) ;
}
/**
@@ -69,18 +80,55 @@
* @return 褰卞搷璁板綍鏁伴噺
*/
@Transactional
- public int update(BaUser po){
- return this.dao.updateByPrimaryKeySelective(po) ;
+ public int update(BaUser po) {
+ return this.dao.updateByPrimaryKeySelective(po);
}
/**
* 淇敼瀵嗙爜
- * @param id 鐢ㄦ埛ID
+ *
+ * @param id 鐢ㄦ埛ID
* @param password 鏂板瘑鐮�
* @return 褰卞搷璁板綍鏁伴噺
*/
- public int changePassword(Long id, String password){
- return this.dao.changePassword(id, password) ;
+ public int changePassword(Long id, String password) {
+ return this.dao.changePassword(id, password);
+ }
+
+ /**
+ * 璁剧疆鐢ㄦ埛瑙掕壊
+ *
+ * @param userId 鐢ㄦ埛id
+ * @param roleIds 閫夋嫨鐨勮鑹瞚d闆嗗悎
+ * @return 鎻掑叆鐢ㄦ埛涓庤鑹插叧鑱旇褰曟暟閲�
+ */
+ public int setRoles(Long userId, Long[] roleIds) {
+ this.urDao.deleteByUserId(userId);
+ int count = 0;
+ if (roleIds != null && roleIds.length > 0) {
+ for (Long roleId : roleIds) {
+ count += this.urDao.insertSelective(new BaUserRole(userId, roleId));
+ }
+ }
+ return count ;
+ }
+
+ /**
+ * 璁剧疆鐢ㄦ埛瑙掕壊
+ *
+ * @param userId 鐢ㄦ埛id
+ * @param roleIds 閫夋嫨鐨勮鑹瞚d闆嗗悎
+ * @return 鎻掑叆鐢ㄦ埛涓庤鑹插叧鑱旇褰曟暟閲�
+ */
+ public int setRoles(Long userId, String[] roleIds) {
+ this.urDao.deleteByUserId(userId);
+ int count = 0;
+ if (roleIds != null && roleIds.length > 0) {
+ for (String roleId : roleIds) {
+ count += this.urDao.insertSelective(new BaUserRole(userId, Long.parseLong(roleId)));
+ }
+ }
+ return count;
}
/**
@@ -89,8 +137,38 @@
* @return 褰卞搷璁板綍鏁伴噺
*/
@Transactional
- public int delete(Long id){
- return this.dao.deleteLogicById(id) ;
+ public int delete(Long id) {
+ return this.dao.deleteLogicById(id);
}
+
+ /**
+ * 鐢熸垚鎸囧畾浣嶆暟闅忔満鏁板瓧瀵嗙爜
+ *
+ * @param length 澶氶暱闅忔満鏁�
+ * @return 闅忔満鏁�
+ */
+ public String getStringRandom(int length) {
+ String val = "";
+ Random random = new Random();
+ for (int i = 0; i < length; i++) {
+ String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
+ if ("char".equalsIgnoreCase(charOrNum)) {
+ int temp = random.nextInt(2) % 2 == 0 ? 65 : 97;
+ val += (char) (random.nextInt(26) + temp);
+ } else if ("num".equalsIgnoreCase(charOrNum)) {
+ val += String.valueOf(random.nextInt(10));
+ }
+ }
+ return val;
+ }
+
+ /**
+ * 鏍规嵁鐢ㄦ埛缂栧彿鑾峰彇鐢ㄦ埛淇℃伅
+ * @param userId 鐢ㄦ埛缂栧彿
+ * @return 鐢ㄦ埛淇℃伅鍒楄〃
+ */
+ public List<VoUserInfo> getUserInfos(Long userId) {
+ return dao.getUserInfos(userId);
+ }
}
--
Gitblit v1.8.0