From 6c788dd6ea84415920dee4242fe428adea92e0f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=B9=90?= <419641032@qq.com> Date: Tue, 15 Sep 2020 17:38:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=91=E9=80=81=E7=9F=AD=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/service/impl/SmsServiceImpl.java | 1 - .../service/impl/SystemCityServiceImpl.java | 1 + .../service/impl/SystemConfigServiceImpl.java | 1 + .../controller/WechatMediaController.java | 63 ------- .../controller/WechatMessageController.java | 116 ------------ .../zbkj/crmeb/wechat/dao/WechatMediaDao.java | 16 -- .../crmeb/wechat/dao/WechatMessageDao.java | 16 -- .../zbkj/crmeb/wechat/model/WechatMedia.java | 58 ------ .../crmeb/wechat/model/WechatMessage.java | 52 ------ .../wechat/request/WechatMediaRequest.java | 46 ----- .../request/WechatMediaSearchRequest.java | 50 ------ .../wechat/request/WechatMessageRequest.java | 44 ----- .../request/WechatMessageSearchRequest.java | 44 ----- .../wechat/service/WechatMediaService.java | 16 -- .../wechat/service/WechatMessageService.java | 18 -- .../service/impl/WechatMediaServiceImpl.java | 170 ------------------ .../impl/WechatMessageServiceImpl.java | 45 ----- 17 files changed, 2 insertions(+), 755 deletions(-) delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/controller/WechatMediaController.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/controller/WechatMessageController.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/dao/WechatMediaDao.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/dao/WechatMessageDao.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/model/WechatMedia.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/model/WechatMessage.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMediaRequest.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMediaSearchRequest.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMessageRequest.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMessageSearchRequest.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/service/WechatMediaService.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/service/WechatMessageService.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/service/impl/WechatMediaServiceImpl.java delete mode 100644 crmeb/src/main/java/com/zbkj/crmeb/wechat/service/impl/WechatMessageServiceImpl.java diff --git a/crmeb/src/main/java/com/zbkj/crmeb/sms/service/impl/SmsServiceImpl.java b/crmeb/src/main/java/com/zbkj/crmeb/sms/service/impl/SmsServiceImpl.java index 3f0de236..5c2d8c4b 100644 --- a/crmeb/src/main/java/com/zbkj/crmeb/sms/service/impl/SmsServiceImpl.java +++ b/crmeb/src/main/java/com/zbkj/crmeb/sms/service/impl/SmsServiceImpl.java @@ -369,7 +369,6 @@ public class SmsServiceImpl implements SmsService { Integer code = CrmebUtil.randomCount(111111, 999999); HashMap justPram = new HashMap<>(); justPram.put("code", code); - justPram.put("time", codeExpireStr); push(phone,SmsConstants.SMS_CONFIG_VERIFICATION_CODE, SmsConstants.SMS_CONFIG_VERIFICATION_CODE_TEMP_ID,false,justPram); diff --git a/crmeb/src/main/java/com/zbkj/crmeb/system/service/impl/SystemCityServiceImpl.java b/crmeb/src/main/java/com/zbkj/crmeb/system/service/impl/SystemCityServiceImpl.java index b7710e1d..e5b12adf 100644 --- a/crmeb/src/main/java/com/zbkj/crmeb/system/service/impl/SystemCityServiceImpl.java +++ b/crmeb/src/main/java/com/zbkj/crmeb/system/service/impl/SystemCityServiceImpl.java @@ -73,6 +73,7 @@ public class SystemCityServiceImpl extends ServiceImpl> upload( - @RequestParam("media") @ApiParam(name = "media", value = "待上传素材图片文件", required = true) MultipartFile file, - @RequestParam("type") @ApiParam(name = "type", value = "媒体文件类型,分别有图片(image)、语音(voice", required = true, allowableValues = "range[image,voice]") String type - ) throws Exception { - return CommonResult.success(wechatMediaService.upload(file, type)); - } - - /** - * 根据素材id查询素材 - * @param mediaId String 关键字 - * @author Mr.Zhang - * @since 2020-04-18 - */ - @ApiOperation(value = "根据素材id查询素材") - @RequestMapping(value = "/get", method = RequestMethod.GET) - public CommonResult> get(@RequestParam(value = "mediaId") String mediaId){ - Map map = new HashMap<>(); - String code = wechatMediaService.getMedia(mediaId); - map.put("code", code); - return CommonResult.success(map); - } -} - - - diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/controller/WechatMessageController.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/controller/WechatMessageController.java deleted file mode 100644 index d6c7494d..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/controller/WechatMessageController.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.zbkj.crmeb.wechat.controller; - -import com.common.CommonPage; -import com.common.CommonResult; -import com.common.PageParamRequest; -import com.zbkj.crmeb.wechat.request.WechatMessageRequest; -import com.zbkj.crmeb.wechat.request.WechatMessageSearchRequest; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.BeanUtils; -import org.springframework.web.bind.annotation.*; -import com.zbkj.crmeb.wechat.service.WechatMessageService; -import com.zbkj.crmeb.wechat.model.WechatMessage; - - -/** - * 用户行为记录表 前端控制器 - */ -@Slf4j -@RestController -@RequestMapping("api/admin/wechat/user/log") -@Api(tags = "微信开放平台 -- 用户行为记录") -public class WechatMessageController { - - @Autowired - private WechatMessageService wechatMessageService; - - /** - * 分页显示用户行为记录表 - * @param request 搜索条件 - * @param pageParamRequest 分页参数 - * @author Mr.Zhang - * @since 2020-04-18 - */ - @ApiOperation(value = "分页列表") - @RequestMapping(value = "/list", method = RequestMethod.GET) - public CommonResult> getList(@Validated WechatMessageSearchRequest request, @Validated PageParamRequest pageParamRequest){ - CommonPage wechatMessageCommonPage = CommonPage.restPage(wechatMessageService.getList(request, pageParamRequest)); - return CommonResult.success(wechatMessageCommonPage); - } - - /** - * 新增用户行为记录表 - * @param wechatMessageRequest 新增参数 - * @author Mr.Zhang - * @since 2020-04-18 - */ - @ApiOperation(value = "新增") - @RequestMapping(value = "/save", method = RequestMethod.POST) - public CommonResult save(@Validated WechatMessageRequest wechatMessageRequest){ - WechatMessage wechatMessage = new WechatMessage(); - BeanUtils.copyProperties(wechatMessageRequest, wechatMessage); - - if(wechatMessageService.save(wechatMessage)){ - return CommonResult.success(); - }else{ - return CommonResult.failed(); - } - } - - /** - * 删除用户行为记录表 - * @param id Integer - * @author Mr.Zhang - * @since 2020-04-18 - */ - @ApiOperation(value = "删除") - @RequestMapping(value = "/delete", method = RequestMethod.GET) - public CommonResult delete(@RequestParam(value = "id") Integer id){ - if(wechatMessageService.removeById(id)){ - return CommonResult.success(); - }else{ - return CommonResult.failed(); - } - } - - /** - * 修改用户行为记录表 - * @param id integer id - * @param wechatMessageRequest 修改参数 - * @author Mr.Zhang - * @since 2020-04-18 - */ - @ApiOperation(value = "修改") - @RequestMapping(value = "/update", method = RequestMethod.POST) - public CommonResult update(@RequestParam Integer id, @Validated WechatMessageRequest wechatMessageRequest){ - WechatMessage wechatMessage = new WechatMessage(); - BeanUtils.copyProperties(wechatMessageRequest, wechatMessage); - wechatMessage.setId(id); - - if(wechatMessageService.updateById(wechatMessage)){ - return CommonResult.success(); - }else{ - return CommonResult.failed(); - } - } - - /** - * 查询用户行为记录表信息 - * @param id Integer - * @author Mr.Zhang - * @since 2020-04-18 - */ - @ApiOperation(value = "详情") - @RequestMapping(value = "/info", method = RequestMethod.GET) - public CommonResult info(@RequestParam(value = "id") Integer id){ - WechatMessage wechatMessage = wechatMessageService.getById(id); - return CommonResult.success(wechatMessage); - } -} - - - diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/dao/WechatMediaDao.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/dao/WechatMediaDao.java deleted file mode 100644 index 1ab8d3d2..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/dao/WechatMediaDao.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.zbkj.crmeb.wechat.dao; - -import com.zbkj.crmeb.wechat.model.WechatMedia; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -/** - *

- * 微信回复表 Mapper 接口 - *

- * - * @author Mr.Zhang - * @since 2020-04-18 - */ -public interface WechatMediaDao extends BaseMapper { - -} diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/dao/WechatMessageDao.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/dao/WechatMessageDao.java deleted file mode 100644 index 550fac71..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/dao/WechatMessageDao.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.zbkj.crmeb.wechat.dao; - -import com.zbkj.crmeb.wechat.model.WechatMessage; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -/** - *

- * 用户行为记录表 Mapper 接口 - *

- * - * @author Mr.Zhang - * @since 2020-04-18 - */ -public interface WechatMessageDao extends BaseMapper { - -} diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/model/WechatMedia.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/model/WechatMedia.java deleted file mode 100644 index 4f123381..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/model/WechatMedia.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.zbkj.crmeb.wechat.model; - -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import java.io.Serializable; -import java.util.Date; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -/** - *

- * 微信回复表 - *

- * - * @author Mr.Zhang - * @since 2020-04-18 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@Accessors(chain = true) -@TableName("eb_wechat_media") -@ApiModel(value="WechatMedia对象", description="微信回复表") -public class WechatMedia implements Serializable { - - private static final long serialVersionUID=1L; - - @ApiModelProperty(value = "微信视频音频id") - @TableId(value = "id", type = IdType.AUTO) - private Integer id; - - @ApiModelProperty(value = "回复类型") - private String type; - - @ApiModelProperty(value = "文件路径") - private String path; - - @ApiModelProperty(value = "微信服务器返回的id") - private String mediaId; - - @ApiModelProperty(value = "地址") - private String url; - - @ApiModelProperty(value = "是否永久或者临时 0永久1临时") - private Boolean temporary; - - @ApiModelProperty(value = "创建时间") - private Date createTime; - - @ApiModelProperty(value = "修改时间") - private Date updateTime; - - -} diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/model/WechatMessage.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/model/WechatMessage.java deleted file mode 100644 index 75d21b5d..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/model/WechatMessage.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.zbkj.crmeb.wechat.model; - -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import java.io.Serializable; -import java.util.Date; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -/** - *

- * 用户行为记录表 - *

- * - * @author Mr.Zhang - * @since 2020-04-18 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@Accessors(chain = true) -@TableName("eb_wechat_message") -@ApiModel(value="WechatMessage对象", description="用户行为记录表") -public class WechatMessage implements Serializable { - - private static final long serialVersionUID=1L; - - @ApiModelProperty(value = "用户行为记录id") - @TableId(value = "id", type = IdType.AUTO) - private Integer id; - - @ApiModelProperty(value = "用户openid") - private String openid; - - @ApiModelProperty(value = "操作类型") - private String type; - - @ApiModelProperty(value = "操作详细记录") - private String result; - - @ApiModelProperty(value = "创建时间") - private Date createTime; - - @ApiModelProperty(value = "修改时间") - private Date updateTime; - - -} diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMediaRequest.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMediaRequest.java deleted file mode 100644 index bdd6f945..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMediaRequest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.zbkj.crmeb.wechat.request; - -import com.baomidou.mybatisplus.annotation.IdType; -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; - -/** - *

- * 微信回复表 - *

- * - * @author Mr.Zhang - * @since 2020-04-18 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@Accessors(chain = true) -@TableName("eb_wechat_media") -@ApiModel(value="WechatMedia对象", description="微信回复表") -public class WechatMediaRequest implements Serializable { - - private static final long serialVersionUID=1L; - - @ApiModelProperty(value = "回复类型") - private String type; - - @ApiModelProperty(value = "文件路径") - private String path; - - @ApiModelProperty(value = "微信服务器返回的id") - private String mediaId; - - @ApiModelProperty(value = "地址") - private String url; - - @ApiModelProperty(value = "是否永久或者临时 0永久1临时") - private Boolean temporary; - -} diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMediaSearchRequest.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMediaSearchRequest.java deleted file mode 100644 index 3a97453d..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMediaSearchRequest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.zbkj.crmeb.wechat.request; - -import com.baomidou.mybatisplus.annotation.IdType; -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; - -/** - *

- * 微信回复表 - *

- * - * @author Mr.Zhang - * @since 2020-04-18 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@Accessors(chain = true) -@TableName("eb_wechat_media") -@ApiModel(value="WechatMedia对象", description="微信回复表") -public class WechatMediaSearchRequest implements Serializable { - - private static final long serialVersionUID=1L; - - @ApiModelProperty(value = "微信视频音频id") - @TableId(value = "id", type = IdType.AUTO) - private Integer id; - - @ApiModelProperty(value = "回复类型") - private String type; - - @ApiModelProperty(value = "文件路径") - private String path; - - @ApiModelProperty(value = "微信服务器返回的id") - private String mediaId; - - @ApiModelProperty(value = "地址") - private String url; - - @ApiModelProperty(value = "是否永久或者临时 0永久1临时") - private Boolean temporary; - -} diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMessageRequest.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMessageRequest.java deleted file mode 100644 index 527abc1e..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMessageRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.zbkj.crmeb.wechat.request; - -import com.baomidou.mybatisplus.annotation.IdType; -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; - -/** - *

- * 用户行为记录表 - *

- * - * @author Mr.Zhang - * @since 2020-04-18 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@Accessors(chain = true) -@TableName("eb_wechat_message") -@ApiModel(value="WechatMessage对象", description="用户行为记录表") -public class WechatMessageRequest implements Serializable { - - private static final long serialVersionUID=1L; - - @ApiModelProperty(value = "用户openid") - private String openid; - - @ApiModelProperty(value = "操作类型") - private String type; - - @ApiModelProperty(value = "操作详细记录") - private String result; - - @ApiModelProperty(value = "操作时间") - private Integer addTime; - - -} diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMessageSearchRequest.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMessageSearchRequest.java deleted file mode 100644 index e134de52..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/request/WechatMessageSearchRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.zbkj.crmeb.wechat.request; - -import com.baomidou.mybatisplus.annotation.IdType; -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; - -/** - *

- * 用户行为记录表 - *

- * - * @author Mr.Zhang - * @since 2020-04-18 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@Accessors(chain = true) -@TableName("eb_wechat_message") -@ApiModel(value="WechatMessage对象", description="用户行为记录表") -public class WechatMessageSearchRequest implements Serializable { - - private static final long serialVersionUID=1L; - - @ApiModelProperty(value = "用户openid") - private String openid; - - @ApiModelProperty(value = "操作类型") - private String type; - - @ApiModelProperty(value = "操作详细记录") - private String result; - - @ApiModelProperty(value = "操作时间") - private Integer addTime; - - -} diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/service/WechatMediaService.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/service/WechatMediaService.java deleted file mode 100644 index 6519a67e..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/service/WechatMediaService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.zbkj.crmeb.wechat.service; - -import org.springframework.web.multipart.MultipartFile; - -import java.util.Map; - -/** -* @author Mr.Zhang -* @Description WechatMediaService 接口 -* @since 2020-04-18 -*/ -public interface WechatMediaService{ - Map upload(MultipartFile file, String type) throws Exception; - - String getMedia(String mediaId); -} \ No newline at end of file diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/service/WechatMessageService.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/service/WechatMessageService.java deleted file mode 100644 index 8ddceda5..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/service/WechatMessageService.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.zbkj.crmeb.wechat.service; - -import com.common.PageParamRequest; -import com.zbkj.crmeb.wechat.model.WechatMessage; -import com.baomidou.mybatisplus.extension.service.IService; -import com.zbkj.crmeb.wechat.request.WechatMessageSearchRequest; - -import java.util.List; - -/** -* @author Mr.Zhang -* @Description WechatMessageService 接口 -* @since 2020-04-18 -*/ -public interface WechatMessageService extends IService { - - List getList(WechatMessageSearchRequest request, PageParamRequest pageParamRequest); -} \ No newline at end of file diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/service/impl/WechatMediaServiceImpl.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/service/impl/WechatMediaServiceImpl.java deleted file mode 100644 index 1921cfb3..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/service/impl/WechatMediaServiceImpl.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.zbkj.crmeb.wechat.service.impl; - -import com.alibaba.fastjson.JSONObject; -import com.exception.CrmebException; -import com.utils.CrmebUtil; -import com.utils.RestTemplateUtil; -import com.utils.UploadWeChatMediaUtil; -import com.zbkj.crmeb.wechat.service.WeChatService; -import com.zbkj.crmeb.wechat.service.WechatMediaService; -import lombok.Data; -import org.apache.commons.codec.binary.Base64; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** -* @author Mr.Zhang -* @Description WechatMediaServiceImpl 接口实现 -* @since 2020-04-18 -*/ -@Data -@Service -public class WechatMediaServiceImpl implements WechatMediaService { - - @Autowired - private WeChatService weChatService; - - @Autowired - private RestTemplateUtil restTemplateUtil; - - private static final long maxSizeImage = 1024 * 1024 * 10; - - private static final String suffixNameImage = "bmp,png,jpeg,jpg,gif"; - - private static final long maxSizeVoice = 1024 * 1024 * 2; - - private static final String suffixNameVoice = "mp3,wma,wav,amr"; - - - - - - /** - * 上传素材到微信素材库 - * @param file MultipartFile 上传文件 - * @param type String 类型 媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb) - * @author Mr.Zhang - * @since 2020-04-18 - * @return String - */ - public Map upload(MultipartFile file, String type) throws Exception{ - try{ - String[] split = Objects.requireNonNull(file.getOriginalFilename()).split("\\."); - String suffixName = split[split.length-1]; - isValidPic(file.getSize(), suffixName, type); - - String url = weChatService.getUploadMedia() + "&type=" + type; - JSONObject response = UploadWeChatMediaUtil.uploadFile(url, file.getResource().getInputStream(), file.getOriginalFilename()); - if(null == response || !response.containsKey("media_id")){ - assert response != null; - throw new CrmebException("素材上传失败" + response.getString("errmsg")); - } - - Map map = new HashMap<>(); - map.put("mediaId", response.getString("media_id")); - map.put("url", response.getString("url")); - map.put("name", file.getOriginalFilename().replace(suffixName, "")); - - return map; - -// String mediaId = response.getString("media_id") ; //媒体文件id -// int count = weChatService.getMediaCount(type); //总数 -// -// if(count == 0){ -// throw new CrmebException("素材图片上传失败, 没有从微信服务器上找到相关信息"); -// } -// -// //获取最新的5个素材来对比 -// JSONObject info = weChatService.getMediaInfo(type, count-1, 5); //微信返回数据是倒序排序,所以拿到最新的5个即可,这里考虑到并发上传的问题,如果不存在并发只需要拿最新的一个即可 -// if(null == info){ -// throw new CrmebException("素材图片上传失败, 没有从微信服务器上找到相关信息1"); -// } -// String mediaUrl = ""; -// List list = JSONObject.parseArray(info.toJSONString(), MediaDetailVo.class); -// for (MediaDetailVo mediaDetailVo : list) { -// if(mediaId.equals(mediaDetailVo.getMediaId())){ -// mediaUrl = mediaDetailVo.getUrl(); -// break; -// } -// } -// -// if(StringUtils.isBlank(mediaUrl)){ -// throw new CrmebException("素材图片上传失败, 没有从微信服务器上找到相关信息2"); -// } -// -// Map map = new HashMap<>(); -// map.put("mediaId", mediaId); -// map.put("mediaUrl", mediaUrl); -// -// return map; - - }catch (Exception e){ - throw new CrmebException(e.getMessage()); - } - - - } - - /** - * 根据素材id查询素材 - * @param mediaId String 关键字 - * @author Mr.Zhang - * @since 2020-04-18 - * @return String - */ - @Override - public String getMedia(String mediaId) { - String url = weChatService.getUploadMedia(); - Map map = new HashMap<>(); - map.put("media_id", mediaId); - byte[] bytes = restTemplateUtil.postJsonDataAndReturnBuffer(url, JSONObject.parseObject("{\"media_id\", mediaId}")); - return CrmebUtil.getBase64Image(Base64.encodeBase64String(bytes)); - } - - - /** - * 是否符合微信规范 - * @param size long 文件大小 - * @param suffixName String 后缀名 - * @author Mr.Zhang - * @since 2020-04-18 - */ - private void isValidPic(long size, String suffixName, String type) { - JSONObject config = getConfig(); - if(!config.containsKey(type)){ - throw new CrmebException("不支持此类型"); - } - - long supportSize = config.getJSONObject(type).getLong("size"); - if(supportSize < size){ - throw new CrmebException("文件大小不能超过" + supportSize); - } - String supportNameSuffix = config.getJSONObject(type).getString("suffix"); - List suffixNameList = CrmebUtil.stringToArrayStr(supportNameSuffix); - if(!suffixNameList.contains(suffixName)){ - throw new CrmebException("文件格式必须是" + supportSize); - } - } - - /** - * 参数配置 - * @author Mr.Zhang - * @since 2020-04-18 - * @return JSONObject - */ - private JSONObject getConfig(){ - String data = "{" + - "image:{size:\""+maxSizeImage+"\", suffix: \""+suffixNameImage+"\"}, " + - "voice:{size:\""+maxSizeVoice+"\", suffix: \""+suffixNameVoice+"\"}" + - "}"; - return JSONObject.parseObject(data); - } - -} - diff --git a/crmeb/src/main/java/com/zbkj/crmeb/wechat/service/impl/WechatMessageServiceImpl.java b/crmeb/src/main/java/com/zbkj/crmeb/wechat/service/impl/WechatMessageServiceImpl.java deleted file mode 100644 index 83ee0a5c..00000000 --- a/crmeb/src/main/java/com/zbkj/crmeb/wechat/service/impl/WechatMessageServiceImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.zbkj.crmeb.wechat.service.impl; - -import com.common.PageParamRequest; -import com.github.pagehelper.PageHelper; -import com.utils.CrmebUtil; - -import com.zbkj.crmeb.wechat.model.WechatMessage; -import com.zbkj.crmeb.wechat.dao.WechatMessageDao; -import com.zbkj.crmeb.wechat.request.WechatMessageSearchRequest; -import com.zbkj.crmeb.wechat.service.WechatMessageService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.List; - -/** -* @author Mr.Zhang -* @Description WechatMessageServiceImpl 接口实现 -* @since 2020-04-18 -*/ -@Service -public class WechatMessageServiceImpl extends ServiceImpl implements WechatMessageService { - - @Resource - private WechatMessageDao dao; - - - /** - * 列表 - * @param request 请求参数 - * @param pageParamRequest 分页类参数 - * @author Mr.Zhang - * @since 2020-04-18 - * @return List - */ - @Override - public List getList(WechatMessageSearchRequest request, PageParamRequest pageParamRequest) { - PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit()); - return dao.selectList(null); - } - -} -