| | |
| | | package com.dsh.guns.modular.system.controller.code; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.course.feignClient.communityWorldCup.Model.Referee; |
| | | import com.dsh.course.feignClient.communityWorldCup.Model.RefereeList; |
| | | import com.dsh.course.feignClient.communityWorldCup.RefereeClient; |
| | | import com.dsh.guns.core.base.controller.BaseController; |
| | | import com.dsh.course.feignClient.account.RefereeClient; |
| | | import com.dsh.course.feignClient.account.model.Referee; |
| | | import com.dsh.course.feignClient.account.model.RefereeList; |
| | | import com.dsh.guns.modular.system.model.Region; |
| | | import com.dsh.guns.modular.system.service.IRegionService; |
| | | import com.dsh.guns.modular.system.util.ResultUtil; |
| | | import groovy.transform.AutoImplement; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 裁判管理 |
| | |
| | | @ResponseBody |
| | | @PostMapping("/addReferee") |
| | | public ResultUtil addReferee(Referee referee){ |
| | | Referee refereeByPhone = refereeClient.getRefereeByPhone(referee.getPhone()); |
| | | if(null != refereeByPhone){ |
| | | return ResultUtil.error("电话号码已使用"); |
| | | } |
| | | Region region = regionService.getOne(new QueryWrapper<Region>().eq("code", referee.getProvinceCode())); |
| | | referee.setProvince(region.getName()); |
| | | region = regionService.getOne(new QueryWrapper<Region>().eq("code", referee.getCityCode())); |
| | |
| | | refereeClient.addReferee(referee); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据id获取数据 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getReferee") |
| | | public Object getReferee(Integer id){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Referee referee = refereeClient.getRefereeById(id); |
| | | map.put("referee", referee); |
| | | List<Region> parent = regionService.list(new QueryWrapper<Region>().eq("parent_id", 0)); |
| | | map.put("province", parent); |
| | | Region region = regionService.getOne(new QueryWrapper<Region>().eq("code", referee.getProvinceCode())); |
| | | List<Region> citys = regionService.list(new QueryWrapper<Region>().eq("parent_id", region.getId())); |
| | | map.put("city", citys); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改裁判数据 |
| | | * @param referee |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/editReferee") |
| | | public ResultUtil editReferee(Referee referee){ |
| | | Referee refereeByPhone = refereeClient.getRefereeByPhone(referee.getPhone()); |
| | | if(null != refereeByPhone && !referee.getId().equals(refereeByPhone.getId())){ |
| | | return ResultUtil.error("电话号码已使用"); |
| | | } |
| | | Region region = regionService.getOne(new QueryWrapper<Region>().eq("code", referee.getProvinceCode())); |
| | | referee.setProvince(region.getName()); |
| | | region = regionService.getOne(new QueryWrapper<Region>().eq("code", referee.getCityCode())); |
| | | referee.setCity(region.getName()); |
| | | refereeClient.editReferee(referee); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改状态 |
| | | * @param id |
| | | * @param state |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/updateState") |
| | | public ResultUtil updateState(Integer id, Integer state){ |
| | | Referee referee = new Referee(); |
| | | referee.setState(state); |
| | | referee.setId(id); |
| | | refereeClient.editReferee(referee); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | } |