Commit e3a4b34c by giaogiao

添加或修改推送设备信息(每次请求都会覆盖之前的数据)

parent adfd5e2f
package com.wecloud.im.controller;
import com.wecloud.im.param.add.ImClientDeviceInfoAdd;
import com.wecloud.im.service.ImClientService;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
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.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;
......@@ -17,12 +26,23 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/imClient")
@Api(value = "终端表API", tags = {"终端表"})
@Api(value = "终端", tags = {"终端"})
public class ImClientController extends BaseController {
@Autowired
private ImClientService imClientService;
//
/**
* 添加或修改推送设备信息
*/
@PostMapping("/addDeviceInfo")
@OperationLog(name = "添加或修改推送设备信息", type = OperationLogType.ADD)
@ApiOperation(value = "添加或修改推送设备信息(每次请求都会覆盖之前的数据)")
public ApiResult<Boolean> addDeviceInfo(@Validated(Add.class) @RequestBody ImClientDeviceInfoAdd imClientDevice) throws Exception {
boolean flag = imClientService.addDeviceInfo(imClientDevice);
return ApiResult.result(flag);
}
// /**
// * 添加终端表
// */
......
......@@ -50,4 +50,7 @@ public class ImClient extends BaseEntity {
@ApiModelProperty("设备类型1:ios; 2:android")
private Integer deviceType;
@ApiModelProperty("设备推送token")
private String deviceToken;
}
package com.wecloud.im.param.add;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 添加或修改推送设备信息
*
* @author wei
* @since 2021-04-27
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "添加或修改推送设备信息")
public class ImClientDeviceInfoAdd extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("设备不想收到推送提醒, 1想, 0不想")
private Integer valid;
@ApiModelProperty("设备类型1:ios; 2:android")
private Integer deviceType;
@ApiModelProperty("设备推送token")
private String deviceToken;
}
......@@ -3,6 +3,7 @@ package com.wecloud.im.service;
import com.wecloud.im.entity.ImClient;
import com.wecloud.im.param.ImClientPageParam;
import com.wecloud.im.param.ImClientQueryVo;
import com.wecloud.im.param.add.ImClientDeviceInfoAdd;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
......@@ -24,6 +25,14 @@ public interface ImClientService extends BaseService<ImClient> {
boolean saveImClient(ImClient imClient) throws Exception;
/**
* 添加或修改推送设备信息
*
* @param imClientDevice
* @return
*/
boolean addDeviceInfo(ImClientDeviceInfoAdd imClientDevice);
/**
* 修改
*
* @param imClient
......@@ -60,6 +69,11 @@ public interface ImClientService extends BaseService<ImClient> {
Paging<ImClientQueryVo> getImClientPageList(ImClientPageParam imClientPageParam) throws Exception;
/**
* 获取当前请求的client
*
* @return
*/
ImClient getClient();
}
......@@ -9,6 +9,7 @@ import com.wecloud.im.entity.ImClient;
import com.wecloud.im.mapper.ImClientMapper;
import com.wecloud.im.param.ImClientPageParam;
import com.wecloud.im.param.ImClientQueryVo;
import com.wecloud.im.param.add.ImClientDeviceInfoAdd;
import com.wecloud.im.service.ImApplicationService;
import com.wecloud.im.service.ImClientService;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
......@@ -17,6 +18,7 @@ import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.geekidea.springbootplus.framework.shiro.util.JwtUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -42,6 +44,16 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
return super.save(imClient);
}
@Override
public boolean addDeviceInfo(ImClientDeviceInfoAdd imClientDevice) {
ImClient client = getClient();
ImClient clientNew = new ImClient();
BeanUtils.copyProperties(imClientDevice, clientNew);
clientNew.setId(client.getId());
return this.saveOrUpdate(clientNew);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateImClient(ImClient imClient) throws Exception {
......@@ -69,6 +81,7 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
@Override
public ImClient getClient() {
// shiro线程中获取当前token
JwtToken curentJwtToken = JwtUtil.getCurentJwtToken();
// 根据appKey查询appid
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment