Browse Source

登录,登出,验证相关功能

hym 4 years ago
parent
commit
8d26e841f1

+ 155 - 0
user_auth/src/main/resources/mapper/LoginLogMapper.xml

@@ -0,0 +1,155 @@
+<?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.LoginLogMapper">
+    <!-- 结果集 -->
+    <resultMap type="com.huaxu.entity.LoginLog" id="LoginLogMap">
+        <result property="id" column="id" jdbcType="INTEGER"/>
+        <result property="name" column="name" jdbcType="VARCHAR"/>
+        <result property="phone" column="phone" jdbcType="VARCHAR"/>
+        <result property="companyId" column="company_id" jdbcType="INTEGER"/>
+        <result property="departmentId" column="department_id" jdbcType="INTEGER"/>
+        <result property="type" column="type" jdbcType="VARCHAR"/>
+        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+        <result property="loginIp" column="login_ip" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <!-- 基本字段 -->
+    <sql id="Base_Column_List">
+        id, name, phone, company_id, department_id, type, create_time, login_ip    </sql>
+
+    <!-- 查询单个 -->
+    <select id="selectById" resultMap="LoginLogMap">
+        select
+        <include refid="Base_Column_List"/>
+        from uims_login_log
+        where id = #{id}
+    </select>
+
+
+    <!-- 查询全部 -->
+    <select id="selectAll" resultMap="LoginLogMap">
+        select
+        <include refid="Base_Column_List"/>
+        from uims_login_log
+    </select>
+
+    <!--通过实体作为筛选条件查询-->
+    <select id="selectList" resultMap="LoginLogMap">
+        select
+        <include refid="Base_Column_List"/>
+        from uims_login_log
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="name != null and name != ''">
+                and name = #{name}
+            </if>
+            <if test="phone != null and phone != ''">
+                and phone = #{phone}
+            </if>
+            <if test="companyId != null">
+                and company_id = #{companyId}
+            </if>
+            <if test="departmentId != null">
+                and department_id = #{departmentId}
+            </if>
+            <if test="type != null and type != ''">
+                and type = #{type}
+            </if>
+            <if test="createTime != null">
+                and create_time = #{createTime}
+            </if>
+            <if test="loginIp != null and loginIp != ''">
+                and login_ip = #{loginIp}
+            </if>
+        </where>
+    </select>
+
+    <!-- 新增所有列 -->
+    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
+        insert into uims_login_log(id, name, phone, company_id, department_id, type, create_time, login_ip)
+        values ( #{id}, #{name}, #{phone}, #{companyId}, #{departmentId}, #{type}, #{createTime}, #{loginIp})
+    </insert>
+
+    <!-- 批量新增 -->
+    <insert id="batchInsert">
+        insert into uims_login_log(id, name, phone, company_id, department_id, type, create_time, login_ip)
+        values
+        <foreach collection="loginLogs" item="item" index="index" separator=",">
+            (
+            #{item.id}, #{item.name}, #{item.phone}, #{item.companyId}, #{item.departmentId}, #{item.type},
+            #{item.createTime}, #{item.loginIp} )
+        </foreach>
+    </insert>
+
+    <!-- 通过主键修改数据 -->
+    <update id="update">
+        update uims.uims_login_log
+        <set>
+            <if test="name != null and name != ''">
+                name = #{name},
+            </if>
+            <if test="phone != null and phone != ''">
+                phone = #{phone},
+            </if>
+            <if test="companyId != null">
+                company_id = #{companyId},
+            </if>
+            <if test="departmentId != null">
+                department_id = #{departmentId},
+            </if>
+            <if test="type != null and type != ''">
+                type = #{type},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime},
+            </if>
+            <if test="loginIp != null and loginIp != ''">
+                login_ip = #{loginIp},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+
+    <!--通过主键删除-->
+    <delete id="deleteById">
+        delete from uims_login_log where id = #{id}
+    </delete>
+
+    <!-- 总数 -->
+    <select id="count" resultType="int">
+        select count(*) from uims_login_log
+    </select>
+    <select id="selectPage" resultMap="LoginLogMap">
+        select
+        <include refid="Base_Column_List"/>
+        from uims_login_log
+        <where>
+            <if test="loginLog.id != null">
+                and id = #{loginLog.id}
+            </if>
+            <if test="loginLog.name != null and loginLog.name != ''">
+                and name = #{loginLog.name}
+            </if>
+            <if test="loginLog.phone != null and loginLog.phone != ''">
+                and phone = #{loginLog.phone}
+            </if>
+            <if test="loginLog.companyId != null">
+                and company_id = #{loginLog.companyId}
+            </if>
+            <if test="loginLog.departmentId != null">
+                and department_id = #{loginLog.departmentId}
+            </if>
+            <if test="loginLog.type != null and loginLog.type != ''">
+                and type = #{loginLog.type}
+            </if>
+            <if test="loginLog.createTime != null">
+                and create_time = #{loginLog.createTime}
+            </if>
+            <if test="loginLog.loginIp != null and loginLog.loginIp != ''">
+                and login_ip = #{loginLog.loginIp}
+            </if>
+        </where>
+    </select>
+</mapper>

+ 303 - 0
user_auth/src/main/resources/mapper/UserMapper.xml

@@ -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>