tongz
This commit is contained in:
@@ -19,7 +19,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 【请填写功能名称】Controller
|
* 【请填写功能名称】Controller
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2025-08-23
|
* @date 2025-08-23
|
||||||
*/
|
*/
|
||||||
@@ -77,7 +77,7 @@ public class NotificationsController extends BaseController
|
|||||||
recordsService.bind(id, shopUsers);
|
recordsService.bind(id, shopUsers);
|
||||||
return AjaxResult.success("绑定用户成功");
|
return AjaxResult.success("绑定用户成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取通知已绑定的用户列表
|
* 获取通知已绑定的用户列表
|
||||||
*/
|
*/
|
||||||
@@ -86,7 +86,7 @@ public class NotificationsController extends BaseController
|
|||||||
List<ShopUser> list = recordsService.getBindUsers(id);
|
List<ShopUser> list = recordsService.getBindUsers(id);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布通知
|
* 发布通知
|
||||||
*/
|
*/
|
||||||
@@ -95,6 +95,12 @@ public class NotificationsController extends BaseController
|
|||||||
public AjaxResult publish(@PathVariable("id") Long id) {
|
public AjaxResult publish(@PathVariable("id") Long id) {
|
||||||
return notificationsService.publishNotification(id);
|
return notificationsService.publishNotification(id);
|
||||||
}
|
}
|
||||||
|
// 发送全部
|
||||||
|
@Log(title = "发送全部通知", businessType = BusinessType.OTHER)
|
||||||
|
@PostMapping("/sendAll/{id}")
|
||||||
|
public AjaxResult sendAll(@PathVariable("id") Long id) {
|
||||||
|
return notificationsService.publishSendAll(id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ public class ClientShopUserController {
|
|||||||
* 获取验证码
|
* 获取验证码
|
||||||
*/
|
*/
|
||||||
@PostMapping("/getCode")
|
@PostMapping("/getCode")
|
||||||
public AjaxResult getCode(@RequestBody ShopUser shopUser){
|
public AjaxResult getCode(@RequestBody ShopUser shopUser) {
|
||||||
String result = aliConfigService.sendMsg(shopUser);
|
String result = aliConfigService.sendMsg(shopUser);
|
||||||
if (result != null){
|
if (result != null) {
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
return AjaxResult.error("发送验证码失败");
|
return AjaxResult.error("发送验证码失败");
|
||||||
@@ -49,13 +49,14 @@ public class ClientShopUserController {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/shopLogin")
|
@PostMapping("/shopLogin")
|
||||||
public AjaxResult shopLogin(@RequestBody ShopUserResq userResq)
|
public AjaxResult shopLogin(@RequestBody ShopUserResq userResq) {
|
||||||
{
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ShopUser shopUser = shopUserService.login(userResq);
|
ShopUser shopUser = shopUserService.login(userResq);
|
||||||
if (shopUser == null || shopUser.getMsg() != null){
|
if (shopUser == null) {
|
||||||
return new AjaxResult(999,"登录失败");
|
return new AjaxResult(999, "登录失败");
|
||||||
}else {
|
} else if (shopUser.getMsg() != null) {
|
||||||
|
return new AjaxResult(999, shopUser.getMsg());
|
||||||
|
} else {
|
||||||
// 生成令牌
|
// 生成令牌
|
||||||
String token = loginService.shopUserLogin(shopUser.getUsername(), shopUser.getPassword());
|
String token = loginService.shopUserLogin(shopUser.getUsername(), shopUser.getPassword());
|
||||||
ajax.put("data", shopUser);
|
ajax.put("data", shopUser);
|
||||||
@@ -66,14 +67,15 @@ public class ClientShopUserController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改个人信息
|
* 修改个人信息
|
||||||
|
*
|
||||||
* @param shopUser 个人信息
|
* @param shopUser 个人信息
|
||||||
* @return 成功
|
* @return 成功
|
||||||
*/
|
*/
|
||||||
@PostMapping("/updateUser")
|
@PostMapping("/updateUser")
|
||||||
public AjaxResult modifyUserInfo(@RequestBody ShopUser shopUser){
|
public AjaxResult modifyUserInfo(@RequestBody ShopUser shopUser) {
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
return AjaxResult.error(401,"用户未登录");
|
return AjaxResult.error(401, "用户未登录");
|
||||||
}
|
}
|
||||||
shopUser.setUserId(userId);
|
shopUser.setUserId(userId);
|
||||||
return AjaxResult.success(shopUserService.modifyUser(shopUser));
|
return AjaxResult.success(shopUserService.modifyUser(shopUser));
|
||||||
@@ -81,6 +83,7 @@ public class ClientShopUserController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取个人信息
|
* 获取个人信息
|
||||||
|
*
|
||||||
* @return 个人信息
|
* @return 个人信息
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getUserInfo")
|
@GetMapping("/getUserInfo")
|
||||||
@@ -88,23 +91,24 @@ public class ClientShopUserController {
|
|||||||
// 获取当前登录用户名
|
// 获取当前登录用户名
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
return AjaxResult.error(401,"用户未登录");
|
return AjaxResult.error(401, "用户未登录");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据用户ID查询完整的用户信息
|
// 根据用户ID查询完整的用户信息
|
||||||
ShopUser shopUser = iShopUserService.selectShopUserByUserId(userId);
|
ShopUser shopUser = iShopUserService.selectShopUserByUserId(userId);
|
||||||
if (shopUser == null) {
|
if (shopUser == null) {
|
||||||
return AjaxResult.error("未找到用户信息");
|
return AjaxResult.error("未找到用户信息");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 出于安全考虑,清除敏感信息
|
// 出于安全考虑,清除敏感信息
|
||||||
shopUser.setPassword(null);
|
shopUser.setPassword(null);
|
||||||
|
|
||||||
return AjaxResult.success(shopUser);
|
return AjaxResult.success(shopUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID获取个人信息
|
* 根据用户ID获取个人信息
|
||||||
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return 个人信息
|
* @return 个人信息
|
||||||
*/
|
*/
|
||||||
@@ -113,20 +117,19 @@ public class ClientShopUserController {
|
|||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
return AjaxResult.error("用户ID不能为空");
|
return AjaxResult.error("用户ID不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据用户ID查询完整的用户信息
|
// 根据用户ID查询完整的用户信息
|
||||||
ShopUser shopUser = iShopUserService.selectShopUserByUserId(userId);
|
ShopUser shopUser = iShopUserService.selectShopUserByUserId(userId);
|
||||||
if (shopUser == null) {
|
if (shopUser == null) {
|
||||||
return AjaxResult.error("未找到用户信息");
|
return AjaxResult.error("未找到用户信息");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 出于安全考虑,清除敏感信息
|
// 出于安全考虑,清除敏感信息
|
||||||
shopUser.setPassword(null);
|
shopUser.setPassword(null);
|
||||||
|
|
||||||
return AjaxResult.success(shopUser);
|
return AjaxResult.success(shopUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/user/file")
|
@PostMapping("/user/file")
|
||||||
public AjaxResult addConfigFile(
|
public AjaxResult addConfigFile(
|
||||||
@RequestParam("file") MultipartFile file
|
@RequestParam("file") MultipartFile file
|
||||||
@@ -134,17 +137,17 @@ public class ClientShopUserController {
|
|||||||
// 检查是否已经登录
|
// 检查是否已经登录
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
return AjaxResult.error(401,"用户未登录");
|
return AjaxResult.error(401, "用户未登录");
|
||||||
}
|
}
|
||||||
// 1. 处理文件上传
|
// 1. 处理文件上传
|
||||||
if (file != null && !file.isEmpty()) {
|
if (file != null && !file.isEmpty()) {
|
||||||
// 保存文件逻辑
|
// 保存文件逻辑
|
||||||
String url = AliConfig.ossUp("user/", file.getOriginalFilename(), file.getInputStream());
|
String url = AliConfig.ossUp("user/", file.getOriginalFilename(), file.getInputStream());
|
||||||
Map<String,Object> head = new HashMap<>();
|
Map<String, Object> head = new HashMap<>();
|
||||||
head.put("headImg",url);
|
head.put("headImg", url);
|
||||||
return AjaxResult.success("请求成功", head);
|
return AjaxResult.success("请求成功", head);
|
||||||
}
|
}
|
||||||
return AjaxResult.error("文件不能为空");
|
return AjaxResult.error("文件不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,6 @@ public class PushMsgInfo {
|
|||||||
private String title;
|
private String title;
|
||||||
private String text;
|
private String text;
|
||||||
private String ticker;
|
private String ticker;
|
||||||
|
private String deviceIds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,13 @@ import com.ruoyi.common.core.domain.UmResp;
|
|||||||
import com.ruoyi.common.core.domain.entity.PushMsgInfo;
|
import com.ruoyi.common.core.domain.entity.PushMsgInfo;
|
||||||
import com.ruoyi.common.enums.DeviceTypeEnum;
|
import com.ruoyi.common.enums.DeviceTypeEnum;
|
||||||
import com.ruoyi.common.utils.uuid.UUID;
|
import com.ruoyi.common.utils.uuid.UUID;
|
||||||
|
import com.ruoyi.system.config.push.AndroidColumnOn;
|
||||||
import com.ruoyi.system.config.push.AndroidNotification;
|
import com.ruoyi.system.config.push.AndroidNotification;
|
||||||
|
import com.ruoyi.system.config.push.IOSColumnOn;
|
||||||
import com.ruoyi.system.config.push.PushClient;
|
import com.ruoyi.system.config.push.PushClient;
|
||||||
|
import com.ruoyi.system.config.push.android.AndroidBroadcast;
|
||||||
import com.ruoyi.system.config.push.android.AndroidCustomizedcast;
|
import com.ruoyi.system.config.push.android.AndroidCustomizedcast;
|
||||||
|
import com.ruoyi.system.config.push.ios.IOSBroadcast;
|
||||||
import com.ruoyi.system.config.push.ios.IOSCustomizedcast;
|
import com.ruoyi.system.config.push.ios.IOSCustomizedcast;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
@@ -158,12 +162,101 @@ public class UmengConfig {
|
|||||||
client.send(customizedcast);
|
client.send(customizedcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendIOSBroadcast(PushMsgInfo pushMsgInfo) throws Exception {
|
||||||
|
IOSBroadcast broadcast = new IOSBroadcast(AliKeyConfig.UMApp_IOS_Key,AliKeyConfig.IOS_SECRET);
|
||||||
|
//alert值设置为字符串
|
||||||
|
//broadcast.setAlert("IOS 广播测试");
|
||||||
|
//alert的值设置为字典
|
||||||
|
broadcast.setAlert(pushMsgInfo.getTitle());
|
||||||
|
broadcast.setBadge(0);
|
||||||
|
broadcast.setSound( "default");
|
||||||
|
// TODO set 'production_mode' to 'true' if your app is under production mode
|
||||||
|
broadcast.setTestMode();
|
||||||
|
// Set customized fields
|
||||||
|
broadcast.setCustomizedField(pushMsgInfo.getTitle(), pushMsgInfo.getText());
|
||||||
|
client.send(broadcast);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendIOSColumnOn(PushMsgInfo pushMsgInfo) throws Exception {
|
||||||
|
// 自定义实体类, 附有代码
|
||||||
|
IOSColumnOn columnOn = new IOSColumnOn(AliKeyConfig.UMApp_IOS_Key,AliKeyConfig.IOS_SECRET);
|
||||||
|
columnOn.setDeviceToken(pushMsgInfo.getDeviceIds());
|
||||||
|
// 列播中 传入的deviceToken类似于 1,2,3,4,5
|
||||||
|
columnOn.setDeviceToken(pushMsgInfo.getDeviceIds());
|
||||||
|
columnOn.setAlert(pushMsgInfo.getTicker());
|
||||||
|
columnOn.setBadge(0);
|
||||||
|
columnOn.setSound("default");
|
||||||
|
// 点击"通知"的后续行为,默认为打开app。
|
||||||
|
columnOn.setTestMode();
|
||||||
|
columnOn.setCustomizedField(pushMsgInfo.getTitle(), pushMsgInfo.getText());
|
||||||
|
client.send(columnOn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendAndroidBroadcast(PushMsgInfo pushMsgInfo) throws Exception {
|
||||||
|
//"68a9988ce563686f4288e26d","vxq4qfnb3jbb3jahrcxpbtpjgcuu7dtm"
|
||||||
|
AndroidBroadcast broadcast = new AndroidBroadcast(AliKeyConfig.UMApp_Android_Key,AliKeyConfig.Android_SECRET);
|
||||||
|
broadcast.setTicker(pushMsgInfo.getTicker());
|
||||||
|
broadcast.setTitle(pushMsgInfo.getTitle());
|
||||||
|
broadcast.setText(pushMsgInfo.getText());
|
||||||
|
broadcast.goAppAfterOpen();
|
||||||
|
broadcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
|
||||||
|
// TODO Set 'production_mode' to 'false' if it's a test device.
|
||||||
|
// For how to register a test device, please see the developer doc.
|
||||||
|
broadcast.setProductionMode();
|
||||||
|
// Set customized fields
|
||||||
|
//broadcast.setExtraField("test", "helloworld");
|
||||||
|
//厂商通道相关参数
|
||||||
|
// broadcast.setChannelActivity("your channel activity");
|
||||||
|
// broadcast.setChannelProperties("abc");
|
||||||
|
client.send(broadcast);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列播推送
|
||||||
|
*
|
||||||
|
* @param deviceToken 多个device_tokens是用英文逗号间隔, 不能超过五百个
|
||||||
|
*/
|
||||||
|
public void sendAndroidColumnOn(PushMsgInfo pushMsgInfo) throws Exception {
|
||||||
|
// 自定义实体类, 附有代码
|
||||||
|
AndroidColumnOn columnOn = new AndroidColumnOn(AliKeyConfig.UMApp_Android_Key,AliKeyConfig.Android_SECRET);
|
||||||
|
// 列播中 传入的deviceToken类似于 1,2,3,4,5
|
||||||
|
columnOn.setDeviceToken(pushMsgInfo.getDeviceIds());
|
||||||
|
// 当你没有下拉通知栏的时候, 写入的文字会在顶端翻转显示, 有的可以显示有的不可以显示, 看你设置和设备的允许情况
|
||||||
|
columnOn.setTicker(pushMsgInfo.getTicker());
|
||||||
|
// 标题
|
||||||
|
columnOn.setTitle(pushMsgInfo.getTitle());
|
||||||
|
// 内容
|
||||||
|
columnOn.setText(pushMsgInfo.getText());
|
||||||
|
// 点击"通知"的后续行为,默认为打开app。
|
||||||
|
columnOn.goAppAfterOpen();
|
||||||
|
/**
|
||||||
|
* NOTIFICATION 是友盟做处理在通知栏上显示通知内容
|
||||||
|
* MESSAGE 是传给应用自身进行解析处理
|
||||||
|
*/
|
||||||
|
columnOn.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
|
||||||
|
|
||||||
|
// 测试模式使用false, 正式模式使用true
|
||||||
|
columnOn.setProductionMode();
|
||||||
|
|
||||||
|
// Set customized fields
|
||||||
|
columnOn.setExtraField("test", "helloworld");
|
||||||
|
|
||||||
|
// 自定义的一些东西
|
||||||
|
columnOn.setChannelActivity("your channel activity");
|
||||||
|
columnOn.setChannelProperties("abc");
|
||||||
|
client.send(columnOn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
UmengConfig umengConfig = new UmengConfig();
|
UmengConfig umengConfig = new UmengConfig();
|
||||||
System.out.println(DeviceTypeEnum.ANDROID.name());
|
//umengConfig.sendAndroidBroadcast();
|
||||||
UmResp sss1 = umengConfig.send(
|
// umengConfig.sendAndroidColumnOn("ArQoP2TkOFOCc11xP_biFmEO_DLfdKO0PZ4lvoWp5enm");
|
||||||
"eyJvIjoiaU9TIiwiayI6ImJNSGJwMktVdjhVaE5zOW1wQWhwYlwvWCtVRTlqcnZKeXhjb091N3BDdVlqcHNEc2RKM3A2M0pJZ056U0JrdlY5UlFPSHo3U25ZMmNcL3ZpbUI3ZHN2THFwQXlkbmRJeDB4NHhLSytFR2pvVEF4eU1oUnpUVHlrNHYzZThCSjNIajJOamJoK0VPdUtRTXV3N2pnS0dIdHJoT3FJRFF4QXJ0NisrUTI1ODhhQWdEVnp5TUVZdmxpTFhKeDUwS1wvZWI5VjdSb1VoNkMzc2E5Mm1xcHI1S3FxMm9KZHk3THoyYkVPQUVnM1hvWHJWVlwvcmtOMFluV1AyMVBZb0xrVFgxXC84TWZhVXZJRkY2aWJldDVaYkNzMVNhZU9LVU1rcnlicVpINHBMNlF5TzBFRjkrUHljT01hOGlVTjZabVZ6dm1HOFJHK3BjQjF1amVpSVpRN2N5bDRPOGxnPT0iLCJjIjoiSW02VTJVV3IxYTlDTkpmN29WR2FpRGxCZ3RSamQ5djUwaENCajJMWXd5N2Y3dzV2SndnWHFSXC8zeTlWYzFpSDFITnFHN1wvcUZpN2cxXC94cGQ5RGNsVjE0SXFKYmsxSHppZkNcL0JSU0NaeGpFTm5qWndTR3l1K1VnR3luajhnMWlHbkFhOHRmVWRUN0lGNWdrOGpVSVlteTZBNllkXC92Z2RXXC9wa1krcE9pczVWZEUrTjhXMjhEXC9idXhjQm1Wbm5obHpMWmdzRHUrdWcwQ0FMY2M0V3JybWdGdFcyOWN4Mkh5SGNNZ3AwY2xuOW5GQnNaS20zbDV3QWZIeUd2WkRpU1R3Q0lpSjFHUzNXUm1oZFVVdXo4NHRqMnBhWHZ1Y01Sa0tnNGt6Mk9cLyt4QmMrRzJ1VGpETXNtcW1nVUdBSWFoMlNyaGs5MEJMZWlKSFRLY0diTjlZbmN2cjZlMTBlZE1nSDR3QTB5K0lnTzlXd2t5OVAwb1FUbEZpUHd1Tm9PMm1OUEFpTDVwb3ZkZEp0QmY4TDZmb3B1NWl4a0FnVzBUdFM2OHN3Y3BaeWhuT25zRks0dXI2OHc3YWIySWJPNWpZMnhLTHZvb1NjMmRcLzhcL2JSTmxFM0txUUFLcDRGQUpxdWJ2bjhQRzdPcGN2bXhuSkF4bTJYNTFkQUZtaTdsSjZuZlc0MlJSNDRZWDBtMlhkczAwY3hZa2s5Q29zeVdWVUdGUkVDMjdjUUFURU9PMWp2TzdlMHEwOTRLZjdnaEx2UFJadlo2bFIxSUxmTTJxeWlQc0V5dmRiSUJyaG1yVEtJOWdqRW5Qc3U2dEZPc1RiZ0oxaVwvNGZBRFBKWDhOczF1Ym9taVl2KzZnVGsyNzlZTmQ3WU9OT21mMzlTOG05RktrNEN3Uk1QT1wvcVVSMGRJN25HbER4U1wvWEFFbWNHU0wxcDllczN0U0lsVUIrbHNcL3luWWZFNWNicDIwRE9NV3ZcL0xLa0I2cXA5RkVtaXV6eDY2MWYzZE9hZnk2WUJ2V2dsQnljU05TSkdDNkpYeTZnWHEwR1wvNE9XTkRPdjFhakIxMnhGRk9PK1dhbUVKcG9Takxic0FFV0V5eEtDb3pXaU9meG0ydEJ0bHdoM2hwXC9Vb3RyRCtIbkY2Z1NOOGtCblVtYnJRU3FzYUdsM2g3WDZSZUREbXdRSmMzSzY0QkxNcCJ9", "IOS");
|
// umengConfig.sendAndroidColumnOn("ApqqKzPuBZdgILvIrX0Hq099e3qN_Z8ub_P0qoIvwEdi");
|
||||||
|
// System.out.println(DeviceTypeEnum.ANDROID.name());
|
||||||
|
// UmResp sss1 = umengConfig.send(
|
||||||
|
// "eyJvIjoiaU9TIiwiayI6ImJNSGJwMktVdjhVaE5zOW1wQWhwYlwvWCtVRTlqcnZKeXhjb091N3BDdVlqcHNEc2RKM3A2M0pJZ056U0JrdlY5UlFPSHo3U25ZMmNcL3ZpbUI3ZHN2THFwQXlkbmRJeDB4NHhLSytFR2pvVEF4eU1oUnpUVHlrNHYzZThCSjNIajJOamJoK0VPdUtRTXV3N2pnS0dIdHJoT3FJRFF4QXJ0NisrUTI1ODhhQWdEVnp5TUVZdmxpTFhKeDUwS1wvZWI5VjdSb1VoNkMzc2E5Mm1xcHI1S3FxMm9KZHk3THoyYkVPQUVnM1hvWHJWVlwvcmtOMFluV1AyMVBZb0xrVFgxXC84TWZhVXZJRkY2aWJldDVaYkNzMVNhZU9LVU1rcnlicVpINHBMNlF5TzBFRjkrUHljT01hOGlVTjZabVZ6dm1HOFJHK3BjQjF1amVpSVpRN2N5bDRPOGxnPT0iLCJjIjoiSW02VTJVV3IxYTlDTkpmN29WR2FpRGxCZ3RSamQ5djUwaENCajJMWXd5N2Y3dzV2SndnWHFSXC8zeTlWYzFpSDFITnFHN1wvcUZpN2cxXC94cGQ5RGNsVjE0SXFKYmsxSHppZkNcL0JSU0NaeGpFTm5qWndTR3l1K1VnR3luajhnMWlHbkFhOHRmVWRUN0lGNWdrOGpVSVlteTZBNllkXC92Z2RXXC9wa1krcE9pczVWZEUrTjhXMjhEXC9idXhjQm1Wbm5obHpMWmdzRHUrdWcwQ0FMY2M0V3JybWdGdFcyOWN4Mkh5SGNNZ3AwY2xuOW5GQnNaS20zbDV3QWZIeUd2WkRpU1R3Q0lpSjFHUzNXUm1oZFVVdXo4NHRqMnBhWHZ1Y01Sa0tnNGt6Mk9cLyt4QmMrRzJ1VGpETXNtcW1nVUdBSWFoMlNyaGs5MEJMZWlKSFRLY0diTjlZbmN2cjZlMTBlZE1nSDR3QTB5K0lnTzlXd2t5OVAwb1FUbEZpUHd1Tm9PMm1OUEFpTDVwb3ZkZEp0QmY4TDZmb3B1NWl4a0FnVzBUdFM2OHN3Y3BaeWhuT25zRks0dXI2OHc3YWIySWJPNWpZMnhLTHZvb1NjMmRcLzhcL2JSTmxFM0txUUFLcDRGQUpxdWJ2bjhQRzdPcGN2bXhuSkF4bTJYNTFkQUZtaTdsSjZuZlc0MlJSNDRZWDBtMlhkczAwY3hZa2s5Q29zeVdWVUdGUkVDMjdjUUFURU9PMWp2TzdlMHEwOTRLZjdnaEx2UFJadlo2bFIxSUxmTTJxeWlQc0V5dmRiSUJyaG1yVEtJOWdqRW5Qc3U2dEZPc1RiZ0oxaVwvNGZBRFBKWDhOczF1Ym9taVl2KzZnVGsyNzlZTmQ3WU9OT21mMzlTOG05RktrNEN3Uk1QT1wvcVVSMGRJN25HbER4U1wvWEFFbWNHU0wxcDllczN0U0lsVUIrbHNcL3luWWZFNWNicDIwRE9NV3ZcL0xLa0I2cXA5RkVtaXV6eDY2MWYzZE9hZnk2WUJ2V2dsQnljU05TSkdDNkpYeTZnWHEwR1wvNE9XTkRPdjFhakIxMnhGRk9PK1dhbUVKcG9Takxic0FFV0V5eEtDb3pXaU9meG0ydEJ0bHdoM2hwXC9Vb3RyRCtIbkY2Z1NOOGtCblVtYnJRU3FzYUdsM2g3WDZSZUREbXdRSmMzSzY0QkxNcCJ9", "IOS");
|
||||||
// String sss;
|
// String sss;
|
||||||
|
|
||||||
// sss = "{\"success\":true,\"data\":{\"mobile\":\"18518753918\",\"score\":null,\"activeScore\":null,\"aesEncryptKey\":null},\"code\":2001,\"message\":\"gain mobile's result success\",\"requestId\":\"0E87E249-42A0-42C0-94D3-7424D45E571E\"}\n";
|
// sss = "{\"success\":true,\"data\":{\"mobile\":\"18518753918\",\"score\":null,\"activeScore\":null,\"aesEncryptKey\":null},\"code\":2001,\"message\":\"gain mobile's result success\",\"requestId\":\"0E87E249-42A0-42C0-94D3-7424D45E571E\"}\n";
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.ruoyi.system.config.push;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列播(要求不超过500个device_token) 用英文逗号隔开
|
||||||
|
*/
|
||||||
|
public class AndroidColumnOn extends AndroidNotification {
|
||||||
|
|
||||||
|
public AndroidColumnOn(String appkey,String appMasterSecret) throws Exception {
|
||||||
|
setAppMasterSecret(appMasterSecret);
|
||||||
|
setPredefinedKeyValue("appkey", appkey);
|
||||||
|
this.setPredefinedKeyValue("type", "listcast"); // type = listcast 是群体发送
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceToken(String token) throws Exception {
|
||||||
|
setPredefinedKeyValue("device_tokens", token);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ public class Demo {
|
|||||||
private String appMasterSecret = null;
|
private String appMasterSecret = null;
|
||||||
private String timestamp = null;
|
private String timestamp = null;
|
||||||
private PushClient client = new PushClient();
|
private PushClient client = new PushClient();
|
||||||
|
|
||||||
public Demo(String key, String secret) {
|
public Demo(String key, String secret) {
|
||||||
try {
|
try {
|
||||||
appkey = key;
|
appkey = key;
|
||||||
@@ -21,25 +21,9 @@ public class Demo {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendAndroidBroadcast() throws Exception {
|
|
||||||
AndroidBroadcast broadcast = new AndroidBroadcast(appkey,appMasterSecret);
|
|
||||||
broadcast.setTicker( "Android broadcast ticker");
|
|
||||||
broadcast.setTitle( "中文的title");
|
|
||||||
broadcast.setText( "Android broadcast text");
|
|
||||||
broadcast.goAppAfterOpen();
|
|
||||||
broadcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
|
|
||||||
// TODO Set 'production_mode' to 'false' if it's a test device.
|
|
||||||
// For how to register a test device, please see the developer doc.
|
|
||||||
broadcast.setProductionMode();
|
|
||||||
// Set customized fields
|
|
||||||
broadcast.setExtraField("test", "helloworld");
|
|
||||||
//厂商通道相关参数
|
|
||||||
broadcast.setChannelActivity("your channel activity");
|
|
||||||
broadcast.setChannelProperties("abc");
|
|
||||||
client.send(broadcast);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendAndroidUnicast() throws Exception {
|
public void sendAndroidUnicast() throws Exception {
|
||||||
AndroidUnicast unicast = new AndroidUnicast(appkey,appMasterSecret);
|
AndroidUnicast unicast = new AndroidUnicast(appkey,appMasterSecret);
|
||||||
// TODO Set your device token
|
// TODO Set your device token
|
||||||
@@ -49,7 +33,7 @@ public class Demo {
|
|||||||
unicast.setText( "Android unicast text");
|
unicast.setText( "Android unicast text");
|
||||||
unicast.goAppAfterOpen();
|
unicast.goAppAfterOpen();
|
||||||
unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
|
unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
|
||||||
// TODO Set 'production_mode' to 'false' if it's a test device.
|
// TODO Set 'production_mode' to 'false' if it's a test device.
|
||||||
// For how to register a test device, please see the developer doc.
|
// For how to register a test device, please see the developer doc.
|
||||||
unicast.setProductionMode();
|
unicast.setProductionMode();
|
||||||
// Set customized fields
|
// Set customized fields
|
||||||
@@ -58,14 +42,14 @@ public class Demo {
|
|||||||
unicast.setChannelProperties("abc");
|
unicast.setChannelProperties("abc");
|
||||||
client.send(unicast);
|
client.send(unicast);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendAndroidGroupcast() throws Exception {
|
public void sendAndroidGroupcast() throws Exception {
|
||||||
AndroidGroupcast groupcast = new AndroidGroupcast(appkey,appMasterSecret);
|
AndroidGroupcast groupcast = new AndroidGroupcast(appkey,appMasterSecret);
|
||||||
/* TODO
|
/* TODO
|
||||||
* Construct the filter condition:
|
* Construct the filter condition:
|
||||||
* "where":
|
* "where":
|
||||||
* {
|
* {
|
||||||
* "and":
|
* "and":
|
||||||
* [
|
* [
|
||||||
* {"tag":"test"},
|
* {"tag":"test"},
|
||||||
* {"tag":"Test"}
|
* {"tag":"Test"}
|
||||||
@@ -91,7 +75,7 @@ public class Demo {
|
|||||||
groupcast.goAppAfterOpen();
|
groupcast.goAppAfterOpen();
|
||||||
groupcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
|
groupcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
|
||||||
groupcast.setChannelActivity("your channel activity");
|
groupcast.setChannelActivity("your channel activity");
|
||||||
// TODO Set 'production_mode' to 'false' if it's a test device.
|
// TODO Set 'production_mode' to 'false' if it's a test device.
|
||||||
// For how to register a test device, please see the developer doc.
|
// For how to register a test device, please see the developer doc.
|
||||||
groupcast.setProductionMode();
|
groupcast.setProductionMode();
|
||||||
//厂商通道相关参数
|
//厂商通道相关参数
|
||||||
@@ -99,7 +83,7 @@ public class Demo {
|
|||||||
groupcast.setChannelProperties("abc");
|
groupcast.setChannelProperties("abc");
|
||||||
client.send(groupcast);
|
client.send(groupcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void sendAndroidCustomizedcast() throws Exception {
|
// public void sendAndroidCustomizedcast() throws Exception {
|
||||||
// AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey,appMasterSecret);
|
// AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey,appMasterSecret);
|
||||||
// // TODO Set your alias here, and use comma to split them if there are multiple alias.
|
// // TODO Set your alias here, and use comma to split them if there are multiple alias.
|
||||||
@@ -119,11 +103,11 @@ public class Demo {
|
|||||||
// customizedcast.setChannelProperties("abc");
|
// customizedcast.setChannelProperties("abc");
|
||||||
// client.send(customizedcast);
|
// client.send(customizedcast);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public void sendAndroidCustomizedcastFile() throws Exception {
|
public void sendAndroidCustomizedcastFile() throws Exception {
|
||||||
AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey,appMasterSecret);
|
AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey,appMasterSecret);
|
||||||
// TODO Set your alias here, and use comma to split them if there are multiple alias.
|
// TODO Set your alias here, and use comma to split them if there are multiple alias.
|
||||||
// And if you have many alias, you can also upload a file containing these alias, then
|
// And if you have many alias, you can also upload a file containing these alias, then
|
||||||
// use file_id to send customized notification.
|
// use file_id to send customized notification.
|
||||||
String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb"+"\n"+"alias");
|
String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb"+"\n"+"alias");
|
||||||
customizedcast.setFileId(fileId, "alias_type");
|
customizedcast.setFileId(fileId, "alias_type");
|
||||||
@@ -132,7 +116,7 @@ public class Demo {
|
|||||||
customizedcast.setText( "Android customizedcast text");
|
customizedcast.setText( "Android customizedcast text");
|
||||||
customizedcast.goAppAfterOpen();
|
customizedcast.goAppAfterOpen();
|
||||||
customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
|
customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
|
||||||
// TODO Set 'production_mode' to 'false' if it's a test device.
|
// TODO Set 'production_mode' to 'false' if it's a test device.
|
||||||
// For how to register a test device, please see the developer doc.
|
// For how to register a test device, please see the developer doc.
|
||||||
customizedcast.setProductionMode();
|
customizedcast.setProductionMode();
|
||||||
//厂商通道相关参数
|
//厂商通道相关参数
|
||||||
@@ -140,10 +124,10 @@ public class Demo {
|
|||||||
customizedcast.setChannelProperties("abc");
|
customizedcast.setChannelProperties("abc");
|
||||||
client.send(customizedcast);
|
client.send(customizedcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendAndroidFilecast() throws Exception {
|
public void sendAndroidFilecast() throws Exception {
|
||||||
AndroidFilecast filecast = new AndroidFilecast(appkey,appMasterSecret);
|
AndroidFilecast filecast = new AndroidFilecast(appkey,appMasterSecret);
|
||||||
// TODO upload your device tokens, and use '\n' to split them if there are multiple tokens
|
// TODO upload your device tokens, and use '\n' to split them if there are multiple tokens
|
||||||
String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb");
|
String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb");
|
||||||
filecast.setFileId( fileId);
|
filecast.setFileId( fileId);
|
||||||
filecast.setTicker( "Android filecast ticker");
|
filecast.setTicker( "Android filecast ticker");
|
||||||
@@ -156,7 +140,7 @@ public class Demo {
|
|||||||
filecast.setChannelProperties("abc");
|
filecast.setChannelProperties("abc");
|
||||||
client.send(filecast);
|
client.send(filecast);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendIOSBroadcast() throws Exception {
|
public void sendIOSBroadcast() throws Exception {
|
||||||
IOSBroadcast broadcast = new IOSBroadcast(appkey,appMasterSecret);
|
IOSBroadcast broadcast = new IOSBroadcast(appkey,appMasterSecret);
|
||||||
//alert值设置为字符串
|
//alert值设置为字符串
|
||||||
@@ -171,7 +155,7 @@ public class Demo {
|
|||||||
broadcast.setCustomizedField("test", "helloworld");
|
broadcast.setCustomizedField("test", "helloworld");
|
||||||
client.send(broadcast);
|
client.send(broadcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendIOSUnicast() throws Exception {
|
public void sendIOSUnicast() throws Exception {
|
||||||
IOSUnicast unicast = new IOSUnicast(appkey,appMasterSecret);
|
IOSUnicast unicast = new IOSUnicast(appkey,appMasterSecret);
|
||||||
// TODO Set your device token
|
// TODO Set your device token
|
||||||
@@ -189,14 +173,14 @@ public class Demo {
|
|||||||
client.send(unicast);
|
client.send(unicast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void sendIOSGroupcast() throws Exception {
|
public void sendIOSGroupcast() throws Exception {
|
||||||
IOSGroupcast groupcast = new IOSGroupcast(appkey,appMasterSecret);
|
IOSGroupcast groupcast = new IOSGroupcast(appkey,appMasterSecret);
|
||||||
/* TODO
|
/* TODO
|
||||||
* Construct the filter condition:
|
* Construct the filter condition:
|
||||||
* "where":
|
* "where":
|
||||||
* {
|
* {
|
||||||
* "and":
|
* "and":
|
||||||
* [
|
* [
|
||||||
* {"tag":"iostest"}
|
* {"tag":"iostest"}
|
||||||
* ]
|
* ]
|
||||||
@@ -211,7 +195,7 @@ public class Demo {
|
|||||||
whereJson.put("and", tagArray);
|
whereJson.put("and", tagArray);
|
||||||
filterJson.put("where", whereJson);
|
filterJson.put("where", whereJson);
|
||||||
System.out.println(filterJson.toString());
|
System.out.println(filterJson.toString());
|
||||||
|
|
||||||
// Set filter condition into rootJson
|
// Set filter condition into rootJson
|
||||||
groupcast.setFilter(filterJson);
|
groupcast.setFilter(filterJson);
|
||||||
//groupcast.setAlert("IOS 组播测试");
|
//groupcast.setAlert("IOS 组播测试");
|
||||||
@@ -223,11 +207,11 @@ public class Demo {
|
|||||||
groupcast.setTestMode();
|
groupcast.setTestMode();
|
||||||
client.send(groupcast);
|
client.send(groupcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendIOSCustomizedcast() throws Exception {
|
public void sendIOSCustomizedcast() throws Exception {
|
||||||
IOSCustomizedcast customizedcast = new IOSCustomizedcast(appkey,appMasterSecret);
|
IOSCustomizedcast customizedcast = new IOSCustomizedcast(appkey,appMasterSecret);
|
||||||
// TODO Set your alias and alias_type here, and use comma to split them if there are multiple alias.
|
// TODO Set your alias and alias_type here, and use comma to split them if there are multiple alias.
|
||||||
// And if you have many alias, you can also upload a file containing these alias, then
|
// And if you have many alias, you can also upload a file containing these alias, then
|
||||||
// use file_id to send customized notification.
|
// use file_id to send customized notification.
|
||||||
customizedcast.setAlias("alias", "alias_type");
|
customizedcast.setAlias("alias", "alias_type");
|
||||||
//customizedcast.setAlert("IOS 个性化测试");
|
//customizedcast.setAlert("IOS 个性化测试");
|
||||||
@@ -239,10 +223,10 @@ public class Demo {
|
|||||||
customizedcast.setTestMode();
|
customizedcast.setTestMode();
|
||||||
client.send(customizedcast);
|
client.send(customizedcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendIOSFilecast() throws Exception {
|
public void sendIOSFilecast() throws Exception {
|
||||||
IOSFilecast filecast = new IOSFilecast(appkey,appMasterSecret);
|
IOSFilecast filecast = new IOSFilecast(appkey,appMasterSecret);
|
||||||
// TODO upload your device tokens, and use '\n' to split them if there are multiple tokens
|
// TODO upload your device tokens, and use '\n' to split them if there are multiple tokens
|
||||||
String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb");
|
String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb");
|
||||||
filecast.setFileId( fileId);
|
filecast.setFileId( fileId);
|
||||||
//filecast.setAlert("IOS 文件播测试");
|
//filecast.setAlert("IOS 文件播测试");
|
||||||
@@ -254,7 +238,7 @@ public class Demo {
|
|||||||
filecast.setTestMode();
|
filecast.setTestMode();
|
||||||
client.send(filecast);
|
client.send(filecast);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO set your appkey and master secret here
|
// TODO set your appkey and master secret here
|
||||||
Demo demo = new Demo("your appkey", "your master secret");
|
Demo demo = new Demo("your appkey", "your master secret");
|
||||||
@@ -267,7 +251,7 @@ public class Demo {
|
|||||||
* demo.sendAndroidGroupcast();
|
* demo.sendAndroidGroupcast();
|
||||||
* demo.sendAndroidCustomizedcast();
|
* demo.sendAndroidCustomizedcast();
|
||||||
* demo.sendAndroidFilecast();
|
* demo.sendAndroidFilecast();
|
||||||
*
|
*
|
||||||
* demo.sendIOSBroadcast();
|
* demo.sendIOSBroadcast();
|
||||||
* demo.sendIOSUnicast();
|
* demo.sendIOSUnicast();
|
||||||
* demo.sendIOSGroupcast();
|
* demo.sendIOSGroupcast();
|
||||||
@@ -278,6 +262,6 @@ public class Demo {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ruoyi.system.config.push;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述:
|
||||||
|
*
|
||||||
|
* @author MXP by 2025/10/14
|
||||||
|
*/
|
||||||
|
public class IOSColumnOn extends IOSNotification{
|
||||||
|
|
||||||
|
public IOSColumnOn(String appkey,String appMasterSecret) throws Exception {
|
||||||
|
setAppMasterSecret(appMasterSecret);
|
||||||
|
setPredefinedKeyValue("appkey", appkey);
|
||||||
|
this.setPredefinedKeyValue("type", "listcast"); // type = listcast 是群体发送
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceToken(String token) throws Exception {
|
||||||
|
setPredefinedKeyValue("device_tokens", token);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.ruoyi.system.config.push;
|
|||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
@@ -11,19 +12,19 @@ import org.apache.http.client.methods.HttpPost;
|
|||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.http.entity.StringEntity;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
public class PushClient {
|
public class PushClient {
|
||||||
|
|
||||||
// The user agent
|
// The user agent
|
||||||
protected final String USER_AGENT = "Mozilla/5.0";
|
protected final String USER_AGENT = "Mozilla/5.0";
|
||||||
|
|
||||||
// This object is used for sending the post request to Umeng
|
// This object is used for sending the post request to Umeng
|
||||||
protected HttpClient client = new DefaultHttpClient();
|
protected HttpClient client = new DefaultHttpClient();
|
||||||
|
|
||||||
// The host
|
// The host
|
||||||
protected static final String host = "http://msg.umeng.com";
|
protected static final String host = "http://msg.umeng.com";
|
||||||
|
|
||||||
// The upload path
|
// The upload path
|
||||||
protected static final String uploadPath = "/upload";
|
protected static final String uploadPath = "/upload";
|
||||||
|
|
||||||
// The post path
|
// The post path
|
||||||
protected static final String postPath = "/api/send";
|
protected static final String postPath = "/api/send";
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ public class PushClient {
|
|||||||
msg.setPredefinedKeyValue("timestamp", timestamp);
|
msg.setPredefinedKeyValue("timestamp", timestamp);
|
||||||
String url = host + postPath;
|
String url = host + postPath;
|
||||||
String postBody = msg.getPostBody();
|
String postBody = msg.getPostBody();
|
||||||
String sign = DigestUtils.md5Hex(("POST" + url + postBody + msg.getAppMasterSecret()).getBytes("utf8"));
|
String sign = DigestUtils.md5Hex(("POST" + url + postBody + msg.getAppMasterSecret()).getBytes(StandardCharsets.UTF_8));
|
||||||
url = url + "?sign=" + sign;
|
url = url + "?sign=" + sign;
|
||||||
HttpPost post = new HttpPost(url);
|
HttpPost post = new HttpPost(url);
|
||||||
post.setHeader("User-Agent", USER_AGENT);
|
post.setHeader("User-Agent", USER_AGENT);
|
||||||
@@ -93,7 +94,7 @@ public class PushClient {
|
|||||||
JSONObject data = respJson.getJSONObject("data");
|
JSONObject data = respJson.getJSONObject("data");
|
||||||
String fileId = data.getString("file_id");
|
String fileId = data.getString("file_id");
|
||||||
// Set file_id into rootJson using setPredefinedKeyValue
|
// Set file_id into rootJson using setPredefinedKeyValue
|
||||||
|
|
||||||
return fileId;
|
return fileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.entity.ShopUser;
|
import com.ruoyi.common.core.domain.entity.ShopUser;
|
||||||
|
import com.ruoyi.common.core.domain.entity.ShopUserResq;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
@@ -69,7 +70,7 @@ public interface ShopUserMapper {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteShopUserByIds(String[] ids);
|
public int deleteShopUserByIds(String[] ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新用户在线时长
|
* 更新用户在线时长
|
||||||
*
|
*
|
||||||
@@ -77,7 +78,7 @@ public interface ShopUserMapper {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int updateUserOnlineTime(ShopUser shopUser);
|
public int updateUserOnlineTime(ShopUser shopUser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户的音乐标签
|
* 查询用户的音乐标签
|
||||||
*
|
*
|
||||||
@@ -88,5 +89,9 @@ public interface ShopUserMapper {
|
|||||||
|
|
||||||
List<String> selectPhoneShopUserByUserIds(List<Long> userIds);
|
List<String> selectPhoneShopUserByUserIds(List<Long> userIds);
|
||||||
|
|
||||||
|
List<String> selectDeviceIdShopUserByUserIds(List<Long> userIds);
|
||||||
|
|
||||||
int updateShopUserId(ShopUser shopUser);
|
int updateShopUserId(ShopUser shopUser);
|
||||||
}
|
|
||||||
|
int updateDeviceIdByPhone(ShopUserResq shopUser);
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 【请填写功能名称】Service接口
|
* 【请填写功能名称】Service接口
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2025-08-23
|
* @date 2025-08-23
|
||||||
*/
|
*/
|
||||||
public interface INotificationsService
|
public interface INotificationsService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 查询【请填写功能名称】
|
* 查询【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param id 【请填写功能名称】主键
|
* @param id 【请填写功能名称】主键
|
||||||
* @return 【请填写功能名称】
|
* @return 【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
@@ -23,7 +23,7 @@ public interface INotificationsService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询【请填写功能名称】列表
|
* 查询【请填写功能名称】列表
|
||||||
*
|
*
|
||||||
* @param notifications 【请填写功能名称】
|
* @param notifications 【请填写功能名称】
|
||||||
* @return 【请填写功能名称】集合
|
* @return 【请填写功能名称】集合
|
||||||
*/
|
*/
|
||||||
@@ -31,7 +31,7 @@ public interface INotificationsService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param notifications 【请填写功能名称】
|
* @param notifications 【请填写功能名称】
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -39,7 +39,7 @@ public interface INotificationsService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改【请填写功能名称】
|
* 修改【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param notifications 【请填写功能名称】
|
* @param notifications 【请填写功能名称】
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -47,7 +47,7 @@ public interface INotificationsService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除【请填写功能名称】
|
* 批量删除【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的【请填写功能名称】主键集合
|
* @param ids 需要删除的【请填写功能名称】主键集合
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -55,17 +55,19 @@ public interface INotificationsService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除【请填写功能名称】信息
|
* 删除【请填写功能名称】信息
|
||||||
*
|
*
|
||||||
* @param id 【请填写功能名称】主键
|
* @param id 【请填写功能名称】主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteNotificationsById(Long id);
|
public int deleteNotificationsById(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布通知
|
* 发布通知
|
||||||
*
|
*
|
||||||
* @param id 通知ID
|
* @param id 通知ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public AjaxResult publishNotification(Long id);
|
public AjaxResult publishNotification(Long id);
|
||||||
|
|
||||||
|
AjaxResult publishSendAll(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class CShopUserServiceImpl implements ShopUserService {
|
|||||||
// 验证码
|
// 验证码
|
||||||
String code = redisCache.getCacheObject("sms_code:"+shopUser.getPhone());
|
String code = redisCache.getCacheObject("sms_code:"+shopUser.getPhone());
|
||||||
// TODO:写死
|
// TODO:写死
|
||||||
// String code="9527";
|
//String code="9527";
|
||||||
String reqCode = shopUser.getCode();
|
String reqCode = shopUser.getCode();
|
||||||
if (code != null && code.equals(reqCode)){
|
if (code != null && code.equals(reqCode)){
|
||||||
// 登录
|
// 登录
|
||||||
@@ -143,6 +143,8 @@ public class CShopUserServiceImpl implements ShopUserService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 修改外设id
|
||||||
|
shopUserMapper.updateDeviceIdByPhone(shopUser);
|
||||||
return member;
|
return member;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,20 +15,20 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 【请填写功能名称】Service业务层处理
|
* 【请填写功能名称】Service业务层处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2025-08-23
|
* @date 2025-08-23
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
@Service
|
@Service
|
||||||
public class NotificationRecordsServiceImpl implements INotificationRecordsService
|
public class NotificationRecordsServiceImpl implements INotificationRecordsService
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private NotificationRecordsMapper notificationRecordsMapper;
|
private NotificationRecordsMapper notificationRecordsMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询【请填写功能名称】
|
* 查询【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param id 【请填写功能名称】主键
|
* @param id 【请填写功能名称】主键
|
||||||
* @return 【请填写功能名称】
|
* @return 【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
@@ -40,7 +40,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询【请填写功能名称】列表
|
* 查询【请填写功能名称】列表
|
||||||
*
|
*
|
||||||
* @param notificationRecords 【请填写功能名称】
|
* @param notificationRecords 【请填写功能名称】
|
||||||
* @return 【请填写功能名称】
|
* @return 【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
@@ -52,7 +52,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param notificationRecords 【请填写功能名称】
|
* @param notificationRecords 【请填写功能名称】
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -65,7 +65,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改【请填写功能名称】
|
* 修改【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param notificationRecords 【请填写功能名称】
|
* @param notificationRecords 【请填写功能名称】
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -78,7 +78,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除【请填写功能名称】
|
* 批量删除【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的【请填写功能名称】主键
|
* @param ids 需要删除的【请填写功能名称】主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -90,7 +90,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除【请填写功能名称】信息
|
* 删除【请填写功能名称】信息
|
||||||
*
|
*
|
||||||
* @param id 【请填写功能名称】主键
|
* @param id 【请填写功能名称】主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -99,7 +99,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi
|
|||||||
{
|
{
|
||||||
return notificationRecordsMapper.deleteNotificationRecordsById(id);
|
return notificationRecordsMapper.deleteNotificationRecordsById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 绑定用户到通知记录
|
* 绑定用户到通知记录
|
||||||
*
|
*
|
||||||
@@ -110,22 +110,22 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void bind(Long id, List<ShopUser> shopUsers) {
|
public void bind(Long id, List<ShopUser> shopUsers) {
|
||||||
System.out.println("开始绑定用户,通知ID: " + id + ", 用户数量: " + (shopUsers != null ? shopUsers.size() : 0));
|
System.out.println("开始绑定用户,通知ID: " + id + ", 用户数量: " + (shopUsers != null ? shopUsers.size() : 0));
|
||||||
|
|
||||||
if (id == null || shopUsers == null || shopUsers.isEmpty()) {
|
if (id == null || shopUsers == null || shopUsers.isEmpty()) {
|
||||||
System.out.println("通知ID为空或用户列表为空,无法绑定");
|
System.out.println("通知ID为空或用户列表为空,无法绑定");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打印用户列表信息
|
// 打印用户列表信息
|
||||||
System.out.println("用户列表详情:");
|
System.out.println("用户列表详情:");
|
||||||
for (ShopUser user : shopUsers) {
|
// for (ShopUser user : shopUsers) {
|
||||||
System.out.println("用户ID: " + (user != null ? user.getUserId() : "null") +
|
// System.out.println("用户ID: " + (user != null ? user.getUserId() : "null") +
|
||||||
", 类型: " + (user != null && user.getUserId() != null ? user.getUserId().getClass().getName() : "null"));
|
// ", 类型: " + (user != null && user.getUserId() != null ? user.getUserId().getClass().getName() : "null"));
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
Date now = DateUtils.getNowDate();
|
Date now = DateUtils.getNowDate();
|
||||||
|
|
||||||
// 查询该通知已经绑定的用户ID列表
|
// 查询该通知已经绑定的用户ID列表
|
||||||
NotificationRecords query = new NotificationRecords();
|
NotificationRecords query = new NotificationRecords();
|
||||||
query.setNotificationId(id);
|
query.setNotificationId(id);
|
||||||
@@ -134,33 +134,33 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi
|
|||||||
.map(NotificationRecords::getUserId)
|
.map(NotificationRecords::getUserId)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
System.out.println("已绑定用户数量: " + existingUserIds.size());
|
System.out.println("已绑定用户数量: " + existingUserIds.size());
|
||||||
|
|
||||||
// 创建通知记录列表
|
// 创建通知记录列表
|
||||||
List<NotificationRecords> recordsList = new ArrayList<>();
|
List<NotificationRecords> recordsList = new ArrayList<>();
|
||||||
|
|
||||||
// 遍历用户列表,为每个用户创建通知记录(排除已绑定的用户)
|
// 遍历用户列表,为每个用户创建通知记录(排除已绑定的用户)
|
||||||
int validUserCount = 0;
|
int validUserCount = 0;
|
||||||
int invalidUserCount = 0;
|
int invalidUserCount = 0;
|
||||||
int duplicateUserCount = 0;
|
int duplicateUserCount = 0;
|
||||||
|
|
||||||
for (ShopUser user : shopUsers) {
|
for (ShopUser user : shopUsers) {
|
||||||
try {
|
try {
|
||||||
// 验证用户ID是否有效
|
// 验证用户ID是否有效
|
||||||
if (user == null || user.getUserId() == null) {
|
if (user == null || user.getUserId() == null) {
|
||||||
System.out.println("用户或用户ID为空,跳过");
|
//System.out.println("用户或用户ID为空,跳过");
|
||||||
invalidUserCount++;
|
invalidUserCount++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (existingUserIds.contains(user.getUserId())) {
|
if (existingUserIds.contains(user.getUserId())) {
|
||||||
System.out.println("用户ID: " + user.getUserId() + " 已绑定,跳过");
|
// System.out.println("用户ID: " + user.getUserId() + " 已绑定,跳过");
|
||||||
duplicateUserCount++;
|
duplicateUserCount++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建通知记录
|
// 创建通知记录
|
||||||
NotificationRecords record = new NotificationRecords();
|
NotificationRecords record = new NotificationRecords();
|
||||||
record.setUserId(user.getUserId());
|
record.setUserId(user.getUserId());
|
||||||
@@ -172,19 +172,19 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi
|
|||||||
record.setNotificationId(id);
|
record.setNotificationId(id);
|
||||||
recordsList.add(record);
|
recordsList.add(record);
|
||||||
validUserCount++;
|
validUserCount++;
|
||||||
|
|
||||||
System.out.println("添加用户ID: " + user.getUserId() + " 到待绑定列表");
|
System.out.println("添加用户ID: " + user.getUserId() + " 到待绑定列表");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 记录错误日志,但继续处理其他用户
|
// 记录错误日志,但继续处理其他用户
|
||||||
System.err.println("处理用户ID时出错: " + (user != null ? user.getUserId() : "null") + ", 错误: " + e.getMessage());
|
//lo.error("处理用户ID时出错: " + (user != null ? user.getUserId() : "null") + ", 错误: " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
invalidUserCount++;
|
invalidUserCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("有效用户数: " + validUserCount + ", 无效用户数: " + invalidUserCount + ", 重复用户数: " + duplicateUserCount);
|
System.out.println("有效用户数: " + validUserCount + ", 无效用户数: " + invalidUserCount + ", 重复用户数: " + duplicateUserCount);
|
||||||
System.out.println("待插入记录数: " + recordsList.size());
|
System.out.println("待插入记录数: " + recordsList.size());
|
||||||
|
|
||||||
// 批量插入通知记录
|
// 批量插入通知记录
|
||||||
if (!recordsList.isEmpty()) {
|
if (!recordsList.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
@@ -199,7 +199,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi
|
|||||||
System.out.println("没有需要插入的记录");
|
System.out.println("没有需要插入的记录");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取通知已绑定的用户列表
|
* 获取通知已绑定的用户列表
|
||||||
*
|
*
|
||||||
@@ -211,25 +211,25 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi
|
|||||||
if (notificationId == null) {
|
if (notificationId == null) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建查询条件
|
// 创建查询条件
|
||||||
NotificationRecords query = new NotificationRecords();
|
NotificationRecords query = new NotificationRecords();
|
||||||
query.setNotificationId(notificationId);
|
query.setNotificationId(notificationId);
|
||||||
|
|
||||||
// 查询通知记录
|
// 查询通知记录
|
||||||
List<NotificationRecords> records = notificationRecordsMapper.selectNotificationRecordsList(query);
|
List<NotificationRecords> records = notificationRecordsMapper.selectNotificationRecordsList(query);
|
||||||
|
|
||||||
// 提取用户ID列表
|
// 提取用户ID列表
|
||||||
List<Long> userIds = records.stream()
|
List<Long> userIds = records.stream()
|
||||||
.map(NotificationRecords::getUserId)
|
.map(NotificationRecords::getUserId)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// 如果没有绑定用户,返回空列表
|
// 如果没有绑定用户,返回空列表
|
||||||
if (userIds.isEmpty()) {
|
if (userIds.isEmpty()) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询用户信息
|
// 查询用户信息
|
||||||
// 这里需要调用ShopUserMapper来查询用户信息
|
// 这里需要调用ShopUserMapper来查询用户信息
|
||||||
// 由于没有提供ShopUserMapper,这里简单处理,将用户ID封装成ShopUser对象返回
|
// 由于没有提供ShopUserMapper,这里简单处理,将用户ID封装成ShopUser对象返回
|
||||||
@@ -239,7 +239,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi
|
|||||||
user.setUserId(userId);
|
user.setUserId(userId);
|
||||||
users.add(user);
|
users.add(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,19 +22,19 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 【请填写功能名称】Service业务层处理
|
* 【请填写功能名称】Service业务层处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2025-08-23
|
* @date 2025-08-23
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
@Service
|
@Service
|
||||||
public class NotificationsServiceImpl implements INotificationsService
|
public class NotificationsServiceImpl implements INotificationsService
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(NotificationsServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(NotificationsServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private NotificationsMapper notificationsMapper;
|
private NotificationsMapper notificationsMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private NotificationRecordsMapper notificationRecordsMapper;
|
private NotificationRecordsMapper notificationRecordsMapper;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ public class NotificationsServiceImpl implements INotificationsService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询【请填写功能名称】
|
* 查询【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param id 【请填写功能名称】主键
|
* @param id 【请填写功能名称】主键
|
||||||
* @return 【请填写功能名称】
|
* @return 【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
@@ -58,7 +58,7 @@ public class NotificationsServiceImpl implements INotificationsService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询【请填写功能名称】列表
|
* 查询【请填写功能名称】列表
|
||||||
*
|
*
|
||||||
* @param notifications 【请填写功能名称】
|
* @param notifications 【请填写功能名称】
|
||||||
* @return 【请填写功能名称】
|
* @return 【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
@@ -70,7 +70,7 @@ public class NotificationsServiceImpl implements INotificationsService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param notifications 【请填写功能名称】
|
* @param notifications 【请填写功能名称】
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -83,7 +83,7 @@ public class NotificationsServiceImpl implements INotificationsService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改【请填写功能名称】
|
* 修改【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param notifications 【请填写功能名称】
|
* @param notifications 【请填写功能名称】
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -95,7 +95,7 @@ public class NotificationsServiceImpl implements INotificationsService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除【请填写功能名称】
|
* 批量删除【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的【请填写功能名称】主键
|
* @param ids 需要删除的【请填写功能名称】主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -107,7 +107,7 @@ public class NotificationsServiceImpl implements INotificationsService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除【请填写功能名称】信息
|
* 删除【请填写功能名称】信息
|
||||||
*
|
*
|
||||||
* @param id 【请填写功能名称】主键
|
* @param id 【请填写功能名称】主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -116,10 +116,10 @@ public class NotificationsServiceImpl implements INotificationsService
|
|||||||
{
|
{
|
||||||
return notificationsMapper.deleteNotificationsById(id);
|
return notificationsMapper.deleteNotificationsById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布通知
|
* 发布通知
|
||||||
*
|
*
|
||||||
* @param id 通知ID
|
* @param id 通知ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -133,7 +133,7 @@ public class NotificationsServiceImpl implements INotificationsService
|
|||||||
{
|
{
|
||||||
return AjaxResult.error("通知不存在");
|
return AjaxResult.error("通知不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询该通知的所有记录
|
// 查询该通知的所有记录
|
||||||
NotificationRecords query = new NotificationRecords();
|
NotificationRecords query = new NotificationRecords();
|
||||||
query.setNotificationId(id);
|
query.setNotificationId(id);
|
||||||
@@ -145,14 +145,11 @@ public class NotificationsServiceImpl implements INotificationsService
|
|||||||
{
|
{
|
||||||
return AjaxResult.error("该通知没有绑定任何用户,请先绑定用户");
|
return AjaxResult.error("该通知没有绑定任何用户,请先绑定用户");
|
||||||
}
|
}
|
||||||
List<String> phones = shopUserMapper.selectPhoneShopUserByUserIds(userIds);
|
List<String> deviceIds = shopUserMapper.selectDeviceIdShopUserByUserIds(userIds);
|
||||||
// 当前时间
|
// 当前时间
|
||||||
Date now = DateUtils.getNowDate();
|
Date now = DateUtils.getNowDate();
|
||||||
int successCount = 0;
|
|
||||||
int failCount = 0;
|
|
||||||
|
|
||||||
|
sendNotificationToThirdParty(notification, deviceIds);
|
||||||
sendNotificationToThirdParty(notification, phones);
|
|
||||||
query.setStatus("sent");
|
query.setStatus("sent");
|
||||||
notificationRecordsMapper.updateNotificationRecords(query);
|
notificationRecordsMapper.updateNotificationRecords(query);
|
||||||
|
|
||||||
@@ -201,23 +198,44 @@ public class NotificationsServiceImpl implements INotificationsService
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// 更新通知状态为已发布
|
// 更新通知状态为已发布
|
||||||
// notification.setStatus("published");
|
// notification.setStatus("published");
|
||||||
// notification.setPublishTime(now);
|
// notification.setPublishTime(now);
|
||||||
// notificationsMapper.updateNotifications(notification);
|
// notificationsMapper.updateNotifications(notification);
|
||||||
|
|
||||||
return AjaxResult.success("通知发布完成,成功:" + successCount + ",失败:" + failCount);
|
return AjaxResult.success("通知发布完成,成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult publishSendAll(Long id) {
|
||||||
|
// 查询通知信息
|
||||||
|
Notifications notification = notificationsMapper.selectNotificationsById(id);
|
||||||
|
sendAllToThirdParty(notification);
|
||||||
|
return AjaxResult.success("通知发布完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendAllToThirdParty(Notifications notification) {
|
||||||
|
PushMsgInfo pushMsgInfo = new PushMsgInfo();
|
||||||
|
pushMsgInfo.setTitle(notification.getTitle());
|
||||||
|
pushMsgInfo.setText(notification.getContent());
|
||||||
|
pushMsgInfo.setTicker(notification.getTitle());
|
||||||
|
try {
|
||||||
|
umengConfig.sendAndroidBroadcast(pushMsgInfo);
|
||||||
|
umengConfig.sendIOSBroadcast(pushMsgInfo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用第三方接口发送通知
|
* 调用第三方接口发送通知
|
||||||
*
|
*
|
||||||
* @param notification 通知信息
|
* @param notification 通知信息
|
||||||
* @param record 通知记录
|
* @param record 通知记录
|
||||||
* @return 发送结果
|
* @return 发送结果
|
||||||
*/
|
*/
|
||||||
private boolean sendNotificationToThirdParty(Notifications notification, List<String> phones)
|
private boolean sendNotificationToThirdParty(Notifications notification, List<String> deviceIds)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -227,18 +245,18 @@ public class NotificationsServiceImpl implements INotificationsService
|
|||||||
// notification.getId(), record.getUserId(), notification.getTitle(), notification.getContent());
|
// notification.getId(), record.getUserId(), notification.getTitle(), notification.getContent());
|
||||||
//
|
//
|
||||||
// 按照499个手机号一组进行分批处理
|
// 按照499个手机号一组进行分批处理
|
||||||
for (int i = 0; i < phones.size(); i += 499) {
|
for (int i = 0; i < deviceIds.size(); i += 499) {
|
||||||
int endIndex = Math.min(i + 499, phones.size());
|
int endIndex = Math.min(i + 499, deviceIds.size());
|
||||||
List<String> phoneBatch = phones.subList(i, endIndex);
|
List<String> phoneBatch = deviceIds.subList(i, endIndex);
|
||||||
String phoneS = String.join(",", phoneBatch);
|
String deviceIdS = String.join(",", phoneBatch);
|
||||||
PushMsgInfo pushMsgInfo = new PushMsgInfo();
|
PushMsgInfo pushMsgInfo = new PushMsgInfo();
|
||||||
pushMsgInfo.setAlias(phoneS);
|
pushMsgInfo.setDeviceIds(deviceIdS);
|
||||||
pushMsgInfo.setTitle(notification.getTitle());
|
pushMsgInfo.setTitle(notification.getTitle());
|
||||||
pushMsgInfo.setText(notification.getContent());
|
pushMsgInfo.setText(notification.getContent());
|
||||||
umengConfig.sendAndroidCustomizedcast(pushMsgInfo);
|
umengConfig.sendAndroidColumnOn(pushMsgInfo);
|
||||||
umengConfig.sendIOSCustomizedcast(pushMsgInfo);
|
umengConfig.sendIOSColumnOn(pushMsgInfo);
|
||||||
log.info("发送通知批次 {}/{}, 本批次包含 {} 个手机号",
|
log.info("发送通知批次 {}/{}, 本批次包含 {} 个手机号",
|
||||||
(i / 499) + 1, (phones.size() + 498) / 499, phoneBatch.size());
|
(i / 499) + 1, (deviceIds.size() + 498) / 499, phoneBatch.size());
|
||||||
}
|
}
|
||||||
// 模拟发送成功
|
// 模拟发送成功
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -204,7 +204,7 @@
|
|||||||
<include refid="selectShopUserVo"/>
|
<include refid="selectShopUserVo"/>
|
||||||
where shop_user.user_id = #{userId}
|
where shop_user.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 更新用户在线时长 -->
|
<!-- 更新用户在线时长 -->
|
||||||
<update id="updateUserOnlineTime" parameterType="ShopUser">
|
<update id="updateUserOnlineTime" parameterType="ShopUser">
|
||||||
update shop_user
|
update shop_user
|
||||||
@@ -214,19 +214,19 @@
|
|||||||
</set>
|
</set>
|
||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<!-- 查询用户的音乐标签 -->
|
<!-- 查询用户的音乐标签 -->
|
||||||
<select id="selectUserMusicTags" parameterType="String" resultType="String">
|
<select id="selectUserMusicTags" parameterType="String" resultType="String">
|
||||||
SELECT mi.label FROM user_history uh
|
SELECT mi.label FROM user_history uh
|
||||||
LEFT JOIN music_info mi on uh.music_id = mi.music_id
|
LEFT JOIN music_info mi on uh.music_id = mi.music_id
|
||||||
LEFT JOIN shop_user su on uh.user_id = su.user_id
|
LEFT JOIN shop_user su on uh.user_id = su.user_id
|
||||||
WHERE su.user_id = #{userId} AND mi.label IS NOT NULL AND mi.label != ''
|
WHERE su.user_id = #{userId} AND mi.label IS NOT NULL AND mi.label != ''
|
||||||
GROUP BY mi.label
|
GROUP BY mi.label
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectPhoneShopUserByUserIds" resultType="java.lang.String">
|
<select id="selectPhoneShopUserByUserIds" resultType="java.lang.String">
|
||||||
SELECT phone from shop_user where user_id in
|
SELECT phone from shop_user where user_id in
|
||||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
<foreach collection="list" item="userId" open="(" close=")" separator=",">
|
||||||
#{userId}
|
#{userId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
@@ -256,4 +256,15 @@
|
|||||||
</trim>
|
</trim>
|
||||||
where shop_user.id = #{id}
|
where shop_user.id = #{id}
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
|
||||||
|
<update id="updateDeviceIdByPhone">
|
||||||
|
update shop_user set device_id = #{deviceId} where shop_user.phone = #{phone}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="selectDeviceIdShopUserByUserIds" resultType="java.lang.String">
|
||||||
|
SELECT device_id from shop_user where user_id in
|
||||||
|
<foreach collection="list" item="userId" open="(" close=")" separator=",">
|
||||||
|
#{userId}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user