44323
2023-11-27 aa925d851857f50eff0556411366690d9a78a0e5
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.dsh.account.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.account.entity.Coach;
import com.dsh.account.entity.CoachType;
import com.dsh.account.service.CoachService;
import com.dsh.account.service.CoachTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * 教练类型
 */
@RestController
@RequestMapping("")
public class CoachTypeController {
 
    @Autowired
    private CoachService service;
    @Autowired
    private CoachTypeService typeService;
 
    /**
     * 根据门店
     *
     * @param
     * @return
     */
    @ResponseBody
    @PostMapping("/coachType/list")
    public List<CoachType> list() {
 
        return typeService.list(new QueryWrapper<CoachType>().ne("state", 3));
    }
 
    /**
     * 新增教练类型
     *
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping("/coachType/add")
    public Object add(@RequestBody String name) {
 
        List<CoachType> list = typeService.list(new QueryWrapper<CoachType>().eq("name", name));
        if (list.size() != 0) {
            return 500;
        } else {
            CoachType coachType = new CoachType();
            coachType.setName(name);
            coachType.setState(1);
            typeService.save(coachType);
            return 200;
        }
    }
 
    /**
     * 删除教练类型
     *
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping("/coachType/delete")
    public Object delete(@RequestBody Integer id) {
        CoachType coachType = new CoachType();
        coachType.setId(id);
        coachType.setState(3);
        return typeService.updateById(coachType);
    }
 
    /**
     * 修改教练类型
     *
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping("/coachType/update")
    public Object update(@RequestBody CoachType coachType) {
        List<CoachType> list = typeService.list(new QueryWrapper<CoachType>().eq("name", coachType.getName()));
        if (list.size() != 0) {
            return 500;
        } else {
            typeService.updateById(coachType);
            return 200;
 
        }
 
    }
 
}