xiangpei
2025-05-14 47cd9ecc0eff38ffe6b3b794b2bf197e958f4403
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.mindskip.xzs.controller.student;
 
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.domain.vo.SelfPracticeVO;
import com.mindskip.xzs.service.SelfPracticeService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.constraints.NotEmpty;
import java.util.List;
 
/**
 * @author:xp
 * @date:2024/5/9 16:17
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/api/student/self/practice")
public class SelfPracticeController {
 
    private final SelfPracticeService selfPracticeService;
 
    @PostMapping
    public RestResponse add(@RequestBody @Validated SelfPracticeVO vo) {
        return selfPracticeService.add(vo);
    }
 
    @GetMapping("/page")
    public RestResponse page(SelfPracticeVO vo) {
        return selfPracticeService.page(vo);
    }
 
    @PostMapping("/remove")
    public RestResponse remove(@RequestBody @NotEmpty(message = "请选择要删除的数据") List<Integer> ids) {
        return selfPracticeService.remove(ids);
    }
 
    /**
     * 开始练习
     *
     * @param id 练习id
     * @return
     */
    @PostMapping("/start/{id}")
    public RestResponse startPractice(@PathVariable("id") Integer id) {
        return selfPracticeService.startPractice(id);
    }
 
    /**
     * 开始看题
     *
     * @param id 练习id
     * @return
     */
    @PostMapping("/start/look/{id}")
    public RestResponse startLook(@PathVariable("id") Integer id) {
        return selfPracticeService.startLook(id);
    }
 
    /**
     * 随机一道题
     *
     * @param id
     * @return
     */
    @GetMapping("/random/{id}")
    public RestResponse randomOneQuestion(@PathVariable("id") Integer id) {
        return selfPracticeService.randomOneQuestion(id);
    }
 
}