init
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.mapper.EnterpriseConfigMapper;
|
||||
import com.cool.store.model.entity.EnterpriseConfigDO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: EnterpriseConfigDAO
|
||||
* @Description:
|
||||
* @date 2023-05-18 11:15
|
||||
*/
|
||||
@Service
|
||||
public class EnterpriseConfigDAO {
|
||||
|
||||
@Resource
|
||||
private EnterpriseConfigMapper enterpriseConfigMapper;
|
||||
|
||||
|
||||
public EnterpriseConfigDO selectByEnterpriseId(String enterpriseId) {
|
||||
if(StringUtils.isBlank(enterpriseId)){
|
||||
return null;
|
||||
}
|
||||
return enterpriseConfigMapper.selectByEnterpriseId(enterpriseId);
|
||||
}
|
||||
|
||||
public EnterpriseConfigDO getDbInfoByDbName(String dbName) {
|
||||
if(StringUtils.isBlank(dbName)){
|
||||
return null;
|
||||
}
|
||||
return enterpriseConfigMapper.getDbInfoByDbName(dbName);
|
||||
}
|
||||
|
||||
public List<EnterpriseConfigDO> getDistinctDbServer() {
|
||||
return enterpriseConfigMapper.getDistinctDbServer();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.model.entity.EnterpriseConfigDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-18 11:09
|
||||
*/
|
||||
public interface EnterpriseConfigMapper {
|
||||
|
||||
/**
|
||||
* 根据企业id获取config
|
||||
* @param enterpriseId
|
||||
* @return
|
||||
*/
|
||||
EnterpriseConfigDO selectByEnterpriseId(@Param("enterpriseId") String enterpriseId);
|
||||
|
||||
/**
|
||||
* 获取dbServer
|
||||
* @return
|
||||
*/
|
||||
List<EnterpriseConfigDO> getDistinctDbServer();
|
||||
|
||||
/**
|
||||
* 根据dbName 获取数据库信息
|
||||
* @param dbName
|
||||
* @return
|
||||
*/
|
||||
EnterpriseConfigDO getDbInfoByDbName(@Param("dbName")String dbName);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.model.entity.EnterpriseUserDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 02:58
|
||||
*/
|
||||
public interface EnterpriseUserMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 02:58
|
||||
*/
|
||||
int insertSelective(@Param("record") EnterpriseUserDO record, @Param("enterpriseId") String enterpriseId);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 02:58
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") EnterpriseUserDO record, @Param("enterpriseId") String enterpriseId);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.model.entity.EnterpriseUserRoleDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 02:59
|
||||
*/
|
||||
public interface EnterpriseUserRoleMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 02:59
|
||||
*/
|
||||
int insertSelective(@Param("record") EnterpriseUserRoleDO record, @Param("enterpriseId") String enterpriseId);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 02:59
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") EnterpriseUserRoleDO record, @Param("enterpriseId") String enterpriseId);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.model.entity.RegionDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 02:59
|
||||
*/
|
||||
public interface RegionMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 02:59
|
||||
*/
|
||||
int insertSelective(@Param("record") RegionDO record, @Param("enterpriseId") String enterpriseId);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 02:59
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") RegionDO record, @Param("enterpriseId") String enterpriseId);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.model.entity.SysDepartmentDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
*/
|
||||
public interface SysDepartmentMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 03:00
|
||||
*/
|
||||
int insertSelective(@Param("record") SysDepartmentDO record, @Param("enterpriseId") String enterpriseId);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 03:00
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") SysDepartmentDO record, @Param("enterpriseId") String enterpriseId);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.model.entity.SysRoleDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
*/
|
||||
public interface SysRoleMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 03:00
|
||||
*/
|
||||
int insertSelective(@Param("record") SysRoleDO record, @Param("enterpriseId") String enterpriseId);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 03:00
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") SysRoleDO record, @Param("enterpriseId") String enterpriseId);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.model.entity.SysRoleMenuDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:01
|
||||
*/
|
||||
public interface SysRoleMenuMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 03:01
|
||||
*/
|
||||
int insertSelective(@Param("record") SysRoleMenuDO record, @Param("enterpriseId") String enterpriseId);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 03:01
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") SysRoleMenuDO record, @Param("enterpriseId") String enterpriseId);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.model.entity.UserAuthMappingDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 02:54
|
||||
*/
|
||||
public interface UserAuthMappingMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 02:54
|
||||
*/
|
||||
int insertSelective(@Param("record") UserAuthMappingDO record, @Param("enterpriseId") String enterpriseId);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 02:54
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") UserAuthMappingDO record, @Param("enterpriseId") String enterpriseId);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.model.entity.UserRegionMappingDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
*/
|
||||
public interface UserRegionMappingMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 03:00
|
||||
*/
|
||||
int insertSelective(@Param("record") UserRegionMappingDO record, @Param("enterpriseId") String enterpriseId);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 03:00
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") UserRegionMappingDO record, @Param("enterpriseId") String enterpriseId);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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.EnterpriseConfigMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.EnterpriseConfigDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="current_package" jdbcType="BIGINT" property="currentPackage"/>
|
||||
<result column="enterprise_id" jdbcType="VARCHAR" property="enterpriseId"/>
|
||||
<result column="staff_count" jdbcType="INTEGER" property="staffCount"/>
|
||||
<result column="db_source_name" jdbcType="VARCHAR" property="dbSourceName"/>
|
||||
<result column="db_server" jdbcType="VARCHAR" property="dbServer"/>
|
||||
<result column="db_port" jdbcType="INTEGER" property="dbPort"/>
|
||||
<result column="db_name" jdbcType="VARCHAR" property="dbName"/>
|
||||
<result column="db_user" jdbcType="VARCHAR" property="dbUser"/>
|
||||
<result column="db_pwd" jdbcType="VARCHAR" property="dbPwd"/>
|
||||
<result column="license" jdbcType="VARCHAR" property="license"/>
|
||||
<result column="license_expires" jdbcType="TIMESTAMP" property="licenseExpires"/>
|
||||
<result column="license_type" jdbcType="INTEGER" property="licenseType"/>
|
||||
<result column="ding_corp_id" jdbcType="VARCHAR" property="dingCorpId"/>
|
||||
<result column="ding_corp_secret" jdbcType="VARCHAR" property="dingCorpSecret"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="create_user" jdbcType="VARCHAR" property="createUser"/>
|
||||
<result column="main_corp_id" jdbcType="VARCHAR" property="mainCorpId"/>
|
||||
<result column="app_type" jdbcType="VARCHAR" property="appType"/>
|
||||
<result column="permanent_code" jdbcType="VARCHAR" property="permanentCode"/>
|
||||
<result column="agentid" jdbcType="VARCHAR" property="agentid"/>
|
||||
<result column="cool_college_enterprise_id" jdbcType="VARCHAR" property="coolCollegeEnterpriseId"/>
|
||||
<result column="cool_college_secret" jdbcType="VARCHAR" property="coolCollegeSecret"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, current_package, enterprise_id, staff_count, db_source_name, db_server, db_port,
|
||||
db_name, db_user, db_pwd, license, license_expires, license_type, ding_corp_id, ding_corp_secret,
|
||||
create_time, create_user, main_corp_id, app_type, permanent_code, agentid, cool_college_enterprise_id,
|
||||
cool_college_secret
|
||||
</sql>
|
||||
|
||||
<select id="selectByEnterpriseId" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from
|
||||
enterprise_config
|
||||
where
|
||||
enterprise_id = #{enterpriseId}
|
||||
</select>
|
||||
|
||||
<select id="getDistinctDbServer" resultMap="BaseResultMap">
|
||||
select
|
||||
distinct db_server, db_port, db_user, db_pwd
|
||||
from
|
||||
enterprise_config
|
||||
</select>
|
||||
|
||||
<select id="getDbInfoByDbName" resultMap="BaseResultMap">
|
||||
select
|
||||
db_server, db_port, db_user, db_pwd
|
||||
from
|
||||
enterprise_config
|
||||
where
|
||||
db_name = #{dbName} limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,391 @@
|
||||
<?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.EnterpriseUserMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.EnterpriseUserDO">
|
||||
<id column="id" jdbcType="VARCHAR" property="id"/>
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
||||
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||
<result column="tel" jdbcType="VARCHAR" property="tel"/>
|
||||
<result column="work_place" jdbcType="VARCHAR" property="workPlace"/>
|
||||
<result column="remark" jdbcType="VARCHAR" property="remark"/>
|
||||
<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
|
||||
<result column="email" jdbcType="VARCHAR" property="email"/>
|
||||
<result column="org_email" jdbcType="VARCHAR" property="orgEmail"/>
|
||||
<result column="active" jdbcType="BIT" property="active"/>
|
||||
<result column="order_in_depts" jdbcType="VARCHAR" property="orderInDepts"/>
|
||||
<result column="main_admin" jdbcType="TINYINT" property="mainAdmin"/>
|
||||
<result column="is_admin" jdbcType="BIT" property="isAdmin"/>
|
||||
<result column="is_boss" jdbcType="BIT" property="isBoss"/>
|
||||
<result column="dingId" jdbcType="VARCHAR" property="dingid"/>
|
||||
<result column="unionid" jdbcType="VARCHAR" property="unionid"/>
|
||||
<result column="is_hide" jdbcType="BIT" property="isHide"/>
|
||||
<result column="position" jdbcType="VARCHAR" property="position"/>
|
||||
<result column="avatar" jdbcType="VARCHAR" property="avatar"/>
|
||||
<result column="extattr" jdbcType="VARCHAR" property="extattr"/>
|
||||
<result column="is_enterprise" jdbcType="BIT" property="isEnterprise"/>
|
||||
<result column="roles" jdbcType="VARCHAR" property="roles"/>
|
||||
<result column="is_leader" jdbcType="BIT" property="isLeader"/>
|
||||
<result column="face_url" jdbcType="VARCHAR" property="faceUrl"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="language" jdbcType="CHAR" property="language"/>
|
||||
<result column="user_status" jdbcType="TINYINT" property="userStatus"/>
|
||||
<result column="third_oa_unique_flag" jdbcType="VARCHAR" property="thirdOaUniqueFlag"/>
|
||||
<result column="subordinate_change" jdbcType="TINYINT" property="subordinateChange"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="subordinate_range" jdbcType="VARCHAR" property="subordinateRange"/>
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.cool.store.model.entity.EnterpriseUserDO">
|
||||
<result column="is_leader_in_depts" jdbcType="LONGVARCHAR" property="isLeaderInDepts"/>
|
||||
<result column="department" jdbcType="LONGVARCHAR" property="department"/>
|
||||
<result column="jobnumber" jdbcType="LONGVARCHAR" property="jobnumber"/>
|
||||
<result column="monitored_departments" jdbcType="LONGVARCHAR" property="monitoredDepartments"/>
|
||||
<result column="departments" jdbcType="LONGVARCHAR" property="departments"/>
|
||||
<result column="user_region_ids" jdbcType="LONGVARCHAR" property="userRegionIds"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, name, tel, work_place, remark, mobile, email, org_email, active, order_in_depts,
|
||||
main_admin, is_admin, is_boss, dingId, unionid, is_hide, position, avatar, extattr,
|
||||
is_enterprise, roles, is_leader, face_url, create_time, language, user_status, third_oa_unique_flag,
|
||||
subordinate_change, update_time, subordinate_range
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
is_leader_in_depts, department, jobnumber, monitored_departments, departments, user_region_ids
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into enterprise_user_${enterpriseId}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="record.tel != null">
|
||||
tel,
|
||||
</if>
|
||||
<if test="record.workPlace != null">
|
||||
work_place,
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
remark,
|
||||
</if>
|
||||
<if test="record.mobile != null">
|
||||
mobile,
|
||||
</if>
|
||||
<if test="record.email != null">
|
||||
email,
|
||||
</if>
|
||||
<if test="record.orgEmail != null">
|
||||
org_email,
|
||||
</if>
|
||||
<if test="record.active != null">
|
||||
active,
|
||||
</if>
|
||||
<if test="record.orderInDepts != null">
|
||||
order_in_depts,
|
||||
</if>
|
||||
<if test="record.mainAdmin != null">
|
||||
main_admin,
|
||||
</if>
|
||||
<if test="record.isAdmin != null">
|
||||
is_admin,
|
||||
</if>
|
||||
<if test="record.isBoss != null">
|
||||
is_boss,
|
||||
</if>
|
||||
<if test="record.dingid != null">
|
||||
dingId,
|
||||
</if>
|
||||
<if test="record.unionid != null">
|
||||
unionid,
|
||||
</if>
|
||||
<if test="record.isHide != null">
|
||||
is_hide,
|
||||
</if>
|
||||
<if test="record.position != null">
|
||||
position,
|
||||
</if>
|
||||
<if test="record.avatar != null">
|
||||
avatar,
|
||||
</if>
|
||||
<if test="record.extattr != null">
|
||||
extattr,
|
||||
</if>
|
||||
<if test="record.isEnterprise != null">
|
||||
is_enterprise,
|
||||
</if>
|
||||
<if test="record.roles != null">
|
||||
roles,
|
||||
</if>
|
||||
<if test="record.isLeader != null">
|
||||
is_leader,
|
||||
</if>
|
||||
<if test="record.faceUrl != null">
|
||||
face_url,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.language != null">
|
||||
language,
|
||||
</if>
|
||||
<if test="record.userStatus != null">
|
||||
user_status,
|
||||
</if>
|
||||
<if test="record.thirdOaUniqueFlag != null">
|
||||
third_oa_unique_flag,
|
||||
</if>
|
||||
<if test="record.subordinateChange != null">
|
||||
subordinate_change,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="record.subordinateRange != null">
|
||||
subordinate_range,
|
||||
</if>
|
||||
<if test="record.isLeaderInDepts != null">
|
||||
is_leader_in_depts,
|
||||
</if>
|
||||
<if test="record.department != null">
|
||||
department,
|
||||
</if>
|
||||
<if test="record.jobnumber != null">
|
||||
jobnumber,
|
||||
</if>
|
||||
<if test="record.monitoredDepartments != null">
|
||||
monitored_departments,
|
||||
</if>
|
||||
<if test="record.departments != null">
|
||||
departments,
|
||||
</if>
|
||||
<if test="record.userRegionIds != null">
|
||||
user_region_ids,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.userId != null">
|
||||
#{record.userId},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
#{record.name},
|
||||
</if>
|
||||
<if test="record.tel != null">
|
||||
#{record.tel},
|
||||
</if>
|
||||
<if test="record.workPlace != null">
|
||||
#{record.workPlace},
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
#{record.remark},
|
||||
</if>
|
||||
<if test="record.mobile != null">
|
||||
#{record.mobile},
|
||||
</if>
|
||||
<if test="record.email != null">
|
||||
#{record.email},
|
||||
</if>
|
||||
<if test="record.orgEmail != null">
|
||||
#{record.orgEmail},
|
||||
</if>
|
||||
<if test="record.active != null">
|
||||
#{record.active},
|
||||
</if>
|
||||
<if test="record.orderInDepts != null">
|
||||
#{record.orderInDepts},
|
||||
</if>
|
||||
<if test="record.mainAdmin != null">
|
||||
#{record.mainAdmin},
|
||||
</if>
|
||||
<if test="record.isAdmin != null">
|
||||
#{record.isAdmin},
|
||||
</if>
|
||||
<if test="record.isBoss != null">
|
||||
#{record.isBoss},
|
||||
</if>
|
||||
<if test="record.dingid != null">
|
||||
#{record.dingid},
|
||||
</if>
|
||||
<if test="record.unionid != null">
|
||||
#{record.unionid},
|
||||
</if>
|
||||
<if test="record.isHide != null">
|
||||
#{record.isHide},
|
||||
</if>
|
||||
<if test="record.position != null">
|
||||
#{record.position},
|
||||
</if>
|
||||
<if test="record.avatar != null">
|
||||
#{record.avatar},
|
||||
</if>
|
||||
<if test="record.extattr != null">
|
||||
#{record.extattr},
|
||||
</if>
|
||||
<if test="record.isEnterprise != null">
|
||||
#{record.isEnterprise},
|
||||
</if>
|
||||
<if test="record.roles != null">
|
||||
#{record.roles},
|
||||
</if>
|
||||
<if test="record.isLeader != null">
|
||||
#{record.isLeader},
|
||||
</if>
|
||||
<if test="record.faceUrl != null">
|
||||
#{record.faceUrl},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.language != null">
|
||||
#{record.language},
|
||||
</if>
|
||||
<if test="record.userStatus != null">
|
||||
#{record.userStatus},
|
||||
</if>
|
||||
<if test="record.thirdOaUniqueFlag != null">
|
||||
#{record.thirdOaUniqueFlag},
|
||||
</if>
|
||||
<if test="record.subordinateChange != null">
|
||||
#{record.subordinateChange},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
<if test="record.subordinateRange != null">
|
||||
#{record.subordinateRange},
|
||||
</if>
|
||||
<if test="record.isLeaderInDepts != null">
|
||||
#{record.isLeaderInDepts},
|
||||
</if>
|
||||
<if test="record.department != null">
|
||||
#{record.department},
|
||||
</if>
|
||||
<if test="record.jobnumber != null">
|
||||
#{record.jobnumber},
|
||||
</if>
|
||||
<if test="record.monitoredDepartments != null">
|
||||
#{record.monitoredDepartments},
|
||||
</if>
|
||||
<if test="record.departments != null">
|
||||
#{record.departments},
|
||||
</if>
|
||||
<if test="record.userRegionIds != null">
|
||||
#{record.userRegionIds},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update enterprise_user_${enterpriseId}
|
||||
<set>
|
||||
<if test="record.userId != null">
|
||||
user_id = #{record.userId},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
name = #{record.name},
|
||||
</if>
|
||||
<if test="record.tel != null">
|
||||
tel = #{record.tel},
|
||||
</if>
|
||||
<if test="record.workPlace != null">
|
||||
work_place = #{record.workPlace},
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
remark = #{record.remark},
|
||||
</if>
|
||||
<if test="record.mobile != null">
|
||||
mobile = #{record.mobile},
|
||||
</if>
|
||||
<if test="record.email != null">
|
||||
email = #{record.email},
|
||||
</if>
|
||||
<if test="record.orgEmail != null">
|
||||
org_email = #{record.orgEmail},
|
||||
</if>
|
||||
<if test="record.active != null">
|
||||
active = #{record.active},
|
||||
</if>
|
||||
<if test="record.orderInDepts != null">
|
||||
order_in_depts = #{record.orderInDepts},
|
||||
</if>
|
||||
<if test="record.mainAdmin != null">
|
||||
main_admin = #{record.mainAdmin},
|
||||
</if>
|
||||
<if test="record.isAdmin != null">
|
||||
is_admin = #{record.isAdmin},
|
||||
</if>
|
||||
<if test="record.isBoss != null">
|
||||
is_boss = #{record.isBoss},
|
||||
</if>
|
||||
<if test="record.dingid != null">
|
||||
dingId = #{record.dingid},
|
||||
</if>
|
||||
<if test="record.unionid != null">
|
||||
unionid = #{record.unionid},
|
||||
</if>
|
||||
<if test="record.isHide != null">
|
||||
is_hide = #{record.isHide},
|
||||
</if>
|
||||
<if test="record.position != null">
|
||||
position = #{record.position},
|
||||
</if>
|
||||
<if test="record.avatar != null">
|
||||
avatar = #{record.avatar},
|
||||
</if>
|
||||
<if test="record.extattr != null">
|
||||
extattr = #{record.extattr},
|
||||
</if>
|
||||
<if test="record.isEnterprise != null">
|
||||
is_enterprise = #{record.isEnterprise},
|
||||
</if>
|
||||
<if test="record.roles != null">
|
||||
roles = #{record.roles},
|
||||
</if>
|
||||
<if test="record.isLeader != null">
|
||||
is_leader = #{record.isLeader},
|
||||
</if>
|
||||
<if test="record.faceUrl != null">
|
||||
face_url = #{record.faceUrl},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
</if>
|
||||
<if test="record.language != null">
|
||||
language = #{record.language},
|
||||
</if>
|
||||
<if test="record.userStatus != null">
|
||||
user_status = #{record.userStatus},
|
||||
</if>
|
||||
<if test="record.thirdOaUniqueFlag != null">
|
||||
third_oa_unique_flag = #{record.thirdOaUniqueFlag},
|
||||
</if>
|
||||
<if test="record.subordinateChange != null">
|
||||
subordinate_change = #{record.subordinateChange},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
</if>
|
||||
<if test="record.subordinateRange != null">
|
||||
subordinate_range = #{record.subordinateRange},
|
||||
</if>
|
||||
<if test="record.isLeaderInDepts != null">
|
||||
is_leader_in_depts = #{record.isLeaderInDepts},
|
||||
</if>
|
||||
<if test="record.department != null">
|
||||
department = #{record.department},
|
||||
</if>
|
||||
<if test="record.jobnumber != null">
|
||||
jobnumber = #{record.jobnumber},
|
||||
</if>
|
||||
<if test="record.monitoredDepartments != null">
|
||||
monitored_departments = #{record.monitoredDepartments},
|
||||
</if>
|
||||
<if test="record.departments != null">
|
||||
departments = #{record.departments},
|
||||
</if>
|
||||
<if test="record.userRegionIds != null">
|
||||
user_region_ids = #{record.userRegionIds},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,63 @@
|
||||
<?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.EnterpriseUserRoleMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.EnterpriseUserRoleDO">
|
||||
<id column="id" jdbcType="INTEGER" property="id"/>
|
||||
<result column="role_id" jdbcType="BIGINT" property="roleId"/>
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, role_id, user_id, create_time, update_time
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into enterprise_user_role_${enterpriseId}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.roleId != null">
|
||||
role_id,
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.roleId != null">
|
||||
#{record.roleId},
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
#{record.userId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update enterprise_user_role_${enterpriseId}
|
||||
<set>
|
||||
<if test="record.roleId != null">
|
||||
role_id = #{record.roleId},
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
user_id = #{record.userId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
</mapper>
|
||||
205
coolstore-partner-dao/src/main/resources/mapper/RegionMapper.xml
Normal file
205
coolstore-partner-dao/src/main/resources/mapper/RegionMapper.xml
Normal file
@@ -0,0 +1,205 @@
|
||||
<?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.RegionMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.RegionDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="region_id" jdbcType="VARCHAR" property="regionId"/>
|
||||
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||
<result column="parent_id" jdbcType="BIGINT" property="parentId"/>
|
||||
<result column="group_id" jdbcType="VARCHAR" property="groupId"/>
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
|
||||
<result column="create_name" jdbcType="VARCHAR" property="createName"/>
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime"/>
|
||||
<result column="update_name" jdbcType="VARCHAR" property="updateName"/>
|
||||
<result column="vds_group_corp_id" jdbcType="VARCHAR" property="vdsGroupCorpId"/>
|
||||
<result column="syn_ding_dept_id" jdbcType="VARCHAR" property="synDingDeptId"/>
|
||||
<result column="region_type" jdbcType="VARCHAR" property="regionType"/>
|
||||
<result column="region_path" jdbcType="VARCHAR" property="regionPath"/>
|
||||
<result column="deleted" jdbcType="BIT" property="deleted"/>
|
||||
<result column="store_num" jdbcType="INTEGER" property="storeNum"/>
|
||||
<result column="store_id" jdbcType="VARCHAR" property="storeId"/>
|
||||
<result column="unclassified_flag" jdbcType="TINYINT" property="unclassifiedFlag"/>
|
||||
<result column="order_num" jdbcType="INTEGER" property="orderNum"/>
|
||||
<result column="third_dept_id" jdbcType="VARCHAR" property="thirdDeptId"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, region_id, name, parent_id, group_id, create_time, create_name, update_time,
|
||||
update_name, vds_group_corp_id, syn_ding_dept_id, region_type, region_path, deleted,
|
||||
store_num, store_id, unclassified_flag, order_num, third_dept_id
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into region_${enterpriseId}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
region_id,
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id,
|
||||
</if>
|
||||
<if test="record.groupId != null">
|
||||
group_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
create_name,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="record.updateName != null">
|
||||
update_name,
|
||||
</if>
|
||||
<if test="record.vdsGroupCorpId != null">
|
||||
vds_group_corp_id,
|
||||
</if>
|
||||
<if test="record.synDingDeptId != null">
|
||||
syn_ding_dept_id,
|
||||
</if>
|
||||
<if test="record.regionType != null">
|
||||
region_type,
|
||||
</if>
|
||||
<if test="record.regionPath != null">
|
||||
region_path,
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="record.storeNum != null">
|
||||
store_num,
|
||||
</if>
|
||||
<if test="record.storeId != null">
|
||||
store_id,
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
unclassified_flag,
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
order_num,
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
third_dept_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
#{record.regionId},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
#{record.name},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
#{record.parentId},
|
||||
</if>
|
||||
<if test="record.groupId != null">
|
||||
#{record.groupId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
#{record.createName},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
<if test="record.updateName != null">
|
||||
#{record.updateName},
|
||||
</if>
|
||||
<if test="record.vdsGroupCorpId != null">
|
||||
#{record.vdsGroupCorpId},
|
||||
</if>
|
||||
<if test="record.synDingDeptId != null">
|
||||
#{record.synDingDeptId},
|
||||
</if>
|
||||
<if test="record.regionType != null">
|
||||
#{record.regionType},
|
||||
</if>
|
||||
<if test="record.regionPath != null">
|
||||
#{record.regionPath},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
<if test="record.storeNum != null">
|
||||
#{record.storeNum},
|
||||
</if>
|
||||
<if test="record.storeId != null">
|
||||
#{record.storeId},
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
#{record.unclassifiedFlag},
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
#{record.orderNum},
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
#{record.thirdDeptId},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update region_${enterpriseId}
|
||||
<set>
|
||||
<if test="record.regionId != null">
|
||||
region_id = #{record.regionId},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
name = #{record.name},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id = #{record.parentId},
|
||||
</if>
|
||||
<if test="record.groupId != null">
|
||||
group_id = #{record.groupId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
create_name = #{record.createName},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
</if>
|
||||
<if test="record.updateName != null">
|
||||
update_name = #{record.updateName},
|
||||
</if>
|
||||
<if test="record.vdsGroupCorpId != null">
|
||||
vds_group_corp_id = #{record.vdsGroupCorpId},
|
||||
</if>
|
||||
<if test="record.synDingDeptId != null">
|
||||
syn_ding_dept_id = #{record.synDingDeptId},
|
||||
</if>
|
||||
<if test="record.regionType != null">
|
||||
region_type = #{record.regionType},
|
||||
</if>
|
||||
<if test="record.regionPath != null">
|
||||
region_path = #{record.regionPath},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted = #{record.deleted},
|
||||
</if>
|
||||
<if test="record.storeNum != null">
|
||||
store_num = #{record.storeNum},
|
||||
</if>
|
||||
<if test="record.storeId != null">
|
||||
store_id = #{record.storeId},
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
unclassified_flag = #{record.unclassifiedFlag},
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
order_num = #{record.orderNum},
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
third_dept_id = #{record.thirdDeptId},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,200 @@
|
||||
<?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.SysDepartmentMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.SysDepartmentDO">
|
||||
<id column="id" jdbcType="VARCHAR" property="id"/>
|
||||
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||
<result column="parent_id" jdbcType="VARCHAR" property="parentId"/>
|
||||
<result column="depart_order" jdbcType="INTEGER" property="departOrder"/>
|
||||
<result column="create_dept_group" jdbcType="BIT" property="createDeptGroup"/>
|
||||
<result column="auto_add_user" jdbcType="BIT" property="autoAddUser"/>
|
||||
<result column="dep_Hiding" jdbcType="BIT" property="depHiding"/>
|
||||
<result column="dept_perimits" jdbcType="VARCHAR" property="deptPerimits"/>
|
||||
<result column="user_perimits" jdbcType="VARCHAR" property="userPerimits"/>
|
||||
<result column="outer_dept" jdbcType="BIT" property="outerDept"/>
|
||||
<result column="outer_permit_depts" jdbcType="VARCHAR" property="outerPermitDepts"/>
|
||||
<result column="outer_permit_users" jdbcType="VARCHAR" property="outerPermitUsers"/>
|
||||
<result column="org_dept_owner" jdbcType="VARCHAR" property="orgDeptOwner"/>
|
||||
<result column="dept_manager_userid_list" jdbcType="VARCHAR" property="deptManagerUseridList"/>
|
||||
<result column="user_count" jdbcType="INTEGER" property="userCount"/>
|
||||
<result column="unactive_user_count" jdbcType="INTEGER" property="unactiveUserCount"/>
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.cool.store.model.entity.SysDepartmentDO">
|
||||
<result column="parent_ids" jdbcType="LONGVARCHAR" property="parentIds"/>
|
||||
<result column="sub_ids" jdbcType="LONGVARCHAR" property="subIds"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, name, parent_id, depart_order, create_dept_group, auto_add_user, dep_Hiding,
|
||||
dept_perimits, user_perimits, outer_dept, outer_permit_depts, outer_permit_users,
|
||||
org_dept_owner, dept_manager_userid_list, user_count, unactive_user_count
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
parent_ids, sub_ids
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into sys_department_${enterpriseId}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id,
|
||||
</if>
|
||||
<if test="record.departOrder != null">
|
||||
depart_order,
|
||||
</if>
|
||||
<if test="record.createDeptGroup != null">
|
||||
create_dept_group,
|
||||
</if>
|
||||
<if test="record.autoAddUser != null">
|
||||
auto_add_user,
|
||||
</if>
|
||||
<if test="record.depHiding != null">
|
||||
dep_Hiding,
|
||||
</if>
|
||||
<if test="record.deptPerimits != null">
|
||||
dept_perimits,
|
||||
</if>
|
||||
<if test="record.userPerimits != null">
|
||||
user_perimits,
|
||||
</if>
|
||||
<if test="record.outerDept != null">
|
||||
outer_dept,
|
||||
</if>
|
||||
<if test="record.outerPermitDepts != null">
|
||||
outer_permit_depts,
|
||||
</if>
|
||||
<if test="record.outerPermitUsers != null">
|
||||
outer_permit_users,
|
||||
</if>
|
||||
<if test="record.orgDeptOwner != null">
|
||||
org_dept_owner,
|
||||
</if>
|
||||
<if test="record.deptManagerUseridList != null">
|
||||
dept_manager_userid_list,
|
||||
</if>
|
||||
<if test="record.userCount != null">
|
||||
user_count,
|
||||
</if>
|
||||
<if test="record.unactiveUserCount != null">
|
||||
unactive_user_count,
|
||||
</if>
|
||||
<if test="record.parentIds != null">
|
||||
parent_ids,
|
||||
</if>
|
||||
<if test="record.subIds != null">
|
||||
sub_ids,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.name != null">
|
||||
#{record.name},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
#{record.parentId},
|
||||
</if>
|
||||
<if test="record.departOrder != null">
|
||||
#{record.departOrder},
|
||||
</if>
|
||||
<if test="record.createDeptGroup != null">
|
||||
#{record.createDeptGroup},
|
||||
</if>
|
||||
<if test="record.autoAddUser != null">
|
||||
#{record.autoAddUser},
|
||||
</if>
|
||||
<if test="record.depHiding != null">
|
||||
#{record.depHiding},
|
||||
</if>
|
||||
<if test="record.deptPerimits != null">
|
||||
#{record.deptPerimits},
|
||||
</if>
|
||||
<if test="record.userPerimits != null">
|
||||
#{record.userPerimits},
|
||||
</if>
|
||||
<if test="record.outerDept != null">
|
||||
#{record.outerDept},
|
||||
</if>
|
||||
<if test="record.outerPermitDepts != null">
|
||||
#{record.outerPermitDepts},
|
||||
</if>
|
||||
<if test="record.outerPermitUsers != null">
|
||||
#{record.outerPermitUsers},
|
||||
</if>
|
||||
<if test="record.orgDeptOwner != null">
|
||||
#{record.orgDeptOwner},
|
||||
</if>
|
||||
<if test="record.deptManagerUseridList != null">
|
||||
#{record.deptManagerUseridList},
|
||||
</if>
|
||||
<if test="record.userCount != null">
|
||||
#{record.userCount},
|
||||
</if>
|
||||
<if test="record.unactiveUserCount != null">
|
||||
#{record.unactiveUserCount},
|
||||
</if>
|
||||
<if test="record.parentIds != null">
|
||||
#{record.parentIds},
|
||||
</if>
|
||||
<if test="record.subIds != null">
|
||||
#{record.subIds},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update sys_department_${enterpriseId}
|
||||
<set>
|
||||
<if test="record.name != null">
|
||||
name = #{record.name},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id = #{record.parentId},
|
||||
</if>
|
||||
<if test="record.departOrder != null">
|
||||
depart_order = #{record.departOrder},
|
||||
</if>
|
||||
<if test="record.createDeptGroup != null">
|
||||
create_dept_group = #{record.createDeptGroup},
|
||||
</if>
|
||||
<if test="record.autoAddUser != null">
|
||||
auto_add_user = #{record.autoAddUser},
|
||||
</if>
|
||||
<if test="record.depHiding != null">
|
||||
dep_Hiding = #{record.depHiding},
|
||||
</if>
|
||||
<if test="record.deptPerimits != null">
|
||||
dept_perimits = #{record.deptPerimits},
|
||||
</if>
|
||||
<if test="record.userPerimits != null">
|
||||
user_perimits = #{record.userPerimits},
|
||||
</if>
|
||||
<if test="record.outerDept != null">
|
||||
outer_dept = #{record.outerDept},
|
||||
</if>
|
||||
<if test="record.outerPermitDepts != null">
|
||||
outer_permit_depts = #{record.outerPermitDepts},
|
||||
</if>
|
||||
<if test="record.outerPermitUsers != null">
|
||||
outer_permit_users = #{record.outerPermitUsers},
|
||||
</if>
|
||||
<if test="record.orgDeptOwner != null">
|
||||
org_dept_owner = #{record.orgDeptOwner},
|
||||
</if>
|
||||
<if test="record.deptManagerUseridList != null">
|
||||
dept_manager_userid_list = #{record.deptManagerUseridList},
|
||||
</if>
|
||||
<if test="record.userCount != null">
|
||||
user_count = #{record.userCount},
|
||||
</if>
|
||||
<if test="record.unactiveUserCount != null">
|
||||
unactive_user_count = #{record.unactiveUserCount},
|
||||
</if>
|
||||
<if test="record.parentIds != null">
|
||||
parent_ids = #{record.parentIds},
|
||||
</if>
|
||||
<if test="record.subIds != null">
|
||||
sub_ids = #{record.subIds},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,164 @@
|
||||
<?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.SysRoleMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.SysRoleDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="role_name" jdbcType="VARCHAR" property="roleName"/>
|
||||
<result column="is_internal" jdbcType="BIT" property="isInternal"/>
|
||||
<result column="role_auth" jdbcType="VARCHAR" property="roleAuth"/>
|
||||
<result column="source" jdbcType="CHAR" property="source"/>
|
||||
<result column="position_type" jdbcType="VARCHAR" property="positionType"/>
|
||||
<result column="app_menu" jdbcType="VARCHAR" property="appMenu"/>
|
||||
<result column="syn_ding_role_id" jdbcType="BIGINT" property="synDingRoleId"/>
|
||||
<result column="priority" jdbcType="INTEGER" property="priority"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="role_enum" jdbcType="VARCHAR" property="roleEnum"/>
|
||||
<result column="create_user" jdbcType="VARCHAR" property="createUser"/>
|
||||
<result column="update_user" jdbcType="VARCHAR" property="updateUser"/>
|
||||
<result column="third_unique_id" jdbcType="VARCHAR" property="thirdUniqueId"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, role_name, is_internal, role_auth, source, position_type, app_menu, syn_ding_role_id,
|
||||
priority, create_time, update_time, role_enum, create_user, update_user, third_unique_id
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into sys_role_${enterpriseId}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.roleName != null">
|
||||
role_name,
|
||||
</if>
|
||||
<if test="record.isInternal != null">
|
||||
is_internal,
|
||||
</if>
|
||||
<if test="record.roleAuth != null">
|
||||
role_auth,
|
||||
</if>
|
||||
<if test="record.source != null">
|
||||
source,
|
||||
</if>
|
||||
<if test="record.positionType != null">
|
||||
position_type,
|
||||
</if>
|
||||
<if test="record.appMenu != null">
|
||||
app_menu,
|
||||
</if>
|
||||
<if test="record.synDingRoleId != null">
|
||||
syn_ding_role_id,
|
||||
</if>
|
||||
<if test="record.priority != null">
|
||||
priority,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="record.roleEnum != null">
|
||||
role_enum,
|
||||
</if>
|
||||
<if test="record.createUser != null">
|
||||
create_user,
|
||||
</if>
|
||||
<if test="record.updateUser != null">
|
||||
update_user,
|
||||
</if>
|
||||
<if test="record.thirdUniqueId != null">
|
||||
third_unique_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.roleName != null">
|
||||
#{record.roleName},
|
||||
</if>
|
||||
<if test="record.isInternal != null">
|
||||
#{record.isInternal},
|
||||
</if>
|
||||
<if test="record.roleAuth != null">
|
||||
#{record.roleAuth},
|
||||
</if>
|
||||
<if test="record.source != null">
|
||||
#{record.source},
|
||||
</if>
|
||||
<if test="record.positionType != null">
|
||||
#{record.positionType},
|
||||
</if>
|
||||
<if test="record.appMenu != null">
|
||||
#{record.appMenu},
|
||||
</if>
|
||||
<if test="record.synDingRoleId != null">
|
||||
#{record.synDingRoleId},
|
||||
</if>
|
||||
<if test="record.priority != null">
|
||||
#{record.priority},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
<if test="record.roleEnum != null">
|
||||
#{record.roleEnum},
|
||||
</if>
|
||||
<if test="record.createUser != null">
|
||||
#{record.createUser},
|
||||
</if>
|
||||
<if test="record.updateUser != null">
|
||||
#{record.updateUser},
|
||||
</if>
|
||||
<if test="record.thirdUniqueId != null">
|
||||
#{record.thirdUniqueId},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update sys_role_${enterpriseId}
|
||||
<set>
|
||||
<if test="record.roleName != null">
|
||||
role_name = #{record.roleName},
|
||||
</if>
|
||||
<if test="record.isInternal != null">
|
||||
is_internal = #{record.isInternal},
|
||||
</if>
|
||||
<if test="record.roleAuth != null">
|
||||
role_auth = #{record.roleAuth},
|
||||
</if>
|
||||
<if test="record.source != null">
|
||||
source = #{record.source},
|
||||
</if>
|
||||
<if test="record.positionType != null">
|
||||
position_type = #{record.positionType},
|
||||
</if>
|
||||
<if test="record.appMenu != null">
|
||||
app_menu = #{record.appMenu},
|
||||
</if>
|
||||
<if test="record.synDingRoleId != null">
|
||||
syn_ding_role_id = #{record.synDingRoleId},
|
||||
</if>
|
||||
<if test="record.priority != null">
|
||||
priority = #{record.priority},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
</if>
|
||||
<if test="record.roleEnum != null">
|
||||
role_enum = #{record.roleEnum},
|
||||
</if>
|
||||
<if test="record.createUser != null">
|
||||
create_user = #{record.createUser},
|
||||
</if>
|
||||
<if test="record.updateUser != null">
|
||||
update_user = #{record.updateUser},
|
||||
</if>
|
||||
<if test="record.thirdUniqueId != null">
|
||||
third_unique_id = #{record.thirdUniqueId},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?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.SysRoleMenuMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.SysRoleMenuDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="menu_id" jdbcType="BIGINT" property="menuId"/>
|
||||
<result column="role_id" jdbcType="BIGINT" property="roleId"/>
|
||||
<result column="platform" jdbcType="VARCHAR" property="platform"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, menu_id, role_id, platform
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into sys_role_menu_${enterpriseId}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.menuId != null">
|
||||
menu_id,
|
||||
</if>
|
||||
<if test="record.roleId != null">
|
||||
role_id,
|
||||
</if>
|
||||
<if test="record.platform != null">
|
||||
platform,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.menuId != null">
|
||||
#{record.menuId},
|
||||
</if>
|
||||
<if test="record.roleId != null">
|
||||
#{record.roleId},
|
||||
</if>
|
||||
<if test="record.platform != null">
|
||||
#{record.platform},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update sys_role_menu_${enterpriseId}
|
||||
<set>
|
||||
<if test="record.menuId != null">
|
||||
menu_id = #{record.menuId},
|
||||
</if>
|
||||
<if test="record.roleId != null">
|
||||
role_id = #{record.roleId},
|
||||
</if>
|
||||
<if test="record.platform != null">
|
||||
platform = #{record.platform},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,103 @@
|
||||
<?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.UserAuthMappingMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.UserAuthMappingDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
||||
<result column="mapping_id" jdbcType="VARCHAR" property="mappingId"/>
|
||||
<result column="type" jdbcType="VARCHAR" property="type"/>
|
||||
<result column="source" jdbcType="VARCHAR" property="source"/>
|
||||
<result column="create_id" jdbcType="VARCHAR" property="createId"/>
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
|
||||
<result column="update_id" jdbcType="VARCHAR" property="updateId"/>
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, mapping_id, type, source, create_id, create_time, update_id, update_time
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into user_auth_mapping_${enterpriseId}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="record.mappingId != null">
|
||||
mapping_id,
|
||||
</if>
|
||||
<if test="record.type != null">
|
||||
type,
|
||||
</if>
|
||||
<if test="record.source != null">
|
||||
source,
|
||||
</if>
|
||||
<if test="record.createId != null">
|
||||
create_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.updateId != null">
|
||||
update_id,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.userId != null">
|
||||
#{record.userId},
|
||||
</if>
|
||||
<if test="record.mappingId != null">
|
||||
#{record.mappingId},
|
||||
</if>
|
||||
<if test="record.type != null">
|
||||
#{record.type},
|
||||
</if>
|
||||
<if test="record.source != null">
|
||||
#{record.source},
|
||||
</if>
|
||||
<if test="record.createId != null">
|
||||
#{record.createId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateId != null">
|
||||
#{record.updateId},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update user_auth_mapping_${enterpriseId}
|
||||
<set>
|
||||
<if test="record.userId != null">
|
||||
user_id = #{record.userId},
|
||||
</if>
|
||||
<if test="record.mappingId != null">
|
||||
mapping_id = #{record.mappingId},
|
||||
</if>
|
||||
<if test="record.type != null">
|
||||
type = #{record.type},
|
||||
</if>
|
||||
<if test="record.source != null">
|
||||
source = #{record.source},
|
||||
</if>
|
||||
<if test="record.createId != null">
|
||||
create_id = #{record.createId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateId != null">
|
||||
update_id = #{record.updateId},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,83 @@
|
||||
<?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.UserRegionMappingMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.model.entity.UserRegionMappingDO">
|
||||
<id column="id" jdbcType="INTEGER" property="id"/>
|
||||
<result column="region_id" jdbcType="VARCHAR" property="regionId"/>
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
||||
<result column="create_id" jdbcType="VARCHAR" property="createId"/>
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
|
||||
<result column="update_id" jdbcType="VARCHAR" property="updateId"/>
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, region_id, user_id, create_id, create_time, update_id, update_time
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into user_region_mapping_${enterpriseId}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
region_id,
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="record.createId != null">
|
||||
create_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.updateId != null">
|
||||
update_id,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
#{record.regionId},
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
#{record.userId},
|
||||
</if>
|
||||
<if test="record.createId != null">
|
||||
#{record.createId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateId != null">
|
||||
#{record.updateId},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update user_region_mapping_${enterpriseId}
|
||||
<set>
|
||||
<if test="record.regionId != null">
|
||||
region_id = #{record.regionId},
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
user_id = #{record.userId},
|
||||
</if>
|
||||
<if test="record.createId != null">
|
||||
create_id = #{record.createId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateId != null">
|
||||
update_id = #{record.updateId},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,35 @@
|
||||
package generator;
|
||||
|
||||
import org.mybatis.generator.api.MyBatisGenerator;
|
||||
import org.mybatis.generator.config.Configuration;
|
||||
import org.mybatis.generator.config.xml.ConfigurationParser;
|
||||
import org.mybatis.generator.internal.DefaultShellCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GeneratorCodeMain {
|
||||
|
||||
public static void generator() {
|
||||
List<String> warnings = new ArrayList<String>();
|
||||
try {
|
||||
// 解析
|
||||
ConfigurationParser cp = new ConfigurationParser(warnings);
|
||||
Configuration config = cp.parseConfiguration(GeneratorCodeMain.class.getResourceAsStream("/mybatis-generator.xml"));
|
||||
// 是否覆盖
|
||||
DefaultShellCallback dsc = new DefaultShellCallback(false);
|
||||
MyBatisGenerator mg = new MyBatisGenerator(config, dsc, warnings);
|
||||
mg.generate(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
GeneratorCodeMain.generator();
|
||||
System.out.println("done!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package generator.defined;
|
||||
|
||||
import org.mybatis.generator.api.CommentGenerator;
|
||||
import org.mybatis.generator.api.IntrospectedColumn;
|
||||
import org.mybatis.generator.api.IntrospectedTable;
|
||||
import org.mybatis.generator.api.dom.java.Field;
|
||||
import org.mybatis.generator.api.dom.java.Method;
|
||||
import org.mybatis.generator.api.dom.java.TopLevelClass;
|
||||
import org.mybatis.generator.api.dom.xml.XmlElement;
|
||||
import org.mybatis.generator.internal.DefaultCommentGenerator;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: MyCommentGenerator
|
||||
* @Description:
|
||||
* @date 2021-11-18 11:09
|
||||
*/
|
||||
public class MyCommentGenerator extends DefaultCommentGenerator implements CommentGenerator {
|
||||
private String author;
|
||||
/**
|
||||
* 当前时间
|
||||
*/
|
||||
private String currentDateStr;
|
||||
public static final ThreadLocal<String> authorName = new ThreadLocal<String>();
|
||||
|
||||
public MyCommentGenerator() {
|
||||
currentDateStr = (new SimpleDateFormat("yyyy-MM-dd hh:mm")).format(new Date());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addConfigurationProperties(Properties properties) {
|
||||
author = properties.getProperty("author");
|
||||
authorName.set(author);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段注释
|
||||
* @param field
|
||||
* @param introspectedTable
|
||||
* @param introspectedColumn
|
||||
*/
|
||||
@Override
|
||||
public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
|
||||
String remarks = introspectedColumn.getRemarks();
|
||||
field.addAnnotation("@ApiModelProperty(\""+ remarks +"\")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFieldComment(Field field, IntrospectedTable introspectedTable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addModelClassComment(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
|
||||
String remarks = introspectedTable.getRemarks();
|
||||
topLevelClass.addJavaDocLine("/**");
|
||||
topLevelClass.addJavaDocLine(" * " + remarks);
|
||||
topLevelClass.addJavaDocLine(" * @author " + author);
|
||||
topLevelClass.addJavaDocLine(" * @date " + currentDateStr);
|
||||
topLevelClass.addJavaDocLine(" */");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSetterComment(Method method,
|
||||
IntrospectedTable introspectedTable,
|
||||
IntrospectedColumn introspectedColumn) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGeneralMethodComment(Method method,
|
||||
IntrospectedTable introspectedTable) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
method.addJavaDocLine("/**");
|
||||
method.addJavaDocLine(" *");
|
||||
sb.append(" * " + MethodName.getMethodComment(method.getName()));
|
||||
method.addJavaDocLine(sb.toString());
|
||||
method.addJavaDocLine(" * dateTime:" +currentDateStr);
|
||||
method.addJavaDocLine(" */");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addComment(XmlElement xmlElement) {
|
||||
|
||||
}
|
||||
|
||||
public enum MethodName{
|
||||
INSERT_SELECTIVE("insertSelective","默认插入方法,只会给有值的字段赋值\n\t * 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null"),
|
||||
SELECT_BY_PRIMARY_KEY("selectByPrimaryKey","默认查询方法,通过主键获取所有字段的值"),
|
||||
UPDATE_BY_PRIMARY_KEY_SELECTIVE("updateByPrimaryKeySelective","默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的"),
|
||||
DELETE_BY_PRIMARY_KEY("deleteByPrimaryKey","默认更新方法,根据主键物理删除"),;
|
||||
private String methodName;
|
||||
private String comment;
|
||||
|
||||
MethodName(String methodName, String comment) {
|
||||
this.methodName = methodName;
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public static String getMethodComment(String methodName){
|
||||
for (MethodName value : MethodName.values()) {
|
||||
if(value.methodName.equals(methodName)){
|
||||
return value.comment;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,517 @@
|
||||
package generator.defined;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mybatis.generator.api.CommentGenerator;
|
||||
import org.mybatis.generator.api.FullyQualifiedTable;
|
||||
import org.mybatis.generator.api.IntrospectedColumn;
|
||||
import org.mybatis.generator.api.ProgressCallback;
|
||||
import org.mybatis.generator.api.dom.java.*;
|
||||
import org.mybatis.generator.api.dom.xml.Attribute;
|
||||
import org.mybatis.generator.api.dom.xml.TextElement;
|
||||
import org.mybatis.generator.api.dom.xml.XmlElement;
|
||||
import org.mybatis.generator.codegen.AbstractJavaClientGenerator;
|
||||
import org.mybatis.generator.codegen.mybatis3.IntrospectedTableMyBatis3Impl;
|
||||
import org.mybatis.generator.codegen.mybatis3.ListUtilities;
|
||||
import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities;
|
||||
import org.mybatis.generator.codegen.mybatis3.javamapper.JavaMapperGenerator;
|
||||
import org.mybatis.generator.codegen.mybatis3.xmlmapper.XMLMapperGenerator;
|
||||
import org.mybatis.generator.codegen.mybatis3.xmlmapper.elements.AbstractXmlElementGenerator;
|
||||
import org.mybatis.generator.codegen.mybatis3.xmlmapper.elements.InsertSelectiveElementGenerator;
|
||||
import org.mybatis.generator.codegen.mybatis3.xmlmapper.elements.UpdateByPrimaryKeySelectiveElementGenerator;
|
||||
import org.mybatis.generator.config.GeneratedKey;
|
||||
import org.mybatis.generator.config.PropertyRegistry;
|
||||
import org.mybatis.generator.internal.util.JavaBeansUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
|
||||
import static org.mybatis.generator.internal.util.messages.Messages.getString;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: MyIntrospectedTableMyBatis3Impl
|
||||
* @Description:
|
||||
* @date 2021-11-18 15:38
|
||||
*/
|
||||
public class MyIntrospectedTableMyBatis3Impl extends IntrospectedTableMyBatis3Impl {
|
||||
|
||||
private String enterpriseIdTableSuffix = "_${enterpriseId}";
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedTableNameAtRuntime() {
|
||||
return getTableName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAliasedFullyQualifiedTableNameAtRuntime() {
|
||||
return getTableName();
|
||||
}
|
||||
|
||||
private String getTableName() {
|
||||
String tableName = this.getTableConfiguration().getTableName();
|
||||
String tableSuffix = tableName.substring(tableName.lastIndexOf("_") + 1);
|
||||
if(StringUtils.isNotBlank(tableSuffix) && tableSuffix.length() == 32){
|
||||
//企业库
|
||||
return tableName.substring(0, tableName.lastIndexOf("_")) + enterpriseIdTableSuffix;
|
||||
}
|
||||
//平台库
|
||||
return tableName;
|
||||
}
|
||||
|
||||
private String getTableNameFromConfigFile() {
|
||||
String tableName = getTableName();
|
||||
if(tableName.contains(enterpriseIdTableSuffix)){
|
||||
tableName = tableName.replace(enterpriseIdTableSuffix,"");
|
||||
}
|
||||
return JavaBeansUtil.getCamelCaseString(tableName,true);
|
||||
}
|
||||
|
||||
private boolean isConfigTable() {
|
||||
String tableName = this.getTableConfiguration().getTableName();
|
||||
String tableSuffix = tableName.substring(tableName.lastIndexOf("_") + 1);
|
||||
if(StringUtils.isNotBlank(tableSuffix) && tableSuffix.length() == 32){
|
||||
//企业库
|
||||
return false;
|
||||
}
|
||||
//平台库
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String calculateMyBatis3XmlMapperFileName() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getTableNameFromConfigFile());
|
||||
sb.append("Mapper.xml"); //$NON-NLS-1$
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void calculateJavaClientAttributes() {
|
||||
if (context.getJavaClientGeneratorConfiguration() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(calculateJavaClientImplementationPackage());
|
||||
sb.append('.');
|
||||
sb.append(getTableNameFromConfigFile());
|
||||
sb.append("DAOImpl"); //$NON-NLS-1$
|
||||
setDAOImplementationType(sb.toString());
|
||||
|
||||
sb.setLength(0);
|
||||
sb.append(calculateJavaClientInterfacePackage());
|
||||
sb.append('.');
|
||||
sb.append(getTableNameFromConfigFile());
|
||||
sb.append("DAO"); //$NON-NLS-1$
|
||||
setDAOInterfaceType(sb.toString());
|
||||
|
||||
sb.setLength(0);
|
||||
sb.append(calculateJavaClientInterfacePackage());
|
||||
sb.append('.');
|
||||
if (stringHasValue(tableConfiguration.getMapperName())) {
|
||||
sb.append(tableConfiguration.getMapperName());
|
||||
} else {
|
||||
if (stringHasValue(fullyQualifiedTable.getDomainObjectSubPackage())) {
|
||||
sb.append(fullyQualifiedTable.getDomainObjectSubPackage());
|
||||
sb.append('.');
|
||||
}
|
||||
sb.append(getTableNameFromConfigFile());
|
||||
sb.append("Mapper"); //$NON-NLS-1$
|
||||
}
|
||||
setMyBatis3JavaMapperType(sb.toString());
|
||||
|
||||
sb.setLength(0);
|
||||
sb.append(calculateJavaClientInterfacePackage());
|
||||
sb.append('.');
|
||||
if (stringHasValue(tableConfiguration.getSqlProviderName())) {
|
||||
sb.append(tableConfiguration.getSqlProviderName());
|
||||
} else {
|
||||
if (stringHasValue(fullyQualifiedTable.getDomainObjectSubPackage())) {
|
||||
sb.append(fullyQualifiedTable.getDomainObjectSubPackage());
|
||||
sb.append('.');
|
||||
}
|
||||
sb.append(getTableNameFromConfigFile());
|
||||
sb.append("SqlProvider"); //$NON-NLS-1$
|
||||
}
|
||||
setMyBatis3SqlProviderType(sb.toString());
|
||||
|
||||
sb.setLength(0);
|
||||
sb.append(calculateJavaClientInterfacePackage());
|
||||
sb.append('.');
|
||||
sb.append(getTableNameFromConfigFile());
|
||||
sb.append("DynamicSqlSupport"); //$NON-NLS-1$
|
||||
setMyBatisDynamicSqlSupportType(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void calculateModelAttributes() {
|
||||
String pakkage = calculateJavaModelPackage();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(pakkage);
|
||||
sb.append('.');
|
||||
sb.append(getTableNameFromConfigFile());
|
||||
sb.append("Key"); //$NON-NLS-1$
|
||||
setPrimaryKeyType(sb.toString());
|
||||
|
||||
sb.setLength(0);
|
||||
sb.append(pakkage);
|
||||
sb.append('.');
|
||||
sb.append(getTableNameFromConfigFile() + "DO");
|
||||
setBaseRecordType(sb.toString());
|
||||
|
||||
sb.setLength(0);
|
||||
sb.append(pakkage);
|
||||
sb.append('.');
|
||||
sb.append(getTableNameFromConfigFile());
|
||||
sb.append("WithBLOBs"); //$NON-NLS-1$
|
||||
setRecordWithBLOBsType(sb.toString());
|
||||
|
||||
sb.setLength(0);
|
||||
sb.append(pakkage);
|
||||
sb.append('.');
|
||||
sb.append(getTableNameFromConfigFile());
|
||||
sb.append("Example"); //$NON-NLS-1$
|
||||
setExampleType(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void calculateXmlMapperGenerator(AbstractJavaClientGenerator javaClientGenerator,
|
||||
List<String> warnings,
|
||||
ProgressCallback progressCallback) {
|
||||
xmlMapperGenerator = new MyXMLMapperGenerator();
|
||||
|
||||
initializeAbstractGenerator(xmlMapperGenerator, warnings, progressCallback);
|
||||
}
|
||||
|
||||
public class MyXMLMapperGenerator extends XMLMapperGenerator {
|
||||
|
||||
public MyXMLMapperGenerator() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected XmlElement getSqlMapElement() {
|
||||
FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
|
||||
progressCallback.startTask(getString(
|
||||
"Progress.12", table.toString())); //$NON-NLS-1$
|
||||
XmlElement answer = new XmlElement("mapper"); //$NON-NLS-1$
|
||||
String namespace = introspectedTable.getMyBatis3SqlMapNamespace();
|
||||
answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
|
||||
namespace));
|
||||
|
||||
context.getCommentGenerator().addRootComment(answer);
|
||||
addResultMapWithoutBLOBsElement(answer);
|
||||
addResultMapWithBLOBsElement(answer);
|
||||
addExampleWhereClauseElement(answer);
|
||||
addMyBatis3UpdateByExampleWhereClauseElement(answer);
|
||||
addBaseColumnListElement(answer);
|
||||
addBlobColumnListElement(answer);
|
||||
addInsertSelectiveElement(answer);
|
||||
addUpdateByPrimaryKeySelectiveElement(answer);
|
||||
return answer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addInsertSelectiveElement(XmlElement parentElement) {
|
||||
if (introspectedTable.getRules().generateInsertSelective()) {
|
||||
AbstractXmlElementGenerator elementGenerator = new MyInsertSelectiveElementGenerator();
|
||||
initializeAndExecuteGenerator(elementGenerator, parentElement);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addUpdateByPrimaryKeySelectiveElement(XmlElement parentElement) {
|
||||
if (introspectedTable.getRules().generateUpdateByPrimaryKeySelective()) {
|
||||
AbstractXmlElementGenerator elementGenerator = new MyUpdateByPrimaryKeySelectiveElementGenerator();
|
||||
initializeAndExecuteGenerator(elementGenerator, parentElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected AbstractJavaClientGenerator createJavaClientGenerator() {
|
||||
if (context.getJavaClientGeneratorConfiguration() == null) {
|
||||
return null;
|
||||
}
|
||||
AbstractJavaClientGenerator javaGenerator;
|
||||
javaGenerator = new MyJavaMapperGenerator();
|
||||
|
||||
return javaGenerator;
|
||||
}
|
||||
|
||||
public class MyJavaMapperGenerator extends JavaMapperGenerator {
|
||||
|
||||
@Override
|
||||
public List<CompilationUnit> getCompilationUnits() {
|
||||
boolean isConfig = isConfigTable();
|
||||
progressCallback.startTask(getString("Progress.17", //$NON-NLS-1$
|
||||
introspectedTable.getFullyQualifiedTable().toString()));
|
||||
CommentGenerator commentGenerator = context.getCommentGenerator();
|
||||
|
||||
FullyQualifiedJavaType type = new FullyQualifiedJavaType(
|
||||
introspectedTable.getMyBatis3JavaMapperType());
|
||||
Interface interfaze = new Interface(type);
|
||||
interfaze.setVisibility(JavaVisibility.PUBLIC);
|
||||
commentGenerator.addJavaFileComment(interfaze);
|
||||
|
||||
String rootInterface = introspectedTable
|
||||
.getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
|
||||
if (!stringHasValue(rootInterface)) {
|
||||
rootInterface = context.getJavaClientGeneratorConfiguration()
|
||||
.getProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
|
||||
}
|
||||
|
||||
if (stringHasValue(rootInterface)) {
|
||||
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(
|
||||
rootInterface);
|
||||
interfaze.addSuperInterface(fqjt);
|
||||
interfaze.addImportedType(fqjt);
|
||||
}
|
||||
if(!isConfig){
|
||||
interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Param"));
|
||||
}
|
||||
addInsertSelectiveMethod(interfaze);
|
||||
addUpdateByPrimaryKeySelectiveMethod(interfaze);
|
||||
List<Method> methods = interfaze.getMethods();
|
||||
for (Method method : methods) {
|
||||
List<Parameter> parameters = method.getParameters();
|
||||
for (Parameter parameter : parameters) {
|
||||
if(!isConfig){
|
||||
String name = parameter.getName();
|
||||
parameter.addAnnotation("@Param(\""+ name+"\")");
|
||||
}
|
||||
}
|
||||
if(!isConfig){
|
||||
Parameter enterpriseId = new Parameter(FullyQualifiedJavaType.getStringInstance(), "enterpriseId");
|
||||
enterpriseId.addAnnotation("@Param(\"enterpriseId\")");
|
||||
method.addParameter(enterpriseId);
|
||||
}
|
||||
}
|
||||
|
||||
List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
|
||||
if (context.getPlugins().clientGenerated(interfaze, null,
|
||||
introspectedTable)) {
|
||||
answer.add(interfaze);
|
||||
}
|
||||
|
||||
List<CompilationUnit> extraCompilationUnits = getExtraCompilationUnits();
|
||||
if (extraCompilationUnits != null) {
|
||||
answer.addAll(extraCompilationUnits);
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
}
|
||||
|
||||
public class MyInsertSelectiveElementGenerator extends InsertSelectiveElementGenerator{
|
||||
|
||||
public MyInsertSelectiveElementGenerator() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addElements(XmlElement parentElement) {
|
||||
boolean isConfig = isConfigTable();
|
||||
XmlElement answer = new XmlElement("insert"); //$NON-NLS-1$
|
||||
|
||||
answer.addAttribute(new Attribute(
|
||||
"id", introspectedTable.getInsertSelectiveStatementId())); //$NON-NLS-1$
|
||||
|
||||
/*
|
||||
FullyQualifiedJavaType parameterType = introspectedTable.getRules()
|
||||
.calculateAllFieldsClass();
|
||||
answer.addAttribute(new Attribute("parameterType", //$NON-NLS-1$
|
||||
parameterType.getFullyQualifiedName()));*/
|
||||
|
||||
context.getCommentGenerator().addComment(answer);
|
||||
|
||||
GeneratedKey gk = introspectedTable.getGeneratedKey();
|
||||
if (gk != null) {
|
||||
IntrospectedColumn introspectedColumn = introspectedTable
|
||||
.getColumn(gk.getColumn());
|
||||
/*if (introspectedColumn != null) {
|
||||
if (gk.isJdbcStandard()) {
|
||||
answer.addAttribute(new Attribute("useGeneratedKeys", "true")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
answer.addAttribute(new Attribute("keyProperty", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
|
||||
answer.addAttribute(new Attribute("keyColumn", introspectedColumn.getActualColumnName())); //$NON-NLS-1$
|
||||
} else {
|
||||
answer.addElement(getSelectKey(introspectedColumn, gk));
|
||||
}
|
||||
}*/
|
||||
if(introspectedColumn != null){
|
||||
answer.addAttribute(new Attribute("useGeneratedKeys", "true")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
answer.addAttribute(new Attribute("keyProperty", "record."+introspectedColumn.getJavaProperty())); //$NON-NLS-1$
|
||||
answer.addAttribute(new Attribute("keyColumn", introspectedColumn.getActualColumnName())); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("insert into "); //$NON-NLS-1$
|
||||
sb.append(introspectedTable.getFullyQualifiedTableNameAtRuntime());
|
||||
answer.addElement(new TextElement(sb.toString()));
|
||||
|
||||
XmlElement insertTrimElement = new XmlElement("trim"); //$NON-NLS-1$
|
||||
insertTrimElement.addAttribute(new Attribute("prefix", "(")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
insertTrimElement.addAttribute(new Attribute("suffix", ")")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
insertTrimElement.addAttribute(new Attribute("suffixOverrides", ",")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
answer.addElement(insertTrimElement);
|
||||
|
||||
XmlElement valuesTrimElement = new XmlElement("trim"); //$NON-NLS-1$
|
||||
valuesTrimElement.addAttribute(new Attribute("prefix", "values (")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
valuesTrimElement.addAttribute(new Attribute("suffix", ")")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
valuesTrimElement.addAttribute(new Attribute("suffixOverrides", ",")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
answer.addElement(valuesTrimElement);
|
||||
|
||||
for (IntrospectedColumn introspectedColumn : ListUtilities.removeIdentityAndGeneratedAlwaysColumns(introspectedTable.getAllColumns())) {
|
||||
|
||||
if (introspectedColumn.isSequenceColumn() || introspectedColumn.getFullyQualifiedJavaType().isPrimitive()) {
|
||||
sb.setLength(0);
|
||||
sb.append(MyBatis3FormattingUtilities
|
||||
.getEscapedColumnName(introspectedColumn));
|
||||
sb.append(',');
|
||||
insertTrimElement.addElement(new TextElement(sb.toString()));
|
||||
|
||||
sb.setLength(0);
|
||||
sb.append(MyBatis3FormattingUtilities
|
||||
.getParameterClause(introspectedColumn));
|
||||
sb.append(',');
|
||||
valuesTrimElement.addElement(new TextElement(sb.toString()));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
sb.setLength(0);
|
||||
if(!isConfig){
|
||||
sb.append("record.");
|
||||
}
|
||||
sb.append(introspectedColumn.getJavaProperty());
|
||||
sb.append(" != null"); //$NON-NLS-1$
|
||||
XmlElement insertNotNullElement = new XmlElement("if"); //$NON-NLS-1$
|
||||
insertNotNullElement.addAttribute(new Attribute(
|
||||
"test", sb.toString())); //$NON-NLS-1$
|
||||
|
||||
sb.setLength(0);
|
||||
sb.append(MyBatis3FormattingUtilities
|
||||
.getEscapedColumnName(introspectedColumn));
|
||||
sb.append(',');
|
||||
insertNotNullElement.addElement(new TextElement(sb.toString()));
|
||||
insertTrimElement.addElement(insertNotNullElement);
|
||||
|
||||
sb.setLength(0);
|
||||
if(!isConfig){
|
||||
sb.append("record.");
|
||||
}
|
||||
sb.append(introspectedColumn.getJavaProperty());
|
||||
sb.append(" != null"); //$NON-NLS-1$
|
||||
XmlElement valuesNotNullElement = new XmlElement("if"); //$NON-NLS-1$
|
||||
valuesNotNullElement.addAttribute(new Attribute(
|
||||
"test", sb.toString())); //$NON-NLS-1$
|
||||
|
||||
sb.setLength(0);
|
||||
if(isConfig){
|
||||
sb.append("#{"+introspectedColumn.getJavaProperty() + "}");
|
||||
}else{
|
||||
sb.append("#{record."+introspectedColumn.getJavaProperty() + "}");
|
||||
}
|
||||
sb.append(',');
|
||||
valuesNotNullElement.addElement(new TextElement(sb.toString()));
|
||||
valuesTrimElement.addElement(valuesNotNullElement);
|
||||
}
|
||||
|
||||
if (context.getPlugins().sqlMapInsertSelectiveElementGenerated(answer, introspectedTable)) {
|
||||
parentElement.addElement(answer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MyUpdateByPrimaryKeySelectiveElementGenerator extends UpdateByPrimaryKeySelectiveElementGenerator{
|
||||
public MyUpdateByPrimaryKeySelectiveElementGenerator() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addElements(XmlElement parentElement) {
|
||||
boolean isConfig = isConfigTable();
|
||||
XmlElement answer = new XmlElement("update"); //$NON-NLS-1$
|
||||
|
||||
answer.addAttribute(new Attribute(
|
||||
"id", introspectedTable.getUpdateByPrimaryKeySelectiveStatementId())); //$NON-NLS-1$
|
||||
|
||||
String parameterType;
|
||||
|
||||
if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
|
||||
parameterType = introspectedTable.getRecordWithBLOBsType();
|
||||
} else {
|
||||
parameterType = introspectedTable.getBaseRecordType();
|
||||
}
|
||||
|
||||
/*answer.addAttribute(new Attribute("parameterType", //$NON-NLS-1$
|
||||
parameterType));*/
|
||||
|
||||
context.getCommentGenerator().addComment(answer);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("update "); //$NON-NLS-1$
|
||||
sb.append(introspectedTable.getFullyQualifiedTableNameAtRuntime());
|
||||
answer.addElement(new TextElement(sb.toString()));
|
||||
|
||||
XmlElement dynamicElement = new XmlElement("set"); //$NON-NLS-1$
|
||||
answer.addElement(dynamicElement);
|
||||
|
||||
for (IntrospectedColumn introspectedColumn : ListUtilities.removeGeneratedAlwaysColumns(introspectedTable.getNonPrimaryKeyColumns())) {
|
||||
sb.setLength(0);
|
||||
if(!isConfig){
|
||||
sb.append("record.");
|
||||
}
|
||||
sb.append(introspectedColumn.getJavaProperty());
|
||||
sb.append(" != null"); //$NON-NLS-1$
|
||||
XmlElement isNotNullElement = new XmlElement("if"); //$NON-NLS-1$
|
||||
isNotNullElement.addAttribute(new Attribute("test", sb.toString())); //$NON-NLS-1$
|
||||
dynamicElement.addElement(isNotNullElement);
|
||||
|
||||
sb.setLength(0);
|
||||
sb.append(MyBatis3FormattingUtilities
|
||||
.getEscapedColumnName(introspectedColumn));
|
||||
sb.append(" = ");
|
||||
if(!isConfig){
|
||||
sb.append("#{record."+introspectedColumn.getJavaProperty() + "}");
|
||||
}else{
|
||||
sb.append("#{"+introspectedColumn.getJavaProperty() + "}");
|
||||
}
|
||||
sb.append(',');
|
||||
|
||||
isNotNullElement.addElement(new TextElement(sb.toString()));
|
||||
}
|
||||
|
||||
boolean and = false;
|
||||
for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
|
||||
sb.setLength(0);
|
||||
if (and) {
|
||||
sb.append(" and "); //$NON-NLS-1$
|
||||
} else {
|
||||
sb.append("where "); //$NON-NLS-1$
|
||||
and = true;
|
||||
}
|
||||
|
||||
sb.append(MyBatis3FormattingUtilities
|
||||
.getEscapedColumnName(introspectedColumn));
|
||||
sb.append(" = ");
|
||||
if(isConfig){
|
||||
sb.append("#{"+introspectedColumn.getJavaProperty() + "}");
|
||||
}else{
|
||||
sb.append("#{record."+introspectedColumn.getJavaProperty() + "}");
|
||||
}
|
||||
answer.addElement(new TextElement(sb.toString()));
|
||||
}
|
||||
|
||||
if (context.getPlugins()
|
||||
.sqlMapUpdateByPrimaryKeySelectiveElementGenerated(answer,
|
||||
introspectedTable)) {
|
||||
parentElement.addElement(answer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
package generator.defined;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mybatis.generator.api.IntrospectedColumn;
|
||||
import org.mybatis.generator.api.IntrospectedTable;
|
||||
import org.mybatis.generator.api.PluginAdapter;
|
||||
import org.mybatis.generator.api.dom.java.*;
|
||||
import org.mybatis.generator.api.dom.xml.Document;
|
||||
import org.mybatis.generator.api.dom.xml.XmlElement;
|
||||
import org.mybatis.generator.codegen.mybatis3.xmlmapper.elements.AbstractXmlElementGenerator;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: MyPluginAdapter
|
||||
* @Description: 自定义生成器
|
||||
* @date 2021-11-18 14:11
|
||||
*/
|
||||
public class MyPluginAdapter extends PluginAdapter {
|
||||
|
||||
@Override
|
||||
public boolean validate(List<String> list) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* model新增import
|
||||
* @param topLevelClass
|
||||
* @param introspectedTable
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
|
||||
topLevelClass.addImportedType("java.io.Serializable");
|
||||
topLevelClass.addImportedType("lombok.Data");
|
||||
topLevelClass.addImportedType("lombok.Builder");
|
||||
topLevelClass.addImportedType("lombok.NoArgsConstructor");
|
||||
topLevelClass.addImportedType("lombok.AllArgsConstructor");
|
||||
topLevelClass.addImportedType("io.swagger.annotations.ApiModelProperty");
|
||||
topLevelClass.addAnnotation("@Data");
|
||||
topLevelClass.addAnnotation("@Builder");
|
||||
topLevelClass.addAnnotation("@NoArgsConstructor");
|
||||
topLevelClass.addAnnotation("@AllArgsConstructor");
|
||||
topLevelClass.addSuperInterface(new FullyQualifiedJavaType("java.io.Serializable"));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* model不生成set方法
|
||||
* @param method
|
||||
* @param topLevelClass
|
||||
* @param introspectedColumn
|
||||
* @param introspectedTable
|
||||
* @param modelClassType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean modelSetterMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedColumn introspectedColumn, IntrospectedTable introspectedTable, ModelClassType modelClassType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* model不生成get方法
|
||||
* @param method
|
||||
* @param topLevelClass
|
||||
* @param introspectedColumn
|
||||
* @param introspectedTable
|
||||
* @param modelClassType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean modelGetterMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedColumn introspectedColumn, IntrospectedTable introspectedTable, ModelClassType modelClassType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* sql文件 新增动态sql
|
||||
* @param document
|
||||
* @param introspectedTable
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean sqlMapDocumentGenerated(Document document, IntrospectedTable introspectedTable) {
|
||||
AbstractXmlElementGenerator elementGenerator = new CustomAbstractXmlElementGenerator();
|
||||
elementGenerator.setContext(context);
|
||||
elementGenerator.setIntrospectedTable(introspectedTable);
|
||||
elementGenerator.addElements(document.getRootElement());
|
||||
return super.sqlMapDocumentGenerated(document, introspectedTable);
|
||||
}
|
||||
|
||||
/**
|
||||
* mapper文件备注
|
||||
* @param interfaze
|
||||
* @param topLevelClass
|
||||
* @param introspectedTable
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
|
||||
interfaze.addJavaDocLine("/**");
|
||||
interfaze.addJavaDocLine(" * @author zhangchenbiao" );
|
||||
interfaze.addJavaDocLine(" * @date " + (new SimpleDateFormat("yyyy-MM-dd hh:mm")).format(new Date()));
|
||||
interfaze.addJavaDocLine(" */");
|
||||
return super.clientGenerated(interfaze, topLevelClass, introspectedTable);
|
||||
}
|
||||
|
||||
/**
|
||||
* sql新增动态sql
|
||||
*/
|
||||
public class CustomAbstractXmlElementGenerator extends AbstractXmlElementGenerator {
|
||||
|
||||
@Override
|
||||
public void addElements(XmlElement parentElement) {
|
||||
/*String tableName =getTableName();
|
||||
// 增加base_query
|
||||
XmlElement sql = new XmlElement("sql");
|
||||
sql.addAttribute(new Attribute("id", "dynamicQuery"));
|
||||
//在这里添加where条件
|
||||
XmlElement selectTrimElement = new XmlElement("trim"); //设置trim标签
|
||||
selectTrimElement.addAttribute(new Attribute("prefix", "WHERE"));
|
||||
selectTrimElement.addAttribute(new Attribute("prefixOverrides", "AND | OR")); //添加where和and
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(IntrospectedColumn introspectedColumn : introspectedTable.getAllColumns()) {
|
||||
XmlElement selectNotNullElement = new XmlElement("if"); //$NON-NLS-1$
|
||||
sb.setLength(0);
|
||||
sb.append("null != ");
|
||||
sb.append(introspectedColumn.getJavaProperty());
|
||||
selectNotNullElement.addAttribute(new Attribute("test", sb.toString()));
|
||||
sb.setLength(0);
|
||||
// 添加and
|
||||
sb.append(" and ");
|
||||
// 添加别名t
|
||||
sb.append("t.");
|
||||
sb.append(MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn));
|
||||
// 添加等号
|
||||
sb.append(" = ");
|
||||
sb.append("#{"+ introspectedColumn.getJavaProperty() +"}");
|
||||
selectNotNullElement.addElement(new TextElement(sb.toString()));
|
||||
selectTrimElement.addElement(selectNotNullElement);
|
||||
}
|
||||
|
||||
//sql.addElement(selectTrimElement);
|
||||
parentElement.addElement(sql);
|
||||
|
||||
// 公用include
|
||||
XmlElement include = new XmlElement("include");
|
||||
include.addAttribute(new Attribute("refid", "dynamicQuery"));*/
|
||||
|
||||
}
|
||||
|
||||
private String getTableName() {
|
||||
String tableName = introspectedTable.getTableConfiguration().getTableName();
|
||||
String tableSuffix = tableName.substring(tableName.lastIndexOf("_") + 1);
|
||||
if(StringUtils.isNotBlank(tableSuffix) && tableSuffix.length() == 32){
|
||||
//企业库
|
||||
return tableName.substring(0, tableName.lastIndexOf("_")) + "_${enterpriseId}";
|
||||
}
|
||||
//平台库
|
||||
return tableName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 对数据库中的tinyint->byte 处理为 tinyint->integer
|
||||
* @param field
|
||||
* @param topLevelClass
|
||||
* @param introspectedColumn
|
||||
* @param introspectedTable
|
||||
* @param modelClassType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean modelFieldGenerated(Field field,
|
||||
TopLevelClass topLevelClass, IntrospectedColumn introspectedColumn,
|
||||
IntrospectedTable introspectedTable,
|
||||
ModelClassType modelClassType){
|
||||
int jdbcType = introspectedColumn.getJdbcType();
|
||||
if(jdbcType == Types.TINYINT){
|
||||
field.setType(new FullyQualifiedJavaType(Integer.class.getName()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
jdbc.driver = com.mysql.cj.jdbc.Driver
|
||||
jdbc.url = jdbc:mysql://dingpushcoolcollege.mysql.rds.aliyuncs.com:3306/coolcollege_intelligent_base?useSSL=false&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true
|
||||
jdbc.user= coolstore
|
||||
jdbc.password = CSCErYcXniNYm7bT
|
||||
|
||||
table.name = sys_role_menu_e88b6a2bc1334164b54977a4dbfe5d9d
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE generatorConfiguration
|
||||
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
|
||||
<generatorConfiguration>
|
||||
<properties resource="mybatis-generator.properties" />
|
||||
<context id="Mysql" targetRuntime="generator.defined.MyIntrospectedTableMyBatis3Impl" defaultModelType="flat">
|
||||
<plugin type="generator.defined.MyPluginAdapter" >
|
||||
<property name="hasLombok" value="true"/>
|
||||
<property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>
|
||||
</plugin>
|
||||
<commentGenerator type="generator.defined.MyCommentGenerator">
|
||||
<property name="suppressAllComments" value="true" />
|
||||
<property name="author" value="zhangchenbiao"/>
|
||||
</commentGenerator>
|
||||
|
||||
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="${jdbc.url}" userId="${jdbc.user}" password="${jdbc.password}">
|
||||
<property name="nullCatalogMeansCurrent" value="true" />
|
||||
</jdbcConnection>
|
||||
|
||||
<!-- targetProject:生成PO类的位置 -->
|
||||
<javaModelGenerator targetPackage="com.cool.store.model.entity" targetProject="coolstore-partner-model/src/main/java">
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
</javaModelGenerator>
|
||||
|
||||
<!-- targetProject:mapperXML映射文件生成的位置 -->
|
||||
<sqlMapGenerator targetPackage="mapper" targetProject="coolstore-partner-dao/src/main/resources" />
|
||||
|
||||
<!-- targetPackage:mapper接口生成的位置 -->
|
||||
<javaClientGenerator targetPackage="com.cool.store.mapper" targetProject="coolstore-partner-dao/src/main/java" type="XMLMAPPER" />
|
||||
|
||||
<table tableName="${table.name}" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
|
||||
enableSelectByExample="false" selectByExampleQueryId="false">
|
||||
<generatedKey column="id" sqlStatement="Mysql" identity="true" type=""/>
|
||||
</table>
|
||||
</context>
|
||||
</generatorConfiguration>
|
||||
Reference in New Issue
Block a user