Complete team user code

This commit is contained in:
JiaJu Zhuang
2023-08-13 14:57:24 +08:00
parent 697e7bc024
commit af6fcc2baf
56 changed files with 1288 additions and 266 deletions

View File

@ -1,7 +1,6 @@
package ai.chat2db.server.domain.repository.mapper;
import ai.chat2db.server.domain.repository.entity.DataSourceAccessDO;
import ai.chat2db.server.domain.repository.entity.DataSourceDO;
import com.baomidou.mybatisplus.core.mapper.Mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
@ -13,6 +12,8 @@ import org.apache.ibatis.annotations.Param;
*/
public interface DataSourceAccessCustomMapper extends Mapper<DataSourceAccessDO> {
IPage<DataSourceAccessDO> comprehensivePageQuery(IPage<DataSourceDO> page, @Param("dataSourceId") Long dataSourceId, @Param("searchKey") String searchKey);
IPage<DataSourceAccessDO> comprehensivePageQuery(IPage<DataSourceAccessDO> page, @Param("dataSourceId") Long dataSourceId,
@Param("userOrTeamSearchKey") String userOrTeamSearchKey,
@Param("dataSourceSearchKey") String dataSourceSearchKey);
}

View File

@ -1,6 +1,5 @@
package ai.chat2db.server.domain.repository.mapper;
import ai.chat2db.server.domain.repository.entity.DataSourceDO;
import ai.chat2db.server.domain.repository.entity.TeamUserDO;
import com.baomidou.mybatisplus.core.mapper.Mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -13,6 +12,6 @@ import org.apache.ibatis.annotations.Param;
*/
public interface TeamUserCustomMapper extends Mapper<TeamUserDO> {
IPage<TeamUserDO> comprehensivePageQuery(IPage<DataSourceDO> page, @Param("teamId") Long teamId,
IPage<TeamUserDO> comprehensivePageQuery(IPage<TeamUserDO> page, @Param("teamId") Long teamId,
@Param("userId") Long userId, @Param("teamRoleCode") String teamRoleCode);
}

View File

@ -4,18 +4,24 @@
<select id="comprehensivePageQuery" resultType="ai.chat2db.server.domain.repository.entity.DataSourceAccessDO">
select dsa.*
from DATA_SOURCE_ACCESS dsa
<if test="searchKey != null ">
<if test="userOrTeamSearchKey != null ">
left join TEAM t on t.id =dsa.ACCESS_OBJECT_ID and dsa.ACCESS_OBJECT_TYPE = 'TEAM'
left join DBHUB_USER du on du.ID=dsa.ACCESS_OBJECT_ID and dsa.ACCESS_OBJECT_TYPE = 'USER'
</if>
<if test="dataSourceSearchKey != null ">
left join DATA_SOURCE ds on ds.id =dsa.DATA_SOURCE_ID
</if>
<where>
<if test="dataSourceId != null ">
and dsa.DATA_SOURCE_ID = #{dataSourceId}
</if>
<if test="searchKey != null ">
and (t.CODE like concat('%',#{searchKey},'%') or t.NAME like concat('%',#{searchKey},'%') or
du.USER_NAME like concat('%',#{searchKey},'%') or du.NICK_NAME like concat('%',#{searchKey},'%') or
du.EMAIL like concat('%',#{searchKey},'%'))
and (t.CODE like concat('%',#{userOrTeamSearchKey},'%') or t.NAME like concat('%',#{userOrTeamSearchKey},'%') or
du.USER_NAME like concat('%',#{userOrTeamSearchKey},'%') or du.NICK_NAME like concat('%',#{userOrTeamSearchKey},'%') or
du.EMAIL like concat('%',#{userOrTeamSearchKey},'%'))
</if>
<if test="dataSourceSearchKey != null ">
and (ds.ALIAS like concat('%',#{dataSourceSearchKey},'%') or ds.URL like concat('%',#{dataSourceSearchKey},'%'))
</if>
</where>
</select>

View File

@ -4,9 +4,12 @@
<select id="comprehensivePageQuery" resultType="ai.chat2db.server.domain.repository.entity.TeamUserDO">
select tu.*
from TEAM_USER tu
<if test="teamRoleCode != null ">
<if test="teamRoleCode != null or teamSearchKey != null">
left join TEAM t on t.id = tu.TEAM_ID
</if>
<if test="userSearchKey != null">
left join DBHUB_USER du on du.id = tu.USER_ID
</if>
<where>
<if test="teamId != null ">
and tu.TEAM_ID = #{teamId}
@ -18,6 +21,14 @@
and t.ROLE_CODE = #{teamRoleCode}
and t.STATUS = 'VALID'
</if>
<if test="teamSearchKey != null ">
and (t.CODE like concat('%',#{teamSearchKey},'%') or t.NAME like concat('%',#{teamSearchKey},'%'))
</if>
<if test="userSearchKey != null ">
and ( du.USER_NAME like concat('%',#{userSearchKey},'%') or du.NICK_NAME like
concat('%',#{userSearchKey},'%') or
du.EMAIL like concat('%',#{userSearchKey},'%'))
</if>
</where>
</select>