Commit b4f8f87f authored by shangtx's avatar shangtx

feat: 根据参数注解自动生成sql where条件方法

parent c1bb377f
......@@ -19,10 +19,10 @@ import java.time.LocalDateTime;
public class BaseErrorDTO extends PageParams {
@ApiModelProperty("开始结束时间")
@FieldCondition(column = "create_time", rel = ConditionEnum.LTEQ)
@FieldCondition(column = "create_time", rel = ConditionEnum.GTEQ)
private LocalDateTime createTimeBegin;
@FieldCondition(column = "create_time", rel = ConditionEnum.GTEQ)
@FieldCondition(column = "create_time", rel = ConditionEnum.LTEQ)
private LocalDateTime createTimeEnd;
@FieldCondition
......
package com.onsiteservice.admin.mapper.base;
import com.onsiteservice.admin.controller.base.dto.BaseErrorDTO;
import com.onsiteservice.common.annotation.sql.AutoCondition;
import com.onsiteservice.dao.common.page.PageParams;
import org.apache.ibatis.annotations.Param;
......@@ -18,5 +19,5 @@ public interface BaseErrorLogBizMapper {
* 分页查询列表
*/
@AutoCondition
List<Map> getPage(@Param("param") PageParams param);
List<Map> getPage(@Param("param") BaseErrorDTO param);
}
package com.onsiteservice.admin.service.base;
import com.github.pagehelper.PageHelper;
import com.onsiteservice.admin.controller.base.dto.BaseErrorDTO;
import com.onsiteservice.admin.mapper.base.BaseErrorLogBizMapper;
import com.onsiteservice.dao.common.AbstractMapper;
import com.onsiteservice.dao.common.page.PageInfoVO;
......@@ -26,7 +27,7 @@ public class BaseErrorLogService extends AbstractMapper<BaseErrorLog> {
/**
* 分页查询列表
*/
public PageInfoVO getPage(PageParams param) {
public PageInfoVO getPage(BaseErrorDTO param) {
PageHelper.startPage(param.getPage(), param.getSize());
return new PageInfoVO(baseErrorLogBizMapper.getPage(param));
}
......
......@@ -7,6 +7,26 @@
select t1.*
from base_error_log t1
<where>
<!-- <if test="param.projectName != null and param.projectName != '' ">
and t1.project_name like "%"#{param.projectName}"%"
</if>
<if test="param.environment != null and param.environment != '' ">
and t1.environment like "%"#{param.environment}"%"
</if>
<if test="param.errorCode != null and param.errorCode != '' ">
and t1.error_code like "%"#{param.errorCode}"%"
</if>
<if test="param.platform != null and param.platform != '' ">
and t1.platform like "%"#{param.platform}"%"
</if>
<if test="param.createTime != null and param.createTime.length == 2 ">
and t1.create_time <![CDATA[>]]> #{param.createTime[0]}
and t1.create_time <![CDATA[<=]]> #{param.createTime[1]}
</if>-->
<include refid="com.onsiteservice.dao.mapper.base.CommonSnippet.condition">
<property name="param" value="param"/>
</include>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment