Przeglądaj źródła

需求:实现ADM登录权限控制逻辑

lijie 3 lat temu
rodzic
commit
83bfea4bfb
19 zmienionych plików z 379 dodań i 69 usunięć
  1. 7 4
      adm-business/adm-server/.easy.api.config
  2. 16 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/dao/AdmProjectMapper.java
  3. 27 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/dao/AdmProjectUserMapper.java
  4. 38 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/entity/AdmProject.java
  5. 20 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/entity/AdmProjectUser.java
  6. 13 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/service/AdmProjectService.java
  7. 23 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/service/AdmProjectUserService.java
  8. 22 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/service/impl/AdmProjectServiceImpl.java
  9. 45 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/service/impl/AdmProjectUserServiceImpl.java
  10. 0 20
      adm-business/adm-server/src/main/java/com/persagy/adm/server/auth/constant/DeviceTypeEnum.java
  11. 0 18
      adm-business/adm-server/src/main/java/com/persagy/adm/server/auth/constant/LoginTypeEnum.java
  12. 20 15
      adm-business/adm-server/src/main/java/com/persagy/adm/server/auth/controller/AdmAuthController.java
  13. 4 2
      adm-business/adm-server/src/main/java/com/persagy/adm/server/auth/domain/LoginVo.java
  14. 18 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/auth/service/AdmAuthService.java
  15. 56 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/auth/service/impl/AdmAuthServiceImpl.java
  16. 9 9
      adm-business/adm-server/src/main/resources/application-dev.yml
  17. 1 1
      adm-business/adm-server/src/main/resources/bootstrap.yml
  18. 30 0
      adm-business/adm-server/src/main/resources/mapper/AdmProjectMapper.xml
  19. 30 0
      adm-business/adm-server/src/main/resources/mapper/AdmProjectUserMapper.xml

+ 7 - 4
adm-business/adm-server/.easy.api.config

@@ -1,5 +1,8 @@
 #额外要求header中携带token
-method.additional.param={name:"projectId",value:"Pj5001120003",desc:"项目id",required:true}
-method.additional.param={name:"groupCode",value:"XG",desc:"集团编码",required:true}
-method.additional.param={name:"appId",value:"ADM",desc:"appId",required:true}
-method.additional.param={name:"userId",value:"0",desc:"账号id",required:true}
+module=adm-server
+method.additional.param[groovy:!it.containingClass().name().startsWith("com.persagy.adm.server.auth.controller")]={name:"projectId",value:"Pj5001120003",desc:"项目id",required:true}
+method.additional.param[groovy:!it.containingClass().name().startsWith("com.persagy.adm.server.auth.controller")]={name:"groupCode",value:"XG",desc:"集团编码",required:true}
+method.additional.param[groovy:!it.containingClass().name().startsWith("com.persagy.adm.server.auth.controller")]={name:"appId",value:"ADM",desc:"appId",required:false}
+method.additional.param[groovy:!it.containingClass().name().startsWith("com.persagy.adm.server.auth.controller")]={name:"userId",value:"0",desc:"账号id",required:true}
+method.additional.header[groovy:!it.ann("org.springframework.web.bind.annotation.PostMapping","value").startsWith("/account/login")]={name:"token",value:"12.13.14",desc:"当前用户token值",required:true}
+method.additional.header[groovy:it.ann("org.springframework.web.bind.annotation.PostMapping","value").startsWith("/login/loginInfo")]={name:"loginDeviceType",value:"1",desc:"登录设备类型,1-pc,2-Android,3-ios,4-其他",required:true}

+ 16 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/dao/AdmProjectMapper.java

@@ -0,0 +1,16 @@
+package com.persagy.adm.server.algorithm.dao;
+
+import com.persagy.adm.server.algorithm.entity.AdmProject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @Entity com.persagy.adm.server.algorithm.entity.AdmProject
+ */
+public interface AdmProjectMapper extends BaseMapper<AdmProject> {
+
+}
+
+
+
+

+ 27 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/dao/AdmProjectUserMapper.java

@@ -0,0 +1,27 @@
+package com.persagy.adm.server.algorithm.dao;
+
+import com.persagy.adm.server.algorithm.entity.AdmProjectUser;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.persagy.dmp.auth.domain.Project;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @Entity com.persagy.adm.server.algorithm.entity.AdmProjectUser
+ */
+public interface AdmProjectUserMapper extends BaseMapper<AdmProjectUser> {
+    /**
+     * 根据用户id获取其项目权限
+     * @param userId : 用户id
+     * @return : java.util.List<com.persagy.dmp.auth.domain.Project>
+     * @author : lijie
+     * Update By 2022/1/11 20:08
+     */
+    List<Project> getProjectsByUserId(@Param("userId") String userId);
+}
+
+
+
+

