package com.jeequan.jeepay.mch.ctrl.payconfig;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.db.entity.QualificationDefineEntity;
import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
import com.jeequan.jeepay.service.impl.QualificationDefineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/api/qualificationDefine")
@RestController
public class QualificationDefineController extends CommonCtrl {

    @Autowired
    private QualificationDefineService qualificationDefineService;

    @GetMapping("/page")
    public ApiRes page() {
        Page<QualificationDefineEntity> iPage = getIPage(false);
        QualificationDefineEntity condition = getObject(QualificationDefineEntity.class);
        qualificationDefineService.lambdaQuery().setEntity(condition).page(iPage);

        return ApiRes.ok(iPage);
    }

    @GetMapping("/{code}")
    public ApiRes one(@PathVariable String code) {
        QualificationDefineEntity one = qualificationDefineService.lambdaQuery().eq(QualificationDefineEntity::getCode, code).one();
        return ApiRes.ok(one);
    }
}
