puzhibing
2023-06-13 7860e5cb6db60aeb82c640651998f8294635df5b
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
package com.dsh.course.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.course.entity.City;
import com.dsh.course.model.vo.CityReq;
import com.dsh.course.model.vo.CityRes;
import com.dsh.course.service.ICityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
 
@RestController
@RequestMapping("/city")
public class CityController {
 
    @Autowired
    private ICityService cityService;
 
 
    /**
     * 远程调用
     * @return
     */
    @PostMapping("/queryList")
    public CityRes queryList(CityReq req){
        CityRes res = new CityRes();
        try {
            QueryWrapper<City> wrapper = new QueryWrapper<>();
            if(req.getLanguage() == 1){//中文
                wrapper.in("chineseName", req.getCitys());
            }
            if(req.getLanguage() == 2){//英文
                wrapper.in("englishName", req.getCitys());
            }
            if(req.getLanguage() == 3){//印尼文
                wrapper.in("indonesianName", req.getCitys());
            }
            res.setCities(cityService.list(wrapper));
        }catch (Exception e){
            e.printStackTrace();
        }
        return res;
    }
}