+ 38 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/entity/AdmProject.java

@@ -0,0 +1,38 @@
+package com.persagy.adm.server.algorithm.entity;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.persagy.dmp.common.model.entity.AuditableEntity;
+import lombok.Data;
+
+/**
+ * adm项目配置实体类
+ * @author : lijie
+ * Update By 2022/1/11 20:01
+ */
+@TableName(value ="project",autoResultMap = true)
+@Data
+public class AdmProject extends AuditableEntity<AdmProject> {
+
+    /**项目名称*/
+    private String name;
+
+    /**模型解析的配置*/
+    @TableField(value = "config_json",typeHandler = JacksonTypeHandler.class)
+    private JsonNode configJson;
+
+    /**空间类型*/
+    private String type;
+
+    /**空间code*/
+    private String roomSpace;
+
+    /**集团编码*/
+    private String groupCode;
+
+    /**集团名称*/
+    private String groupName;
+}

+ 20 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/entity/AdmProjectUser.java

@@ -0,0 +1,20 @@
+package com.persagy.adm.server.algorithm.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.persagy.dmp.common.model.entity.AuditableEntity;
+import lombok.Data;
+
+/**
+ * 项目用户关系表
+ * @TableName project_user
+ */
+@TableName(value ="project_user")
+@Data
+public class AdmProjectUser extends AuditableEntity<AdmProjectUser> {
+
+    /**项目id*/
+    private String projectId;
+
+    /**用户id*/
+    private String userId;
+}

+ 13 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/service/AdmProjectService.java

@@ -0,0 +1,13 @@
+package com.persagy.adm.server.algorithm.service;
+
+import com.persagy.adm.server.algorithm.entity.AdmProject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * ADM项目配置逻辑处理接口
+ * @author : lijie
+ * Update By 2022/1/11 20:03
+ */
+public interface AdmProjectService extends IService<AdmProject> {
+
+}

+ 23 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/service/AdmProjectUserService.java

@@ -0,0 +1,23 @@
+package com.persagy.adm.server.algorithm.service;
+
+import com.persagy.adm.server.algorithm.entity.AdmProjectUser;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.persagy.dmp.auth.domain.Project;
+
+import java.util.List;
+
+/**
+ * ADM项目用户关系逻辑处理接口
+ * @author : lijie
+ * Update By 2022/1/11 20:05
+ */
+public interface AdmProjectUserService extends IService<AdmProjectUser> {
+    /**
+     * 根据用户id获取其项目权限
+     * @param userId : 用户id
+     * @return : java.util.List<com.persagy.dmp.auth.domain.Project>
+     * @author : lijie
+     * Update By 2022/1/11 20:08
+     */
+    List<Project> getProjectsByUserId(String userId);
+}

+ 22 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/service/impl/AdmProjectServiceImpl.java

@@ -0,0 +1,22 @@
+package com.persagy.adm.server.algorithm.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.persagy.adm.server.algorithm.entity.AdmProject;
+import com.persagy.adm.server.algorithm.service.AdmProjectService;
+import com.persagy.adm.server.algorithm.dao.AdmProjectMapper;
+import org.springframework.stereotype.Service;
+
+/**
+ * ADM项目配置逻辑处理接口
+ * @author : lijie
+ * Update By 2022/1/11 20:02
+ */
+@Service
+public class AdmProjectServiceImpl extends ServiceImpl<AdmProjectMapper, AdmProject>
+implements AdmProjectService{
+
+}
+
+
+
+

+ 45 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/algorithm/service/impl/AdmProjectUserServiceImpl.java

