SpringBoot 后端请求-万能参数

知识点:

1、Java返回JSON的时间格式

/** 操作时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date oper_time;

2、Bean万能参数,在实体之外加一个Key,Value的参数

/** 请求参数 */
private Map<String, Object> params;

3、前端请求的日期格式化

this.loading = true;
if (this.queryForm.operTime.length == 2) {
    this.queryForm.params.beginTime = this.queryForm.operTime[0].format('YYYY-MM-DD')
    this.queryForm.params.endTime = this.queryForm.operTime[1].format('YYYY-MM-DD')
} else {
    this.queryForm.params.beginTime = ""
    this.queryForm.params.endTime = ""
}

//合并查询对象和分页对象
getOperLogList(Object.assign(this.queryForm, this.tablePage))

4、Mybits的使用

<select id="selectOperLogList" parameterType="com.java.core.entity.master.SysOperLog" resultType="com.java.core.entity.master.SysOperLog">
        select * from sys_oper_log o
        where 1=1
        <if test="title != null and title != ''">
            AND o.title like concat('%', #{title}, '%')
        </if>
        <if test="oper_user_name != null and oper_user_name != ''">
            AND o.oper_user_name like concat('%', #{oper_user_name}, '%')
        </if>
        <if test="business_type != null and business_type != ''">
            AND o.business_type = #{business_type}
        </if>
        <if test="status != null and status != ''">
            AND o.status = #{status}
        </if>
        <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
            and date_format(o.oper_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
        </if>
        <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
            and date_format(o.oper_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
        </if>
    </select>

5、后端接收

@ApiOperation(value = "分页查询信息")
    @Log(title = "系统配置信息", businessType = BusinessType.GET)
    @PreAuthorize("hasAuthority('sys:oper_log:get')")
    @GetMapping(value = "/getOperLogList")
    public HttpResult getOperLogList(SysOperLog operLog){
        this.startPage();
        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
        TableDataInfo dataInfo = this.getDataTable(list);
        return HttpResult.ok(dataInfo.getRows(),dataInfo.getTotal());
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值