<?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.sunxung.factoring.mapper.sys.SystemSerialNumMapper">

	<resultMap type="SystemSerialNum" id="sysSerialNumResult">
		<result property="id" column="id" />
		<result property="name" column="name" />
		<result property="curNum" column="cur_num" />
		<result property="step" column="step" />
		<result property="remark" column="remark" />
		<result property="gmtCreate" column="gmt_create" />
		<result property="gmtModified" column="gmt_modified" />
		<result property="userCreate" column="user_create" />
		<result property="userModified" column="user_modified" />
	</resultMap>

	<sql id="fields">
		n.id,
		n.name,
		n.cur_num,
		n.step,
		n.remark,
		n.gmt_create,
		n.gmt_modified,
		n.user_create,
		n.user_modified
	</sql>

	<insert id="add" useGeneratedKeys="true" keyProperty="id" keyColumn="id" parameterType="SystemSerialNum">
		insert into system_serial_num( name,cur_num,step,remark, user_create )
		values ( #{name},#{curNum}, #{step}, #{remark},#{userCreate})
	</insert>

	<update id="update" parameterType="SystemSerialNum">
		update system_serial_num
		<set>
			name=#{name},
			cur_num=#{curNum},
			step=#{step},
			remark=#{remark},
			user_modified=#{userModified}
		</set>
		where id=#{id}
	</update>

	<select id="get" parameterType="java.lang.Long" resultMap="sysSerialNumResult">
		select <include refid="fields" /> from system_serial_num n where n.id=#{value}
	</select>
	
	<select id="getByName" parameterType="java.lang.String" resultMap="sysSerialNumResult">
		select <include refid="fields" /> from system_serial_num n where n.name=#{value}
	</select>
	
	<delete id="delete" parameterType="java.lang.Long">
		delete from system_serial_num where id = #{value}
	</delete>
	
	<select id="countBySearch"  resultType="java.lang.Integer">
		select count(*) from  system_serial_num n
	</select>
	
	<select id="findBySearch"    resultMap="sysSerialNumResult">
	    select  <include refid="fields"/>from system_serial_num n
	</select>

</mapper>