|
@@ -9,6 +9,8 @@ import com.miaxis.common.core.domain.Response;
|
|
|
import com.miaxis.common.core.page.ResponsePageInfo;
|
|
|
import com.miaxis.common.utils.ServletUtils;
|
|
|
import com.miaxis.common.utils.ip.IpUtils;
|
|
|
+import com.miaxis.dict.domain.DictCity;
|
|
|
+import com.miaxis.dict.service.IDictCityService;
|
|
|
import com.miaxis.exam.domain.ExamInfo;
|
|
|
import com.miaxis.exam.service.IExamInfoService;
|
|
|
import com.miaxis.exam.vo.ExamInfoCityVo;
|
|
@@ -35,24 +37,28 @@ import java.util.Map;
|
|
|
* @date 2023-03-20
|
|
|
*/
|
|
|
@RestController
|
|
|
-@RequestMapping(Constants.STUDENT_PREFIX+"/exam/info")
|
|
|
-@Api(tags={"【APP-考场信息】"})
|
|
|
-public class ExamInfoController extends BaseController{
|
|
|
+@RequestMapping(Constants.STUDENT_PREFIX + "/exam/info")
|
|
|
+@Api(tags = {"【APP-考场信息】"})
|
|
|
+public class ExamInfoController extends BaseController {
|
|
|
@Autowired
|
|
|
private IExamInfoService examInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IDictCityService dictCityService;
|
|
|
+
|
|
|
@Value("${geo.path}")
|
|
|
private String dbPath;
|
|
|
+
|
|
|
/**
|
|
|
* 查询考场信息列表
|
|
|
*/
|
|
|
@GetMapping("/list")
|
|
|
@ApiOperation("查询考场信息列表")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
|
|
|
- @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "pageNum", value = "当前页码", dataType = "int", paramType = "query", required = false),
|
|
|
+ @ApiImplicitParam(name = "pageSize", value = "每页数据量", dataType = "int", paramType = "query", required = false),
|
|
|
})
|
|
|
- public ResponsePageInfo<ExamInfo> list(@ModelAttribute ExamInfo examInfo){
|
|
|
+ public ResponsePageInfo<ExamInfo> list(@ModelAttribute ExamInfo examInfo) {
|
|
|
startPage();
|
|
|
List<ExamInfo> list = examInfoService.selectExamInfoList(examInfo);
|
|
|
return toResponsePageInfo(list);
|
|
@@ -66,7 +72,7 @@ public class ExamInfoController extends BaseController{
|
|
|
public Response<ExamInfo> getInfo(
|
|
|
@ApiParam(name = "id", value = "考场信息参数", required = true)
|
|
|
@PathVariable("id") Long id
|
|
|
- ){
|
|
|
+ ) {
|
|
|
return Response.success(examInfoService.getById(id));
|
|
|
}
|
|
|
|
|
@@ -76,7 +82,7 @@ public class ExamInfoController extends BaseController{
|
|
|
*/
|
|
|
@GetMapping("/getProvice")
|
|
|
@ApiOperation("获取考场省份")
|
|
|
- public Response<List<ExamInfoProviceVo>> getProvice(){
|
|
|
+ public Response<List<ExamInfoProviceVo>> getProvice() {
|
|
|
List<ExamInfoProviceVo> list = examInfoService.getProvice();
|
|
|
return Response.success(list);
|
|
|
}
|
|
@@ -90,18 +96,18 @@ public class ExamInfoController extends BaseController{
|
|
|
public Response<List<ExamInfoCityVo>> getCity(
|
|
|
@ApiParam(name = "proviceId", value = "考场信息参数", required = true)
|
|
|
@PathVariable("proviceId") String proviceId
|
|
|
- ){
|
|
|
+ ) {
|
|
|
return Response.success(examInfoService.getCity(proviceId));
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/ip")
|
|
|
@ApiOperation("获取访问IP")
|
|
|
- public Response<Map<String,Object>> exampleMethod() throws IOException, GeoIp2Exception {
|
|
|
+ public Response<Map<String, Object>> exampleMethod() throws IOException, GeoIp2Exception {
|
|
|
|
|
|
String ipAddr = IpUtils.getIpAddr(ServletUtils.getRequest());
|
|
|
System.out.println(ipAddr);
|
|
|
|
|
|
- // File database = new ClassPathResource("geolite/GeoLite2-City.mmdb").getFile();
|
|
|
+ // File database = new ClassPathResource("geolite/GeoLite2-City.mmdb").getFile();
|
|
|
File database = new File(dbPath);
|
|
|
|
|
|
// 初始化 GeoIP 数据库
|
|
@@ -114,9 +120,35 @@ public class ExamInfoController extends BaseController{
|
|
|
System.out.println(response.getCountry().getNames().get("zh-CN"));
|
|
|
System.out.println(response.getMostSpecificSubdivision().getNames().get("zh-CN"));
|
|
|
System.out.println(response.getCity().getNames().get("zh-CN"));
|
|
|
- Map<String,Object> resultMap = new HashMap<String,Object>();
|
|
|
- resultMap.put("provice",response.getMostSpecificSubdivision().getNames().get("zh-CN"));
|
|
|
- resultMap.put("city",response.getCity().getNames().get("zh-CN"));
|
|
|
+
|
|
|
+ String countryName = response.getCountry().getNames().get("zh-CN");
|
|
|
+ String proviceName = response.getMostSpecificSubdivision().getNames().get("zh-CN");
|
|
|
+ String cityName = response.getMostSpecificSubdivision().getNames().get("zh-CN");
|
|
|
+
|
|
|
+ DictCity provice = null;
|
|
|
+ DictCity city = null;
|
|
|
+ if (proviceName != null) {
|
|
|
+ provice = dictCityService.getDictCityByName(proviceName);
|
|
|
+ }
|
|
|
+ if (cityName != null) {
|
|
|
+ city = dictCityService.getDictCityByName(cityName);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new HashMap<String, Object>();
|
|
|
+ if (provice != null) {
|
|
|
+ resultMap.put("provice", provice.getCode());
|
|
|
+ resultMap.put("proviceName", provice.getName());
|
|
|
+ } else {
|
|
|
+ resultMap.put("provice", null);
|
|
|
+ resultMap.put("proviceName", null);
|
|
|
+ }
|
|
|
+ if (city != null) {
|
|
|
+ resultMap.put("city", city.getCode());
|
|
|
+ resultMap.put("cityName", city.getName());
|
|
|
+ } else {
|
|
|
+ resultMap.put("city", null);
|
|
|
+ resultMap.put("cityName", null);
|
|
|
+ }
|
|
|
return Response.success(resultMap);
|
|
|
}
|
|
|
|