This commit is contained in:
zhangchenbiao
2023-05-23 16:37:25 +08:00
parent 63505941d0
commit 799b6b8cf5
59 changed files with 1994 additions and 76 deletions

View File

@@ -39,6 +39,13 @@ public class EnterpriseConfigDAO {
return enterpriseConfigMapper.getDistinctDbServer();
}
public EnterpriseConfigDO getConfigByCorpIdAndAppType(String corpId, String appType){
if(StringUtils.isAnyBlank(corpId, appType)){
return null;
}
return enterpriseConfigMapper.getConfigByCorpIdAndAppType(corpId, appType);
}
}

View File

@@ -0,0 +1,30 @@
package com.cool.store.dao;
import com.cool.store.mapper.EnterpriseMapper;
import com.cool.store.model.entity.EnterpriseDO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author zhangchenbiao
* @FileName: EnterpriseDAO
* @Description:
* @date 2023-05-23 13:52
*/
@Service
public class EnterpriseDAO {
@Resource
private EnterpriseMapper enterpriseMapper;
public EnterpriseDO getEnterpriseById(String enterpriseId){
if(StringUtils.isBlank(enterpriseId)){
return null;
}
return enterpriseMapper.getEnterpriseById(enterpriseId);
}
}

View File

@@ -1,7 +1,12 @@
package com.cool.store.dao;
import com.cool.store.entity.EnterpriseUserDO;
import com.cool.store.mapper.EnterpriseUserMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author zhangchenbiao
* @date 2023-05-19 02:58
@@ -9,4 +14,15 @@ import org.springframework.stereotype.Service;
@Service
public class EnterpriseUserDAO {
@Resource
private EnterpriseUserMapper enterpriseUserMapper;
public EnterpriseUserDO getUserInfoById(String enterpriseId, String userId){
if(StringUtils.isAnyBlank(enterpriseId, userId)){
return null;
}
return enterpriseUserMapper.getUserInfoById(enterpriseId, userId);
}
}

View File

@@ -0,0 +1,28 @@
package com.cool.store.dao;
import com.cool.store.mapper.LoginRecordMapper;
import com.cool.store.model.entity.LoginRecordDO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author zhangchenbiao
* @FileName: LoginRecordDAO
* @Description:
* @date 2023-05-23 15:48
*/
@Service
public class LoginRecordDAO {
@Resource
private LoginRecordMapper loginRecordMapper;
public void addLoginRecord(String enterpriseId, String userId){
LoginRecordDO record = new LoginRecordDO();
record.setUserId(userId);
record.setCreateTime(System.currentTimeMillis());
loginRecordMapper.insertSelective(record, enterpriseId);
}
}

View File

@@ -1,7 +1,12 @@
package com.cool.store.dao;
import com.cool.store.entity.SysRoleDO;
import com.cool.store.mapper.SysRoleMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author zhangchenbiao
* @date 2023-05-19 03:00
@@ -9,4 +14,20 @@ import org.springframework.stereotype.Service;
@Service
public class SysRoleDAO {
@Resource
private SysRoleMapper sysRoleMapper;
/**
* 获取高优先级的角色
* @param enterpriseId
* @param userId
* @return
*/
public SysRoleDO getHighestPrioritySysRoleDoByUserId(String enterpriseId, String userId){
if(StringUtils.isAnyBlank(enterpriseId, userId)){
return null;
}
return sysRoleMapper.getHighestPrioritySysRoleDoByUserId(enterpriseId, userId);
}
}

View File

@@ -31,4 +31,12 @@ public interface EnterpriseConfigMapper {
*/
EnterpriseConfigDO getDbInfoByDbName(@Param("dbName")String dbName);
/**
* 根据corpId 和 appType 获取config信息
* @param corpId
* @param appType
* @return
*/
EnterpriseConfigDO getConfigByCorpIdAndAppType(@Param("corpId")String corpId, @Param("appType")String appType);
}

View File

@@ -0,0 +1,32 @@
package com.cool.store.mapper;
import com.cool.store.model.entity.EnterpriseDO;
import org.apache.ibatis.annotations.Param;
/**
* @author zhangchenbiao
* @date 2023-05-23 11:36
*/
public interface EnterpriseMapper {
/**
*
* 默认插入方法,只会给有值的字段赋值
* 会对传进来的字段做判空处理如果字段为空则使用数据库默认字段或者null
* dateTime:2023-05-23 11:36
*/
int insertSelective(EnterpriseDO record);
/**
*
* 默认更新方法根据主键更新不会把null值更新到数据库避免覆盖之前有值的
* dateTime:2023-05-23 11:36
*/
int updateByPrimaryKeySelective(EnterpriseDO record);
/**
* 获取企业信息
* @param enterpriseId
* @return
*/
EnterpriseDO getEnterpriseById(@Param("enterpriseId") String enterpriseId);
}

View File

@@ -22,4 +22,12 @@ public interface EnterpriseUserMapper {
* dateTime:2023-05-19 02:58
*/
int updateByPrimaryKeySelective(@Param("record") EnterpriseUserDO record, @Param("enterpriseId") String enterpriseId);
/**
*
* @param enterpriseId
* @param userId
* @return
*/
EnterpriseUserDO getUserInfoById(@Param("enterpriseId")String enterpriseId, @Param("userId")String userId);
}

