package cn.teammodel.controller.admin.controller;

import cn.teammodel.common.R;
import cn.teammodel.controller.admin.service.AdminAppraiseService;
import cn.teammodel.model.dto.admin.appraise.UpdateAchievementRuleDto;
import cn.teammodel.model.entity.appraise.AchievementRule;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

/**
 * @author winter
 * @create 2023-12-13 16:07
 */
@RestController
@RequestMapping("admin/appraise")
@Api(tags = "管理员端-学生评价管理")
public class AdminAppraiseController {
    @Resource
    private AdminAppraiseService adminAppraiseService;

    @PostMapping("updateAchieveRule")
    @ApiOperation("更新的 rule 节点将会直接覆盖老节点")
    public R<List<AchievementRule>> updateAchieveRule(@RequestBody @Valid UpdateAchievementRuleDto ruleDto) {
        List<AchievementRule> res = adminAppraiseService.updateAchieveRule(ruleDto);
        return R.success(res);
    }

    @GetMapping("getAchieveRules/{periodId}")
    @ApiOperation("获取当前学段下的成就规则")
    public R<List<AchievementRule>> getAchieveRules(@PathVariable String periodId){
        List<AchievementRule> res = adminAppraiseService.getAchieveRules(periodId);
        return R.success(res);
    }
}
