Files
cashier-client/src/main/resources/mapper/TbPrintPCMachineMapper.xml
2024-04-02 14:42:41 +08:00

193 lines
8.0 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="com.chaozhanggui.system.cashierservice.dao.TbPrintPCMachineMapper">
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbPrintPCMachine" id="TbPrintMachineMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="VARCHAR"/>
<result property="connectionType" column="connection_type" jdbcType="VARCHAR"/>
<result property="address" column="address" jdbcType="VARCHAR"/>
<result property="port" column="port" jdbcType="VARCHAR"/>
<result property="subType" column="sub_type" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="shopId" column="shop_id" jdbcType="VARCHAR"/>
<result property="categoryIds" column="category_ids" jdbcType="VARCHAR"/>
<result property="contentType" column="content_type" jdbcType="VARCHAR"/>
<result property="config" column="config" jdbcType="VARCHAR"/>
<result property="createdAt" column="created_at" jdbcType="INTEGER"/>
<result property="updatedAt" column="updated_at" jdbcType="INTEGER"/>
<result property="categoryList" column="category_list" jdbcType="VARCHAR"/>
<result property="sort" column="sort" jdbcType="INTEGER"/>
<result property="vendorId" column="vendor_id" jdbcType="VARCHAR"/>
<result property="productId" column="product_id" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id
, name, type, connection_type, address, port, sub_type, status, shop_id, category_ids, content_type, config, created_at, updated_at, category_list, sort, vendor_id, product_id </sql>
<!--查询单个-->
<select id="queryById" resultMap="TbPrintMachineMap">
select
<include refid="Base_Column_List"/>
from tb_print_machine
where id = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAll" resultMap="TbPrintMachineMap">
select
<include refid="Base_Column_List"/>
from tb_print_machine
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="type != null and type != ''">
and type = #{type}
</if>
<if test="connectionType != null and connectionType != ''">
and connection_type = #{connectionType}
</if>
<if test="address != null and address != ''">
and address = #{address}
</if>
<if test="port != null and port != ''">
and port = #{port}
</if>
<if test="subType != null and subType != ''">
and sub_type = #{subType}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="shopId != null and shopId != ''">
and shop_id = #{shopId}
</if>
<if test="categoryIds != null and categoryIds != ''">
and category_ids = #{categoryIds}
</if>
<if test="contentType != null and contentType != ''">
and content_type = #{contentType}
</if>
<if test="config != null and config != ''">
and config = #{config}
</if>
<if test="createdAt != null">
and created_at = #{createdAt}
</if>
<if test="updatedAt != null">
and updated_at = #{updatedAt}
</if>
<if test="categoryList != null and categoryList != ''">
and category_list = #{categoryList}
</if>
<if test="sort != null">
and sort = #{sort}
</if>
<if test="vendorId != null and vendorId != ''">
and vendor_id = #{vendorId}
</if>
<if test="productId != null and productId != ''">
and product_id = #{productId}
</if>
</where>
order by created_at desc
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into tb_print_machine(name, type, connection_type, address, port, sub_type, status, shop_id,
category_ids, content_type, config, created_at, updated_at, category_list, sort,
vendor_id, product_id)
values (#{name}, #{type}, #{connectionType}, #{address}, #{port}, #{subType}, #{status}, #{shopId},
#{categoryIds}, #{contentType}, #{config}, #{createdAt}, #{updatedAt}, #{categoryList}, #{sort},
#{vendorId}, #{productId})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into tb_print_machine(name, type, connection_type, address, port, sub_type, status, shop_id,
category_ids, content_type, config, created_at, updated_at, category_list, sort, vendor_id, product_id)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name}, #{entity.type}, #{entity.connectionType}, #{entity.address}, #{entity.port},
#{entity.subType}, #{entity.status}, #{entity.shopId}, #{entity.categoryIds}, #{entity.contentType},
#{entity.config}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.categoryList}, #{entity.sort},
#{entity.vendorId}, #{entity.productId})
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
update tb_print_machine
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="type != null and type != ''">
type = #{type},
</if>
<if test="connectionType != null and connectionType != ''">
connection_type = #{connectionType},
</if>
<if test="address != null and address != ''">
address = #{address},
</if>
<if test="port != null and port != ''">
port = #{port},
</if>
<if test="subType != null and subType != ''">
sub_type = #{subType},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="shopId != null and shopId != ''">
shop_id = #{shopId},
</if>
<if test="categoryIds != null and categoryIds != ''">
category_ids = #{categoryIds},
</if>
<if test="contentType != null and contentType != ''">
content_type = #{contentType},
</if>
<if test="config != null and config != ''">
config = #{config},
</if>
<if test="createdAt != null">
created_at = #{createdAt},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt},
</if>
<if test="categoryList != null and categoryList != ''">
category_list = #{categoryList},
</if>
<if test="sort != null">
sort = #{sort},
</if>
<if test="vendorId != null and vendorId != ''">
vendor_id = #{vendorId},
</if>
<if test="productId != null and productId != ''">
product_id = #{productId},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from tb_print_machine
where id = #{id}
</delete>
</mapper>