package com.chinaweal.aiccs.crgs.punish.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chinaweal.aiccs.common.base.controller.BaseController;
import com.chinaweal.aiccs.crgs.punish.entity.TbIlcPunInfoQuery;
import com.chinaweal.aiccs.crgs.punish.service.TbIlcPunInfoQueryService;
import com.chinaweal.youfool.framework.springboot.rest.RestResult;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sh
 * @since 2022-05-26
 */
@RestController
@RequestMapping("/tbIlcPunInfoQuery")
public class TbIlcPunInfoQueryController extends BaseController {

    @Autowired
    TbIlcPunInfoQueryService tbIlcPunInfoQueryService;

    @RequestMapping("queryById")
    public RestResult<?> queryById(@RequestParam String id) {
        TbIlcPunInfoQuery tbIlcPunInfoQuery = tbIlcPunInfoQueryService.getById(id);
        return RestResult.ok(tbIlcPunInfoQuery);
    }

    @RequestMapping("queryForList")
    public RestResult<?> queryForList(@RequestParam @ApiParam("sbookcode") String sbookcode,
                                      @RequestParam @ApiParam("dsrmc") String dsrmc) {
        LambdaQueryWrapper wrapper = new LambdaQueryWrapper<TbIlcPunInfoQuery>()
                .like(StringUtils.isNotBlank(sbookcode), TbIlcPunInfoQuery::getSbookcode, sbookcode)
                .like(StringUtils.isNotBlank(dsrmc), TbIlcPunInfoQuery::getDsrmc, dsrmc);
        Page<TbIlcPunInfoQuery> page = tbIlcPunInfoQueryService.page(new Page<>(0, 5,false), wrapper);
        return RestResult.ok(page.getRecords());
    }
}

