Commit 5f5189a7 by XiaHou

增加万科 从微V导入 功能

parent 698273f2
...@@ -9,8 +9,10 @@ import com.macro.mall.model.common.ResultMsg; ...@@ -9,8 +9,10 @@ import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.UmsAdminDto; import com.macro.mall.model.dto.UmsAdminDto;
import com.macro.mall.model.dto.quanxing.UmsMemberDto; import com.macro.mall.model.dto.quanxing.UmsMemberDto;
import com.macro.mall.model.dto.vanke.VankeImportMemberDto; import com.macro.mall.model.dto.vanke.VankeImportMemberDto;
import com.macro.mall.model.dto.vanke.VankeVvUserImportVo;
import com.macro.mall.service.member.UmsMemberService; import com.macro.mall.service.member.UmsMemberService;
import com.macro.mall.service.system.UmsAdminService; import com.macro.mall.service.system.UmsAdminService;
import com.macro.mall.service.vanke.IVankeMemberLoginService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
...@@ -18,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -18,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
@Controller @Controller
@Api(tags = "万科后台_用户列表管理员相关接口", description = "用户列表控制器") @Api(tags = "万科后台_用户列表管理员相关接口", description = "用户列表控制器")
@RequestMapping("/umsMember") @RequestMapping("/umsMember")
...@@ -27,6 +31,8 @@ public class UmsMemberController { ...@@ -27,6 +31,8 @@ public class UmsMemberController {
private UmsMemberService umsMemberService; private UmsMemberService umsMemberService;
@Autowired @Autowired
private UmsAdminService umsAdminService; private UmsAdminService umsAdminService;
@Autowired
private IVankeMemberLoginService vankeMemberLoginService;
@ApiOperation("万科后台_用户分页操作") @ApiOperation("万科后台_用户分页操作")
@RequestMapping(value = "/list", method = RequestMethod.GET) @RequestMapping(value = "/list", method = RequestMethod.GET)
...@@ -82,6 +88,14 @@ public class UmsMemberController { ...@@ -82,6 +88,14 @@ public class UmsMemberController {
} }
@ApiOperation("分页获取万科企业所有组织人员")
@RequestMapping(value = "/getAllPersons", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<VankeVvUserImportVo>> getAllPersons(@ApiParam(value="起始数据下表") @RequestParam(value = "pageSize", required = true) Integer pageSize,
@ApiParam(value="结束数据下表") @RequestParam(value = "pageNum", required = true) Integer pageNum) {
return CommonResult.success(this.vankeMemberLoginService.getAllPersons(pageNum,pageSize));
}
@ApiOperation("根据会员id查询一条数据") @ApiOperation("根据会员id查询一条数据")
@RequestMapping(value = "/selectOneByMemberId", method = RequestMethod.GET) @RequestMapping(value = "/selectOneByMemberId", method = RequestMethod.GET)
@ResponseBody @ResponseBody
......
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId> <groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId> <artifactId>pagehelper-spring-boot-starter</artifactId>
</dependency> </dependency>
......
package com.macro.mall.common.utils; package com.macro.mall.common.utils;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair; import org.apache.http.NameValuePair;
...@@ -168,4 +169,35 @@ public class HttpClientUtil { ...@@ -168,4 +169,35 @@ public class HttpClientUtil {
return resultString; return resultString;
} }
/**
* 通过Post请求 x-www-form-urlencoded 此方式请求Url
* @param actionUrl
* @param data
* @return
* @throws IOException
* auth xh
*/
public static String formUrlencodedPost(String actionUrl, org.apache.commons.httpclient.NameValuePair[] data) throws IOException {
String result = "";
try {
String postURL = actionUrl;
PostMethod postMethod = null;
postMethod = new PostMethod(postURL);
postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
//参数设置,需要注意的就是里边不能传NULL,要传空字符串
postMethod.setRequestBody(data);
org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
int response = httpClient.executeMethod(postMethod); // 执行POST方法
result = postMethod.getResponseBodyAsString();
System.out.println(response);
System.out.println(result);
} catch (Exception e) {
// logger.info("请求异常"+e.getMessage(),e);
throw new RuntimeException(e.getMessage());
}
return result;
}
} }
...@@ -20,6 +20,21 @@ public class VankeConfig implements Serializable { ...@@ -20,6 +20,21 @@ public class VankeConfig implements Serializable {
@ApiModelProperty(value = "领取时间间隔") @ApiModelProperty(value = "领取时间间隔")
private BigDecimal receiveInterval; private BigDecimal receiveInterval;
@ApiModelProperty(value = "轻应用id")
private String appid;
@ApiModelProperty(value = "轻应用secret,即appsecret")
private String secret;
@ApiModelProperty(value = "授权级别:例如app")
private String scope;
@ApiModelProperty(value = "企业id 例如:测试环境:eid:16216997 生产环境:eid:101")
private String eid;
@ApiModelProperty(value = "访问接口地址 测试环境:https://vvtest.vanke.com 生产环境:https://vv9.vanke.com")
private String host;
@ApiModelProperty(value = "创建人") @ApiModelProperty(value = "创建人")
private Long createBy; private Long createBy;
...@@ -60,6 +75,46 @@ public class VankeConfig implements Serializable { ...@@ -60,6 +75,46 @@ public class VankeConfig implements Serializable {
this.receiveInterval = receiveInterval; this.receiveInterval = receiveInterval;
} }
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getEid() {
return eid;
}
public void setEid(String eid) {
this.eid = eid;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public Long getCreateBy() { public Long getCreateBy() {
return createBy; return createBy;
} }
...@@ -101,6 +156,11 @@ public class VankeConfig implements Serializable { ...@@ -101,6 +156,11 @@ public class VankeConfig implements Serializable {
sb.append(", id=").append(id); sb.append(", id=").append(id);
sb.append(", stockWarning=").append(stockWarning); sb.append(", stockWarning=").append(stockWarning);
sb.append(", receiveInterval=").append(receiveInterval); sb.append(", receiveInterval=").append(receiveInterval);
sb.append(", appid=").append(appid);
sb.append(", secret=").append(secret);
sb.append(", scope=").append(scope);
sb.append(", eid=").append(eid);
sb.append(", host=").append(host);
sb.append(", createBy=").append(createBy); sb.append(", createBy=").append(createBy);
sb.append(", updateBy=").append(updateBy); sb.append(", updateBy=").append(updateBy);
sb.append(", createtime=").append(createtime); sb.append(", createtime=").append(createtime);
......
...@@ -286,6 +286,356 @@ public class VankeConfigExample { ...@@ -286,6 +286,356 @@ public class VankeConfigExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andAppidIsNull() {
addCriterion("appid is null");
return (Criteria) this;
}
public Criteria andAppidIsNotNull() {
addCriterion("appid is not null");
return (Criteria) this;
}
public Criteria andAppidEqualTo(String value) {
addCriterion("appid =", value, "appid");
return (Criteria) this;
}
public Criteria andAppidNotEqualTo(String value) {
addCriterion("appid <>", value, "appid");
return (Criteria) this;
}
public Criteria andAppidGreaterThan(String value) {
addCriterion("appid >", value, "appid");
return (Criteria) this;
}
public Criteria andAppidGreaterThanOrEqualTo(String value) {
addCriterion("appid >=", value, "appid");
return (Criteria) this;
}
public Criteria andAppidLessThan(String value) {
addCriterion("appid <", value, "appid");
return (Criteria) this;
}
public Criteria andAppidLessThanOrEqualTo(String value) {
addCriterion("appid <=", value, "appid");
return (Criteria) this;
}
public Criteria andAppidLike(String value) {
addCriterion("appid like", value, "appid");
return (Criteria) this;
}
public Criteria andAppidNotLike(String value) {
addCriterion("appid not like", value, "appid");
return (Criteria) this;
}
public Criteria andAppidIn(List<String> values) {
addCriterion("appid in", values, "appid");
return (Criteria) this;
}
public Criteria andAppidNotIn(List<String> values) {
addCriterion("appid not in", values, "appid");
return (Criteria) this;
}
public Criteria andAppidBetween(String value1, String value2) {
addCriterion("appid between", value1, value2, "appid");
return (Criteria) this;
}
public Criteria andAppidNotBetween(String value1, String value2) {
addCriterion("appid not between", value1, value2, "appid");
return (Criteria) this;
}
public Criteria andSecretIsNull() {
addCriterion("secret is null");
return (Criteria) this;
}
public Criteria andSecretIsNotNull() {
addCriterion("secret is not null");
return (Criteria) this;
}
public Criteria andSecretEqualTo(String value) {
addCriterion("secret =", value, "secret");
return (Criteria) this;
}
public Criteria andSecretNotEqualTo(String value) {
addCriterion("secret <>", value, "secret");
return (Criteria) this;
}
public Criteria andSecretGreaterThan(String value) {
addCriterion("secret >", value, "secret");
return (Criteria) this;
}
public Criteria andSecretGreaterThanOrEqualTo(String value) {
addCriterion("secret >=", value, "secret");
return (Criteria) this;
}
public Criteria andSecretLessThan(String value) {
addCriterion("secret <", value, "secret");
return (Criteria) this;
}
public Criteria andSecretLessThanOrEqualTo(String value) {
addCriterion("secret <=", value, "secret");
return (Criteria) this;
}
public Criteria andSecretLike(String value) {
addCriterion("secret like", value, "secret");
return (Criteria) this;
}
public Criteria andSecretNotLike(String value) {
addCriterion("secret not like", value, "secret");
return (Criteria) this;
}
public Criteria andSecretIn(List<String> values) {
addCriterion("secret in", values, "secret");
return (Criteria) this;
}
public Criteria andSecretNotIn(List<String> values) {
addCriterion("secret not in", values, "secret");
return (Criteria) this;
}
public Criteria andSecretBetween(String value1, String value2) {
addCriterion("secret between", value1, value2, "secret");
return (Criteria) this;
}
public Criteria andSecretNotBetween(String value1, String value2) {
addCriterion("secret not between", value1, value2, "secret");
return (Criteria) this;
}
public Criteria andScopeIsNull() {
addCriterion("scope is null");
return (Criteria) this;
}
public Criteria andScopeIsNotNull() {
addCriterion("scope is not null");
return (Criteria) this;
}
public Criteria andScopeEqualTo(String value) {
addCriterion("scope =", value, "scope");
return (Criteria) this;
}
public Criteria andScopeNotEqualTo(String value) {
addCriterion("scope <>", value, "scope");
return (Criteria) this;
}
public Criteria andScopeGreaterThan(String value) {
addCriterion("scope >", value, "scope");
return (Criteria) this;
}
public Criteria andScopeGreaterThanOrEqualTo(String value) {
addCriterion("scope >=", value, "scope");
return (Criteria) this;
}
public Criteria andScopeLessThan(String value) {
addCriterion("scope <", value, "scope");
return (Criteria) this;
}
public Criteria andScopeLessThanOrEqualTo(String value) {
addCriterion("scope <=", value, "scope");
return (Criteria) this;
}
public Criteria andScopeLike(String value) {
addCriterion("scope like", value, "scope");
return (Criteria) this;
}
public Criteria andScopeNotLike(String value) {
addCriterion("scope not like", value, "scope");
return (Criteria) this;
}
public Criteria andScopeIn(List<String> values) {
addCriterion("scope in", values, "scope");
return (Criteria) this;
}
public Criteria andScopeNotIn(List<String> values) {
addCriterion("scope not in", values, "scope");
return (Criteria) this;
}
public Criteria andScopeBetween(String value1, String value2) {
addCriterion("scope between", value1, value2, "scope");
return (Criteria) this;
}
public Criteria andScopeNotBetween(String value1, String value2) {
addCriterion("scope not between", value1, value2, "scope");
return (Criteria) this;
}
public Criteria andEidIsNull() {
addCriterion("eid is null");
return (Criteria) this;
}
public Criteria andEidIsNotNull() {
addCriterion("eid is not null");
return (Criteria) this;
}
public Criteria andEidEqualTo(String value) {
addCriterion("eid =", value, "eid");
return (Criteria) this;
}
public Criteria andEidNotEqualTo(String value) {
addCriterion("eid <>", value, "eid");
return (Criteria) this;
}
public Criteria andEidGreaterThan(String value) {
addCriterion("eid >", value, "eid");
return (Criteria) this;
}
public Criteria andEidGreaterThanOrEqualTo(String value) {
addCriterion("eid >=", value, "eid");
return (Criteria) this;
}
public Criteria andEidLessThan(String value) {
addCriterion("eid <", value, "eid");
return (Criteria) this;
}
public Criteria andEidLessThanOrEqualTo(String value) {
addCriterion("eid <=", value, "eid");
return (Criteria) this;
}
public Criteria andEidLike(String value) {
addCriterion("eid like", value, "eid");
return (Criteria) this;
}
public Criteria andEidNotLike(String value) {
addCriterion("eid not like", value, "eid");
return (Criteria) this;
}
public Criteria andEidIn(List<String> values) {
addCriterion("eid in", values, "eid");
return (Criteria) this;
}
public Criteria andEidNotIn(List<String> values) {
addCriterion("eid not in", values, "eid");
return (Criteria) this;
}
public Criteria andEidBetween(String value1, String value2) {
addCriterion("eid between", value1, value2, "eid");
return (Criteria) this;
}
public Criteria andEidNotBetween(String value1, String value2) {
addCriterion("eid not between", value1, value2, "eid");
return (Criteria) this;
}
public Criteria andHostIsNull() {
addCriterion("host is null");
return (Criteria) this;
}
public Criteria andHostIsNotNull() {
addCriterion("host is not null");
return (Criteria) this;
}
public Criteria andHostEqualTo(String value) {
addCriterion("host =", value, "host");
return (Criteria) this;
}
public Criteria andHostNotEqualTo(String value) {
addCriterion("host <>", value, "host");
return (Criteria) this;
}
public Criteria andHostGreaterThan(String value) {
addCriterion("host >", value, "host");
return (Criteria) this;
}
public Criteria andHostGreaterThanOrEqualTo(String value) {
addCriterion("host >=", value, "host");
return (Criteria) this;
}
public Criteria andHostLessThan(String value) {
addCriterion("host <", value, "host");
return (Criteria) this;
}
public Criteria andHostLessThanOrEqualTo(String value) {
addCriterion("host <=", value, "host");
return (Criteria) this;
}
public Criteria andHostLike(String value) {
addCriterion("host like", value, "host");
return (Criteria) this;
}
public Criteria andHostNotLike(String value) {
addCriterion("host not like", value, "host");
return (Criteria) this;
}
public Criteria andHostIn(List<String> values) {
addCriterion("host in", values, "host");
return (Criteria) this;
}
public Criteria andHostNotIn(List<String> values) {
addCriterion("host not in", values, "host");
return (Criteria) this;
}
public Criteria andHostBetween(String value1, String value2) {
addCriterion("host between", value1, value2, "host");
return (Criteria) this;
}
public Criteria andHostNotBetween(String value1, String value2) {
addCriterion("host not between", value1, value2, "host");
return (Criteria) this;
}
public Criteria andCreateByIsNull() { public Criteria andCreateByIsNull() {
addCriterion("create_by is null"); addCriterion("create_by is null");
return (Criteria) this; return (Criteria) this;
......
...@@ -19,6 +19,8 @@ public class VankeImportMemberDto { ...@@ -19,6 +19,8 @@ public class VankeImportMemberDto {
private String username; private String username;
@ApiModelProperty("账号") @ApiModelProperty("账号")
private String account; private String account;
@ApiModelProperty(value = "头像")
private String photourl;
@ApiModelProperty("数据传输 只供导入会员对象集合时候使用") @ApiModelProperty("数据传输 只供导入会员对象集合时候使用")
private List<VankeImportMemberDto> vimdList; private List<VankeImportMemberDto> vimdList;
} }
package com.macro.mall.model.dto.vanke;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class VankeVvUserImportVo implements Serializable {
@ApiModelProperty(value = "头像")
private String photoUrl;
@ApiModelProperty(value = "团队用户id")
private String openid;
@ApiModelProperty(value = "性别: 0未知 1女 2男")
private Integer gender;
@ApiModelProperty(value = "openId")
private String openId;
@ApiModelProperty(value = "员工编号")
private String jobNo;
@ApiModelProperty(value = "用户姓名")
private String name;
@ApiModelProperty(value = "部门名称")
private String department;
}
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id" />
<result column="stock_warning" jdbcType="INTEGER" property="stockWarning" /> <result column="stock_warning" jdbcType="INTEGER" property="stockWarning" />
<result column="receive_interval" jdbcType="DECIMAL" property="receiveInterval" /> <result column="receive_interval" jdbcType="DECIMAL" property="receiveInterval" />
<result column="appid" jdbcType="VARCHAR" property="appid" />
<result column="secret" jdbcType="VARCHAR" property="secret" />
<result column="scope" jdbcType="VARCHAR" property="scope" />
<result column="eid" jdbcType="VARCHAR" property="eid" />
<result column="host" jdbcType="VARCHAR" property="host" />
<result column="create_by" jdbcType="BIGINT" property="createBy" /> <result column="create_by" jdbcType="BIGINT" property="createBy" />
<result column="update_by" jdbcType="BIGINT" property="updateBy" /> <result column="update_by" jdbcType="BIGINT" property="updateBy" />
<result column="createtime" jdbcType="TIMESTAMP" property="createtime" /> <result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
...@@ -69,7 +74,8 @@ ...@@ -69,7 +74,8 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, stock_warning, receive_interval, create_by, update_by, createtime, updatetime id, stock_warning, receive_interval, appid, secret, scope, eid, host, create_by,
update_by, createtime, updatetime
</sql> </sql>
<select id="selectByExample" parameterType="com.macro.mall.model.VankeConfigExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.macro.mall.model.VankeConfigExample" resultMap="BaseResultMap">
select select
...@@ -105,12 +111,14 @@ ...@@ -105,12 +111,14 @@
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID() SELECT LAST_INSERT_ID()
</selectKey> </selectKey>
insert into vanke_config (stock_warning, receive_interval, create_by, insert into vanke_config (stock_warning, receive_interval, appid,
update_by, createtime, updatetime secret, scope, eid,
) host, create_by, update_by,
values (#{stockWarning,jdbcType=INTEGER}, #{receiveInterval,jdbcType=DECIMAL}, #{createBy,jdbcType=BIGINT}, createtime, updatetime)
#{updateBy,jdbcType=BIGINT}, #{createtime,jdbcType=TIMESTAMP}, #{updatetime,jdbcType=TIMESTAMP} values (#{stockWarning,jdbcType=INTEGER}, #{receiveInterval,jdbcType=DECIMAL}, #{appid,jdbcType=VARCHAR},
) #{secret,jdbcType=VARCHAR}, #{scope,jdbcType=VARCHAR}, #{eid,jdbcType=VARCHAR},
#{host,jdbcType=VARCHAR}, #{createBy,jdbcType=BIGINT}, #{updateBy,jdbcType=BIGINT},
#{createtime,jdbcType=TIMESTAMP}, #{updatetime,jdbcType=TIMESTAMP})
</insert> </insert>
<insert id="insertSelective" parameterType="com.macro.mall.model.VankeConfig"> <insert id="insertSelective" parameterType="com.macro.mall.model.VankeConfig">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
...@@ -124,6 +132,21 @@ ...@@ -124,6 +132,21 @@
<if test="receiveInterval != null"> <if test="receiveInterval != null">
receive_interval, receive_interval,
</if> </if>
<if test="appid != null">
appid,
</if>
<if test="secret != null">
secret,
</if>
<if test="scope != null">
scope,
</if>
<if test="eid != null">
eid,
</if>
<if test="host != null">
host,
</if>
<if test="createBy != null"> <if test="createBy != null">
create_by, create_by,
</if> </if>
...@@ -144,6 +167,21 @@ ...@@ -144,6 +167,21 @@
<if test="receiveInterval != null"> <if test="receiveInterval != null">
#{receiveInterval,jdbcType=DECIMAL}, #{receiveInterval,jdbcType=DECIMAL},
</if> </if>
<if test="appid != null">
#{appid,jdbcType=VARCHAR},
</if>
<if test="secret != null">
#{secret,jdbcType=VARCHAR},
</if>
<if test="scope != null">
#{scope,jdbcType=VARCHAR},
</if>
<if test="eid != null">
#{eid,jdbcType=VARCHAR},
</if>
<if test="host != null">
#{host,jdbcType=VARCHAR},
</if>
<if test="createBy != null"> <if test="createBy != null">
#{createBy,jdbcType=BIGINT}, #{createBy,jdbcType=BIGINT},
</if> </if>
...@@ -176,6 +214,21 @@ ...@@ -176,6 +214,21 @@
<if test="record.receiveInterval != null"> <if test="record.receiveInterval != null">
receive_interval = #{record.receiveInterval,jdbcType=DECIMAL}, receive_interval = #{record.receiveInterval,jdbcType=DECIMAL},
</if> </if>
<if test="record.appid != null">
appid = #{record.appid,jdbcType=VARCHAR},
</if>
<if test="record.secret != null">
secret = #{record.secret,jdbcType=VARCHAR},
</if>
<if test="record.scope != null">
scope = #{record.scope,jdbcType=VARCHAR},
</if>
<if test="record.eid != null">
eid = #{record.eid,jdbcType=VARCHAR},
</if>
<if test="record.host != null">
host = #{record.host,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null"> <if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=BIGINT}, create_by = #{record.createBy,jdbcType=BIGINT},
</if> </if>
...@@ -198,6 +251,11 @@ ...@@ -198,6 +251,11 @@
set id = #{record.id,jdbcType=BIGINT}, set id = #{record.id,jdbcType=BIGINT},
stock_warning = #{record.stockWarning,jdbcType=INTEGER}, stock_warning = #{record.stockWarning,jdbcType=INTEGER},
receive_interval = #{record.receiveInterval,jdbcType=DECIMAL}, receive_interval = #{record.receiveInterval,jdbcType=DECIMAL},
appid = #{record.appid,jdbcType=VARCHAR},
secret = #{record.secret,jdbcType=VARCHAR},
scope = #{record.scope,jdbcType=VARCHAR},
eid = #{record.eid,jdbcType=VARCHAR},
host = #{record.host,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=BIGINT}, create_by = #{record.createBy,jdbcType=BIGINT},
update_by = #{record.updateBy,jdbcType=BIGINT}, update_by = #{record.updateBy,jdbcType=BIGINT},
createtime = #{record.createtime,jdbcType=TIMESTAMP}, createtime = #{record.createtime,jdbcType=TIMESTAMP},
...@@ -215,6 +273,21 @@ ...@@ -215,6 +273,21 @@
<if test="receiveInterval != null"> <if test="receiveInterval != null">
receive_interval = #{receiveInterval,jdbcType=DECIMAL}, receive_interval = #{receiveInterval,jdbcType=DECIMAL},
</if> </if>
<if test="appid != null">
appid = #{appid,jdbcType=VARCHAR},
</if>
<if test="secret != null">
secret = #{secret,jdbcType=VARCHAR},
</if>
<if test="scope != null">
scope = #{scope,jdbcType=VARCHAR},
</if>
<if test="eid != null">
eid = #{eid,jdbcType=VARCHAR},
</if>
<if test="host != null">
host = #{host,jdbcType=VARCHAR},
</if>
<if test="createBy != null"> <if test="createBy != null">
create_by = #{createBy,jdbcType=BIGINT}, create_by = #{createBy,jdbcType=BIGINT},
</if> </if>
...@@ -234,6 +307,11 @@ ...@@ -234,6 +307,11 @@
update vanke_config update vanke_config
set stock_warning = #{stockWarning,jdbcType=INTEGER}, set stock_warning = #{stockWarning,jdbcType=INTEGER},
receive_interval = #{receiveInterval,jdbcType=DECIMAL}, receive_interval = #{receiveInterval,jdbcType=DECIMAL},
appid = #{appid,jdbcType=VARCHAR},
secret = #{secret,jdbcType=VARCHAR},
scope = #{scope,jdbcType=VARCHAR},
eid = #{eid,jdbcType=VARCHAR},
host = #{host,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=BIGINT}, create_by = #{createBy,jdbcType=BIGINT},
update_by = #{updateBy,jdbcType=BIGINT}, update_by = #{updateBy,jdbcType=BIGINT},
createtime = #{createtime,jdbcType=TIMESTAMP}, createtime = #{createtime,jdbcType=TIMESTAMP},
......
package com.macro.mall.portal; package com.macro.mall.portal;
import com.macro.mall.common.baiduyun.HttpUtil;
import com.macro.mall.common.utils.MyJsonUtil;
import com.macro.mall.dao.order.PortalProductDao; import com.macro.mall.dao.order.PortalProductDao;
import com.macro.mall.domain.vo.order.PromotionProduct; import com.macro.mall.domain.vo.order.PromotionProduct;
import com.macro.mall.service.vanke.IVankeMemberLoginService;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -10,7 +13,9 @@ import org.springframework.boot.test.context.SpringBootTest; ...@@ -10,7 +13,9 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Created by macro on 2018/8/27. * Created by macro on 2018/8/27.
...@@ -19,16 +24,28 @@ import java.util.List; ...@@ -19,16 +24,28 @@ import java.util.List;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest @SpringBootTest
public class PortalProductDaoTests { public class PortalProductDaoTests {
@Autowired @Autowired
private PortalProductDao portalProductDao; private PortalProductDao portalProductDao;
@Autowired
private IVankeMemberLoginService vankeMemberLoginService;
@Test @Test
public void testGetPromotionProductList(){ public void testGetVankeUserInfo(){//DX5KljWcPLnMkryBZtH2ct0OxcqXxzsE
List<Long> ids = new ArrayList<>(); String accessToken = this.vankeMemberLoginService.getVankeAccessToken();
ids.add(26L); //通过appId 和 ticket 以及 token发起获取用户身份信息请求
ids.add(27L); String params ="{\n" +
ids.add(28L); " \"begin\":0, \n" +
ids.add(29L); " \"count\":100 \n" +
List<PromotionProduct> promotionProductList = portalProductDao.getPromotionProductList(ids); "}}";
Assert.assertEquals(4,promotionProductList.size()); String res = null;
Map<String,Object> map = new HashMap<>();
try {
res = HttpUtil.postGeneralUrl("https://vvtest.vanke.com/gateway/openimport/open/person/getall?accessToken="+accessToken,"application/json",params,"UTF-8");
map = MyJsonUtil.getMapChangeJson(res);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(res);
} }
} }
...@@ -814,8 +814,12 @@ public class UmsMemberServiceImpl implements UmsMemberService { ...@@ -814,8 +814,12 @@ public class UmsMemberServiceImpl implements UmsMemberService {
return new ResultMsg(false,"传入会员集合为空 !"); return new ResultMsg(false,"传入会员集合为空 !");
} }
for(VankeImportMemberDto vimd : vimdList){//遍历导入会员 插入万科会员表数据中 for(VankeImportMemberDto vimd : vimdList){//遍历导入会员 插入万科会员表数据中
UmsMember umsMember = this.memberDao.selectUmsMemberByJobNo(vimd.getJobNo());
if(umsMember != null){ //如果存在 则跳出此次循环
continue;
}
//判断是否已存在 此手机号 //判断是否已存在 此手机号
UmsMember umsMember = this.memberDao.selectOntByPhone(vimd.getMobile()); umsMember = this.memberDao.selectOntByPhone(vimd.getMobile());
if(umsMember != null){ if(umsMember != null){
return new ResultMsg(false,"手机号:"+vimd.getMobile()+"已存在!!"); return new ResultMsg(false,"手机号:"+vimd.getMobile()+"已存在!!");
} }
...@@ -877,4 +881,14 @@ public class UmsMemberServiceImpl implements UmsMemberService { ...@@ -877,4 +881,14 @@ public class UmsMemberServiceImpl implements UmsMemberService {
this.umsMemberMapper.updateByPrimaryKeySelective(umsMember); this.umsMemberMapper.updateByPrimaryKeySelective(umsMember);
return new ResultMsg(true,"操作成功"); return new ResultMsg(true,"操作成功");
} }
@Test
public void test(){
VankeImportMemberDto vimd = new VankeImportMemberDto();
//将对象复制到vankevvuser里去 插入到表中
VankeVvUser vvu = new VankeVvUser();
//将属性赋值到另一个对象中去
BeanUtils.copyProperties(vimd,vvu);
}
} }
...@@ -172,16 +172,16 @@ public class UmsAdminServiceImpl implements UmsAdminService { ...@@ -172,16 +172,16 @@ public class UmsAdminServiceImpl implements UmsAdminService {
return CommonResult.failed("输入验证码错误"); return CommonResult.failed("输入验证码错误");
} }
//如果是admin 登录 则默认为超管登录 判断账号密码即可 其他账号登录均为域登录 //如果是admin 登录 则默认为超管登录 判断账号密码即可 其他账号登录均为域登录
//if("admin".equals(username)){ if("admin".equals(username)){
if (!passwordEncoder.matches(password, userDetails.getPassword())) { if (!passwordEncoder.matches(password, userDetails.getPassword())) {
return CommonResult.failed("密码不正确"); return CommonResult.failed("密码不正确");
} }
/*}else{ //否则通过域登录判断 }else{ //否则通过域登录判断
ResultMsg res = this.aDService.loginAd(username,password); ResultMsg res = this.aDService.loginAd(username,password);
if(!res.isFlag()){ if(!res.isFlag()){
return CommonResult.failed(res.getMsg()); return CommonResult.failed(res.getMsg());
} }
}*/ }
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication); SecurityContextHolder.getContext().setAuthentication(authentication);
token = jwtTokenUtil.generateToken(userDetails); token = jwtTokenUtil.generateToken(userDetails);
......
...@@ -2,7 +2,9 @@ package com.macro.mall.service.vanke; ...@@ -2,7 +2,9 @@ package com.macro.mall.service.vanke;
import com.macro.mall.model.UmsMember; import com.macro.mall.model.UmsMember;
import com.macro.mall.model.common.ResultMsg; import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeVvUserImportVo;
import java.util.List;
import java.util.Map; import java.util.Map;
public interface IVankeMemberLoginService { public interface IVankeMemberLoginService {
...@@ -33,4 +35,12 @@ public interface IVankeMemberLoginService { ...@@ -33,4 +35,12 @@ public interface IVankeMemberLoginService {
* @return * @return
*/ */
ResultMsg updateVankeVvUser(String ticket); ResultMsg updateVankeVvUser(String ticket);
/**
* 通过 起始页 和 每页显示数量获取企业所有组织人员
* @param pageNum
* @param pageSize
* @return
*/
List<VankeVvUserImportVo> getAllPersons(Integer pageNum, Integer pageSize);
} }
...@@ -4,7 +4,9 @@ import com.macro.mall.mapper.VankeConfigMapper; ...@@ -4,7 +4,9 @@ import com.macro.mall.mapper.VankeConfigMapper;
import com.macro.mall.model.VankeConfig; import com.macro.mall.model.VankeConfig;
import com.macro.mall.model.VankeConfigExample; import com.macro.mall.model.VankeConfigExample;
import com.macro.mall.model.common.ResultMsg; import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.service.system.RedisService;
import com.macro.mall.service.vanke.IVankeConfigService; import com.macro.mall.service.vanke.IVankeConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -14,19 +16,22 @@ import java.util.List; ...@@ -14,19 +16,22 @@ import java.util.List;
@Service @Service
public class VankeConfigServiceImpl implements IVankeConfigService { public class VankeConfigServiceImpl implements IVankeConfigService {
@Autowired
private RedisService redisService;
@Resource @Resource
private VankeConfigMapper vankeConfigMapper; private VankeConfigMapper vankeConfigMapper;
/** /**
* 得到config配置 * 得到config配置
*
* @return * @return
*/ */
@Override @Override
public VankeConfig getConfig(){ public VankeConfig getConfig() {
VankeConfigExample example = new VankeConfigExample(); VankeConfigExample example = new VankeConfigExample();
VankeConfigExample.Criteria criteria = example.createCriteria(); VankeConfigExample.Criteria criteria = example.createCriteria();
List<VankeConfig> vcList = this.vankeConfigMapper.selectByExample(example); List<VankeConfig> vcList = this.vankeConfigMapper.selectByExample(example);
if(vcList != null && vcList.size()>0 ){ if (vcList != null && vcList.size() > 0) {
return vcList.get(0); return vcList.get(0);
} }
return null; return null;
...@@ -34,24 +39,40 @@ public class VankeConfigServiceImpl implements IVankeConfigService { ...@@ -34,24 +39,40 @@ public class VankeConfigServiceImpl implements IVankeConfigService {
/** /**
* 根据id判断是修改还是新增 * 根据id判断是修改还是新增
*
* @param vankeConfig * @param vankeConfig
* @return * @return
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResultMsg insertAndUpdateConfig(VankeConfig vankeConfig){ public ResultMsg insertAndUpdateConfig(VankeConfig vankeConfig) {
if(vankeConfig.getStockWarning() == null){ if (vankeConfig.getStockWarning() == null) {
return new ResultMsg(false,"库存预警传入为空"); return new ResultMsg(false, "库存预警传入为空");
} }
if(vankeConfig.getReceiveInterval() == null){ if (vankeConfig.getReceiveInterval() == null) {
return new ResultMsg(false,"领取时间间隔为空"); return new ResultMsg(false, "领取时间间隔为空");
} }
if(vankeConfig.getId() != null){ //如果id不为空 说明是修改 if (vankeConfig.getId() != null) { //如果id不为空 说明是修改
if (!vankeConfig.getAppid().isEmpty()) { //如果参数不为空 则需要更新redis
redisService.set("vanke_appid", vankeConfig.getAppid());
}
if (!vankeConfig.getSecret().isEmpty()) { //如果参数不为空 则需要更新redis
redisService.set("vanke_secret", vankeConfig.getSecret());
}
if (!vankeConfig.getScope().isEmpty()) { //如果参数不为空 则需要更新redis
redisService.set("vanke_scope", vankeConfig.getScope());
}
if (!vankeConfig.getEid().isEmpty()) { //如果参数不为空 则需要更新redis
redisService.set("vanke_eid", vankeConfig.getEid());
}
if (!vankeConfig.getHost().isEmpty()) { //如果参数不为空 则需要更新redis
redisService.set("vanke_host", vankeConfig.getHost());
}
this.vankeConfigMapper.updateByPrimaryKeySelective(vankeConfig); this.vankeConfigMapper.updateByPrimaryKeySelective(vankeConfig);
}else{ //否则新增操作 } else { //否则新增操作
this.vankeConfigMapper.insertSelective(vankeConfig); this.vankeConfigMapper.insertSelective(vankeConfig);
} }
return new ResultMsg(true,"操作成功"); return new ResultMsg(true, "操作成功");
} }
} }
package com.macro.mall.service.vanke.impl; package com.macro.mall.service.vanke.impl;
import com.alibaba.fastjson.JSONArray;
import com.macro.mall.common.baiduyun.HttpUtil; import com.macro.mall.common.baiduyun.HttpUtil;
import com.macro.mall.common.utils.HttpClientUtil;
import com.macro.mall.common.utils.MyJsonUtil; import com.macro.mall.common.utils.MyJsonUtil;
import com.macro.mall.dao.UmsMemberDao; import com.macro.mall.dao.UmsMemberDao;
import com.macro.mall.dao.vanke.VankeVvUserDao;
import com.macro.mall.mapper.UmsMemberMapper; import com.macro.mall.mapper.UmsMemberMapper;
import com.macro.mall.mapper.VankeDepartmentMapper; import com.macro.mall.mapper.VankeDepartmentMapper;
import com.macro.mall.mapper.VankeVvUserMapper; import com.macro.mall.mapper.VankeVvUserMapper;
import com.macro.mall.model.UmsMember; import com.macro.mall.model.*;
import com.macro.mall.model.VankeDepartment;
import com.macro.mall.model.VankeDepartmentExample;
import com.macro.mall.model.VankeVvUser;
import com.macro.mall.model.common.ResultMsg; import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeVvUserImportVo;
import com.macro.mall.service.member.UmsMemberService; import com.macro.mall.service.member.UmsMemberService;
import com.macro.mall.service.system.RedisService; import com.macro.mall.service.system.RedisService;
import com.macro.mall.service.system.impl.RedisServiceImpl; import com.macro.mall.service.vanke.IVankeConfigService;
import com.macro.mall.service.vanke.IVankeMemberLoginService; import com.macro.mall.service.vanke.IVankeMemberLoginService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.httpclient.NameValuePair;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@Service @Service
@Slf4j @Slf4j
public class VankeMemberLoginServiceImpl implements IVankeMemberLoginService { public class VankeMemberLoginServiceImpl implements IVankeMemberLoginService {
//轻应用id // //轻应用id
private String appId="500000185"; // private String appId=this.getConfig("appid");
//轻应用secret,即appsecret // //轻应用secret,即appsecret
private String secret="HEKm5mevdFJjyT7v"; // private String secret=this.getConfig("secret");
//当前北京时间,Unix格式13位时间戳,精确到毫秒,5分钟内有效。 // //授权级别:app
private Long timestamp=new java.util.Date().getTime(); // private String scope=this.getConfig("scope");
//授权级别:app // //需要拉去数据的企业 测试环境:eid:16216997 生产环境:eid:101
private String scope="app"; // private String eid=this.getConfig("eid");
// //测试环境:host:https://vvtest.vanke.com 生产环境:host:https://vv9.vanke.com
// private String host=this.getConfig("host");
@Autowired @Autowired
private RedisService redisService; private RedisService redisService;
@Resource @Autowired
private VankeVvUserDao vankeVvUserDao; private IVankeConfigService vankeConfigService;
@Resource @Resource
private VankeVvUserMapper vankeVvUserMapper; private VankeVvUserMapper vankeVvUserMapper;
@Resource @Resource
...@@ -57,20 +63,18 @@ public class VankeMemberLoginServiceImpl implements IVankeMemberLoginService { ...@@ -57,20 +63,18 @@ public class VankeMemberLoginServiceImpl implements IVankeMemberLoginService {
public String getVankeAccessToken() { public String getVankeAccessToken() {
//先判断redis是否存在vankeAccessToken //先判断redis是否存在vankeAccessToken
String vankeAccessToken = this.redisService.get("vankeAccessToken"); String vankeAccessToken = this.redisService.get("vankeAccessToken");
vankeAccessToken="";
if(vankeAccessToken == null || vankeAccessToken.isEmpty()){ if(vankeAccessToken == null || vankeAccessToken.isEmpty()){
Long times = this.timestamp;
String params ="{\n" + String params ="{\n" +
" \"appId\": \""+this.appId+"\",\n" + " \"appId\": \""+getConfig("appid")+"\",\n" +
" \"secret\": \""+this.secret+"\",\n" + " \"secret\": \""+getConfig("secret")+"\",\n" +
" \"timestamp\": "+times+",\n" + " \"timestamp\": "+new java.util.Date().getTime()+",\n" +
" \"scope\": \""+this.scope+"\"\n" + " \"scope\": \""+getConfig("scope")+"\"\n" +
"}"; "}";
String res = null; String res = null;
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
try { try {
res = HttpUtil.postGeneralUrl("https://vvtest.vanke.com/gateway/oauth2/token/getAccessToken","application/json",params,"UTF-8"); res = HttpUtil.postGeneralUrl(getConfig("host")+"/gateway/oauth2/token/getAccessToken","application/json",params,"UTF-8");
map = MyJsonUtil.getMapChangeJson(res); map = MyJsonUtil.getMapChangeJson(res);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -102,13 +106,13 @@ public class VankeMemberLoginServiceImpl implements IVankeMemberLoginService { ...@@ -102,13 +106,13 @@ public class VankeMemberLoginServiceImpl implements IVankeMemberLoginService {
} }
//通过appId 和 ticket 以及 token发起获取用户身份信息请求 //通过appId 和 ticket 以及 token发起获取用户身份信息请求
String params ="{\n" + String params ="{\n" +
" \"appid\": \""+this.appId+"\",\n" + " \"appid\": \""+getConfig("appid")+"\",\n" +
" \"ticket\": \""+ticket+"\"\n" + " \"ticket\": \""+ticket+"\"\n" +
"}"; "}";
String res = null; String res = null;
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
try { try {
res = HttpUtil.postGeneralUrl("https://vvtest.vanke.com/gateway/ticket/user/acquirecontext?accessToken="+this.getVankeAccessToken(),"application/json",params,"UTF-8"); res = HttpUtil.postGeneralUrl(getConfig("host")+"/gateway/ticket/user/acquirecontext?accessToken="+this.getVankeAccessToken(),"application/json",params,"UTF-8");
map = MyJsonUtil.getMapChangeJson(res); map = MyJsonUtil.getMapChangeJson(res);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -139,13 +143,13 @@ public class VankeMemberLoginServiceImpl implements IVankeMemberLoginService { ...@@ -139,13 +143,13 @@ public class VankeMemberLoginServiceImpl implements IVankeMemberLoginService {
} }
//通过appId 和 ticket 以及 token发起获取用户身份信息请求 //通过appId 和 ticket 以及 token发起获取用户身份信息请求
String params ="{\n" + String params ="{\n" +
" \"appid\": \""+this.appId+"\",\n" + " \"appid\": \""+getConfig("appid")+"\",\n" +
" \"ticket\": \""+ticket+"\"\n" + " \"ticket\": \""+ticket+"\"\n" +
"}"; "}";
String res = null; String res = null;
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
try { try {
res = HttpUtil.postGeneralUrl("https://vvtest.vanke.com/gateway/ticket/user/acquirecontext?accessToken="+this.getVankeAccessToken(),"application/json",params,"UTF-8"); res = HttpUtil.postGeneralUrl(getConfig("host")+"/gateway/ticket/user/acquirecontext?accessToken="+this.getVankeAccessToken(),"application/json",params,"UTF-8");
map = MyJsonUtil.getMapChangeJson(res); map = MyJsonUtil.getMapChangeJson(res);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -295,5 +299,127 @@ public class VankeMemberLoginServiceImpl implements IVankeMemberLoginService { ...@@ -295,5 +299,127 @@ public class VankeMemberLoginServiceImpl implements IVankeMemberLoginService {
} }
/**
* 通过 起始页 和 每页显示数量获取企业所有组织人员
* @return
*/
@Override
public List<VankeVvUserImportVo> getAllPersons(Integer pageNum,Integer pageSize){
String accessToken = this.getVankeAccessToken();
NameValuePair[] data = {
new NameValuePair("eid",getConfig("eid")),
new NameValuePair("time","2010-08-31 01:40:38"),//查询这个时刻之后所有变更的数据
new NameValuePair("begin",""+pageNum+""),
new NameValuePair("count",""+pageSize+"")
};
String res = null;
Map<String,Object> map = new HashMap<>();
try {
res = HttpClientUtil.formUrlencodedPost(getConfig("host")+"/gateway/opendata-control/data/getallpersons?accessToken="+accessToken,data);
map = MyJsonUtil.getMapChangeJson(res);
} catch (Exception e) {
e.printStackTrace();
}
String resJson = map.get("persons") + "";
JSONArray json = JSONArray.parseArray(resJson);
List<VankeVvUserImportVo> list = json.toJavaList(VankeVvUserImportVo.class);
return list;
}
public String testVankerefreshToken() {
//先判断redis是否存在vankeAccessToken
String vankeAccessToken="";
if(vankeAccessToken == null || vankeAccessToken.isEmpty()){
String params ="{\n" +
" \"appId\": \""+getConfig("appid")+"\",\n" +
" \"secret\": \""+getConfig("secret")+"\",\n" +
" \"timestamp\": "+new java.util.Date().getTime()+",\n" +
" \"scope\": \""+getConfig("scope")+"\"\n" +
"}";
String res = null;
Map<String,Object> map = new HashMap<>();
try {
res = HttpUtil.postGeneralUrl(getConfig("host")+"/gateway/oauth2/token/getAccessToken","application/json",params,"UTF-8");
map = MyJsonUtil.getMapChangeJson(res);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
if((boolean)map.get("success")){
//将token储存到redis 设置2小时有效期
}else{//获取token失败
log.info("获取token失败" + res);
}
return (String)map.get("accessToken");
}else{//否则存在直接返回accesToken
return vankeAccessToken;
}
}
/**
* 获取vanke配置 信息
* @return
*/
private VankeConfig getVankeConfig(){
//得到配置信息
VankeConfig vankeConfig = this.vankeConfigService.getConfig();
//将配置信息放置到redis中
//将token储存到redis 设置2小时有效期
redisService.set("vanke_appid", vankeConfig.getAppid());
redisService.set("vanke_secret", vankeConfig.getSecret());
redisService.set("vanke_scope", vankeConfig.getScope());
redisService.set("vanke_eid", vankeConfig.getEid());
redisService.set("vanke_host", vankeConfig.getHost());
return vankeConfig;
}
/**
* 得到具体参数
* @param flag
* @return
*/
private String getConfig(String flag){
String res = "";
if("appid".equals(flag)){
//先判断redis是否存在
String vanke_appid = this.redisService.get("vanke_appid");
if(vanke_appid == null || vanke_appid.isEmpty()){
return this.getVankeConfig().getAppid();
}
res = vanke_appid;
}else if("secret".equals(flag)){
//先判断redis是否存在
String vanke_secret = this.redisService.get("vanke_secret");
if(vanke_secret == null || vanke_secret.isEmpty()){
return this.getVankeConfig().getSecret();
}
res = vanke_secret;
}else if("scope".equals(flag)){
//先判断redis是否存在
String vanke_scope = this.redisService.get("vanke_scope");
if(vanke_scope == null || vanke_scope.isEmpty()){
return this.getVankeConfig().getScope();
}
res = vanke_scope;
}else if("eid".equals(flag)){
//先判断redis是否存在
String vanke_eid = this.redisService.get("vanke_eid");
if(vanke_eid == null || vanke_eid.isEmpty()){
return this.getVankeConfig().getEid();
}
res = vanke_eid;
}else if("host".equals(flag)){
//先判断redis是否存在
String vanke_host = this.redisService.get("vanke_host");
if(vanke_host == null || vanke_host.isEmpty()){
return this.getVankeConfig().getHost();
}
res = vanke_host;
}
return res;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment