(聊天室)极光推送用户注册测试完成

This commit is contained in:
kuang.yifei@iwhalecloud.com 2022-08-04 16:30:43 +08:00
parent e158af6c86
commit 38edc661ea
11 changed files with 159 additions and 15 deletions

View File

@ -95,6 +95,12 @@
<groupId>com.ghy</groupId>
<artifactId>ghy-worker</artifactId>
</dependency>
<dependency>
<groupId>com.ghy</groupId>
<artifactId>ghy-message</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>

View File

@ -0,0 +1,36 @@
package com.ghy.web.controller.message;
import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.utils.ExceptionUtil;
import com.ghy.message.domain.JimUser;
import com.ghy.message.service.JimUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/jim/user")
public class JimUserController extends BaseController {
@Autowired
private JimUserService jimUserService;
@PostMapping("/register")
public AjaxResult register(){
try {
JimUser jimUser = new JimUser();
jimUser.setUserName("clunt");
jimUser.setPassword("password");
jimUserService.registerJimUser(jimUser);
return AjaxResult.success("注册成功!");
}catch (Exception e){
e.printStackTrace();
logger.error(ExceptionUtil.getExceptionMessage(e));
return AjaxResult.error("注册失败!");
}
}
}

View File

@ -122,9 +122,9 @@ adapay:
notifyUrl: 'https://www.opsoul.com/adapay/callback'
jim:
appKey: ''
masterSecret: ''
maxRetryTimes: ''
appKey: '110e8830290152d76e2f1d97'
masterSecret: 'ec49918a5d89526722b05924'
maxRetryTimes: '3'
# 百度地图应用api
baidu:

View File

@ -288,6 +288,7 @@ public class ShiroConfig
filterChainDefinitionMap.put("/adapay/**", "anon");
filterChainDefinitionMap.put("/system/area/**", "anon");
filterChainDefinitionMap.put("/customer/address/**", "anon");
filterChainDefinitionMap.put("/jim/**", "anon");
filterChainDefinitionMap.put("/MP_verify_bRFuvYpyQ4WLr0on.txt", "anon");
// 对静态资源设置匿名访问
filterChainDefinitionMap.put("/favicon.ico**", "anon");

View File

@ -10,9 +10,8 @@ import org.springframework.context.annotation.Configuration;
* @author clunt
* 极光消息配置文件
*/
//@Configuration
//@ConfigurationProperties(prefix = "jim")
@Data
@Configuration
@ConfigurationProperties(prefix = "jim")
public class JimConfig {
private String appKey;
@ -21,9 +20,33 @@ public class JimConfig {
private String maxRetryTimes;
@Bean
public JMessageClient jMessageClient(){
return new JMessageClient(appKey,masterSecret,maxRetryTimes);
public String getAppKey() {
return appKey;
}
public void setAppKey(String appKey) {
this.appKey = appKey;
}
public String getMasterSecret() {
return masterSecret;
}
public void setMasterSecret(String masterSecret) {
this.masterSecret = masterSecret;
}
public String getMaxRetryTimes() {
return maxRetryTimes;
}
public void setMaxRetryTimes(String maxRetryTimes) {
this.maxRetryTimes = maxRetryTimes;
}
// @Bean
// public JMessageClient jMessageClient(){
// return new JMessageClient(appKey,masterSecret,maxRetryTimes);
// }
}

View File

@ -0,0 +1,4 @@
package com.ghy.message.domain;
public class JimRegisterInfo {
}

View File

@ -10,6 +10,18 @@ import lombok.Data;
@Data
public class JimUser extends BaseEntity {
// 自增组件
private Long jimUserId;
// D101W7 系统编码
private String sysUser;
private String userName;
private String password;
private String appKey;
}

View File

@ -0,0 +1,14 @@
package com.ghy.message.mapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 极光推送用户mapper
* @author clunt
*/
@Mapper
public interface JimUserMapper {
}

View File

@ -0,0 +1,12 @@
package com.ghy.message.service;
import com.ghy.message.domain.JimUser;
public interface JimUserService {
/**
* 注册极光推送信息并入库记录
* */
int registerJimUser(JimUser jimUser) throws Exception;
}

View File

@ -0,0 +1,36 @@
package com.ghy.message.service.impl;
import cn.jmessage.api.JMessageClient;
import cn.jmessage.api.common.model.RegisterInfo;
import com.ghy.message.config.JimConfig;
import com.ghy.message.domain.JimUser;
import com.ghy.message.service.JimUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 极光推送用户impl
* @author clunt
*/
@Slf4j
@Service
public class JimUserServiceImpl implements JimUserService {
@Resource
private JimConfig jimConfig;
@Override
public int registerJimUser(JimUser jimUser) throws Exception{
JMessageClient messageClient = new JMessageClient(jimConfig.getAppKey(),jimConfig.getMasterSecret());
RegisterInfo.Builder builder = new RegisterInfo.Builder();
builder.setUsername(jimUser.getUserName());
builder.setPassword(jimUser.getPassword());
RegisterInfo [] registerInfos = new RegisterInfo[1];
registerInfos[0] = builder.build();
String result = messageClient.registerUsers(registerInfos);
return 0;
}
}

12
pom.xml
View File

@ -313,11 +313,11 @@
</dependency>
<!-- 聊天工具-->
<!-- <dependency>-->
<!-- <groupId>com.ghy</groupId>-->
<!-- <artifactId>ghy-message</artifactId>-->
<!-- <version>${ghy.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.ghy</groupId>
<artifactId>ghy-message</artifactId>
<version>${ghy.version}</version>
</dependency>
<!-- 通用工具-->
<dependency>
@ -347,7 +347,7 @@
<module>ghy-common</module>
<module>ghy-custom</module>
<module>ghy-worker</module>
<!-- <module>ghy-message</module>-->
<module>ghy-message</module>
</modules>
<packaging>pom</packaging>