@@ -0,0 +1,45 @@
+package com.persagy.adm.server.algorithm.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.persagy.adm.server.algorithm.entity.AdmProjectUser;
+import com.persagy.adm.server.algorithm.service.AdmProjectUserService;
+import com.persagy.adm.server.algorithm.dao.AdmProjectUserMapper;
+import com.persagy.dmp.auth.domain.Project;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * ADM项目用户关系逻辑处理接口
+ * @author : lijie
+ * Update By 2022/1/11 20:05
+ */
+@Service
+@RequiredArgsConstructor
+public class AdmProjectUserServiceImpl extends ServiceImpl<AdmProjectUserMapper, AdmProjectUser>
+implements AdmProjectUserService{
+
+    private final AdmProjectUserMapper admProjectUserMapper;
+
+    /**
+     * 根据用户id获取其项目权限
+     * @param userId : 用户id
+     * @return : java.util.List<com.persagy.dmp.auth.domain.Project>
+     * @author : lijie
+     * Update By 2022/1/11 20:08
+     */
+    @Override
+    public List<Project> getProjectsByUserId(String userId) {
+        if (StrUtil.isBlank(userId)){
+            return CollUtil.newArrayList();
+        }
+        return admProjectUserMapper.getProjectsByUserId(userId);
+    }
+}
+
+
+
+

+ 0 - 20
adm-business/adm-server/src/main/java/com/persagy/adm/server/auth/constant/DeviceTypeEnum.java

@@ -1,20 +0,0 @@
-package com.persagy.adm.server.auth.constant;
-/***
- * 登录设备类型
- * @author : lijie
- * Update By 2022/1/7 21:50
- */
-public enum DeviceTypeEnum {
-    /**pc*/
-    ONE("1"),
-    /**Android*/
-    TWO("2"),
-    /**ios*/
-    THREE("3"),
-    /**其他*/
-    FOUR("4");
-    private String type;
-    DeviceTypeEnum(String type){
-        this.type=type;
-    };
-}

+ 0 - 18
adm-business/adm-server/src/main/java/com/persagy/adm/server/auth/constant/LoginTypeEnum.java

@@ -1,18 +0,0 @@
-package com.persagy.adm.server.auth.constant;
-/***
- * 登录方式
- * @author : lijie
- * Update By 2022/1/7 21:50
- */
-public enum LoginTypeEnum {
-    /**用户名密码方式(默认是ldap用户)*/
-    ONE("1"),
-    /**使用手机号登录*/
-    TWO("2"),
-    /**钉钉扫码登录*/
-    THREE("3");
-    private String type;
-    LoginTypeEnum(String type){
-        this.type=type;
-    };
-}

+ 20 - 15
adm-business/adm-server/src/main/java/com/persagy/adm/server/auth/controller/AdmAuthController.java

@@ -1,22 +1,14 @@
 package com.persagy.adm.server.auth.controller;
 
-import cn.hutool.core.io.IoUtil;
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.persagy.adm.server.auth.domain.LoginVo;
+import com.persagy.adm.server.auth.service.AdmAuthService;
+import com.persagy.dmp.auth.client.BossAuthFacade;
+import com.persagy.dmp.auth.client.PaasAccountFacade;
+import com.persagy.dmp.auth.domain.BossAuthUser;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ResultHelper;
-import com.persagy.dmp.file.model.FileInfo;
-import com.persagy.dmp.file.model.FileInfoCreator;
-import com.persagy.dmp.file.utils.FileStorageHelper;
-import lombok.SneakyThrows;
+import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.imageio.ImageIO;
-import javax.servlet.http.HttpServletResponse;
-import java.awt.*;
-import java.io.IOException;
-import java.io.InputStream;
 
 /**
  * 00-登录及权限控制
@@ -27,8 +19,11 @@ import java.io.InputStream;
  */
 @RestController
 @RequestMapping("/auth")
+@RequiredArgsConstructor
 public class AdmAuthController {
 
+    private final AdmAuthService admAuthService;
+
     /**
      * 000101-登录-登录接口
      * @param loginVo : 登录信息
@@ -36,11 +31,21 @@ public class AdmAuthController {
      * @author : lijie
      * Update By 2022/1/7 21:57
      */
-    @PostMapping("/account/login")
+    @PostMapping(value = "/account/login")
     public CommonResult<String> accountLogin(@RequestBody LoginVo loginVo) {
-        return ResultHelper.single("eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJ5dXNodS1zYWFzLWNsaWVudCIsInN1YiI6Inl1c2h1LXVzZXIiLCJpc3MiOiJ5dXNodSIsImp0aSI6IjUxNmM2MGFjLWYyNDUtNGFjMC05MjliLTY0MjJkYTk3MjA5ZCJ9.XifozaE83Dktuh9WFCUp10lLt_HP1c5YzFWPBRX53AI");
+        return PaasAccountFacade.accountLogin(loginVo);
     }
 
+    /**
+     * 000102-登录-获取当前登录人的信息
+     * @return : com.persagy.dmp.common.model.response.CommonResult<com.persagy.dmp.auth.domain.BossAuthUser>
+     * @author : lijie
+     * Update By 2022/1/11 15:50
+     */
+    @PostMapping(value = "/login/loginInfo")
+    public CommonResult<BossAuthUser> loginInfo() {
+        return ResultHelper.single(admAuthService.loginInfo());
+    }
 
 
 }

