<?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.nq.dao.StockMapper" >
|
<resultMap id="BaseResultMap" type="com.nq.pojo.Stock" >
|
<id column="id" property="id" />
|
<result column="stock_name" property="stockName" />
|
<result column="stock_code" property="stockCode"/>
|
<result column="stock_spell" property="stockSpell" />
|
<result column="stock_type" property="stockType" />
|
<result column="stock_gid" property="stockGid" />
|
<result column="stock_plate" property="stockPlate" />
|
<result column="is_lock" property="isLock" />
|
<result column="is_show" property="isShow" />
|
<result column="add_time" property="addTime" />
|
<result column="spread_rate" property="spreadRate" />
|
<result column="data_base" property="dataBase" />
|
<result column="increase_ratio" property="increaseRatio" />
|
</resultMap>
|
<sql id="Base_Column_List" >
|
id, stock_name, stock_code, stock_spell, stock_type, stock_gid, stock_plate, is_lock,
|
is_show, add_time,spread_rate,data_base,increase_ratio
|
</sql>
|
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
|
select
|
<include refid="Base_Column_List" />
|
from stock
|
where id = #{id,jdbcType=INTEGER}
|
</select>
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
|
delete from stock
|
where id = #{id,jdbcType=INTEGER}
|
</delete>
|
<insert id="insert1" parameterType="com.nq.pojo.Stock" >
|
insert into stock (id, stock_name, stock_code,
|
stock_spell, stock_type, stock_gid,
|
stock_plate, is_lock, is_show,data_base,
|
add_time,increase_ratio)
|
values (#{id,jdbcType=INTEGER}, #{stockName,jdbcType=VARCHAR}, #{stockCode,jdbcType=VARCHAR},
|
#{stockSpell,jdbcType=VARCHAR}, #{stockType,jdbcType=VARCHAR}, #{stockGid,jdbcType=VARCHAR},
|
#{stockPlate,jdbcType=VARCHAR}, #{isLock,jdbcType=INTEGER}, #{isShow,jdbcType=INTEGER},#{dataBase,jdbcType=INTEGER},
|
#{addTime,jdbcType=TIMESTAMP},#{increaseRatio,jdbcType=DECIMAL})
|
</insert>
|
<insert id="insertSelective" parameterType="com.nq.pojo.Stock" >
|
insert into stock
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="id != null" >
|
id,
|
</if>
|
<if test="stockName != null" >
|
stock_name,
|
</if>
|
<if test="stockCode != null" >
|
stock_code,
|
</if>
|
<if test="stockSpell != null" >
|
stock_spell,
|
</if>
|
<if test="stockType != null" >
|
stock_type,
|
</if>
|
<if test="stockGid != null" >
|
stock_gid,
|
</if>
|
<if test="stockPlate != null" >
|
stock_plate,
|
</if>
|
<if test="isLock != null" >
|
is_lock,
|
</if>
|
<if test="isShow != null" >
|
is_show,
|
</if>
|
<if test="addTime != null" >
|
add_time,
|
</if>
|
<if test="dataBase != null" >
|
data_base,
|
</if>
|
<if test="increaseRatio != null" >
|
increase_ratio,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="id != null" >
|
#{id,jdbcType=INTEGER},
|
</if>
|
<if test="stockName != null" >
|
#{stockName,jdbcType=VARCHAR},
|
</if>
|
<if test="stockCode != null" >
|
#{stockCode,jdbcType=VARCHAR},
|
</if>
|
<if test="stockSpell != null" >
|
#{stockSpell,jdbcType=VARCHAR},
|
</if>
|
<if test="stockType != null" >
|
#{stockType,jdbcType=VARCHAR},
|
</if>
|
<if test="stockGid != null" >
|
#{stockGid,jdbcType=VARCHAR},
|
</if>
|
<if test="stockPlate != null" >
|
#{stockPlate,jdbcType=VARCHAR},
|
</if>
|
<if test="isLock != null" >
|
#{isLock,jdbcType=INTEGER},
|
</if>
|
<if test="isShow != null" >
|
#{isShow,jdbcType=INTEGER},
|
</if>
|
<if test="addTime != null" >
|
#{addTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="dataBase != null" >
|
#{dataBase,jdbcType=INTEGER},
|
</if>
|
<if test="increaseRatio != null" >
|
#{increaseRatio,jdbcType=DECIMAL},
|
</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKeySelective" parameterType="com.nq.pojo.Stock" >
|
update stock
|
<set >
|
<if test="stockName != null" >
|
stock_name = #{stockName,jdbcType=VARCHAR},
|
</if>
|
<if test="stockCode != null" >
|
stock_code = #{stockCode,jdbcType=VARCHAR},
|
</if>
|
<if test="stockSpell != null" >
|
stock_spell = #{stockSpell,jdbcType=VARCHAR},
|
</if>
|
<if test="stockType != null" >
|
stock_type = #{stockType,jdbcType=VARCHAR},
|
</if>
|
<if test="stockGid != null" >
|
stock_gid = #{stockGid,jdbcType=VARCHAR},
|
</if>
|
<if test="stockPlate != null" >
|
stock_plate = #{stockPlate,jdbcType=VARCHAR},
|
</if>
|
<if test="isLock != null" >
|
is_lock = #{isLock,jdbcType=INTEGER},
|
</if>
|
<if test="isShow != null" >
|
is_show = #{isShow,jdbcType=INTEGER},
|
</if>
|
<if test="addTime != null" >
|
add_time = #{addTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="spreadRate != null" >
|
spread_rate = #{spreadRate,jdbcType=DECIMAL},
|
</if>
|
<if test="increaseRatio != null" >
|
increase_ratio = #{increaseRatio,jdbcType=DECIMAL},
|
</if>
|
</set>
|
where id = #{id,jdbcType=INTEGER}
|
</update>
|
<update id="updateByPrimaryKey" parameterType="com.nq.pojo.Stock" >
|
update stock
|
set stock_name = #{stockName,jdbcType=VARCHAR},
|
stock_code = #{stockCode,jdbcType=VARCHAR},
|
stock_spell = #{stockSpell,jdbcType=VARCHAR},
|
stock_type = #{stockType,jdbcType=VARCHAR},
|
stock_gid = #{stockGid,jdbcType=VARCHAR},
|
stock_plate = #{stockPlate,jdbcType=VARCHAR},
|
is_lock = #{isLock,jdbcType=INTEGER},
|
is_show = #{isShow,jdbcType=INTEGER},
|
add_time = #{addTime,jdbcType=TIMESTAMP},
|
data_base = #{dataBase,jdbcType=INTEGER},
|
increase_ratio = #{increaseRatio,jdbcType=DECIMAL}
|
where id = #{id,jdbcType=INTEGER}
|
</update>
|
|
|
<select id="findStockListByKeyWords" resultMap="BaseResultMap" parameterType="map">
|
SELECT
|
*
|
from stock
|
<where>
|
is_show = ${show}
|
<if test="keyWords != null and keyWords != '' ">
|
and ( stock_spell like concat('%',#{keyWords},'%')
|
or stock_name like concat('%',#{keyWords},'%') )
|
</if>
|
|
<!-- <if test="stockPlate != null and stockPlate != '' ">-->
|
<!-- and stock_plate = #{stockPlate}-->
|
<!-- </if>-->
|
<!-- <if test="stockPlate == null or stockPlate == '' ">-->
|
<!-- and (stock_plate is null or stock_plate='' or stock_plate='科创' or stock_plate='创业' )-->
|
<!-- </if>-->
|
<if test="stockType != null and stockType != '' ">
|
and stock_type = #{stockType}
|
</if>
|
|
</where>
|
ORDER BY id ASC
|
</select>
|
|
|
|
<select id="findOptions" resultMap="BaseResultMap" parameterType="map">
|
select * from stock where id in(select stock_id from stock_option where user_id = #{id})
|
</select>
|
|
<select id="findZtStockListByKeyWords" resultMap="BaseResultMap" parameterType="map">
|
SELECT
|
<include refid="Base_Column_List" />
|
from stock
|
<where>
|
and
|
increase_ratio>19.5
|
|
and is_show = #{show}
|
<if test="keyWords != null and keyWords != '' ">
|
|
and (stock_type like concat('%',#{keyWords},'%') or stock_code like concat('%',#{keyWords},'%') or stock_name like concat('%',#{keyWords},'%') )
|
|
</if>
|
<if test="stockPlate != null and stockPlate != '' ">
|
and stock_plate = #{stockPlate}
|
</if>
|
<if test="stockPlate == null or stockPlate == '' ">
|
and (stock_plate is null or stock_plate='' or stock_plate='科创' or stock_plate='创业' )
|
</if>
|
<!-- <if test="stockType != null and stockType != '' ">-->
|
<!-- and stock_type = #{stockType}-->
|
<!-- </if>-->
|
|
</where>
|
ORDER BY id ASC
|
</select>
|
|
|
|
|
<select id="findStockCode" resultMap="BaseResultMap" parameterType="map">
|
SELECT
|
<include refid="Base_Column_List" />
|
from stock
|
<where>
|
<if test="stockType != null and stockType != '' ">
|
and stock_type = #{stockType}
|
</if>
|
GROUP BY stock_gid
|
ORDER BY stock_gid DESC
|
limit #{stock_num},#{stock_nums}
|
</where>
|
</select>
|
|
<select id="findStockByCode" resultMap="BaseResultMap" parameterType="string">
|
SELECT
|
<include refid="Base_Column_List" />
|
from stock
|
WHERE stock_code = #{code}
|
</select>
|
<select id="findStockByName" resultMap="BaseResultMap" parameterType="string">
|
SELECT
|
<include refid="Base_Column_List" />
|
from stock
|
WHERE stock_name = #{name}
|
</select>
|
|
|
<select id="listByAdmin" resultMap="BaseResultMap" parameterType="map">
|
SELECT
|
<include refid="Base_Column_List" />
|
from stock
|
<where>
|
<if test="showState != null ">
|
and is_show = #{showState}
|
</if>
|
<if test="lockState != null ">
|
and is_lock = #{lockState}
|
</if>
|
<if test="code != null and code != '' ">
|
and stock_code like CONCAT('%','${code}','%')
|
</if>
|
<if test="name != null and name != '' ">
|
and stock_name like CONCAT('%','${name}','%')
|
</if>
|
<if test="stockPlate != null and stockPlate != '' ">
|
and stock_plate = #{stockPlate}
|
</if>
|
<if test="stockType != null and stockType != '' ">
|
and stock_type = #{stockType}
|
</if>
|
</where>
|
</select>
|
|
|
<select id="CountStockNum" resultType="integer">
|
SELECT COUNT(id) FROM stock
|
</select>
|
<select id="CountShowNum" resultType="integer" parameterType="integer">
|
SELECT COUNT(id) FROM stock WHERE is_show = #{showState}
|
</select>
|
<select id="CountUnLockNum" resultType="integer" parameterType="integer">
|
SELECT COUNT(id) FROM stock WHERE is_lock = #{showState}
|
</select>
|
|
|
<select id="findStockList" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM stock where stock_type = 'in'
|
</select>
|
|
|
|
<select id="findQhStockList" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM stock where stock_type = 'qh'
|
</select>
|
|
|
|
</mapper>
|