后台的东西

本文介绍了一个DTO类中状态描述的映射方法,并展示了如何通过switch-case结构将数据库中的状态值转换为描述性的字符串。此外,还提供了一种使用MyBatis进行复杂条件查询的例子,包括时间格式化和字段搜索。

dto的Rsp的导出时,数据库存储不同状态,1为好,2为坏,3为不好,等等

public String getStatusDesc() {
    if (status != null) {
        switch (status) {
            case 0:
                return "好";
            case 1:
                return "坏";
            case 2:
                return "不好";
        }
    }
    return "";
}

 

导出时时间的转换注解

@Excel(name = "时间", orderNum = "0", isImportField = "true", exportFormat = "yyyy-MM-dd HH:mm:ss", importFormat = "yyyy-MM-dd HH:mm:ss", databaseFormat = "yyyy-MM-dd HH:mm:ss")

 

 

强大的mapping搜索方法

<mapper namespace="com.chongxuan.web.common.dao.xxMapper">


    <select id="findList" resultType="com.chongxuan.web.common.dto.vo.xx.Rspxx">
        select *
        from table_name
        <where>
            <if test="req.user_name != null and req.user_name != ''">
                and user_name = #{req.user_name} or user_id = #{req.user_name}
            </if>
            <if test="req.startTime != null and req.startTime !=''">
                and DATE(create_time) &gt;=  #{req.startTime} and DATE(create_time) &lt;=  #{req.endTime}
            </if>
        </where>
        order by create_time desc
    </select>

 

 

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值