Browse Source

添加appId

dev_shibei_match
jianjun 5 years ago
parent
commit
cfd46b1bdf
  1. 5
      epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java
  2. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/MqMethodPathEnum.java
  3. 6
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
  4. 112
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/EventDTO.java
  5. 10
      epmet-module/epmet-common-service/common-service-server/pom.xml
  6. 27
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java
  7. 6
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/EventService.java
  8. 25
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java
  9. 8
      epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml
  10. 16
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml

5
epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java

@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
import com.alibaba.fastjson.JSON;
import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
@ -120,10 +121,10 @@ public class LoginServiceImpl implements LoginService {
wxMaJscode2SessionResult = wxMaServiceUtils.resiWxMaService().jsCode2SessionInfo(wxCode);
}
} catch (WxErrorException e) {
log.error("->[getMaOpenId]::error[{}]", "解析微信code失败");
log.error("->[getMaOpenId]::error[{}]", "解析微信code失败",e);
}
if (null == wxMaJscode2SessionResult) {
log.error(String.format("解析微信用户信息失败,app[%s],wxCode[%s]",app,wxCode));
log.error(String.format("解析微信用户信息失败,app[%s],wxCode[%s],result:[%S]",app,wxCode, JSON.toJSONString(wxMaJscode2SessionResult)));
throw new RenException("解析微信用户信息失败");
} else if (StringUtils.isBlank(wxMaJscode2SessionResult.getOpenid())) {
log.error(String.format("获取微信openid失败,app[%s],wxCode[%s]",app,wxCode));

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/MqMethodPathEnum.java

@ -9,6 +9,7 @@ package com.epmet.commons.tools.enums;
**/
public enum MqMethodPathEnum {
SEND_MSG("producerService/producer/sendMsg", "发送消息"),
GET_EVENT_LIST("/eventClass/getList", "获取时间类型列表"),
;

6
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java

@ -27,7 +27,6 @@ import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
@ -45,11 +44,10 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -188,7 +186,7 @@ public class HttpClientManager {
// HttpEntity reqEntity = MultipartEntityBuilder.create()
// .addPart("media", fileBody).build();
// httppost.setEntity(reqEntity);
return execute(httppost);
return execute(httppost,false);
} catch (Exception e) {
log.error("send exception", e);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());

112
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/EventDTO.java

@ -0,0 +1,112 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 事件表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-07-16
*/
@Data
public class EventDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 消息网关事件类别ID 从消息网关获取事件类型Id
*/
private String classId;
/**
* 消息网关APP_ID
*/
private String appId;
/**
* 消息网关APP_NAME
*/
private String appName;
/**
* 事件标识 与消息网关事件tag一致
*/
private String eventCode;
/**
* 事件名称
*/
private String eventName;
/**
* 事件说明
*/
private String eventDesc;
/**
* 事件功能分组ID 来自oper_customize.customer_function表
*/
private String functionId;
/**
* 是否是通用事件 0-1-消息体内需要体现该字段通用则说明由业务系统自己计算分值
*/
private String isCommon;
/**
* 删除标识 0-1-
*/
private String delFlag;
/**
* 乐观锁 查询时添加版本号新加的事件需要更新版本号
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

10
epmet-module/epmet-common-service/common-service-server/pom.xml

@ -116,6 +116,11 @@
<nacos.ip/>
<spring.flyway.enabled>false</spring.flyway.enabled>
<!--亿联云消息网关配置-->
<elink.mq.host>https://epmet-dev.elinkservice.cn/estos/</elink.mq.host>
<elink.mq.sendMsgPath>producerService/producer/sendMsg</elink.mq.sendMsgPath>
<elink.mq.appId>202007161443499985fa2d397436d10356542134c8f008c48</elink.mq.appId>
<elink.mq.token>52d9d9b0e7d0eb5b8b81c205b579e07c</elink.mq.token>
</properties>
</profile>
<profile>
@ -177,6 +182,11 @@
<nacos.ip/>
<spring.flyway.enabled>true</spring.flyway.enabled>
<!--亿联云消息网关配置-->
<elink.mq.host>https://epmet-dev.elinkservice.cn/estos/</elink.mq.host>
<elink.mq.sendMsgPath>producerService/producer/sendMsg</elink.mq.sendMsgPath>
<elink.mq.appId>202007161443499985fa2d397436d10356542134c8f008c48</elink.mq.appId>
<elink.mq.token>52d9d9b0e7d0eb5b8b81c205b579e07c</elink.mq.token>
</properties>
</profile>
</profiles>

27
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/EventController.java

@ -17,15 +17,24 @@
package com.epmet.controller;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.config.MqConfig;
import com.epmet.commons.tools.enums.MqMethodPathEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.form.EventFormDTO;
import com.epmet.dto.result.EventDTO;
import com.epmet.service.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 事件表
@ -39,6 +48,24 @@ public class EventController {
@Autowired
private EventService eventService;
@Autowired
private MqConfig mqConfig;
@GetMapping("page")
public Result<PageData<EventDTO>> page(@RequestParam Map<String, Object> params){
PageData<EventDTO> page = eventService.page(params);
return new Result<PageData<EventDTO>>().ok(page);
}
@GetMapping("geteventclass")
public Result<?> getEventClass(@RequestParam Map<String, Object> params){
params.put("token", mqConfig.getToken());
params.put("appId", mqConfig.getAppId());
Result<String> result = HttpClientManager.getInstance().sendPostByHttps(mqConfig.getHost().concat(MqMethodPathEnum.GET_EVENT_LIST.getCode()), JSON.toJSONString(params));
if (result.success()){
return new Result<>().ok(JSON.parseArray(result.getData()));
}
return new Result<>().error(EpmetErrorCode.SERVER_ERROR.getMsg());
}
/**
* desc:添加事件如果已存在则不作任何改动直接返回成功

6
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/EventService.java

@ -18,9 +18,13 @@
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.form.EventFormDTO;
import com.epmet.dto.result.EventDTO;
import com.epmet.entity.EventEntity;
import java.util.Map;
/**
* 事件表
*
@ -32,4 +36,6 @@ public interface EventService extends BaseService<EventEntity> {
void addEvent(EventFormDTO formDTO);
void updateEvent(EventFormDTO formDTO);
PageData<EventDTO> page(Map<String, Object> params);
}

25
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/EventServiceImpl.java

@ -17,15 +17,23 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.EventDao;
import com.epmet.dto.form.EventFormDTO;
import com.epmet.dto.result.EventDTO;
import com.epmet.entity.EventEntity;
import com.epmet.service.EventService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 事件表
*
@ -35,7 +43,14 @@ import org.springframework.stereotype.Service;
@Slf4j
@Service
public class EventServiceImpl extends BaseServiceImpl<EventDao, EventEntity> implements EventService {
@Override
public PageData<EventDTO> page(Map<String, Object> params) {
IPage<EventEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, EventDTO.class);
}
@Override
public void addEvent(EventFormDTO formDTO) {
EventEntity eventEntity = ConvertUtils.sourceToTarget(formDTO, EventEntity.class);
@ -46,4 +61,12 @@ public class EventServiceImpl extends BaseServiceImpl<EventDao, EventEntity> imp
public void updateEvent(EventFormDTO formDTO) {
//baseDao.update(eventEntity);
}
private QueryWrapper<EventEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<EventEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
}

8
epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml

@ -118,3 +118,11 @@ ribbon:
pagehelper:
helper-dialect: mysql
reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1
#亿联云消息网关
elink:
mq:
appId: @elink.mq.appId@ #项目接入亿联云的应用Id
token: @elink.mq.token@ #项目接入亿联云的应用token 相当于secret
host: @elink.mq.host@ #亿联云消息网关服务地址
sendMsgPath: @elink.mq.sendMsgPath@ #发送消息路径

16
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml

@ -118,13 +118,7 @@ pagehelper:
helper-dialect: mysql
reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1
#亿联云消息网关
elink:
mq:
appId: @elink.mq.appId@ #项目接入亿联云的应用Id
token: @elink.mq.token@ #项目接入亿联云的应用token 相当于secret
host: @elink.mq.host@ #亿联云消息网关服务地址
sendMsgPath: @elink.mq.sendMsgPath@ #发送消息路径
openapi:
scan:
server:
@ -132,3 +126,11 @@ openapi:
method:
imgSyncScan: /imgSyncScan
textSyncScan: /textSyncScan
#亿联云消息网关
elink:
mq:
appId: @elink.mq.appId@ #项目接入亿联云的应用Id
token: @elink.mq.token@ #项目接入亿联云的应用token 相当于secret
host: @elink.mq.host@ #亿联云消息网关服务地址
sendMsgPath: @elink.mq.sendMsgPath@ #发送消息路径
Loading…
Cancel
Save