liujc преди 1 година
родител
ревизия
94a0ba02e0
променени са 20 файла, в които са добавени 520 реда и са изтрити 6 реда
  1. 64 0
      mec-application/src/main/java/com/ym/mec/student/controller/UserController.java
  2. 62 0
      mec-application/src/main/java/com/ym/mec/teacher/controller/UserController.java
  3. 64 0
      mec-application/src/main/java/com/ym/mec/web/controller/UserController.java
  4. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TeacherDao.java
  5. 15 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Employee.java
  6. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SchoolStaff.java
  7. 14 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Student.java
  8. 15 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Teacher.java
  9. 32 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/UserInfoWrapper.java
  10. 3 0
      mec-biz/src/main/java/com/ym/mec/biz/service/SysUserService.java
  11. 78 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysUserServiceImpl.java
  12. 30 0
      mec-biz/src/main/resources/config/mybatis/TeacherMapper.xml
  13. 10 0
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/MessageSenderPlugin.java
  14. 1 1
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/MessageSenderPluginContext.java
  15. 6 0
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/AwSmsPlugin.java
  16. 7 0
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/CommEmailPlugin.java
  17. 90 0
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/JiguangPushPlugin.java
  18. 7 1
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/MOxintongSMSPlugin.java
  19. 6 0
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/ShiyuanSMSPlugin.java
  20. 7 1
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/YimeiSmsPlugin.java

+ 64 - 0
mec-application/src/main/java/com/ym/mec/student/controller/UserController.java

@@ -0,0 +1,64 @@
+package com.ym.mec.student.controller;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.enums.ClientEnum;
+import com.ym.mec.biz.dal.wrapper.UserInfoWrapper;
+import com.ym.mec.biz.service.SysUserService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 用户通讯录表(ImUserFriend)表控制层
+ *
+ * @author zx
+ * @since 2022-03-22 10:45:59
+ */
+@Api(tags = "用户通讯录表")
+@RestController
+@Slf4j
+@RequestMapping("${app-config.url.student:}/user")
+public class UserController extends BaseController {
+
+
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @Autowired
+    private SysUserService sysUserService;
+
+
+
+
+    @ApiOperation(value = "更新更新IM用户信息", notes = "更新用户信息")
+    @PostMapping("/updateImUserInfo")
+    public HttpResponseResult<JSONObject> updateImUserInfo(@Validated @RequestBody UserInfoWrapper.UpdateUser info) {
+
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null || null == user.getId()) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        info.setUserId(user.getId().intValue());
+        info.setClient(ClientEnum.STUDENT);
+
+
+        sysUserService.imDeviceId(info);
+        return succeed();
+    }
+
+}
+

+ 62 - 0
mec-application/src/main/java/com/ym/mec/teacher/controller/UserController.java

@@ -0,0 +1,62 @@
+package com.ym.mec.teacher.controller;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.enums.ClientEnum;
+import com.ym.mec.biz.dal.wrapper.UserInfoWrapper;
+import com.ym.mec.biz.service.SysUserService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 用户通讯录表(ImUserFriend)表控制层
+ *
+ * @author zx
+ * @since 2022-03-22 10:45:59
+ */
+@Api(tags = "用户通讯录表")
+@RestController
+@Slf4j
+@RequestMapping("${app-config.url.student:}/user")
+public class UserController extends BaseController {
+
+
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @Autowired
+    private SysUserService sysUserService;
+
+
+
+
+    @ApiOperation(value = "更新更新IM用户信息", notes = "更新用户信息")
+    @PostMapping("/updateImUserInfo")
+    public HttpResponseResult<JSONObject> updateImUserInfo(@Validated @RequestBody UserInfoWrapper.UpdateUser info) {
+
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null || null == user.getId()) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        info.setUserId(user.getId().intValue());
+        info.setClient(ClientEnum.TEACHER);
+
+
+        sysUserService.imDeviceId(info);
+        return succeed();
+    }
+
+}
+

+ 64 - 0
mec-application/src/main/java/com/ym/mec/web/controller/UserController.java

