From c725e6ea7204318dc60eff9562300165eb4285ad Mon Sep 17 00:00:00 2001 From: liuh Date: Wed, 23 Jun 2021 16:11:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E7=9F=AD=E4=BF=A1=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 11 ++ .../BizServiceEbtpExtendApplication.java | 2 - .../controller/BizShortMsgController.java | 30 +++ .../bizshortmessage/entity/BizQueryMsgVO.java | 72 +++++++ .../entity/BizSendEmailVO.java | 66 +++++++ .../bizshortmessage/entity/BizSendMsgVO.java | 39 ++++ .../bizshortmessage/enums/ExceptionEnum.java | 30 +++ .../service/BizShortMsgService.java | 9 + .../service/impl/BizShortMsgServiceImpl.java | 41 ++++ ...itional-spring-configuration-metadata.json | 1 + src/main/resources/application-local.yml | 22 +-- src/main/resources/application-localuat.yml | 182 ++++++++++++++++++ 12 files changed, 492 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/controller/BizShortMsgController.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/entity/BizQueryMsgVO.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/entity/BizSendEmailVO.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/entity/BizSendMsgVO.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/enums/ExceptionEnum.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/service/BizShortMsgService.java create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/service/impl/BizShortMsgServiceImpl.java create mode 100644 src/main/resources/META-INF/additional-spring-configuration-metadata.json create mode 100644 src/main/resources/application-localuat.yml diff --git a/pom.xml b/pom.xml index 2a0b67f..9014dd5 100644 --- a/pom.xml +++ b/pom.xml @@ -89,6 +89,17 @@ + + cn.chinaunicom.sdsi + core-service-notification-center-api + 1.0.0-SNAPSHOT + + + + + + + diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/BizServiceEbtpExtendApplication.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/BizServiceEbtpExtendApplication.java index 58a2b47..1187fe0 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/BizServiceEbtpExtendApplication.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/BizServiceEbtpExtendApplication.java @@ -3,7 +3,6 @@ package com.chinaunicom.mall.ebtp.extend; import cn.hutool.core.lang.Snowflake; import cn.hutool.core.util.IdUtil; import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; -import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig; import io.micrometer.core.instrument.MeterRegistry; import org.mybatis.spring.annotation.MapperScan; import org.springframework.beans.factory.annotation.Value; @@ -22,7 +21,6 @@ import org.springframework.context.annotation.ComponentScan; @EnableEurekaClient @MapperScan({"com.chinaunicom.mall.ebtp.extend.**.dao"}) @ComponentScan("com.chinaunicom.mall.ebtp.*") -@EnableApolloConfig public class BizServiceEbtpExtendApplication { public static void main(String[] args) { diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/controller/BizShortMsgController.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/controller/BizShortMsgController.java new file mode 100644 index 0000000..91f0568 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/controller/BizShortMsgController.java @@ -0,0 +1,30 @@ +package com.chinaunicom.mall.ebtp.extend.bizshortmessage.controller; + +import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse; +import com.chinaunicom.mall.ebtp.extend.bizshortmessage.entity.BizSendMsgVO; +import com.chinaunicom.mall.ebtp.extend.bizshortmessage.service.BizShortMsgService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@Api(tags = "短信接口") +@RequestMapping("/v1/sms") +public class BizShortMsgController { + + @Resource + private BizShortMsgService msgService; + + @ApiOperation("发送短信") + @PostMapping("/sendMsg") + public BaseResponse saveMsg(@RequestBody BizSendMsgVO msgVO) { + return BaseResponse.success(msgService.sendMsg(msgVO)); + } + + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/entity/BizQueryMsgVO.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/entity/BizQueryMsgVO.java new file mode 100644 index 0000000..f89cecc --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/entity/BizQueryMsgVO.java @@ -0,0 +1,72 @@ +package com.chinaunicom.mall.ebtp.extend.bizshortmessage.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.chinaunicom.mall.ebtp.common.config.CustomLocalDateTimeTypeHandler; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotEmpty; +import java.time.LocalDateTime; + +/** + * @Author liuh + * @Date 2021/6/21 下午6:47 + **/ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "BizQueryMsgVO", description = "短信查询对象") +public class BizQueryMsgVO { + + + + + @ApiModelProperty(value="发起开始时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(typeHandler = CustomLocalDateTimeTypeHandler.class) + private LocalDateTime startDate; + + @ApiModelProperty(value="发起结束时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(typeHandler = CustomLocalDateTimeTypeHandler.class) + private LocalDateTime endDate; + + @ApiModelProperty(value="短信发送状态 1:已发送2:未发送 ") + @NotEmpty(message = "短信发送状态不能为空") + private String sendStatus; + + + @ApiModelProperty(value="发送中心标识") + @NotEmpty(message = "发送中心标识不能为空") + private String sendCenter; + + @ApiModelProperty(value="发送业务模块标识") + @NotEmpty(message = "发送业务模块标识不能为空") + private String sendModule; + @ApiModelProperty(value="发送人标识") + private String sendUid; + @ApiModelProperty(value="邮箱前缀, 仅支持传入一个人的uid查询") + private String uid; + @ApiModelProperty(value="手机号,仅支持传入一个手机查询") + private String strMobileNumberr; + @ApiModelProperty(value="省ou") + private String provinceOu; + @ApiModelProperty(value="市ou") + private String cityOu; + @ApiModelProperty(value="单据id") + private String docId; + + @ApiModelProperty(value="每页数据个数(最大为100)") + private int pageSize; + @ApiModelProperty(value="当前页数") + private int pageNum; + + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/entity/BizSendEmailVO.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/entity/BizSendEmailVO.java new file mode 100644 index 0000000..029b274 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/entity/BizSendEmailVO.java @@ -0,0 +1,66 @@ +package com.chinaunicom.mall.ebtp.extend.bizshortmessage.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; + +/** + * @Author liuh + * @Date 2021/6/21 下午6:47 + **/ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "BizSendEmailVO", description = "发送邮件接口对象") +public class BizSendEmailVO { + + + @ApiModelProperty(value = "发送中心标识(字典表获取)") + @NotEmpty(message = "发送中心标识不能为空") + private String sendCenter; + + @ApiModelProperty(value = "发送业务模块标识(字典表获取)") + @NotEmpty(message = "发送中心标识不能为空") + private String sendModule; + + @ApiModelProperty(value = "发送人标识") + @NotEmpty(message = "发送人标识不能为空") + private String sendUid; + + @ApiModelProperty(value = "发送人名称") + @NotEmpty(message = "发送人名称不能为空") + private String sendUName; + + @ApiModelProperty(value = "1.收件人邮箱,多个逗号(,)分隔\n" + + "2.上限100个,超出部分自动抛弃\n" + + "3.与uId互斥,必选其一\n") + private String sendTo; + + @ApiModelProperty(value = "1.收件人集团用户中心系统账号,多个逗号(,)分隔\n" + + "2.上限100个,超出部分自动抛\n" + + "3.与sendTo 互斥,必选其一\n") + private String uid; + + @ApiModelProperty(value = "邮件标题") + private String subject; + + @ApiModelProperty(value = "邮件内容") + private String msg; + + @ApiModelProperty(value = "附件方式1:url 2:file流") + private String fileType; + + @ApiModelProperty(value = "URL方式或附件文件方式二选一:\n" + + "varchar:附件URL长度不超过1000\n" + + "File:附件文件(限制2M)\n") + private String file; + + @ApiModelProperty(value = "单据id") + private String docId; + + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/entity/BizSendMsgVO.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/entity/BizSendMsgVO.java new file mode 100644 index 0000000..673d6ec --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/entity/BizSendMsgVO.java @@ -0,0 +1,39 @@ +package com.chinaunicom.mall.ebtp.extend.bizshortmessage.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; + +/** + * @Author liuh + * @Date 2021/6/21 下午6:47 + **/ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "BizSendMsgVO对象", description = "发送短信接口对象") +public class BizSendMsgVO { + + + + @ApiModelProperty(value = "发送人标识") + @NotEmpty(message = "发送人标识不能为空") + private String sendUid; + + @ApiModelProperty(value = "发送人名称") + @NotEmpty(message = "发送人名称不能为空") + private String sendUName; + + @ApiModelProperty(value = "接收人手机号,多个逗号(,)分隔;上限100个,超出部分自动抛弃,与uId互斥,必选其一") + private String strMobileNumberr; + + @ApiModelProperty(value = "短信内容(最大长度2000)") + private String strContent; + + + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/enums/ExceptionEnum.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/enums/ExceptionEnum.java new file mode 100644 index 0000000..22ccbd1 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/enums/ExceptionEnum.java @@ -0,0 +1,30 @@ +package com.chinaunicom.mall.ebtp.extend.bizshortmessage.enums; + +import com.chinaunicom.mall.ebtp.common.exception.service.BusinessExceptionAssert; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ExceptionEnum implements BusinessExceptionAssert { + /** + * 发送短信返回结果错误 + */ + FRAME_EXCEPTION_SEND_MSG_FAIL(2200001, "调用短信接口异常!"), + + + + /** + * 判断接口返回是否有数据 + */ + IS_SUCCESS(2200002, "接口返回异常"); + + /** + * 返回码 + */ + private final int code; + /** + * 返回消息 + */ + private final String message; +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/service/BizShortMsgService.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/service/BizShortMsgService.java new file mode 100644 index 0000000..335e76f --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/service/BizShortMsgService.java @@ -0,0 +1,9 @@ +package com.chinaunicom.mall.ebtp.extend.bizshortmessage.service; + + +import com.chinaunicom.mall.ebtp.extend.bizshortmessage.entity.BizSendMsgVO; + +public interface BizShortMsgService { + + Boolean sendMsg(BizSendMsgVO msgVO); +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/service/impl/BizShortMsgServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/service/impl/BizShortMsgServiceImpl.java new file mode 100644 index 0000000..5ea8fb8 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/bizshortmessage/service/impl/BizShortMsgServiceImpl.java @@ -0,0 +1,41 @@ +package com.chinaunicom.mall.ebtp.extend.bizshortmessage.service.impl; + +import cn.chinaunicom.sdsi.notification.NotificationApiFeignClient; +import cn.chinaunicom.sdsi.sms.entity.EshopSmsPendingPO; +import com.chinaunicom.mall.ebtp.extend.bizshortmessage.entity.BizSendMsgVO; +import com.chinaunicom.mall.ebtp.extend.bizshortmessage.enums.ExceptionEnum; +import com.chinaunicom.mall.ebtp.extend.bizshortmessage.service.BizShortMsgService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + + +@Service +public class BizShortMsgServiceImpl implements BizShortMsgService { + + private static final Logger logger = LoggerFactory.getLogger(BizShortMsgServiceImpl.class); + + @Resource + private NotificationApiFeignClient feignClient; + + @Override + public Boolean sendMsg(BizSendMsgVO msgVO) { + EshopSmsPendingPO po = new EshopSmsPendingPO(); + + po.setSendCenter("ebtp"); + po.setSendModule("biz-service-ebtp-extend"); + po.setSendUid(msgVO.getSendUid()); + po.setSendUName(msgVO.getSendUName()); + po.setStrMobileNumber(msgVO.getStrMobileNumberr()); + po.setStrContent(msgVO.getStrContent()); + logger.info("调用短信接口入参:[{}]", po); + cn.chinaunicom.sdsi.framework.response.BaseResponse baseResponse = feignClient.saveMsg(po); + ExceptionEnum.FRAME_EXCEPTION_SEND_MSG_FAIL.customValid(!baseResponse.isSuccess()); + logger.info("调用短信接口返回:[{}]", baseResponse); + + return baseResponse.getData(); + } +} diff --git a/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 0000000..03d6a99 --- /dev/null +++ b/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1 @@ +{ "properties": [ ] } \ No newline at end of file diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 4e95ae0..7ea250f 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -4,17 +4,17 @@ server: context-path: / # 对应 apollo 配置中心的应用名 -app: - id: biz-service-ebtp-extend - -# Apollo 配置信息 -apollo: - meta: http://10.242.37.148:6001/ - bootstrap: - namespace: application - enabled: true - eagerLoad: - enabled: true +#app: +# id: biz-service-ebtp-extend +# +## Apollo 配置信息 +#apollo: +# meta: http://10.242.37.148:6001/ +# bootstrap: +# namespace: application +# enabled: true +# eagerLoad: +# enabled: true seata: service: diff --git a/src/main/resources/application-localuat.yml b/src/main/resources/application-localuat.yml new file mode 100644 index 0000000..c81bc5d --- /dev/null +++ b/src/main/resources/application-localuat.yml @@ -0,0 +1,182 @@ +server: + port: 18018 + servlet: + context-path: / + +# 对应 apollo 配置中心的应用名 +#app: +# id: biz-service-ebtp-extend +# +## Apollo 配置信息 +#apollo: +# meta: http://10.242.37.148:6001/ +# bootstrap: +# namespace: application +# enabled: true +# eagerLoad: +# enabled: true + +seata: + service: + vgroup-mapping: + biz-service-ebtp-extend-dev-service-group: default +spring: + main: + allow-bean-definition-overriding: true #支持名称相同的bean的覆盖 + aop: + auto: true #开启spring的aop配置 + proxy-target-class: true + + application: + name: biz-service-ebtp-extend-uat + + shardingsphere: + datasource: + names: ds0 + ds0: + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + username: mall + password: unicom + jdbc-url: jdbc:mysql://10.125.160.26:3306/ebtp_mall_extend?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true + url: jdbc:mysql://10.125.160.26:3306/ebtp_mall_extend?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true + filters: stat,wall,log4j + maxActive: 20 + initialSize: 1 + maxWait: 60000 + minIdle: 1 + timeBetweenEvictionRunsMillis: 60000 + minEvictableIdleTimeMillis: 300000 + validationQuery: select 'x' + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + poolPreparedStatements: true + maxOpenPreparedStatements: 20 + connection-properties: druid.stat.merggSql=ture;druid.stat.slowSqlMillis=5000 + props: + sql: + show: true + + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + serialization: + write-dates-as-timestamps: false + + # 天宫Kafka增加了安全认证,需要配置安全属性 + kafka: + bootstrap-servers: 10.125.164.192:32005,10.125.164.193:32005,10.125.164.194:32005 + template: + default-topic: jl_test + + # 生产者配置参数 + producer: + client-id: core-service-ebtp-crypt + properties: + security.protocol: SASL_PLAINTEXT + sasl.mechanism: SCRAM-SHA-256 + sasl.jaas.config: org.apache.kafka.common.security.scram.ScramLoginModule required username="jltest" password="Unicom#123"; + + # 消费者配置参数 + consumer: + group-id: core-service-ebtp-crypt-consumer + auto-offset-reset: latest + properties: + security.protocol: SASL_PLAINTEXT + sasl.mechanism: SCRAM-SHA-256 + sasl.jaas.config: org.apache.kafka.common.security.scram.ScramLoginModule required username="jltest" password="Unicom#123"; + + # 天宫 redis 需要使用哨兵进行访问 + redis: + sentinel: + master: eshop-redis + nodes: 10.125.164.124:32718, 10.125.164.118:32716, 10.125.164.121:32716 + password: Unicom#135 + +# 天宫Eureka配置 +eureka: + client: + service-url: + defaultZone: http://10.242.31.158:5001/eureka + instance: + prefer-ip-address: true + ip-address: 125.32.114.204 + hostname: 125.32.114.204 + instance-ip: 125.32.114.204:${server.port} + +mybatis-plus: + configuration: + # 是否开启自动驼峰命名规则映射:从数据库列名到Java属性驼峰命名的类似映射 + map-underscore-to-camel-case: true + auto-mapping-behavior: full + # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + mapper-locations: classpath*:com/chinaunicom/mall/ebtp/**/mapper/*Mapper.xml + global-config: + # 逻辑删除配置 + db-config: + # logic-delete-field: flag # 全局逻辑删除的实体字段名(since 3.3.0,配置后可以忽略不配置步骤2) @TableLogic + logic-delete-value: deleted # 逻辑已删除值 + logic-not-delete-value: normal # 逻辑未删除 + +# --------------feign ------------ +feign: + httpclient: + enabled: false + okhttp: + enabled: true + client: + config: + default: + connect-timeout: 20000 + read-timeout: 20000 + +hystrix: + command: + default: + execution: + timeout: + enabled: true + isolation: + strategy: SEMAPHORE + thread: + timeoutInMilliseconds: 200000 #熔断超时时间 + circuitBreaker: + sleepWindowInMilliseconds: 20000 + forceClosed: true + +ribbon: + ReadTimeout: 20000 #请求处理的超时时间 + ConnectTimeout: 20000 #请求连接超时时间 + MaxAutoRetries: 0 #对当前实例的重试次数 + MaxAutoRetriesNextServer: 1 #切换实例的重试次数 1 + +mconfig: + workerId: 1 + datacenterId: 1 + # 服务名 + feign: + name: + open: biz-service-ebtp-opening #开标大厅服务 + process: biz-service-ebtp-process #评审流程服务 + project: biz-service-ebtp-project #项目服务 + resps: biz-service-ebtp-resps #应答结构化服务 + rsms: biz-service-ebtp-rsms #评审结构化服务 + tender: biz-service-ebtp-tender #投标服务 + documentcenter: core-service-document-center #文档中心 + usercenter: core-service-usercenter-public #用户中心 + + +document: + clientHttpUrl: http://10.242.31.158:8100/auth/oauth/token?grant_type=client_credentials&client_id=bVS46ElU&client_secret=58ea04ba02475c8da2321cc99849d2a10f15b749 + +# 用户暴露给 prometheus 的健康数据 +management: + endpoints: + web: + exposure: + include: "*" + cors: + allowed-origins: "*" + allowed-methods: "*"