220 lines
8.8 KiB
XML
220 lines
8.8 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="cn.iocoder.yudao.module.farm.dal.mysql.disasterdata.DisasterDataMapper">
|
||
|
||
<!--
|
||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||
-->
|
||
|
||
<resultMap id="DisasterDataResultMap" type="cn.iocoder.yudao.module.farm.dal.dataobject.disasterdata.DisasterDataDO">
|
||
<!-- 基础字段 -->
|
||
<id column="id" property="id"/>
|
||
<result column="name" property="name"/>
|
||
<result column="category" property="category"/>
|
||
<result column="type" property="type"/>
|
||
<result column="disaster_description" property="disasterDescription"/>
|
||
<result column="treatment_suggestion" property="treatmentSuggestion"/>
|
||
<result column="img_url" property="imgUrl"/>
|
||
<result column="disaster_count" property="disasterCount"/>
|
||
<result column="disaster_time" property="disasterTime"/>
|
||
<!-- 其他字段 -->
|
||
<result column="creator" property="creator"/>
|
||
<result column="create_time" property="createTime"/>
|
||
<result column="updater" property="updater"/>
|
||
<result column="update_time" property="updateTime"/>
|
||
<result column="use_status" property="useStatus"/>
|
||
<result column="deleted" property="deleted"/>
|
||
</resultMap>
|
||
|
||
<sql id="all_fields">
|
||
id,
|
||
name ,
|
||
category ,
|
||
type ,
|
||
disaster_description ,
|
||
treatment_suggestion ,
|
||
img_url,
|
||
disaster_count,
|
||
disaster_time ,
|
||
creator,
|
||
create_time,
|
||
updater,
|
||
update_time,
|
||
use_status,
|
||
deleted
|
||
</sql>
|
||
<delete id="deleteById" parameterType="String">
|
||
delete
|
||
from farm_disaster_data
|
||
where id = #{id}
|
||
</delete>
|
||
|
||
<!-- 分页查询 -->
|
||
<select id="selectDisasterDataPage"
|
||
parameterType="cn.iocoder.yudao.module.farm.controller.admin.disasterdata.vo.DisasterDataPageReqVO"
|
||
resultMap="DisasterDataResultMap">
|
||
SELECT
|
||
<include refid="all_fields"/>
|
||
FROM farm_disaster_data
|
||
<include refid="where_1"/>
|
||
LIMIT #{req.offset}, #{req.pageSize}
|
||
</select>
|
||
|
||
<!-- 统计总数 -->
|
||
<select id="selectDisasterDataCount" resultType="java.lang.Long">
|
||
SELECT COUNT(*)
|
||
FROM farm_disaster_data
|
||
<include refid="where_1"/>
|
||
</select>
|
||
|
||
<sql id="where_1">
|
||
WHERE deleted = 0
|
||
<if test="req.name != null and req.name != ''">
|
||
AND name LIKE CONCAT('%', #{req.name}, '%')
|
||
</if>
|
||
<if test="req.category != null">
|
||
AND category = #{req.category}
|
||
</if>
|
||
<if test="req.type != null">
|
||
AND type = #{req.type}
|
||
</if>
|
||
<if test="req.deleted != null">
|
||
AND deleted = #{req.deleted}
|
||
</if>
|
||
</sql>
|
||
|
||
<select id="selectById"
|
||
resultType="cn.iocoder.yudao.module.farm.dal.dataobject.disasterdata.DisasterDataDO">
|
||
|
||
SELECT
|
||
<include refid="all_fields"/>
|
||
FROM farm_disaster_data
|
||
WHERE deleted = 0 AND id = #{id}
|
||
|
||
</select>
|
||
|
||
<update id="updateById" parameterType="cn.iocoder.yudao.module.farm.dal.dataobject.disasterdata.DisasterDataDO">
|
||
UPDATE farm_disaster_data
|
||
<set>
|
||
<if test="name != null and name != ''">
|
||
name = #{name},
|
||
</if>
|
||
<if test="category != null">
|
||
category = #{category},
|
||
</if>
|
||
<if test="type != null">
|
||
type = #{type},
|
||
</if>
|
||
<if test="disasterDescription != null">
|
||
disaster_description = #{disasterDescription},
|
||
</if>
|
||
<if test="treatmentSuggestion != null">
|
||
treatment_suggestion = #{treatmentSuggestion},
|
||
</if>
|
||
<if test="imgUrl != null and imgUrl != ''">
|
||
img_url = #{imgUrl},
|
||
</if>
|
||
<if test="disasterCount != null">
|
||
disaster_count = #{disasterCount},
|
||
</if>
|
||
<if test="disasterTime != null and disasterTime != ''">
|
||
disaster_time = #{disasterTime},
|
||
</if>
|
||
<if test="creator != null and creator != ''">
|
||
creator = #{creator},
|
||
</if>
|
||
<if test="updater != null and updater != ''">
|
||
updater = #{updater},
|
||
</if>
|
||
<if test="useStatus != null">
|
||
use_status = #{useStatus},
|
||
</if>
|
||
<if test="deleted != null">
|
||
deleted = #{deleted},
|
||
</if>
|
||
update_time = NOW()
|
||
</set>
|
||
WHERE id = #{id}
|
||
AND deleted = 0
|
||
</update>
|
||
|
||
<insert id="insert" parameterType="cn.iocoder.yudao.module.farm.dal.dataobject.disasterdata.DisasterDataDO">
|
||
|
||
INSERT INTO farm_disaster_data
|
||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
id,
|
||
<if test="name != null and name != ''">name,</if>
|
||
<if test="category != null">category,</if>
|
||
<if test="type != null">type,</if>
|
||
<if test="disasterDescription != null">disaster_description,</if>
|
||
<if test="treatmentSuggestion != null">treatment_suggestion,</if>
|
||
<if test="imgUrl != null and imgUrl != ''">img_url,</if>
|
||
<if test="disasterCount != null">disaster_count,</if>
|
||
<if test="disasterTime != null and disasterTime != ''">disaster_time,</if>
|
||
<if test="creator != null and creator != ''">creator,</if>
|
||
<if test="createTime != null">create_time,</if>
|
||
<if test="updater != null and updater != ''">updater,</if>
|
||
<if test="updateTime != null">update_time,</if>
|
||
<if test="useStatus != null">use_status,</if>
|
||
<if test="deleted != null">deleted,</if>
|
||
<if test="baseId != null">base_id,</if>
|
||
<if test="baseName != null">base_name,</if>
|
||
<if test="plotId != null">plot_id,</if>
|
||
<if test="plotName != null">plot_name,</if>
|
||
<if test="tenantId != null">tenant_id,</if>
|
||
</trim>
|
||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||
#{id},
|
||
<if test="name != null and name != ''">#{name},</if>
|
||
<if test="category != null">#{category},</if>
|
||
<if test="type != null">#{type},</if>
|
||
<if test="disasterDescription != null">#{disasterDescription},</if>
|
||
<if test="treatmentSuggestion != null">#{treatmentSuggestion},</if>
|
||
<if test="imgUrl != null and imgUrl != ''">#{imgUrl},</if>
|
||
<if test="disasterCount != null">#{disasterCount},</if>
|
||
<if test="disasterTime != null and disasterTime != ''">#{disasterTime},</if>
|
||
<if test="creator != null and creator != ''">#{creator},</if>
|
||
<if test="createTime != null">#{createTime},</if>
|
||
<if test="updater != null and updater != ''">#{updater},</if>
|
||
<if test="updateTime != null">#{updateTime},</if>
|
||
<if test="useStatus != null">#{useStatus},</if>
|
||
<if test="deleted != null">#{deleted},</if>
|
||
<if test="baseId != null">#{baseId},</if>
|
||
<if test="baseName != null">#{baseName},</if>
|
||
<if test="plotId != null">#{plotId},</if>
|
||
<if test="plotName != null">#{plotName},</if>
|
||
<if test="tenantId != null">#{tenantId},</if>
|
||
</trim>
|
||
|
||
</insert>
|
||
|
||
<select id="selectOne"
|
||
parameterType="cn.iocoder.yudao.module.farm.controller.admin.dict.vo.DisasterDataReqVO"
|
||
resultType="cn.iocoder.yudao.module.farm.dal.dataobject.disasterdata.DisasterDataDO">
|
||
|
||
SELECT <include refid="all_fields"/> FROM farm_disaster_data
|
||
<where>
|
||
<if test="id != null and id != ''">AND id = #{id}</if>
|
||
<if test="type != null and type != ''">AND type = #{type}</if>
|
||
<if test="name != null and name != ''">AND name = #{name}</if>
|
||
</where>
|
||
|
||
</select>
|
||
|
||
<select id="selectMore"
|
||
parameterType="cn.iocoder.yudao.module.farm.controller.admin.dict.vo.DisasterDataReqVO"
|
||
resultType="cn.iocoder.yudao.module.farm.dal.dataobject.disasterdata.DisasterDataDO">
|
||
SELECT <include refid="all_fields"/> FROM farm_disaster_data
|
||
<where>
|
||
<if test="id != null and id != ''">AND id = #{id}</if>
|
||
<if test="type != null and type != ''">AND type = #{type}</if>
|
||
<if test="name != null and name != ''">AND name = #{name}</if>
|
||
</where>
|
||
|
||
</select>
|
||
|
||
|
||
</mapper> |