@@ -0,0 +1,64 @@
+package com.ym.mec.web.controller;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.enums.ClientEnum;
+import com.ym.mec.biz.dal.wrapper.UserInfoWrapper;
+import com.ym.mec.biz.service.SysUserService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 用户通讯录表(ImUserFriend)表控制层
+ *
+ * @author zx
+ * @since 2022-03-22 10:45:59
+ */
+@Api(tags = "用户通讯录表")
+@RestController
+@Slf4j
+@RequestMapping("${app-config.url.student:}/user")
+public class UserController extends BaseController {
+
+
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @Autowired
+    private SysUserService sysUserService;
+
+
+
+
+    @ApiOperation(value = "更新更新IM用户信息", notes = "更新用户信息")
+    @PostMapping("/updateImUserInfo")
+    public HttpResponseResult<JSONObject> updateImUserInfo(@Validated @RequestBody UserInfoWrapper.UpdateUser info) {
+
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null || null == user.getId()) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        info.setUserId(user.getId().intValue());
+        if (info.getClient() == null) {
+            info.setClient(ClientEnum.SYSTEM);
+        }
+
+
+        sysUserService.imDeviceId(info);
+        return succeed();
+    }
+
+}
+

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TeacherDao.java

@@ -7,6 +7,7 @@ import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.dto.im.BasicUserInfo;
 import com.ym.mec.biz.dal.entity.CourseHomework;
 import com.ym.mec.biz.dal.entity.Teacher;
+import com.ym.mec.biz.dal.wrapper.UserInfoWrapper;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.ImUserModel;
 import org.apache.ibatis.annotations.Param;
@@ -555,4 +556,8 @@ public interface TeacherDao extends BaseDAO<Integer, Teacher> {
     int queryBaseInfoByCount(Map<String, Object> params);
 
     List<SysUser> getUserList(@Param("studentIds") Collection<? extends Serializable> studentIds);
+
+    void updateImDeviceId(@Param("imDeviceId") String imDeviceId, @Param("client") String client, @Param("userId") Integer userId);
+
+    UserInfoWrapper.UpdateUser getUserImDeviceId(@Param("userId") Integer userId, @Param("client") String client);
 }

+ 15 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Employee.java

