|
@@ -0,0 +1,303 @@
|
|
|
+<?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.huaxu.dao.UserMapper">
|
|
|
+ <!-- 结果集 -->
|
|
|
+ <resultMap type="com.huaxu.entity.User" id="UserMap">
|
|
|
+ <result property="id" column="ID" jdbcType="INTEGER"/>
|
|
|
+ <result property="tenantId" column="TENANT_ID" jdbcType="VARCHAR"/>
|
|
|
+ <result property="username" column="USERNAME" jdbcType="VARCHAR"/>
|
|
|
+ <result property="phone" column="PHONE" jdbcType="VARCHAR"/>
|
|
|
+ <result property="companyOrgId" column="COMPANY_ORG_ID" jdbcType="INTEGER"/>
|
|
|
+ <result property="deptOrgId" column="DEPT_ORG_ID" jdbcType="INTEGER"/>
|
|
|
+ <result property="photo" column="PHOTO" jdbcType="VARCHAR"/>
|
|
|
+ <result property="userType" column="USER_TYPE" jdbcType="VARCHAR"/>
|
|
|
+ <result property="enableState" column="ENABLE_STATE" jdbcType="VARCHAR"/>
|
|
|
+ <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
|
|
|
+ <result property="email" column="EMAIL" jdbcType="VARCHAR"/>
|
|
|
+ <result property="status" column="STATUS" jdbcType="INTEGER"/>
|
|
|
+ <result property="dateCreate" column="DATE_CREATE" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="createBy" column="CREATE_BY" jdbcType="VARCHAR"/>
|
|
|
+ <result property="dateUpdate" column="DATE_UPDATE" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="updateBy" column="UPDATE_BY" jdbcType="VARCHAR"/>
|
|
|
+ </resultMap>
|
|
|
+ <resultMap id="loginInfo" type="com.huaxu.dto.UserDto">
|
|
|
+ <association property="user" javaType="com.huaxu.entity.User">
|
|
|
+ <result property="id" column="ID" jdbcType="INTEGER"/>
|
|
|
+ <result property="tenantId" column="TENANT_ID" jdbcType="VARCHAR"/>
|
|
|
+ <result property="username" column="USERNAME" jdbcType="VARCHAR"/>
|
|
|
+ <result property="phone" column="PHONE" jdbcType="VARCHAR"/>
|
|
|
+ <result property="companyOrgId" column="COMPANY_ORG_ID" jdbcType="INTEGER"/>
|
|
|
+ <result property="deptOrgId" column="DEPT_ORG_ID" jdbcType="INTEGER"/>
|
|
|
+ <result property="photo" column="PHOTO" jdbcType="VARCHAR"/>
|
|
|
+ <result property="userType" column="USER_TYPE" jdbcType="VARCHAR"/>
|
|
|
+ <result property="enableState" column="ENABLE_STATE" jdbcType="VARCHAR"/>
|
|
|
+ <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
|
|
|
+ <result property="email" column="EMAIL" jdbcType="VARCHAR"/>
|
|
|
+ <result property="status" column="STATUS" jdbcType="INTEGER"/>
|
|
|
+ <result property="dateCreate" column="DATE_CREATE" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="createBy" column="CREATE_BY" jdbcType="VARCHAR"/>
|
|
|
+ <result property="dateUpdate" column="DATE_UPDATE" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="updateBy" column="UPDATE_BY" jdbcType="VARCHAR"/>
|
|
|
+ </association>
|
|
|
+ <association property="tenant" javaType="com.huaxu.entity.Tenant">
|
|
|
+ <result property="id" column="ID" jdbcType="INTEGER"/>
|
|
|
+ <result property="tenantName" column="TENANT_NAME" jdbcType="VARCHAR"/>
|
|
|
+ <result property="code" column="CODE" jdbcType="VARCHAR"/>
|
|
|
+ <result property="logo" column="LOGO" jdbcType="VARCHAR"/>
|
|
|
+ <result property="webUrl" column="WEB_URL" jdbcType="VARCHAR"/>
|
|
|
+ <result property="startDate" column="START_DATE" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="endDate" column="END_DATE" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="tenantState" column="TENANT_STATE" jdbcType="INTEGER"/>
|
|
|
+ <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
|
|
|
+ <result property="status" column="STATUS" jdbcType="INTEGER"/>
|
|
|
+ <result property="dateCreate" column="DATE_CREATE" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="createBy" column="CREATE_BY" jdbcType="VARCHAR"/>
|
|
|
+ <result property="dateUpdate" column="DATE_UPDATE" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="updateBy" column="UPDATE_BY" jdbcType="VARCHAR"/>
|
|
|
+ </association>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 基本字段 -->
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ ID, TENANT_ID, USERNAME, PHONE, COMPANY_ORG_ID, DEPT_ORG_ID, PHOTO, USER_TYPE, ENABLE_STATE, REMARK, EMAIL, STATUS, DATE_CREATE, CREATE_BY, DATE_UPDATE, UPDATE_BY </sql>
|
|
|
+
|
|
|
+ <!-- 查询单个 -->
|
|
|
+ <select id="selectById" resultMap="UserMap">
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from uims_user
|
|
|
+ where ID = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <!-- 查询全部 -->
|
|
|
+ <select id="selectAll" resultMap="UserMap">
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from uims_user
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--通过实体作为筛选条件查询-->
|
|
|
+ <select id="selectList" resultMap="UserMap">
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from uims_user
|
|
|
+ <where>
|
|
|
+ <if test="id != null">
|
|
|
+ and ID = #{id}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ and TENANT_ID = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="username != null and username != ''">
|
|
|
+ and USERNAME = #{username}
|
|
|
+ </if>
|
|
|
+ <if test="phone != null and phone != ''">
|
|
|
+ and PHONE = #{phone}
|
|
|
+ </if>
|
|
|
+ <if test="companyOrgId != null">
|
|
|
+ and COMPANY_ORG_ID = #{companyOrgId}
|
|
|
+ </if>
|
|
|
+ <if test="deptOrgId != null">
|
|
|
+ and DEPT_ORG_ID = #{deptOrgId}
|
|
|
+ </if>
|
|
|
+ <if test="photo != null and photo != ''">
|
|
|
+ and PHOTO = #{photo}
|
|
|
+ </if>
|
|
|
+ <if test="userType != null and userType != ''">
|
|
|
+ and USER_TYPE = #{userType}
|
|
|
+ </if>
|
|
|
+ <if test="enableState != null and enableState != ''">
|
|
|
+ and ENABLE_STATE = #{enableState}
|
|
|
+ </if>
|
|
|
+ <if test="remark != null">
|
|
|
+ and REMARK = #{remark}
|
|
|
+ </if>
|
|
|
+ <if test="email != null and email != ''">
|
|
|
+ and EMAIL = #{email}
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ and STATUS = #{status}
|
|
|
+ </if>
|
|
|
+ <if test="dateCreate != null">
|
|
|
+ and DATE_CREATE = #{dateCreate}
|
|
|
+ </if>
|
|
|
+ <if test="createBy != null and createBy != ''">
|
|
|
+ and CREATE_BY = #{createBy}
|
|
|
+ </if>
|
|
|
+ <if test="dateUpdate != null">
|
|
|
+ and DATE_UPDATE = #{dateUpdate}
|
|
|
+ </if>
|
|
|
+ <if test="updateBy != null and updateBy != ''">
|
|
|
+ and UPDATE_BY = #{updateBy}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 新增所有列 -->
|
|
|
+ <insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
|
+ insert into uims_user(ID, TENANT_ID, USERNAME, PHONE, COMPANY_ORG_ID, DEPT_ORG_ID, PHOTO, USER_TYPE, ENABLE_STATE, REMARK, EMAIL, STATUS, DATE_CREATE, CREATE_BY, DATE_UPDATE, UPDATE_BY)
|
|
|
+ values ( #{id}, #{tenantId}, #{username}, #{phone}, #{companyOrgId}, #{deptOrgId}, #{photo}, #{userType}, #{enableState}, #{remark}, #{email}, #{status}, #{dateCreate}, #{createBy}, #{dateUpdate}, #{updateBy})
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!-- 批量新增 -->
|
|
|
+ <insert id="batchInsert">
|
|
|
+ insert into uims_user(ID, TENANT_ID, USERNAME, PHONE, COMPANY_ORG_ID, DEPT_ORG_ID, PHOTO, USER_TYPE,
|
|
|
+ ENABLE_STATE, REMARK, EMAIL, STATUS, DATE_CREATE, CREATE_BY, DATE_UPDATE, UPDATE_BY)
|
|
|
+ values
|
|
|
+ <foreach collection="users" item="item" index="index" separator=",">
|
|
|
+ (
|
|
|
+ #{item.id}, #{item.tenantId}, #{item.username}, #{item.phone}, #{item.companyOrgId}, #{item.deptOrgId},
|
|
|
+ #{item.photo}, #{item.userType}, #{item.enableState}, #{item.remark}, #{item.email}, #{item.status},
|
|
|
+ #{item.dateCreate}, #{item.createBy}, #{item.dateUpdate}, #{item.updateBy} )
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!-- 通过主键修改数据 -->
|
|
|
+ <update id="update">
|
|
|
+ update uims.uims_user
|
|
|
+ <set>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ TENANT_ID = #{tenantId},
|
|
|
+ </if>
|
|
|
+ <if test="username != null and username != ''">
|
|
|
+ USERNAME = #{username},
|
|
|
+ </if>
|
|
|
+ <if test="phone != null and phone != ''">
|
|
|
+ PHONE = #{phone},
|
|
|
+ </if>
|
|
|
+ <if test="companyOrgId != null">
|
|
|
+ COMPANY_ORG_ID = #{companyOrgId},
|
|
|
+ </if>
|
|
|
+ <if test="deptOrgId != null">
|
|
|
+ DEPT_ORG_ID = #{deptOrgId},
|
|
|
+ </if>
|
|
|
+ <if test="photo != null and photo != ''">
|
|
|
+ PHOTO = #{photo},
|
|
|
+ </if>
|
|
|
+ <if test="userType != null and userType != ''">
|
|
|
+ USER_TYPE = #{userType},
|
|
|
+ </if>
|
|
|
+ <if test="enableState != null and enableState != ''">
|
|
|
+ ENABLE_STATE = #{enableState},
|
|
|
+ </if>
|
|
|
+ <if test="remark != null">
|
|
|
+ REMARK = #{remark},
|
|
|
+ </if>
|
|
|
+ <if test="email != null and email != ''">
|
|
|
+ EMAIL = #{email},
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ STATUS = #{status},
|
|
|
+ </if>
|
|
|
+ <if test="dateCreate != null">
|
|
|
+ DATE_CREATE = #{dateCreate},
|
|
|
+ </if>
|
|
|
+ <if test="createBy != null and createBy != ''">
|
|
|
+ CREATE_BY = #{createBy},
|
|
|
+ </if>
|
|
|
+ <if test="dateUpdate != null">
|
|
|
+ DATE_UPDATE = #{dateUpdate},
|
|
|
+ </if>
|
|
|
+ <if test="updateBy != null and updateBy != ''">
|
|
|
+ UPDATE_BY = #{updateBy},
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ where ID = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!--通过主键删除-->
|
|
|
+ <delete id="deleteById">
|
|
|
+ delete from uims_user where ID = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 总数 -->
|
|
|
+ <select id="count" resultType="int">
|
|
|
+ select count(*) from uims_user
|
|
|
+ </select>
|
|
|
+ <select id="selectPage" resultMap="UserMap">
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from uims_user
|
|
|
+ <where>
|
|
|
+ <if test="user.id != null">
|
|
|
+ and ID = #{user.id}
|
|
|
+ </if>
|
|
|
+ <if test="user.tenantId != null and user.tenantId != ''">
|
|
|
+ and TENANT_ID = #{user.tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="user.username != null and user.username != ''">
|
|
|
+ and USERNAME = #{user.username}
|
|
|
+ </if>
|
|
|
+ <if test="user.phone != null and user.phone != ''">
|
|
|
+ and PHONE = #{user.phone}
|
|
|
+ </if>
|
|
|
+ <if test="user.companyOrgId != null">
|
|
|
+ and COMPANY_ORG_ID = #{user.companyOrgId}
|
|
|
+ </if>
|
|
|
+ <if test="user.deptOrgId != null">
|
|
|
+ and DEPT_ORG_ID = #{user.deptOrgId}
|
|
|
+ </if>
|
|
|
+ <if test="user.photo != null and user.photo != ''">
|
|
|
+ and PHOTO = #{user.photo}
|
|
|
+ </if>
|
|
|
+ <if test="user.userType != null and user.userType != ''">
|
|
|
+ and USER_TYPE = #{user.userType}
|
|
|
+ </if>
|
|
|
+ <if test="user.enableState != null and user.enableState != ''">
|
|
|
+ and ENABLE_STATE = #{user.enableState}
|
|
|
+ </if>
|
|
|
+ <if test="user.remark != null">
|
|
|
+ and REMARK = #{user.remark}
|
|
|
+ </if>
|
|
|
+ <if test="user.email != null and user.email != ''">
|
|
|
+ and EMAIL = #{user.email}
|
|
|
+ </if>
|
|
|
+ <if test="user.status != null">
|
|
|
+ and STATUS = #{user.status}
|
|
|
+ </if>
|
|
|
+ <if test="user.dateCreate != null">
|
|
|
+ and DATE_CREATE = #{user.dateCreate}
|
|
|
+ </if>
|
|
|
+ <if test="user.createBy != null and user.createBy != ''">
|
|
|
+ and CREATE_BY = #{user.createBy}
|
|
|
+ </if>
|
|
|
+ <if test="user.dateUpdate != null">
|
|
|
+ and DATE_UPDATE = #{user.dateUpdate}
|
|
|
+ </if>
|
|
|
+ <if test="user.updateBy != null and user.updateBy != ''">
|
|
|
+ and UPDATE_BY = #{user.updateBy}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+ <select id="findPermission" resultType="com.huaxu.model.Permission">
|
|
|
+ select * from uims_user a join uims_user_role b on a.id=b.USER_ID
|
|
|
+ join uims_role c on b.ROLE_ID= c.ID
|
|
|
+ join uims_role_menu d on c.ID=d.ROLE_ID
|
|
|
+ join uims_menu e on e.id=d.MENU_ID
|
|
|
+ </select>
|
|
|
+ <select id="findOrgRole" resultType="com.huaxu.model.ProgramItem">
|
|
|
+ select d.ORG_ID orgId,a.TENANT_ID code from uims_user a join uims_user_role b on a.id=b.USER_ID
|
|
|
+ join uims_role c on b.ROLE_ID= c.ID
|
|
|
+ join uims_role_org d on c.ID=d.ROLE_ID
|
|
|
+ </select>
|
|
|
+ <select id="findOrgs" resultType="com.huaxu.entity.Org">
|
|
|
+ select ID, TENANT_ID, ORG_TYPE,
|
|
|
+ PARENT_ORG_ID, ORG_AREA_ID, ORG_NAME, ORG_STATE, REMARK, ORG_LEADER_NAME,
|
|
|
+ ORG_LEADER_PHONE, ORG_LEADER_EMAIL,
|
|
|
+ ORG_LEADER_SEX, STATUS, DATE_CREATE,
|
|
|
+ CREATE_BY, DATE_UPDATE, UPDATE_BY
|
|
|
+ from uims_org
|
|
|
+ <where>
|
|
|
+ and ORG_TYPE=#{orgType}
|
|
|
+ and TENANT_ID=#{tenantId}
|
|
|
+ </where>
|
|
|
+
|
|
|
+ </select>
|
|
|
+ <select id="findLoginInfo" resultMap="loginInfo">
|
|
|
+ select a.PHONE,b.TENANT_NAME,b.CODE,b.WEB_URL from uims_user a left join uims_tenant b on
|
|
|
+ a.TENANT_ID=b.ID
|
|
|
+ where a.PHONE=#{loginName}
|
|
|
+ </select>
|
|
|
+
|
|
|
+</mapper>
|