View File

@@ -0,0 +1,25 @@
package com.cool.store.mapper;
import com.cool.store.model.entity.LoginRecordDO;
import org.apache.ibatis.annotations.Param;
/**
* @author zhangchenbiao
* @date 2023-05-23 03:46
*/
public interface LoginRecordMapper {
/**
*
* 默认插入方法,只会给有值的字段赋值
* 会对传进来的字段做判空处理如果字段为空则使用数据库默认字段或者null
* dateTime:2023-05-23 03:46
*/
int insertSelective(@Param("record") LoginRecordDO record, @Param("enterpriseId") String enterpriseId);
/**
*
* 默认更新方法根据主键更新不会把null值更新到数据库避免覆盖之前有值的
* dateTime:2023-05-23 03:46
*/
int updateByPrimaryKeySelective(@Param("record") LoginRecordDO record, @Param("enterpriseId") String enterpriseId);
}

View File

@@ -22,4 +22,7 @@ public interface SysRoleMapper {
* dateTime:2023-05-19 03:00
*/
int updateByPrimaryKeySelective(@Param("record") SysRoleDO record, @Param("enterpriseId") String enterpriseId);
SysRoleDO getHighestPrioritySysRoleDoByUserId(@Param("enterpriseId") String enterpriseId, @Param("userId") String userId);
}

View File

@@ -57,4 +57,13 @@
where
db_name = #{dbName} limit 1
</select>
<select id="getConfigByCorpIdAndAppType" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
enterprise_config
where
ding_corp_id = #{corpId} and app_type = #{appType}
</select>
</mapper>

View File

