package com.education.api.controller.student;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.education.business.service.education.GradeInfoService;
import com.education.common.base.BaseController;
import com.education.common.model.PageInfo;
import com.education.common.utils.ObjectUtils;
import com.education.common.utils.Result;
import com.education.model.entity.GradeInfo;
import com.education.model.request.PageParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zengjintao
 * @version 1.0
 * @create_at 2020/11/22 9:45
 */
@RestController("student-gradeInfo")
@RequestMapping("/student/gradeInfo")
public class GradeInfoController extends BaseController {

    @Resource
    private GradeInfoService gradeInfoService;

    @GetMapping("/list")
    //@RequiresPermissions("system:grade:list")
    public Result<PageInfo<GradeInfo>> list(PageParam pageParam, GradeInfo gradeInfo) {
        LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(GradeInfo.class)
                .like(ObjectUtils.isNotEmpty(gradeInfo.getName()), GradeInfo::getName, gradeInfo.getName())
                .eq(ObjectUtils.isNotEmpty(gradeInfo.getSchoolType()),
                        GradeInfo::getSchoolType, gradeInfo.getSchoolType());
        return Result.success(gradeInfoService.selectPage(pageParam, queryWrapper));
    }
}
