mybatisplus sql查询 TableField typeHandler

<resultMap id="getListByUserMap" type="com.race.domain.UserFormEntity">
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="formKey" column="form_key" jdbcType="VARCHAR"/>
        <result property="sourceType" column="source_type" jdbcType="VARCHAR"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="description" column="description" jdbcType="VARCHAR"/>
        <result property="type" column="type" jdbcType="VARCHAR"/>


        <result property="status" column="status" jdbcType="INTEGER"/>
        <result property="confirm" column="confirm" jdbcType="INTEGER"/>
        <result property="beginDate" column="begin_date" jdbcType="TIMESTAMP"/>
        <result property="endDate" column="end_date" jdbcType="TIMESTAMP"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="zrqdm" column="zrqdm" jdbcType="VARCHAR"/>
        <result property="zrqmc" column="zrqmc" jdbcType="VARCHAR"/>
        <result property="tableDatasourceId" column="table_datasource_id" jdbcType="VARCHAR"/>
        <result property="priorityLevel" column="priority_level" jdbcType="INTEGER"/>
        <result property="completeTime" column="complete_time" jdbcType="TIMESTAMP"/>
        <result property="reviewStatus" column="review_status" jdbcType="INTEGER"/>


        <result property="excelHeadNames"
                column="excel_head_names"
                typeHandler="com.race.handler.JacksonTypeHandler" jdbcType="VARCHAR"/>

        <result property="tableData"
                column="table_data"
                typeHandler="com.race.handler.JacksonTypeHandler" jdbcType="VARCHAR"/>
        <result property="desFormDesignJson"
                column="des_form_design_json"
                typeHandler="com.race.handler.JacksonTypeHandler" jdbcType="VARCHAR"/>

    </resultMap>
    <select id="getListByUser"
            resultMap="getListByUserMap">
        select a.id,a.form_key,a.source_type,a.name,a.description,a.type,
               a.`status`,a.begin_date,a.end_date,a.create_time,a.zrqdm,a.zrqmc,a.table_datasource_id,
               a.priority_level,a.complete_time,a.review_status,
               a.excel_head_names,
               a.table_data,a.des_form_design_json,a.confirm

        from fm_user_form a
        where a.is_deleted='0' and a.review_status='1'

        <if test="myType != null and myType != ''">
            <if test="myType == 1">
                and zrqdm like CONCAT(#{zrqbm}, '%')
            </if>
            <if test="myType == 2">
                and a.source_id = #{userId}
            </if>
        </if>
        <if test="formState != null and formState != ''">
            and a.type = #{formState}
        </if>
        <if test="formType != null and formType != ''">
            <if test="formType == 1">
                and a.status = '1'
            </if>
            <if test="formType == 2">
                and  end_date &lt;=  CURDATE() + INTERVAL 1 DAY and end_date &gt;= CURDATE()
            </if>
            <if test="formType == 3">
                and a.status = '5'
            </if>
            <if test="formType == 4">
                and a.status = '2'
            </if>
        </if>


        GROUP BY a.task_id
        ORDER BY a.create_time desc
    </select>

对应的实体类


import cn.hutool.core.date.DatePattern;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.race.common.core.enums.*;
import com.race.common.core.utils.validator.group.AddGroup;
import com.race.common.core.utils.validator.group.ExamineGroup;
import com.race.common.core.utils.validator.group.UpdateGroup;
import com.race.entity.FormBaseEntity;
import com.race.entity.UserFormLogicEntity;
import com.race.handler.BooleanTypeHandler;
import com.race.handler.JacksonTypeHandler;
import com.race.utils.HtmlUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldNameConstants;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 用户表单表(Form)表实体类
 *
 * @author zxs
 * @since 2024-05-24 18:16:16
 */
@Data
@FieldNameConstants
@TableName(value = "fm_user_form", autoResultMap = true)
public class UserFormEntity extends FormBaseEntity<UserFormEntity> {
    /**
     * 表单code
     */
    @NotBlank(message = "错误请求", groups = {UpdateGroup.class})
    private String formKey;

    @TableField(value = "task_id")
    private String taskId;

    /**
     * 表单名称
     */
    @NotBlank(message = "任务名称不能为空", groups = {AddGroup.class, UpdateGroup.class, ExamineGroup.class})
    private String name;
    /**
     * 表单描述
     */
    private String description;

    /**
     * 表单来源
     */
    private FormSourceTypeEnum sourceType;

    /**
     * 来源ID
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private String sourceId;

    /**
     * 用户ID
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private String userId;

    /***
     * 状态
     */
    private FormStatusEnum status;
    /**
     * 表单类型
     */
    private FormTypeEnum type;

    /**
     * 是否签收0否,1是
     */
    @TableField(value = "confirm")
    private String confirm;

    /**
     * 审核状态
     */
    @TableField(value = "review_status")
    @NotNull(message = "审核状态不能为空", groups = {ExamineGroup.class})
    private FormReviewStatusEnum reviewStatus;

    /**
     * 任务优先级
     */
    private FormLevelEnum priorityLevel;

    @TableField(value = "is_deleted", typeHandler = BooleanTypeHandler.class)
    private Boolean deleted;

    /**
     * 是否是文件夹
     */
    @TableField(value = "is_folder", typeHandler = BooleanTypeHandler.class)
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Boolean folder;
    /**
     * 父级文件夹ID
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Long folderId;

    /**
     * 任务开始时间
     **/
    @TableField(value = "begin_date")
    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @NotNull(message = "任务开始时间不能为空")
    private LocalDateTime beginDate;

    /**
     * 任务结束时间
     **/
    @TableField(value = "end_date")
    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @NotNull(message = "任务结束时间不能为空")
    private LocalDateTime endDate;

    /**
     * 责任单位代码
     */
    private String zrqdm;

    /**
     * 责任单位名称
     */
    private String zrqmc;

    @TableField(value = "table_datasource_id")
    @NotBlank(message = "数据源id不能为空", groups = {ExamineGroup.class})
    private String tableDatasourceId;

    @TableField(value = "excel_head_names", typeHandler = JacksonTypeHandler.class)
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<Map<String, Object>> excelHeadNames;

    @TableField(value = "table_data", typeHandler = JacksonTypeHandler.class)
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Map<String, Object> tableData;

    @TableField(exist = false, typeHandler = JacksonTypeHandler.class)
    @NotNull(message = "数据源tableData不能为空")
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<Map<String, Object>> tableDataList;

    @TableField(value="des_form_design_json", typeHandler = JacksonTypeHandler.class)
    @NotNull(message = "反馈单不能为空")
    private Map<String, Object> desFormDesignJson;

    @TableField(exist = false, typeHandler = JacksonTypeHandler.class)
    private List<UserFormLogicEntity.Definition> scheme;

    /**
     * 派发策略
     */
    @TableField(value = "distribution_type")
    private String distributionType;

    /**
     * 派发策略对应字段
     */
    @TableField(value = "distribution_column")
    private String distributionColumn;

    @TableField(value = "feedback_column")
    private String feedbackColumn;

    @TableField(exist = false)
    private String finishNum;

    @TableField(exist = false)
    private String unFinishNum;

    @TableField(exist = false)
    private String unConfirmNum;

    @TableField(exist = false)
    private String returnNum;

    @TableField(value = "complete_time")
    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime completeTime;

    /**
     * 移除html标签
     * @return 文本
     */
    public String getTextName() {
        if (StrUtil.isBlank(name)) {
            return null;
        }
        // 标题是富文本 去除html 标签
        return HtmlUtils.cleanHtmlTag(name);
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值