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;
|
|
}
|
|
}
|
|
}
|