@@ -102,7 +102,21 @@ public class Employee extends SysUser {
 
 	private String postalCode;
 
-	public List<Integer> getPositionIds() {
+
+    @ApiModelProperty("IM绑定设备")
+    private String imDeviceId;
+
+
+    public String getImDeviceId() {
+        return imDeviceId;
+    }
+
+    public void setImDeviceId(String imDeviceId) {
+        this.imDeviceId = imDeviceId;
+    }
+
+
+    public List<Integer> getPositionIds() {
 		return positionIds;
 	}
 

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SchoolStaff.java

@@ -71,4 +71,8 @@ public class SchoolStaff implements Serializable {
 	@TableField(value = "create_time_")
     private Date createTime;
 
+
+    @ApiModelProperty("IM绑定设备")
+    @TableField(value = "im_device_id_")
+    private String imDeviceId;
 }

+ 14 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Student.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.ym.mec.auth.api.entity.SysUser;
 import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -88,7 +89,19 @@ public class Student extends SysUser {
 	@ApiModelProperty(value = "排课老师")
 	private Integer courseTeacher;
 
-	public Integer getCourseTeacher() {
+    @ApiModelProperty("IM绑定设备")
+    private String imDeviceId;
+
+
+    public String getImDeviceId() {
+        return imDeviceId;
+    }
+
+    public void setImDeviceId(String imDeviceId) {
+        this.imDeviceId = imDeviceId;
+    }
+
+    public Integer getCourseTeacher() {
 		return courseTeacher;
 	}
 

+ 15 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Teacher.java

@@ -137,7 +137,21 @@ public class Teacher extends SysUser {
 	@ApiModelProperty(value = "云教练限制")
 	private Boolean coursewareLimit;
 
-	public Boolean getIsSettlementSalary() {
+
+    @ApiModelProperty("IM绑定设备")
+    private String imDeviceId;
+
+
+    public String getImDeviceId() {
+        return imDeviceId;
+    }
+
+    public void setImDeviceId(String imDeviceId) {
+        this.imDeviceId = imDeviceId;
+    }
+
+
+    public Boolean getIsSettlementSalary() {
 		return isSettlementSalary;
 	}
 

+ 32 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/UserInfoWrapper.java

@@ -0,0 +1,32 @@
+package com.ym.mec.biz.dal.wrapper;
+
+import com.ym.mec.biz.dal.enums.ClientEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+public class UserInfoWrapper {
+
+
+    @Data
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ApiModel("用户信息更新")
+    public static class UpdateUser implements Serializable {
+
+        @ApiModelProperty("IM设备ID")
+        private String imDeviceId;
+
+
+        @ApiModelProperty("用户ID")
+        private Integer userId;
+
+        @ApiModelProperty("用户类型")
+        private ClientEnum client;
+
+    }
+}

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysUserService.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service;
 
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.wrapper.UserInfoWrapper;
 
 import java.io.Serializable;
 import java.util.Collection;
@@ -29,4 +30,6 @@ public interface SysUserService {
     void registerImUserInfo(Integer userId);
 
     Map<Long, SysUser> getMapByIds(Collection<? extends Serializable> studentIds);
+
+    void imDeviceId(UserInfoWrapper.UpdateUser info);
 }

+ 78 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysUserServiceImpl.java

@@ -6,13 +6,17 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.entity.SysConfig;
+import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.enums.ClientEnum;
+import com.ym.mec.biz.dal.wrapper.UserInfoWrapper;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.SysUserService;
 import com.ym.mec.biz.service.im.ImGroupCoreService;
 import com.ym.mec.common.exception.BizException;
+import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.Nullable;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -32,6 +36,9 @@ public class SysUserServiceImpl implements SysUserService {
     @Autowired
     private ImGroupCoreService imGroupCoreService;
 
+    @Autowired
+    private MessageSenderPluginContext messageSenderPluginContext;
+
     @Override
     public Integer getUserId(){
         return Optional.ofNullable(sysUserFeignService.queryUserInfo())
@@ -137,4 +144,75 @@ public class SysUserServiceImpl implements SysUserService {
         List<SysUser> userList = teacherDao.getUserList(studentIds);
         return userList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId().longValue(), v), HashMap::putAll);
     }
+
+
+
+    @Override
+    public void imDeviceId(UserInfoWrapper.UpdateUser info) {
+
+        List<String> list = new ArrayList<>();
+
+        teacherDao.updateImDeviceId(info.getImDeviceId(), info.getClient().getCode(), info.getUserId());
+
+        if (!checkImDeviceId(info, list)) {
+            return;
+        }
+
+
+        messageSenderPluginContext.getMessageSenderPlugin(MessageSenderPluginContext.MessageSender.JIGUANG)
+            .deviceRemoveAlias(info.getUserId().toString(),list,info.getClient().getCode());
+    }
+
+    private boolean checkImDeviceId(UserInfoWrapper.UpdateUser info, List<String> list) {
+
+        UserInfoWrapper.UpdateUser userImDeviceId = teacherDao.getUserImDeviceId(info.getUserId(), ClientEnum.TEACHER.getCode());
+        if (userImDeviceId != null ) {
+            if (userImDeviceId.getUserId() != null) {
+                list.add(userImDeviceId.getImDeviceId());
+            } else {
+                return false;
+            }
+        }
+
+        userImDeviceId = teacherDao.getUserImDeviceId(info.getUserId(), ClientEnum.STUDENT.getCode());
+        if (userImDeviceId != null ) {
+            if (userImDeviceId.getUserId() != null) {
+                list.add(userImDeviceId.getImDeviceId());
+            } else {
+                return false;
+            }
+        }
+        userImDeviceId = teacherDao.getUserImDeviceId(info.getUserId(), ClientEnum.SYSTEM.getCode());
+        if (userImDeviceId != null ) {
+            if (userImDeviceId.getUserId() != null) {
+                list.add(userImDeviceId.getImDeviceId());
+            } else {
+                return false;
+            }
+        }
+        userImDeviceId = teacherDao.getUserImDeviceId(info.getUserId(), ClientEnum.SCHOOL.getCode());
+        if (userImDeviceId != null ) {
+            if (userImDeviceId.getUserId() != null) {
+                list.add(userImDeviceId.getImDeviceId());
+            } else {
+                return false;
+            }
+        }
+
+        return true;
+
+
+    }
+
+    @Nullable
+    private String getTeacherDeviceId(UserInfoWrapper.UpdateUser info, String teacherDeviceId) {
+        Teacher teacher1 = teacherDao.get(info.getUserId());
+        if (teacher1 != null) {
+            if (org.springframework.util.StringUtils.isEmpty(teacher1.getImDeviceId())) {
+                return null;
+            }
+            teacherDeviceId = teacher1.getImDeviceId();
+        }
+        return teacherDeviceId;
+    }
 }

+ 30 - 0
mec-biz/src/main/resources/config/mybatis/TeacherMapper.xml

@@ -1596,4 +1596,34 @@
             #{studentId}
         </foreach>
     </select>
+
+    <update id="updateImDeviceId">
+        <if test="client =='STUDENT'">
+            UPDATE  student set im_device_id_ = #{imDeviceId} where user_id_ = #{userId}
+        </if>
+        <if test="client =='TEACHER'">
+            UPDATE  teacher set im_device_id_ = #{imDeviceId} where id_ = #{userId}
+        </if>
+        <if test="client =='SYSTEM'">
+            UPDATE  employee set im_device_id_ = #{imDeviceId} where user_id_ = #{userId}
+        </if>
+        <if test="client =='SCHOOL'">
+            UPDATE  school_staff set im_device_id_ = #{imDeviceId} where user_id_ = #{userId}
+        </if>
+    </update>
+
+    <select id="getUserImDeviceId" resultType="com.ym.mec.biz.dal.wrapper.UserInfoWrapper$UpdateUser">
+        <if test="client =='STUDENT'">
+            SELECT im_device_id_ as imDeviceId,user_id_ as userId FROM student WHERE user_id_ = #{userId}
+        </if>
+        <if test="client =='TEACHER'">
+            SELECT im_device_id_  as imDeviceId,id_ as userId  FROM teacher WHERE id_ = #{userId}
+        </if>
+        <if test="client =='SYSTEM'">
+            SELECT im_device_id_   as imDeviceId,user_id_ as userId  FROM employee WHERE user_id_ = #{userId}
+        </if>
+        <if test="client =='SCHOOL'">
+            SELECT im_device_id_  as imDeviceId,user_id_ as userId  FROM school_staff WHERE user_id_ = #{userId}
+        </if>
+    </select>
 </mapper>

+ 10 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/MessageSenderPlugin.java

@@ -1,6 +1,7 @@
 package com.ym.mec.thirdparty.message;
 
 import java.io.IOException;
+import java.util.List;
 
 public interface MessageSenderPlugin {
 	
@@ -27,4 +28,13 @@ public interface MessageSenderPlugin {
 	 * @throws IOException
 	 */
 	public boolean batchSend(String subject, String content, String[] receivers, String url, String jpushType,String sound,String channelId) throws Exception;
+
+    /**
+     * 删除设备的别名
+     *
+     * @param alias      用户别名
+     * @param registerIds 设备注册ID
+     * @param pushType   极光应用类型
+     */
+    void deviceRemoveAlias(String alias, List<String> registerIds, String pushType);
 }

+ 1 - 1
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/MessageSenderPluginContext.java

@@ -112,7 +112,7 @@ public class MessageSenderPluginContext implements ApplicationContextAware {
 		this.applicationContext = applicationContext;
 	}
 
-	private MessageSenderPlugin getMessageSenderPlugin(MessageSender messageSender) {
+	public MessageSenderPlugin getMessageSenderPlugin(MessageSender messageSender) {
 		String beanId = mapper.get(StringUtils.lowerCase(messageSender.name()));
 
 		if (StringUtils.isBlank(beanId)) {

+ 6 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/AwSmsPlugin.java

@@ -2,6 +2,7 @@ package com.ym.mec.thirdparty.message.provider;
 
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
@@ -120,6 +121,11 @@ public class AwSmsPlugin implements MessageSenderPlugin, InitializingBean {
 		}
 	}
 
+    @Override
+    public void deviceRemoveAlias(String alias, List<String> registerIds, String pushType) {
+
+    }
+
 //	public static void main(String[] args) throws IOException {
 //		AwSmsPlugin plugin = new AwSmsPlugin();
 //		plugin.send("测试", "您的验证码为274160(5分钟内有效),您正在进行商户认证,请不要向他人透露验证码", "13720176797", "", "");

+ 7 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/CommEmailPlugin.java

@@ -12,6 +12,8 @@ import org.springframework.stereotype.Service;
 
 import com.ym.mec.thirdparty.message.MessageSenderPlugin;
 
+import java.util.List;
+
 @Service
 public class CommEmailPlugin implements MessageSenderPlugin, InitializingBean {
 
@@ -141,4 +143,9 @@ public class CommEmailPlugin implements MessageSenderPlugin, InitializingBean {
 		return true;
 	}
 
+    @Override
+    public void deviceRemoveAlias(String alias, List<String> registerIds, String pushType) {
+
+    }
+
 }

+ 90 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/JiguangPushPlugin.java

@@ -1,11 +1,14 @@
 package com.ym.mec.thirdparty.message.provider;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
 import com.ym.mec.thirdparty.exception.ThirdpartyException;
 import com.ym.mec.thirdparty.message.MessageSenderPlugin;
 import com.ym.mec.util.http.HttpUtil;
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Value;
@@ -14,6 +17,7 @@ import org.springframework.stereotype.Service;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Optional;
 import java.util.stream.Collectors;
 
@@ -245,4 +249,90 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
         return true;
     }
 
+
+    /**
+     * 删除设备的别名
+     *
+     * @param alias      用户别名
+     * @param registerIds 设备注册ID
+     * @param pushType   极光应用类型
+     */
+    @Override
+    public void deviceRemoveAlias(String alias, List<String> registerIds, String pushType) {
+        //MessageSenderService.super.deviceRemoveAlias(alias, registerId);
+
+        // 接口访问基础
+        String baseUrl = "https://device.jpush.cn";
+
+        String base64_auth_string;
+
+        switch (pushType){
+            case "STUDENT":
+                base64_auth_string = encryptBASE64(this.studentAppKey + ":" + this.studentMasterSecret);
+                break;
+            case "TEACHER":
+                base64_auth_string = encryptBASE64(this.teacherAppKey + ":" + this.teacherMasterSecret);
+                break;
+            default:
+                base64_auth_string = encryptBASE64(this.systemAppKey + ":" + this.systemMasterSecret);
+                break;
+        }
+        String authorization = "Basic " + base64_auth_string;
+
+        List<String> removeIds = Lists.newArrayList();
+        // 查询别名绑定设备
+        {
+
+            // 请求头授权参数
+            HashMap<String, String> HeaderMap = new HashMap<String, String>(){{
+                put("Authorization", authorization.trim());
+            }};
+
+            // 请求参数
+            HashMap<String, Object> data = new HashMap<String, Object>(){{
+                put("new_format", "false"); // 返回结果是否使用新格式
+            }};
+
+            // 发起请求
+            try {
+                String ret = HttpUtil.get(baseUrl + "/v3/aliases/" + alias, data, HeaderMap);
+                if (StringUtils.isNotBlank(ret)) {
+                    JSONObject json = JSONObject.parseObject(ret);
+
+                    json.getJSONArray("registration_ids").forEach(item -> removeIds.add(item.toString()));
+                }
+            } catch (Exception e) {
+                throw new ThirdpartyException("deviceRemoveAlias 查询别名绑定设备", e);
+            }
+
+            // 排除当前设备
+            if (CollectionUtils.isNotEmpty(removeIds) && CollectionUtils.isNotEmpty(registerIds)) {
+                removeIds.removeAll(registerIds);
+            }
+        }
+
+        // 删除别名绑定设备
+        if (CollectionUtils.isNotEmpty(removeIds)) {
+            // 请求头授权参数
+            HashMap<String, String> HeaderMap = new HashMap<String, String>(){{
+                put("Authorization", authorization.trim());
+            }};
+
+            // 请求参数
+            HashMap<String, Object> data = new HashMap<String, Object>(){{
+                put("registration_ids", new HashMap<String, Object>(){{
+                    put("remove", removeIds);
+                }});
+            }};
+
+            // 发起请求
+            try {
+                HttpUtil.postForHttps(baseUrl + "/v3/aliases/" + alias, JSON.toJSONString(data), HeaderMap);
+            } catch (Exception e) {
+                throw new ThirdpartyException("deviceRemoveAlias 删除别名绑定设备", e);
+            }
+        }
+    }
+
+
 }

+ 7 - 1
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/MOxintongSMSPlugin.java

@@ -2,6 +2,7 @@ package com.ym.mec.thirdparty.message.provider;
 
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
@@ -85,7 +86,12 @@ public class MOxintongSMSPlugin implements MessageSenderPlugin, InitializingBean
 		}
 	}
 
-	@Override
+    @Override
+    public void deviceRemoveAlias(String alias, List<String> registerIds, String pushType) {
+
+    }
+
+    @Override
 	public void afterPropertiesSet() throws Exception {
 		// 参数检查
 		if (StringUtils.isBlank(reqUrl)) {

+ 6 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/ShiyuanSMSPlugin.java

@@ -2,6 +2,7 @@ package com.ym.mec.thirdparty.message.provider;
 
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
@@ -121,4 +122,9 @@ public class ShiyuanSMSPlugin implements MessageSenderPlugin, InitializingBean {
 		}
 	}
 
+    @Override
+    public void deviceRemoveAlias(String alias, List<String> registerIds, String pushType) {
+
+    }
+
 }

+ 7 - 1
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/YimeiSmsPlugin.java

@@ -3,6 +3,7 @@ package com.ym.mec.thirdparty.message.provider;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -82,7 +83,12 @@ public class YimeiSmsPlugin implements MessageSenderPlugin, InitializingBean {
 		}
 	}
 
-	@Override
+    @Override
+    public void deviceRemoveAlias(String alias, List<String> registerIds, String pushType) {
+
+    }
+
+    @Override
 	public void afterPropertiesSet() throws Exception {
 
 	}