+ 4 - 2
adm-business/adm-server/src/main/java/com/persagy/adm/server/auth/domain/LoginVo.java

@@ -1,13 +1,15 @@
 package com.persagy.adm.server.auth.domain;
 
-import com.persagy.adm.server.auth.constant.DeviceTypeEnum;
-import com.persagy.adm.server.auth.constant.LoginTypeEnum;
+import com.persagy.dmp.auth.constant.DeviceTypeEnum;
+import com.persagy.dmp.auth.constant.LoginTypeEnum;
+import lombok.Data;
 
 /***
  * Description: 登录的VO类
  * @author : lijie
  * Update By 2022/1/7 21:41
  */
+@Data
 public class LoginVo {
     /**
      * 账号id

+ 18 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/auth/service/AdmAuthService.java

@@ -0,0 +1,18 @@
+package com.persagy.adm.server.auth.service;
+
+import com.persagy.dmp.auth.domain.BossAuthUser;
+
+/**
+ * ADM登录统一处理入口
+ * @author : lijie
+ * Update By 2022/1/11 15:51
+ */
+public interface AdmAuthService {
+    /**
+     * 获取当前登录人的用户信息
+     * @return : com.persagy.dmp.auth.domain.BossAuthUser
+     * @author : lijie
+     * Update By 2022/1/11 15:52
+     */
+    BossAuthUser loginInfo();
+}

+ 56 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/auth/service/impl/AdmAuthServiceImpl.java

@@ -0,0 +1,56 @@
+package com.persagy.adm.server.auth.service.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.persagy.adm.server.algorithm.service.AdmProjectUserService;
+import com.persagy.adm.server.auth.service.AdmAuthService;
+import com.persagy.dmp.auth.client.BossAuthFacade;
+import com.persagy.dmp.auth.domain.BossAuthMenu;
+import com.persagy.dmp.auth.domain.BossAuthUser;
+import com.persagy.dmp.auth.domain.Project;
+import com.persagy.dmp.common.constant.ResponseCode;
+import com.persagy.dmp.common.exception.BusinessException;
+import com.persagy.dmp.common.helper.SpringHelper;
+import com.persagy.dmp.common.model.response.CommonResult;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * ADM鉴权统一逻辑处理类
+ * @author : lijie
+ * Update By 2022/1/11 15:51
+ */
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class AdmAuthServiceImpl implements AdmAuthService {
+    /**adm网站id的配置key,BOSS系统需要.值从BOSS权限系统中创建后获取*/
+    private static final String ADM_WEB_SITE_ID="bdtp.adm.web.site.id";
+    private final AdmProjectUserService admProjectUserService;
+
+    /**
+     * 获取当前登录人的用户信息
+     * @return : com.persagy.dmp.auth.domain.BossAuthUser
+     * @author : lijie
+     * Update By 2022/1/11 15:52
+     */
+    @Override
+    public BossAuthUser loginInfo() {
+        // 1.获取用户的基本信息
+        CommonResult<BossAuthUser> baseUserMesResult = BossAuthFacade.loginInnerLoginInfo();
+        if (!ResponseCode.A00000.getDesc().equals(baseUserMesResult.getResult())){
+            throw new BusinessException(baseUserMesResult.getResult(),baseUserMesResult.getMessage());
+        }
+        BossAuthUser authUser = baseUserMesResult.getData();
+        if (null==authUser || StrUtil.isBlank(authUser.getId())){
+            throw new BusinessException(ResponseCode.A10000.getDesc(),"用户不存在");
+        }
+        // 2.获得用户的菜单权限,略.调用BossAuthFacade.loginMenu(SpringHelper.getString(ADM_WEB_SITE_ID))即可
+        // 3.获得用户的数据权限,略.调用BossAuthFacade.loginPermission(SpringHelper.getString(ADM_WEB_SITE_ID))即可
+        // 4.获得用户的项目权限,暂时根据用户id从配置表中获取
+        authUser.setProjects(admProjectUserService.getProjectsByUserId(authUser.getId()));
+        return authUser;
+    }
+}

+ 9 - 9
adm-business/adm-server/src/main/resources/application-dev.yml

@@ -6,18 +6,18 @@ spring:
       datasource:
         master:
           driver-class-name: com.mysql.cj.jdbc.Driver
-          username: adm
-          password: adm
-          url: jdbc:mysql://192.168.0.11/adm?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai
+          username: root
+          password: persagy@2021
+          url: jdbc:mysql://192.168.100.91:9934/adm-sever?allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai
 #          username: root
 #          password: Bdtp@1qaz@WSX
 #          url: jdbc:mysql://cd-cdb-nboe1rje.sql.tencentcdb.com:61955/adm-poc?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai
-#  rabbitmq:
-#    host: develop.ysbdtp.com
-#    port: 32436
-#    username: admin
-#    password: bdtp123456
-#    virtualHost: /test
+  rabbitmq:
+    host: 192.168.100.93
+    port: 9936
+    username: pbsage
+    password: pbsage123
+    virtualHost: /test
 persagy:
   common:
     file:

+ 1 - 1
adm-business/adm-server/src/main/resources/bootstrap.yml

@@ -7,6 +7,6 @@ spring:
     # 应用名称
     name: adm-poc-backend
   profiles:
-    active: 'test'
+    active: 'dev'
   main:
     allow-bean-definition-overriding: true

+ 30 - 0
adm-business/adm-server/src/main/resources/mapper/AdmProjectMapper.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.persagy.adm.server.algorithm.dao.AdmProjectMapper">
+
+    <resultMap id="BaseResultMap" type="com.persagy.adm.server.algorithm.entity.AdmProject">
+            <id property="id" column="id" jdbcType="VARCHAR"/>
+            <result property="name" column="name" jdbcType="VARCHAR"/>
+            <result property="configJson" column="config_json" jdbcType="OTHER" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
+            <result property="type" column="type" jdbcType="VARCHAR"/>
+            <result property="roomSpace" column="room_space" jdbcType="VARCHAR"/>
+            <result property="groupCode" column="group_code" jdbcType="VARCHAR"/>
+            <result property="groupName" column="group_name" jdbcType="VARCHAR"/>
+            <result property="creator" column="creator" jdbcType="VARCHAR"/>
+            <result property="creationTime" column="creation_time" jdbcType="CHAR"/>
+            <result property="modifier" column="modifier" jdbcType="VARCHAR"/>
+            <result property="modifiedTime" column="modified_time" jdbcType="CHAR"/>
+            <result property="valid" column="valid" jdbcType="TINYINT"/>
+            <result property="ts" column="ts" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,name,config_json,
+        type,room_space,group_code,
+        group_name,creator,creation_time,
+        modifier,modified_time,valid,
+        ts
+    </sql>
+</mapper>

+ 30 - 0
adm-business/adm-server/src/main/resources/mapper/AdmProjectUserMapper.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.persagy.adm.server.algorithm.dao.AdmProjectUserMapper">
+
+    <resultMap id="BaseResultMap" type="com.persagy.adm.server.algorithm.entity.AdmProjectUser">
+            <id property="id" column="id" jdbcType="VARCHAR"/>
+            <result property="projectId" column="project_id" jdbcType="VARCHAR"/>
+            <result property="userId" column="user_id" jdbcType="VARCHAR"/>
+            <result property="creator" column="creator" jdbcType="VARCHAR"/>
+            <result property="creationTime" column="creation_time" jdbcType="CHAR"/>
+            <result property="modifier" column="modifier" jdbcType="VARCHAR"/>
+            <result property="modifiedTime" column="modified_time" jdbcType="CHAR"/>
+            <result property="valid" column="valid" jdbcType="TINYINT"/>
+            <result property="ts" column="ts" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,project_id,user_id,
+        creator,creation_time,modifier,
+        modified_time,valid,ts
+    </sql>
+    <select id="getProjectsByUserId" resultType="com.persagy.dmp.auth.domain.Project">
+        SELECT project_user.project_id AS projectId,project.`name` AS projectName,project.group_code AS groupCode,
+               project.group_name AS groupName FROM project_user INNER JOIN project
+                   ON(project_user.project_id=project.id AND project.valid=TRUE AND project_user.valid=TRUE)
+        WHERE project_user.user_id=#{userId};
+    </select>
+</mapper>