package com.education.api.controller.student;

import com.education.auth.annotation.Logical;
import com.education.auth.annotation.RequiresPermissions;
import com.education.business.service.education.StuHomeworkInfoService;
import com.education.common.base.BaseController;
import com.education.common.utils.Result;
import com.education.model.dto.StuHomeworkInfoDto;
import com.education.model.entity.StuHomeworkInfo;
import com.education.model.request.PageParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 学生作业管理
 */
@RequestMapping("/student/stuHomeworkInfo")
@RestController("student-stuHomeworkInfo")
public class StuHomeworkInfoController extends BaseController {

    @Resource
    private StuHomeworkInfoService stuHomeworkInfoService;

    /**
     * 提交作业
     * @param stuHomeworkInfo
     * @return
     */
    @PostMapping
    //@RequiresPermissions("student:stuHomeworkInfo:update")
    public Result submit(@RequestBody @Validated StuHomeworkInfo stuHomeworkInfo) {
        stuHomeworkInfoService.saveOrUpdate(stuHomeworkInfo);
        return Result.success();
    }

    /**
     * 学生作业信息分页列表
     * @param pageParam
     * @param stuHomeworkInfo
     * @return
     */
    @GetMapping
    //@RequiresPermissions("system:stuHomeworkInfo:list")
    public Result selectPage(PageParam pageParam, StuHomeworkInfo stuHomeworkInfo) {
        return Result.success(stuHomeworkInfoService.selectPageList(pageParam, stuHomeworkInfo));
    }


    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("{id}")
    //@RequiresPermissions("system:stuHomeworkInfo:deleteById")
    public Result deleteById(@PathVariable Integer id) {
        stuHomeworkInfoService.removeById(id);
        return Result.success();
    }
}