mapper.core.BaseDataMapper.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ape-core Show documentation
Show all versions of ape-core Show documentation
Ape low code platform core module
The newest version!
<?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.ape9527.core.mapper.BaseDataMapper"> <insert id="insert"> INSERT INTO ${objectCode} ( uuid, create_time, update_time, del, <foreach collection="fields" item="field" separator=","> <if test="field.fieldCode!=null and field.fieldCode!='' and field.fieldCode!='uuid' and field.fieldCode!='create_time' and field.fieldCode!='update_time' and field.fieldCode!='del' "> `${field.fieldCode}` </if> </foreach> ) VALUE ( REPLACE(UUID(),'-',''),NOW(),NOW(),0, <foreach collection="fields" item="field" separator=","> <if test="field.fieldCode!=null and field.fieldCode!=''and field.fieldCode!='uuid' and field.fieldCode!='create_time' and field.fieldCode!='update_time' and field.fieldCode!='del' "> #{field.value} </if> </foreach> ) </insert> <update id="update"> UPDATE ${objectCode} SET update_time = NOW(), <foreach collection="fields" item="field" separator=","> <if test="field.fieldCode!=null and field.fieldCode!='' and field.fieldCode!='uuid' and field.fieldCode!='create_time' and field.fieldCode!='update_time' and field.fieldCode!='del' "> `${field.fieldCode}` = #{field.value} </if> </foreach> WHERE 1 = 1 <foreach collection="conditions" item="condition"> <choose> <when test='(condition.operator == "in" or condition.operator == "not in") and condition.value != null and condition.value.size() > 0'> AND ${objectCode}.`${condition.fieldCode}` ${condition.operator} <foreach collection="condition.value" item="val" separator="," open="(" close=")"> #{val} </foreach> </when > <when test='condition.operator == "is null" or condition.operator == "is not null"'> AND ${objectCode}.`${condition.fieldCode}` ${condition.operator} </when > <otherwise> AND ${objectCode}.`${condition.fieldCode}` ${condition.operator} #{condition.value} </otherwise> </choose> </foreach> </update> <delete id="del"> UPDATE ${objectCode} SET del = 1 WHERE 1 = 1 <foreach collection="conditions" item="condition"> <choose> <when test='(condition.operator == "in" or condition.operator == "not in") and condition.value != null and condition.value.size() > 0'> AND ${objectCode}.`${condition.fieldCode}` ${condition.operator} <foreach collection="condition.value" item="val" separator="," open="(" close=")"> #{val} </foreach> </when > <when test='condition.operator == "is null" or condition.operator == "is not null"'> AND ${objectCode}.`${condition.fieldCode}` ${condition.operator} </when > <otherwise> AND ${objectCode}.`${condition.fieldCode}` ${condition.operator} #{condition.value} </otherwise> </choose> </foreach> </delete> <select id="selectList" resultType="java.util.Map"> SELECT <if test="selectFields != null and selectFields.size() > 0"> <foreach collection="selectFields" item="selectField" separator=","> ${objectCode}.`${selectField}` </foreach> <if test="correlatedBaseObjs != null and correlatedBaseObjs.size() > 0"> <foreach collection="correlatedBaseObjs" item="correlatedBaseObj" separator="," open=","> ${correlatedBaseObj.correlatedBaseObj}.`${correlatedBaseObj.selectField}` </foreach> </if> </if> <if test="selectFields == null or selectFields.size() == 0"> * </if> FROM ${objectCode} AS ${objectCode} <if test="correlatedBaseObjs != null and correlatedBaseObjs.size() > 0"> <foreach collection="correlatedBaseObjs" item="correlatedBaseObj"> LEFT JOIN ${correlatedBaseObj.correlatedBaseObj} AS ${correlatedBaseObj.correlatedBaseObj} ON ${objectCode}.`${correlatedBaseObj.fieldCode}` = ${correlatedBaseObj.correlatedBaseObj}.`${correlatedBaseObj.correlatedBaseObjField}` </foreach> </if> WHERE ${objectCode}.`del` = 0 <if test="correlatedBaseObjs != null and correlatedBaseObjs.size() > 0"> <foreach collection="correlatedBaseObjs" item="correlatedBaseObj"> AND (${correlatedBaseObj.correlatedBaseObj}.`del` is null or ${correlatedBaseObj.correlatedBaseObj}.`del` = 0) </foreach> </if> <foreach collection="conditions" item="condition"> <choose> <when test='(condition.operator == "in" or condition.operator == "not in") and condition.value != null and condition.value.size() > 0'> AND ${objectCode}.`${condition.fieldCode}` ${condition.operator} <foreach collection="condition.value" item="val" separator="," open="(" close=")"> #{val} </foreach> </when > <when test='condition.operator == "is null" or condition.operator == "is not null"'> AND ${objectCode}.`${condition.fieldCode}` ${condition.operator} </when > <otherwise> AND ${objectCode}.`${condition.fieldCode}` ${condition.operator} #{condition.value} </otherwise> </choose> </foreach> <if test="sorts != null and sorts.size() > 0"> ORDER BY <foreach collection="sorts" item="sort"> ${objectCode}.`${sort.fieldCode}` ${sort.sortType} </foreach> </if> </select> <select id="selectById" resultType="java.util.Map"> SELECT <if test="selectFields != null and selectFields.size() > 0"> <foreach collection="selectFields" item="field" separator=","> ${objectCode}.${field} </foreach> <if test="correlatedBaseObjs != null and correlatedBaseObjs.size() > 0"> <foreach collection="correlatedBaseObjs" item="correlatedBaseObj" separator="," open=","> ${correlatedBaseObj.correlatedBaseObj}.${correlatedBaseObj.selectField} </foreach> </if> </if> <if test="selectFields == null or selectFields.size() == 0"> * </if> FROM ${objectCode} AS ${objectCode} <if test="correlatedBaseObjs != null and correlatedBaseObjs.size() > 0"> <foreach collection="correlatedBaseObjs" item="correlatedBaseObj"> LEFT JOIN ${correlatedBaseObj.correlatedBaseObj} AS ${correlatedBaseObj.correlatedBaseObj} ON ${objectCode}.${correlatedBaseObj.fieldCode} = ${correlatedBaseObj.correlatedBaseObj}.${correlatedBaseObj.correlatedBaseObjField} </foreach> </if> WHERE ${objectCode}.del = 0 AND ${objectCode}.uuid = #{uuid} </select> <select id="selectOne" resultType="java.util.Map"> SELECT <if test="selectFields != null and selectFields.size() > 0"> <foreach collection="selectFields" item="field" separator=","> ${objectCode}.${field} </foreach> <if test="correlatedBaseObjs != null and correlatedBaseObjs.size() > 0"> <foreach collection="correlatedBaseObjs" item="correlatedBaseObj" separator="," open=","> ${correlatedBaseObj.correlatedBaseObj}.${correlatedBaseObj.selectField} </foreach> </if> </if> <if test="selectFields == null or selectFields.size() == 0"> * </if> FROM ${objectCode} AS ${objectCode} <if test="correlatedBaseObjs != null and correlatedBaseObjs.size() > 0"> <foreach collection="correlatedBaseObjs" item="correlatedBaseObj"> LEFT JOIN ${correlatedBaseObj.correlatedBaseObj} AS ${correlatedBaseObj.correlatedBaseObj} ON ${objectCode}.${correlatedBaseObj.fieldCode} = ${correlatedBaseObj.correlatedBaseObj}.${correlatedBaseObj.correlatedBaseObjField} </foreach> </if> WHERE ${objectCode}.del = 0 <foreach collection="conditions" item="condition"> <choose> <when test='condition.operator == "in" and condition.operator == "not in" and condition.value != null and condition.value.size() > 0'> AND ${objectCode}.`${condition.fieldCode}` ${condition.operator} <foreach collection="condition.value" item="val" separator="," open="(" close=")"> #{val} </foreach> </when > <when test='condition.operator == "is null" and condition.operator == "is not null"'> AND ${objectCode}.`${condition.fieldCode}` ${condition.operator} </when > <otherwise> AND ${objectCode}.`${condition.fieldCode}` ${condition.operator} #{condition.value} </otherwise> </choose> </foreach> <if test="sorts != null and sorts.size() > 0"> ORDER BY <foreach collection="sorts" item="sort"> ${objectCode}.${sort.fieldCode} ${sort.sortType} </foreach> </if> LIMIT 1 </select> <select id="selectUuid" resultType="java.lang.String"> select REPLACE(UUID(), '-', '') </select> </mapper>