guoyujie
7 天以前 b9fa1c266e2d51388a757cf361680d82f6edfbea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?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.example.erp.mapper.userInfo.UserMapper">
    <resultMap id="findAllMap" type="com.example.erp.entity.userInfo.User">
        <id property="id" column="id"/>
        <result property="loginName" column="login_name"/>
        <result property="userName" column="user_name"/>
        <result property="address" column="address"/>
        <result property="createTime" column="create_time"/>
 
        <collection property="userRoleList" ofType="com.example.erp.entity.userInfo.UserRole">
            <result property="userId" column="user_id"/>
            <result property="roleId" column="role_id"/>
            <result property="role" column="role"/>
        </collection>
    </resultMap>
 
 
    <select id="findAll" resultMap="findAllMap">
        SELECT a.*,
        b.role_id,
        c.role
        FROM erp_user_info.user as a
        left join user_role as b
        on a.id = b.user_id
        left join role as c
        on b.role_id = c.id
        where state =1 and a.id != 1
    </select>
    <select id="findByAddress" resultMap="findAllMap">
        SELECT a.*,
               b.role_id,
               c.role
        FROM erp_user_info.user as a
                 left join user_role as b
                           on a.id = b.user_id
                 left join role as c
                           on b.role_id = c.id
        where state =1 and a.id != 1 and address is not null and address !=''
        <if test="userName != null and userName != '' and userName != 'null'">
            and user_name like concat('%',#{userName},'%')
        </if>
    </select>
 
    <select id="findOne" >
        SELECT *
        FROM erp_user_info.user
        where id=#{id}
    </select>
 
    <select id="findOneLoginName" >
        SELECT *
        FROM erp_user_info.user
        where login_name=#{LoginName}
    </select>
 
    <select id="findOnePassWord" >
        SELECT *
        FROM erp_user_info.user
        where id=#{id} and password=#{passWord}
    </select>
 
    <insert id="register"  useGeneratedKeys="true" keyProperty="id">
        insert erp_user_info.user
            (password,user_name)
        values (
                 #{password} ,#{userName}
               )
    </insert>
 
    <select id="getUserRole">
        SELECT
            c.role
        from
            user as a
        left join user_role as b
            on a.id = b.user_id
        left join role as c
            on b.role_id = c.id
        where a.id = #{loginId}
 
    </select>
    <update id="userDelete">
        update user
        set state =0
        where id = #{id}
    </update>
 
    <update id="updatePassWordById">
        update erp_user_info.user
        set password=#{passWord},update_time=now()
        where id=#{id}
    </update>
 
    <update id="updateUserNameById">
        update erp_user_info.user
        set user_name=#{userName},update_time=now()
        where id=#{id}
    </update>
    <update id="updateProcessMp">
        update erp_user_info.user
        set address=#{process},update_time=now()
        where id=#{id}
    </update>
 
 
        <select id="selectOptimizeParmsById" resultType="String">
            SELECT optimize_parms FROM erp_user_info.user WHERE user_name = #{username}
        </select>
 
    <select id="getUserLog" >
        SELECT operator_id,operator,DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') AS format_create_time
        FROM erp_log.log
        WHERE create_time >= DATE_SUB(NOW(), INTERVAL 1 MONTH) and `function`='用户登录' order by create_time desc limit 0,100
    </select>
 
</mapper>