parent
5ed6453b52
commit
087ac25304
@ -0,0 +1,36 @@
|
||||
package com.ruoyi.programManagement.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.programManagement.service.IUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.service.ResponseMessage;
|
||||
|
||||
/**
|
||||
* @Project: emergency-management2
|
||||
* @Package: com.geowisdom.emergencymanagement.business.controller
|
||||
* @ClassName: UserController
|
||||
* @Description: TODO
|
||||
* @Author: Jason<genyong.yang @ gmail.com>
|
||||
* @Date: 2021/7/18 12:31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pharmaceuticals/user")
|
||||
@Api(tags = "用户信息接口")
|
||||
@CrossOrigin
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
IUserService userService;
|
||||
|
||||
@ApiOperation(value = "获取用户信息", notes = "根据code获取用户信息")
|
||||
@GetMapping("/getUserInfo")
|
||||
public AjaxResult getAllGeoLayers(@RequestParam String code) {
|
||||
|
||||
return AjaxResult.success(userService.getUserByCode(code));
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package com.ruoyi.programManagement.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author Jason
|
||||
* @since 2021-06-20
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("ent_geo_layer")
|
||||
@ApiModel(value="GeoLayer对象", description="")
|
||||
public class GeoLayer implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "原表编号")
|
||||
@TableField("origin_id")
|
||||
private String originId;
|
||||
|
||||
@ApiModelProperty(value = "原表名称")
|
||||
@TableField("origin_table")
|
||||
private String originTable;
|
||||
|
||||
@ApiModelProperty(value = "名称")
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "地址")
|
||||
@TableField("address")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "一级类目")
|
||||
@TableField("type1")
|
||||
private String type1;
|
||||
|
||||
@ApiModelProperty(value = "二级类目")
|
||||
@TableField("type2")
|
||||
private String type2;
|
||||
|
||||
@ApiModelProperty(value = "三级类目")
|
||||
@TableField("type3")
|
||||
private String type3;
|
||||
@ApiModelProperty(value = "四级类目")
|
||||
@TableField("type4")
|
||||
private String type4;
|
||||
|
||||
@ApiModelProperty(value = "五级类目")
|
||||
@TableField("type5")
|
||||
private String type5;
|
||||
|
||||
@ApiModelProperty(value = "六级类目")
|
||||
@TableField("type6")
|
||||
private String type6;
|
||||
@ApiModelProperty(value = "七级类目")
|
||||
@TableField("type7")
|
||||
private String type7;
|
||||
|
||||
@ApiModelProperty(value = "八级类目")
|
||||
@TableField("type8")
|
||||
private String type8;
|
||||
|
||||
@ApiModelProperty(value = "九级类目")
|
||||
@TableField("type9")
|
||||
private String type9;
|
||||
|
||||
@ApiModelProperty(value = "十级类目")
|
||||
@TableField("type10")
|
||||
private String type10;
|
||||
|
||||
@ApiModelProperty(value = "县区")
|
||||
@TableField("county")
|
||||
private String county;
|
||||
|
||||
@ApiModelProperty(value = "乡镇")
|
||||
@TableField("town")
|
||||
private String town;
|
||||
|
||||
@ApiModelProperty(value = "经度")
|
||||
@TableField("lng")
|
||||
private BigDecimal lng;
|
||||
|
||||
@ApiModelProperty(value = "纬度")
|
||||
@TableField("lat")
|
||||
private BigDecimal lat;
|
||||
|
||||
@ApiModelProperty(value = "空间")
|
||||
@TableField("shape")
|
||||
private String shape;
|
||||
|
||||
@ApiModelProperty(value = "空间字符串")
|
||||
@TableField(value = "shape_str",exist = false)
|
||||
private String shapeStr;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.ruoyi.programManagement.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Project: emergency-management2
|
||||
* @Package: com.geowisdom.emergencymanagement.business.vo
|
||||
* @ClassName: UserVO
|
||||
* @Description: TODO
|
||||
* @Author: Jason<genyong.yang @ gmail.com>
|
||||
* @Date: 2021/7/18 12:49
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
public class UserVO<T> {
|
||||
private Integer code;
|
||||
|
||||
private String msg;
|
||||
|
||||
private T data;
|
||||
|
||||
public UserVO() {
|
||||
}
|
||||
|
||||
public UserVO(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.msg = message;
|
||||
}
|
||||
|
||||
public UserVO(Integer code, String message, T data) {
|
||||
this.code = code;
|
||||
this.msg = message;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.ruoyi.programManagement.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.programManagement.entity.GeoLayer;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Jason
|
||||
* @since 2021-06-20
|
||||
*/
|
||||
public interface GeoLayerMapper extends BaseMapper<GeoLayer> {
|
||||
|
||||
|
||||
@Select("SELECT t.id,t.origin_id,t.origin_table,t.name,t.address,t.type1,t.type2,t.type3,t.county,t.town,t.lng,t.lat,ST_AsGeoJson( t.shape) as shape_str FROM ent_geo_layer t ${ew.customSqlSegment} ")
|
||||
List<GeoLayer> getGeoLayerById( @Param(Constants.WRAPPER) Wrapper wrapper);
|
||||
|
||||
@Select("SELECT t.id,t.origin_id,t.origin_table,t.name,t.address,t.type1,t.type2,t.type3,t.county,t.town,t.lng,t.lat,ST_AsGeoJson( t.shape) as shape_str FROM ent_geo_layer t ${ew.customSqlSegment} ")
|
||||
List<GeoLayer> getGeoLayerByCondition( @Param(Constants.WRAPPER) Wrapper wrapper);
|
||||
|
||||
@Select("SELECT t.id,t.origin_id,t.origin_table,t.name,t.address,t.type1,t.type2,t.type3,t.type4,t.type5,t.type6,t.type7,t.type8,t.type9,t.type10,t.county,t.town,t.lng,t.lat,ST_AsGeoJson( t.shape) as shape_str FROM ent_geo_layer t ${ew.customSqlSegment} ")
|
||||
List<GeoLayer> getGeoLayerByPage(Page<GeoLayer> page, @Param(Constants.WRAPPER) Wrapper wrapper);
|
||||
|
||||
@Select("SELECT t.id,t.origin_id,t.origin_table,t.name,t.address,t.type1,t.type2,t.type3,t.county,t.town,t.lng,t.lat,ST_AsGeoJson( t.shape) as shape_str FROM ent_geo_layer t ${ew.customSqlSegment} ")
|
||||
List<GeoLayer> getGeoLayerByCenterPoint(@Param(Constants.WRAPPER) Wrapper wrapper);
|
||||
|
||||
@Select("SELECT t.id,t.origin_id,t.origin_table,t.name,t.address,t.type1,t.type2,t.type3,t.type4,t.type5,t.type6,t.type7,t.type8,t.type9,t.type10,t.county,t.town,t.lng,t.lat,ST_AsGeoJson( t.shape) as shape_str FROM ent_geo_layer t ${ew.customSqlSegment} ")
|
||||
List<GeoLayer> getGeoLayerByCenterPointAndPage(Page<GeoLayer> page, @Param(Constants.WRAPPER) Wrapper wrapper);
|
||||
|
||||
@Select("SELECT t.id,t.origin_id,t.origin_table,t.name,t.address,t.type1,t.type2,t.type3,t.type4,t.type5,t.type6,t.type7,t.type8,t.type9,t.type10,t.county,t.town,t.lng,t.lat,ST_AsGeoJson( t.shape) as shape_str FROM ent_geo_layer t ${ew.customSqlSegment} ")
|
||||
List<Map<String, Object>> getCountyStatistics(@Param(Constants.WRAPPER) Wrapper wrapper);
|
||||
|
||||
@Select("SELECT t.id,t.origin_id,t.origin_table,t.name,t.address,t.type1,t.type2,t.type3,t.type4,t.type5,t.type6,t.type7,t.type8,t.type9,t.type10,t.county,t.town,t.lng,t.lat,ST_AsGeoJson( t.shape) as shape_str FROM ent_geo_layer t ${ew.customSqlSegment} ")
|
||||
List<Map<String, Object>> getTownStatistics(@Param(Constants.WRAPPER) Wrapper wrapper);
|
||||
// @Select("select * from ${viewName} t ${ew.customSqlSegment} ")
|
||||
// List<Map<String,Object>> getGeoLayerById(@Param("id") Integer id,
|
||||
// @Param(Constants.WRAPPER) Wrapper wrapper);
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.ruoyi.programManagement.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.programManagement.entity.GeoLayer;
|
||||
|
||||
|
||||
/**
|
||||
* @Project: emergency-management2
|
||||
* @Package: com.geowisdom.emergencymanagement.business.service
|
||||
* @InterfaceName: IUserService
|
||||
* @Description: TODO
|
||||
* @Author: Jason<genyong.yang @ gmail.com>
|
||||
* @Date: 2021/7/18 12:33
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IUserService extends IService<GeoLayer> {
|
||||
Object getUserByCode(String code);
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.ruoyi.programManagement.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import com.ruoyi.programManagement.entity.GeoLayer;
|
||||
import com.ruoyi.programManagement.entity.vo.UserVO;
|
||||
import com.ruoyi.programManagement.mapper.GeoLayerMapper;
|
||||
import com.ruoyi.programManagement.service.IUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @Project: emergency-management2
|
||||
* @Package: com.geowisdom.emergencymanagement.business.service.impl
|
||||
* @ClassName: UserServiceImpl
|
||||
* @Description: TODO
|
||||
* @Author: Jason<genyong.yang @ gmail.com>
|
||||
* @Date: 2021/7/18 12:35
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<GeoLayerMapper, GeoLayer> implements IUserService {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Object getUserByCode(String code) {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
// 先请求accessToken
|
||||
String accessTokenUrl = "http://2.46.4.197:8090/sso-server/oauth2/accessToken";
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
MultiValueMap map = new LinkedMultiValueMap();
|
||||
map.add("code",code);
|
||||
map.add("aid", "17847210");
|
||||
map.add("sk", "m1r4tyiv7aq4wzoux24q0ak6dl8f15du");
|
||||
map.add("grant_type", "authorization_code");
|
||||
|
||||
HttpEntity requestBody = new HttpEntity(map, headers);
|
||||
|
||||
ResponseEntity<UserVO> responseEntity = restTemplate.postForEntity(accessTokenUrl, requestBody, UserVO.class);
|
||||
UserVO userVO = responseEntity.getBody();
|
||||
LinkedHashMap data = (LinkedHashMap)userVO.getData();
|
||||
// 获取accessToken
|
||||
String accessToken=data.get("accessToken").toString();
|
||||
// 获取用户
|
||||
String userUrl = "http://2.46.4.197:8090/sso-server/oauth2/getUser";
|
||||
headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
map = new LinkedMultiValueMap();
|
||||
map.add("accessToken",accessToken);
|
||||
requestBody = new HttpEntity(map, headers);
|
||||
|
||||
responseEntity = restTemplate.postForEntity(userUrl, requestBody, UserVO.class);
|
||||
userVO = responseEntity.getBody();
|
||||
Object user = userVO.getData();
|
||||
return user;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue