package com.trs.ggzyexchange.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.trs.ggzyexchange.api.vo.Result;
import com.trs.ggzyexchange.entity.XyInfo;
import com.trs.ggzyexchange.service.XyInfoService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

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

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 信用信息 前端控制器
 * </p>
 *
 * @author trs
 * @since 2023-12-27
 */
@RestController
@RequestMapping("/xy-info")
public class XyInfoController extends BaseController {

    @Autowired
    private XyInfoService xyInfoService;

    @GetMapping(value = "/list")
    public Result<IPage<XyInfo>> queryPageList(
            @RequestParam(name="empName",required=false) String empName,
            @RequestParam(name="empCode",required=false) String empCode,
            @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
            @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                               HttpServletRequest req) {
        QueryWrapper<XyInfo> queryWrapper = new QueryWrapper<XyInfo>();
        if(!ObjectUtils.isEmpty(empName) && empName != ""){
            queryWrapper.like("emp_name",empName);
        }
        if(!ObjectUtils.isEmpty(empCode) && empCode != ""){
            queryWrapper.like("emp_code",empCode);
        }
        Page<XyInfo> page = new Page<XyInfo>(pageNo, pageSize);
        IPage<XyInfo> pageList = xyInfoService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
}
