From 0c6754b975a29eb207304a9714a0d0f6a7d9748c Mon Sep 17 00:00:00 2001
From: liyj <1003249715@qq.com>
Date: Wed, 21 Aug 2024 20:37:15 +0800
Subject: [PATCH] 1、优化代码生成器 2、优化用户中心 3、新增client微服务调用controller

---
 dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUseroleService.java |   47 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUseroleService.java b/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUseroleService.java
index 9abd698..c829593 100644
--- a/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUseroleService.java
+++ b/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUseroleService.java
@@ -5,9 +5,12 @@
 import cn.huge.base.common.utils.IdUtils;
 import cn.huge.module.client.api.impl.UtilsClientImpl;
 import cn.huge.module.ctuser.dao.mapper.CtUseroleMapper;
+import cn.huge.module.ctuser.domain.po.CtUsepost;
 import cn.huge.module.ctuser.domain.po.CtUserole;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,13 +29,16 @@
  * @Description 客户用户角色表业务逻辑处理
  * @company hugeinfo
  * @author liyj
- * @Time 2024-08-17 15:30:57
+ * @Time 2024-08-19 20:04:19
  * @version 1.0.0
  */
 @Slf4j
 @Service
 @Transactional(rollbackFor = Exception.class)
 public class CtUseroleService extends ServiceImpl<CtUseroleMapper, CtUserole>{
+
+    @Autowired
+    private RedisTemplate<String, Object> redisTemplate;
 
     @Autowired
     private CtUseroleMapper mapper;
@@ -116,7 +122,7 @@
     */
     public void saveCtUserole(CtUserole ctUserole){
         try{
-            Date nowDate = DateUtils.getMowDate();
+            Date nowDate = DateUtils.getNowDate();
             // 判断是否新增
             if (IdUtils.checkNewId(ctUserole.getId())){
                 ctUserole.setId(utilsClient.getNewTimeId());
@@ -130,4 +136,39 @@
         }
     }
 
-}
+    /**
+     * 根据userId查询
+     * @param userId 用户编号
+     * @return
+     */
+    public List<CtUserole> listByUserId(String userId){
+        QueryWrapper<CtUserole> ctUseroleQueryWrapper = new QueryWrapper<>();
+        ctUseroleQueryWrapper.eq("user_id", userId);
+        List<CtUserole> ctUseroleList = mapper.selectList(ctUseroleQueryWrapper);
+        return ctUseroleList;
+    }
+
+    /**
+     * 根据用户编号获取其角色代码
+     * @param userId 用户编号
+     * @return List<String>
+     */
+    public  List<String> listRoleCode(String userId){
+        return mapper.listRoleCode(userId);
+    }
+
+    /**
+     * 根据用户编号物理删除
+     * @param userId 用户编号
+     */
+    public void deleteByUserId(String userId){
+        try{
+            QueryWrapper<CtUserole> ctUseroleQueryWrapper = new QueryWrapper<>();
+            ctUseroleQueryWrapper.eq("user_id", userId);
+            mapper.delete(ctUseroleQueryWrapper);
+        }catch (Exception e){
+            log.error("[CtUseroleService.deleteByUserId]调用失败,异常信息:"+e, e);
+            throw new ServiceException("CtUseroleService.deleteByUserId", e);
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.8.0