123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?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.tld.mapper.UserMaterialMapper">
- <!-- 查询用户绑定物料信息 -->
- <select id="getUserMaterial" resultType="com.tld.model.UserMaterial">
- select
- distinct
- a.id,
- a.material_id,
- a.user_id,
- a.scrq,
- b.name as materialName,
- c.user_name as userName,
- b.code as wllbCode,
- c.real_name,
- a.modify_time,
- f.user_name as modifyUser
- from tld_user_material a
- left join tld_material b on a.material_id = b.code
- left join tld_user c on a.user_id = c.id
- left join tld_user f on a.modify_user = f.id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialId != null and materialId != ''">
- and a.material_id = #{materialId}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="userId != null and userId != ''">
- and a.user_id = #{userId}
- </if>
- <if test="id != null and id != ''">
- and a.id = #{id}
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 新增用户绑定物料信息 -->
- <insert id="addUserMaterial">
- insert into tld_user_material(material_id,user_id,scrq,modify_user,modify_time) value(#{materialId},#{userId},now(),#{modifyUser},now())
- </insert>
- <!-- 修改用户绑定物料信息 -->
- <update id="updateUserMaterial">
- update tld_user_material
- <set>
- <trim suffixOverrides=",">
- <if test="materialId != null and materialId != ''">
- material_id = #{materialId},
- </if>
- <if test="userId != null and userId != ''">
- user_id = #{userId},
- </if>
- modify_user = #{modifyUser},modify_time=now(),
- </trim>
- </set>
- where id = #{id}
- </update>
- <!-- 删除用户绑定物料信息 -->
- <delete id="delUserMaterial">
- delete from tld_user_material where id = #{id}
- </delete>
- <!-- 查询所有用户 -->
- <select id="getUser" resultType="com.tld.model.User">
- select
- a.id,
- a.code,
- a.user_name,
- a.password,
- a.real_name,
- a.email,
- a.landline,
- a.phone,
- a.department,
- a.role,
- b.menu
- from tld_user a
- left join tld_role b on a.role = b.id
- </select>
- <select id="getMaterial" resultType="java.lang.Integer">
- select COUNT(*) from tld_material where code = #{wllbCode}
- </select>
- <!--查询用户绑定物料信息导出-->
- <select id="Export" resultType="java.util.LinkedHashMap">
- SELECT DISTINCT
- b.CODE AS wllbCode,
- b.NAME AS materialName,
- c.user_name AS userName
- FROM
- tld_user_material a
- LEFT JOIN tld_material b ON a.material_id = b.CODE
- LEFT JOIN tld_user c ON a.user_id = c.id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialId != null and materialId != ''">
- and a.material_id = #{materialId}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="userId != null and userId != ''">
- and a.user_id = #{userId}
- </if>
- <if test="id != null and id != ''">
- and a.id = #{id}
- </if>
- </trim>
- order by a.id desc
- </select>
- </mapper>
|