@@ -0,0 +1,295 @@
<?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.cool.store.mapper.EnterpriseMapper">
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.EnterpriseDO">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="original_name" jdbcType="VARCHAR" property="originalName"/>
<result column="mobile" jdbcType="CHAR" property="mobile"/>
<result column="province" jdbcType="VARCHAR" property="province"/>
<result column="city" jdbcType="VARCHAR" property="city"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="logo" jdbcType="VARCHAR" property="logo"/>
<result column="is_vip" jdbcType="INTEGER" property="isVip"/>
<result column="auth_type" jdbcType="INTEGER" property="authType"/>
<result column="auth_user_id" jdbcType="VARCHAR" property="authUserId"/>
<result column="industry" jdbcType="VARCHAR" property="industry"/>
<result column="logo_name" jdbcType="VARCHAR" property="logoName"/>
<result column="corp_logo_url" jdbcType="VARCHAR" property="corpLogoUrl"/>
<result column="is_authenticated" jdbcType="INTEGER" property="isAuthenticated"/>
<result column="auth_level" jdbcType="INTEGER" property="authLevel"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="package_begin_date" jdbcType="TIMESTAMP" property="packageBeginDate"/>
<result column="package_end_date" jdbcType="TIMESTAMP" property="packageEndDate"/>
<result column="aliyun_person_group_crop_id" jdbcType="VARCHAR" property="aliyunPersonGroupCropId"/>
<result column="app_type" jdbcType="VARCHAR" property="appType"/>
<result column="tag" jdbcType="VARCHAR" property="tag"/>
<result column="dataware_config" jdbcType="VARCHAR" property="datawareConfig"/>
<result column="is_leave_info" jdbcType="BIT" property="isLeaveInfo"/>
<result column="limit_store_count" jdbcType="INTEGER" property="limitStoreCount"/>
<result column="limit_device_count" jdbcType="INTEGER" property="limitDeviceCount"/>
</resultMap>
<sql id="Base_Column_List">
id, name, original_name, mobile, province, city, status, logo, is_vip, auth_type,
auth_user_id, industry, logo_name, corp_logo_url, is_authenticated, auth_level, create_time,
update_time, package_begin_date, package_end_date, aliyun_person_group_crop_id, app_type,
tag, dataware_config, is_leave_info, limit_store_count, limit_device_count
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
insert into enterprise
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">
name,
</if>
<if test="originalName != null">
original_name,
</if>
<if test="mobile != null">
mobile,
</if>
<if test="province != null">
province,
</if>
<if test="city != null">
city,
</if>
<if test="status != null">
status,
</if>
<if test="logo != null">
logo,
</if>
<if test="isVip != null">
is_vip,
</if>
<if test="authType != null">
auth_type,
</if>
<if test="authUserId != null">
auth_user_id,
</if>
<if test="industry != null">
industry,
</if>
<if test="logoName != null">
logo_name,
</if>
<if test="corpLogoUrl != null">
corp_logo_url,
</if>
<if test="isAuthenticated != null">
is_authenticated,
</if>
<if test="authLevel != null">
auth_level,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="packageBeginDate != null">
package_begin_date,
</if>
<if test="packageEndDate != null">
package_end_date,
</if>
<if test="aliyunPersonGroupCropId != null">
aliyun_person_group_crop_id,
</if>
<if test="appType != null">
app_type,
</if>
<if test="tag != null">
tag,
</if>
<if test="datawareConfig != null">
dataware_config,
</if>
<if test="isLeaveInfo != null">
is_leave_info,
</if>
<if test="limitStoreCount != null">
limit_store_count,
</if>
<if test="limitDeviceCount != null">
limit_device_count,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
#{name},
</if>
<if test="originalName != null">
#{originalName},
</if>
<if test="mobile != null">
#{mobile},
</if>
<if test="province != null">
#{province},
</if>
<if test="city != null">
#{city},
</if>
<if test="status != null">
#{status},
</if>
<if test="logo != null">
#{logo},
</if>
<if test="isVip != null">
#{isVip},
</if>
<if test="authType != null">
#{authType},
</if>
<if test="authUserId != null">
#{authUserId},
</if>
<if test="industry != null">
#{industry},
</if>
<if test="logoName != null">
#{logoName},
</if>
<if test="corpLogoUrl != null">
#{corpLogoUrl},
</if>
<if test="isAuthenticated != null">
#{isAuthenticated},
</if>
<if test="authLevel != null">
#{authLevel},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="packageBeginDate != null">
#{packageBeginDate},
</if>
<if test="packageEndDate != null">
#{packageEndDate},
</if>
<if test="aliyunPersonGroupCropId != null">
#{aliyunPersonGroupCropId},
</if>
<if test="appType != null">
#{appType},
</if>
<if test="tag != null">
#{tag},
</if>
<if test="datawareConfig != null">
#{datawareConfig},
</if>
<if test="isLeaveInfo != null">
#{isLeaveInfo},
</if>
<if test="limitStoreCount != null">
#{limitStoreCount},
</if>
<if test="limitDeviceCount != null">
#{limitDeviceCount},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective">
update enterprise
<set>
<if test="name != null">
name = #{name},
</if>
<if test="originalName != null">
original_name = #{originalName},
</if>
<if test="mobile != null">
mobile = #{mobile},
</if>
<if test="province != null">
province = #{province},
</if>
<if test="city != null">
city = #{city},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="logo != null">
logo = #{logo},
</if>
<if test="isVip != null">
is_vip = #{isVip},
</if>
<if test="authType != null">
auth_type = #{authType},
</if>
<if test="authUserId != null">
auth_user_id = #{authUserId},
</if>
<if test="industry != null">
industry = #{industry},
</if>
<if test="logoName != null">
logo_name = #{logoName},
</if>
<if test="corpLogoUrl != null">
corp_logo_url = #{corpLogoUrl},
</if>
<if test="isAuthenticated != null">
is_authenticated = #{isAuthenticated},
</if>
<if test="authLevel != null">
auth_level = #{authLevel},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="packageBeginDate != null">
package_begin_date = #{packageBeginDate},
</if>
<if test="packageEndDate != null">
package_end_date = #{packageEndDate},
</if>
<if test="aliyunPersonGroupCropId != null">
aliyun_person_group_crop_id = #{aliyunPersonGroupCropId},
</if>
<if test="appType != null">
app_type = #{appType},
</if>
<if test="tag != null">
tag = #{tag},
</if>
<if test="datawareConfig != null">
dataware_config = #{datawareConfig},
</if>
<if test="isLeaveInfo != null">
is_leave_info = #{isLeaveInfo},
</if>
<if test="limitStoreCount != null">
limit_store_count = #{limitStoreCount},
</if>
<if test="limitDeviceCount != null">
limit_device_count = #{limitDeviceCount},
</if>
</set>
where id = #{id}
</update>
<select id="getEnterpriseById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
enterprise
where
id = #{id}
</select>
</mapper>

View File

@@ -388,4 +388,14 @@
</set>
where id = #{record.id}
</update>
<select id="getUserInfoById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>,
<include refid="Blob_Column_List"/>
from
enterprise_user_${enterpriseId}
where
user_id = #{userId}
</select>
</mapper>

View File

@@ -0,0 +1,43 @@
<?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.cool.store.mapper.LoginRecordMapper">
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.LoginRecordDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id, user_id, create_time
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
insert into login_record_${enterpriseId}
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.userId != null">
user_id,
</if>
<if test="record.createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.userId != null">
#{record.userId},
</if>
<if test="record.createTime != null">
#{record.createTime},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective">
update login_record_${enterpriseId}
<set>
<if test="record.userId != null">
user_id = #{record.userId},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime},
</if>
</set>
where id = #{record.id}
</update>
</mapper>

View File

@@ -161,4 +161,23 @@
</set>
where id = #{record.id}
</update>
<select id="getHighestPrioritySysRoleDoByUserId" resultMap="BaseResultMap">
select
c.id as id,
c.role_name as roleName,
c.role_auth as roleAuth,
c.position_type as positionType,
c.app_menu as appMenu,
c.role_enum as roleEnum
from
enterprise_user_${enterpriseId} a
left join enterprise_user_role_${enterpriseId} b on a.user_id =b.user_id
left join sys_role_${enterpriseId} c on c.id=b.role_id
where
a.user_id= #{userId} and a.active = true
order by
c.priority is null, c.priority, position_type desc
LIMIT 1
</select>
</mapper>