zhangjinli 3 years ago
parent 9e258a0a92
commit 7cdb21ee0b

@ -7,15 +7,13 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.zh.project0512.annotation.AdminCheckAuthorityAnnotation;
import com.zh.project0512.annotation.AdminTokenValid;
import com.zh.project0512.mapper.UserEffectRecordsMapper;
import com.zh.project0512.model.AppMessage;
import com.zh.project0512.model.UserEffectRecords;
import com.zh.project0512.model.Video;
import com.zh.project0512.model.VideoEffectSetting;
import com.zh.project0512.model.*;
import com.zh.project0512.service.IUserEffectRecordsService;
import com.zh.project0512.service.IUserService;
import com.zh.project0512.service.IVideoEffectSettingService;
import com.zh.project0512.service.IVideoService;
import com.zh.project0512.utils.AppMessageUtil;
import com.zh.project0512.utils.HttpUtil;
import com.zh.project0512.utils.MybatisPlusUtil;
import com.zh.project0512.utils.result.HttpStatusEnum;
import com.zh.project0512.utils.result.Result;
@ -54,6 +52,8 @@ public class VideoController {
private IVideoEffectSettingService videoEffectSettingService;
@Autowired
private UserEffectRecordsMapper userEffectRecordsMapper;
@Autowired
private HttpUtil httpUtil;
@Data
static class VParam {
@ -182,8 +182,20 @@ public class VideoController {
break;
default:
}
AppMessageUtil.sendMessage(new AppMessage().setTitle("传播效果审核结果").setDescription("恭喜您," + platForm + "传播效果审核通过,平台评定传播值为" + effectResult + "。")
.setUrl("pages/quest/subpage/detail/detail?id=" + video.getTaskId()).setReceiverId(video.getUserId()));
AppMessage appMessage = new AppMessage().setTitle("传播效果审核结果")
.setDescription("恭喜您," + platForm + "传播效果审核通过,平台评定传播值为" + effectResult + "。")
.setUrl("pages/quest/subpage/detail/detail?id=" + video.getTaskId())
.setReceiverId(video.getUserId());
// 企业微信消息通知
String touser = userService.getById(video.getUserId()).getUserid();
if (touser != null) {
appMessage.setTouser(touser);
// List<JSONObject>
JSONObject content_item = new JSONObject();
// content_item.fluentPut("")
httpUtil.qywxMessage(httpUtil.qywxGetToken(),touser,"传播效果审核",null,appMessage.getUrl(),null);
}
AppMessageUtil.sendMessage(appMessage);
return Result.success("", "审核完成");
}

@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -58,6 +60,12 @@ public class AppMessage extends Model {
@TableField("receiverId")
private Integer receiverId;
/**
* userid
*/
@TableField("touser")
private String touser;
/**
*
*/

@ -2,6 +2,7 @@ package com.zh.project0512.utils;
import com.zh.project0512.mapper.AppMessageMapper;
import com.zh.project0512.model.AppMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@ -15,7 +16,6 @@ import java.time.LocalDateTime;
public class AppMessageUtil {
@Resource
AppMessageMapper appMessageMapper;
//解决工具类无法调用Dao层数据数据为null
//静态初始化当前类
private static AppMessageUtil appMessageUtil;

@ -1,6 +1,7 @@
package com.zh.project0512.utils;
import com.alibaba.fastjson.JSONObject;
import com.zh.project0512.model.AppMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@ -21,6 +22,10 @@ public class HttpUtil {
private String corpid;
@Value("${qywx.corpsecret}")
private String corpsecret;
@Value("${qywx.agentid}")
private String agentid;
@Value("${wx.appid}")
private String appid;
public String qywxGetToken() {
String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
@ -28,18 +33,21 @@ public class HttpUtil {
String str = httpRequest(requestUrl, "GET", null);
return JSONObject.parseObject(str).getString("access_token");
}
public JSONObject qywxDepartmentList(String access_token) {
String url = "https://qyapi.weixin.qq.com/cgi-bin/department/list";
String requestUrl = url + "?access_token=" + access_token;
String str = httpRequest(requestUrl, "GET", null);
return JSONObject.parseObject(str);
}
public JSONObject qywxUserSession(String access_token, String code) {
String url = "https://qyapi.weixin.qq.com/cgi-bin/miniprogram/jscode2session";
String requestUrl = url + "?access_token=" + access_token + "&js_code=" + code + "&grant_type=authorization_code";
String str = httpRequest(requestUrl, "GET", null);
return JSONObject.parseObject(str);
}
public JSONObject qywxUser(String access_token, String userid) {
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/get";
String requestUrl = url + "?access_token=" + access_token + "&userid=" + userid;
@ -57,6 +65,32 @@ public class HttpUtil {
}
return parentid;
}
/**
*
* @param access_token
* @param touser:ID|1000eg:"zhangsan|lisi"
* @param title:4-12
* @param description:4-12
* @param wxAppUrl:1024
* @param content_item:10item
*/
public void qywxMessage(String access_token,String touser, String title,String description,String wxAppUrl,JSONObject content_item) {
JSONObject obj = new JSONObject();
obj.fluentPut("msgtype", "miniprogram_notice").fluentPut("agentid", agentid).fluentPut("touser", touser)
.fluentPut("miniprogram_notice",
new JSONObject().fluentPut("appid",appid)
.fluentPut("description",description)
.fluentPut("page",wxAppUrl)
.fluentPut("title",title)
.fluentPut("content_item",content_item));
String url = " https://qyapi.weixin.qq.com/cgi-bin/message/send";
String requestUrl = url + "?access_token=" + access_token;
String str = httpPost(requestUrl, obj);
System.out.println(obj);
System.out.println(str);
}
public static String httpRequest(String requestUrl, String requestMethod, String output) {
try {
URL url = new URL(requestUrl);

@ -102,6 +102,7 @@ wx:
qywx:
corpid: wwf8467e6545ca4032
corpsecret: u0bzd2vXOib7a6sVy60fwzR9v0Xgea929CApV4eChD0
agentid: 1000003
# 抖音开放平台配置信息
dy:
clientKey: awty3wnxx90jper9 #抖音开放平台key

Loading…
Cancel
Save