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) >= #{req.startTime} and DATE(create_time) <= #{req.endTime}
</if>
</where>
order by create_time desc
</select>
本文介绍了一个DTO类中状态描述的映射方法,并展示了如何通过switch-case结构将数据库中的状态值转换为描述性的字符串。此外,还提供了一种使用MyBatis进行复杂条件查询的例子,包括时间格式化和字段搜索。
2104

被折叠的 条评论
为什么被折叠?



