<?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.thhy.secure.modules.biz.good.mapper.SecureGoodMapper">
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
t.id as id,
|
t.good_name as goodName,
|
t.good_type as goodType,
|
t.use_way as useWay,
|
t.good_position as goodPosition,
|
t.company_id as companyId,
|
t.create_time as createTime,
|
t.create_user as createUser,
|
t.update_time as updateTime,
|
t.update_user as updateUser,
|
t.is_use as isUse
|
</sql>
|
|
<sql id="condition_query">
|
<where>
|
<trim suffixOverrides=" AND ">
|
<if test="goodName!=null and goodName!=''">
|
t.good_name = #{goodName} AND
|
</if>
|
<if test="goodType!=null and goodType!=''">
|
t.good_type = #{goodType} AND
|
</if>
|
<if test="useWay!=null and useWay!=''">
|
t.use_way = #{useWay} AND
|
</if>
|
<if test="goodPosition!=null and goodPosition!=''">
|
t.good_position = #{goodPosition} AND
|
</if>
|
<if test="companyId!=null and companyId!=''">
|
t.company_id = #{companyId} AND
|
</if>
|
<if test="createTime!=null">
|
t.create_time = #{createTime} AND
|
</if>
|
<if test="createUser!=null and createUser!=''">
|
t.create_user = #{createUser} AND
|
</if>
|
<if test="updateTime!=null">
|
t.update_time = #{updateTime} AND
|
</if>
|
<if test="updateUser!=null and updateUser!=''">
|
t.update_user = #{updateUser} AND
|
</if>
|
<if test="isUse!=null">
|
t.is_use = #{isUse} AND
|
</if>
|
</trim>
|
</where>
|
</sql>
|
|
<select id="queryById" resultType="com.thhy.secure.modules.biz.good.entity.SecureGood">
|
select <include refid="Base_Column_List" />
|
from t_secure_good t
|
where t.id=#{id}
|
</select>
|
|
<select id="queryVersionById" resultType="integer">
|
select version from t_secure_good
|
where id=#{id}
|
</select>
|
|
<!--查询列表-->
|
<select id="findList" resultType="com.thhy.secure.modules.biz.good.entity.SecureGood">
|
SELECT
|
<include refid="Base_Column_List" />
|
from t_secure_good t
|
<where>
|
<trim suffixOverrides=" AND ">
|
t.is_use = 1 AND t.company_id = #{companyId} AND
|
<if test="goodName!=null and goodName!=''">
|
t.good_name LIKE concat('%',#{goodName},'%') AND
|
</if>
|
<if test="startTime!=null">
|
t.create_time >= #{startTime} AND
|
</if>
|
<if test="endTime!=null">
|
t.create_time <= #{endTime} AND
|
</if>
|
</trim>
|
</where>
|
order by t.create_time desc
|
</select>
|
|
<select id="fileList" resultType="com.thhy.secure.modules.biz.good.entity.SecureGoodFile">
|
select id,file from t_secure_good_file where secure_good_id = #{id}
|
</select>
|
|
<!--查询列表-->
|
<select id="findAll" resultType="com.thhy.secure.modules.biz.good.entity.SecureGood">
|
SELECT
|
<include refid="Base_Column_List" />
|
from t_secure_good t
|
</select>
|
|
<!--插入操作-->
|
<insert id="insert">
|
insert into t_secure_good
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="id != null">
|
id,
|
</if>
|
<if test="goodName != null">
|
good_name,
|
</if>
|
<if test="goodType != null">
|
good_type,
|
</if>
|
<if test="useWay != null">
|
use_way,
|
</if>
|
<if test="goodPosition != null">
|
good_position,
|
</if>
|
<if test="companyId != null">
|
company_id,
|
</if>
|
<if test="createTime != null">
|
create_time,
|
</if>
|
<if test="createUser != null">
|
create_user,
|
</if>
|
<if test="updateTime != null">
|
update_time,
|
</if>
|
<if test="updateUser != null">
|
update_user,
|
</if>
|
<if test="isUse != null">
|
is_use,
|
</if>
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="id != null">
|
#{id},
|
</if>
|
<if test="goodName != null">
|
#{goodName},
|
</if>
|
<if test="goodType != null">
|
#{goodType},
|
</if>
|
<if test="useWay != null">
|
#{useWay},
|
</if>
|
<if test="goodPosition != null">
|
#{goodPosition},
|
</if>
|
<if test="companyId != null">
|
#{companyId},
|
</if>
|
<if test="createTime != null">
|
#{createTime},
|
</if>
|
<if test="createUser != null">
|
#{createUser},
|
</if>
|
<if test="updateTime != null">
|
#{updateTime},
|
</if>
|
<if test="updateUser != null">
|
#{updateUser},
|
</if>
|
<if test="isUse != null">
|
#{isUse},
|
</if>
|
</trim>
|
</insert>
|
|
<!--插入操作-->
|
<insert id="insertGoodFile">
|
insert into t_secure_good_file
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="id != null">
|
id,
|
</if>
|
<if test="secureGoodId != null">
|
secure_good_id,
|
</if>
|
<if test="file != null">
|
file,
|
</if>
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="id != null">
|
#{id},
|
</if>
|
<if test="secureGoodId != null">
|
#{secureGoodId},
|
</if>
|
<if test="file != null">
|
#{file},
|
</if>
|
</trim>
|
</insert>
|
|
|
<!--更新操作-->
|
<update id="update">
|
update t_secure_good
|
<set>
|
<if test="goodName != null">
|
good_name=#{goodName},
|
</if>
|
<if test="goodType != null">
|
good_type=#{goodType},
|
</if>
|
<if test="useWay != null">
|
use_way=#{useWay},
|
</if>
|
<if test="goodPosition != null">
|
good_position=#{goodPosition},
|
</if>
|
<if test="companyId != null">
|
company_id=#{companyId},
|
</if>
|
<if test="createTime != null">
|
create_time=#{createTime},
|
</if>
|
<if test="createUser != null">
|
create_user=#{createUser},
|
</if>
|
<if test="updateTime != null">
|
update_time=#{updateTime},
|
</if>
|
<if test="updateUser != null">
|
update_user=#{updateUser},
|
</if>
|
<if test="isUse != null">
|
is_use=#{isUse},
|
</if>
|
</set>
|
where id=#{id}
|
</update>
|
|
<!--逻辑删除-->
|
<update id="deletelogic">
|
update t_secure_good
|
SET is_use = 0
|
where id=#{id}
|
</update>
|
|
<!--根据ID删除-->
|
<delete id="deleteById">
|
delete from t_secure_good
|
where id=#{id}
|
</delete>
|
|
<delete id="deleteFileByGoodId">
|
delete from t_secure_good_file where secure_good_id = #{secureGoodId}
|
</delete>
|
|
</mapper>
|