puzhibing
2024-03-02 48f8fffb3df2d8fd77c0a52df0e56e04eb5931ae
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
package com.dsh.guns.modular.system.controller.code;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 裁判管理
 * @author zhibing.pu
 * @Date 2024/3/1 14:08
 */
@Controller
@RequestMapping("/referee")
public class RefereeController {
 
    private String PREFIX = "/system/referee/";
 
    @Resource
    private RefereeClient refereeClient;
 
    @Autowired
    private IRegionService regionService;
 
 
 
 
    @RequestMapping("")
    public String showList(){
        return PREFIX + "referee.html";
    }
 
 
    /**
     * 获取列表数据
     * @param refereeList
     * @return
     */
    @ResponseBody
    @PostMapping("/listAll")
    public Object listAll(RefereeList refereeList){
        return refereeClient.getRefereeList(refereeList);
    }
 
 
    /**
     * 添加数据
     * @param referee
     * @return
     */
    @ResponseBody
    @PostMapping("/addReferee")
    public ResultUtil addReferee(Referee referee){
        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.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;
    }
}