144 lines
5.5 KiB
XML
144 lines
5.5 KiB
XML
|
|
<?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="GoodsAuthLog">
|
||
|
|
|
||
|
|
<sql id="baseSql" >
|
||
|
|
goodsauthlogid,adminid,authtype,objecttype,objectid,uid,created,goods,starttime,endtime,description
|
||
|
|
</sql>
|
||
|
|
|
||
|
|
<insert id="insertGoodsAuthLog" parameterType="GoodsAuthLog" flushCache="true">
|
||
|
|
INSERT INTO GoodsAuthLog ( nextval('seq_goodsauthlogid') ,
|
||
|
|
adminid,authtype,
|
||
|
|
objecttype,objectid,uid,created,goods,starttime,
|
||
|
|
endtime,description )
|
||
|
|
Values ( #{goodsauthlogid},#{adminid},#{authtype},
|
||
|
|
#{objecttype},#{objectid},#{uid}, current_timestamp ,#{goods},#{starttime},
|
||
|
|
#{endtime},#{description})
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updateGoodsAuthLog" parameterType="GoodsAuthLog">
|
||
|
|
UPDATE GoodsAuthLog
|
||
|
|
SET goodsauthlogid=#{goodsauthlogid},adminid=#{adminid},
|
||
|
|
authtype=#{authtype},objecttype=#{objecttype},
|
||
|
|
objectid=#{objectid},uid=#{uid},created=#{created},
|
||
|
|
goods=#{goods},starttime=#{starttime},endtime=#{endtime},
|
||
|
|
description=#{description}
|
||
|
|
WHERE goodsauthlogid=#{goodsauthlogid}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id="getGoodsAuthLog" parameterType="java.lang.Integer" resultType="GoodsAuthLog">
|
||
|
|
SELECT goodsauthlogid,adminid,authtype,objecttype,objectid,
|
||
|
|
uid,created,goods,starttime,endtime,description
|
||
|
|
FROM GoodsAuthLog
|
||
|
|
WHERE goodsauthlogid=#{goodsauthlogid}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getMockLogs" parameterType="java.util.Map" resultType="GoodsAuthLog">
|
||
|
|
select <include refid="baseSql"/> FROM
|
||
|
|
goodsauthlog
|
||
|
|
where
|
||
|
|
<if test="uid!=null">
|
||
|
|
uid=#{uid}
|
||
|
|
</if>
|
||
|
|
<if test="authType!=null">
|
||
|
|
and authtype = #{authType}
|
||
|
|
</if>
|
||
|
|
order by goodsauthlogid desc
|
||
|
|
<if test="pageSize != null">
|
||
|
|
limit #{pageSize}
|
||
|
|
</if>
|
||
|
|
<if test="offset != null">
|
||
|
|
offset #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getGoodsAuthLogsByUid" parameterType="java.util.Map" resultType="GoodsAuthLog">
|
||
|
|
with temp as (SELECT goodsauthlogid
|
||
|
|
FROM GoodsAuthLog as a where exists (select goodsauthlogid from GoodsAuthLog as b where a.authtype=1 and b.uid=#{uid} and b.starttime is null and b.endtime is null and a.goodsauthlogid=b.goodsauthlogid ) ),
|
||
|
|
temp2 as (SELECT goodsauthlogid
|
||
|
|
FROM GoodsAuthLog as a where exists (select goodsauthlogid from GoodsAuthLog as b where a.authtype=2 and b.uid=#{uid} and b.starttime is null and b.endtime is null and a.goodsauthlogid=b.goodsauthlogid ) )
|
||
|
|
|
||
|
|
SELECT goodsauthlogid,adminid,authtype,objecttype,objectid,
|
||
|
|
uid,created,goods,starttime,endtime,description
|
||
|
|
FROM GoodsAuthLog
|
||
|
|
WHERE uid=#{uid} and authtype != 5
|
||
|
|
<if test="isAll!=null">
|
||
|
|
and created>='2019-1-1 00:00:00'
|
||
|
|
</if>
|
||
|
|
and goodsauthlogid not in (select goodsauthlogid from temp) and goodsauthlogid not in (select goodsauthlogid from temp2)
|
||
|
|
order by goodsauthlogid desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
limit #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
offset #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getGoodsAuthLogsByObjectId" parameterType="java.util.Map" resultType="GoodsAuthLog" >
|
||
|
|
select max(goodsauthlogId) goodsauthlogId,created,starttime,endtime,goods,description,authtype,objecttype,objectid
|
||
|
|
from goodsauthlog where objecttype=#{objectType} and objectid=#{objectId}
|
||
|
|
group by created,starttime,endtime,goods,description,authtype,objecttype,objectid
|
||
|
|
order by created desc
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getGoodsAuthLogsByUidCount" parameterType="java.lang.Long" resultType="java.lang.Integer">
|
||
|
|
with temp as (SELECT goodsauthlogid
|
||
|
|
FROM GoodsAuthLog as a where exists (select goodsauthlogid from GoodsAuthLog as b where a.authtype=1 and b.uid=#{uid} and b.starttime is null and b.endtime is null and a.goodsauthlogid=b.goodsauthlogid ) ),
|
||
|
|
temp2 as (SELECT goodsauthlogid
|
||
|
|
FROM GoodsAuthLog as a where exists (select goodsauthlogid from GoodsAuthLog as b where a.authtype=2 and b.uid=#{uid} and b.starttime is null and b.endtime is null and a.goodsauthlogid=b.goodsauthlogid ) )
|
||
|
|
SELECT count(goodsauthlogid)
|
||
|
|
FROM GoodsAuthLog
|
||
|
|
WHERE uid=#{uid} and authtype != 5 and goodsauthlogid not in (select goodsauthlogid from temp) and goodsauthlogid not in (select goodsauthlogid from temp2)
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getSeqGoodsAuthLog" resultType="Long" useCache="false" flushCache="true">
|
||
|
|
SELECT nextval('seq_goodsauthlogid')
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="insertGoodsAuthLogsBatch" parameterType="java.util.List" flushCache="true">
|
||
|
|
INSERT INTO GoodsAuthLog ( goodsauthlogid,adminid,authtype,
|
||
|
|
objecttype,objectid,uid,created,goods,starttime,
|
||
|
|
endtime,description )
|
||
|
|
Values
|
||
|
|
<foreach collection="list" index="index" item="item" separator=",">
|
||
|
|
( nextval('seq_goodsauthlogid') ,
|
||
|
|
#{item.adminid} , #{item.authtype},
|
||
|
|
#{item.objecttype} , #{item.objectid},
|
||
|
|
#{item.uid} , current_timestamp ,
|
||
|
|
#{item.goods} , #{item.starttime},
|
||
|
|
#{item.endtime} , #{item.description} )
|
||
|
|
</foreach>
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<select id="userAuthCountTotalByEndTimeTwo" parameterType="java.util.Date" resultType="java.lang.Integer">
|
||
|
|
|
||
|
|
select count(distinct uid) from goodsauthlog where
|
||
|
|
created < #{endTime} and created >='2016-10-27 15:25:32'
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getCountByUidAndAuthType" parameterType="java.util.Map" resultType="java.lang.Integer">
|
||
|
|
select count(uid) from goodsauthlog
|
||
|
|
<where>
|
||
|
|
<if test="uid!=null">
|
||
|
|
uid = #{uid}
|
||
|
|
</if>
|
||
|
|
<if test="authType!=null">
|
||
|
|
and authtype = #{authType}
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
</mapper>
|