package com.xjrsoft.module.banding.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.xjrsoft.common.model.result.RT;
import com.xjrsoft.module.banding.dto.BandingTaskMajorConditionListDto;
import com.xjrsoft.module.banding.dto.SaveMajorConditionDto;
import com.xjrsoft.module.banding.service.IBandingTaskMajorConditionService;
import com.xjrsoft.module.banding.vo.BandingTaskMajorConditionListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
* @title: 新生分班任务
* @Author dzx
* @Date: 2024-07-01
* @Version 1.0
*/
@RestController
@RequestMapping("/banding" + "/bandingTaskMajorCondition")
@Api(value = "/banding"  + "/bandingTaskMajorCondition",tags = "新生分班任务专业限制条件代码")
@AllArgsConstructor
public class BandingTaskMajorConditionController {


    private final IBandingTaskMajorConditionService conditionService;

    @GetMapping(value = "/list")
    @ApiOperation(value="专业限制条件列表")
    @SaCheckPermission("bandingtaskmajorcondition:detail")
    public RT<List<BandingTaskMajorConditionListVo>> page(@Valid BandingTaskMajorConditionListDto dto){
        List<BandingTaskMajorConditionListVo> page = conditionService.getList(dto);
        return RT.ok(page);
    }


    @PostMapping("save")
    @ApiOperation(value = "保存")
    @SaCheckPermission("bandingtaskmajorcondition:save")
    public RT<Boolean> add(@Valid @RequestBody SaveMajorConditionDto dto){
        boolean isSuccess = conditionService.save(dto);
        return RT.ok(isSuccess);
    }
}