增加app相关账号配置:push、webapp账号 · JavaBaas/JavaBaasServer@d36e869 · GitHub
Skip to content

Commit d36e869

Browse files
author
zangyilinzw@126.com
committed
增加app相关账号配置:push、webapp账号
修改第三方账号绑定登录 增加微信小程序登录处理 增加Account账号测试用例 修改测试用例,在每个测试用例的@before中,创建应用之前,先删除该应用,目的是为了防止在某次执行测试用例失败或则中断时,相关的测试表并未删除,使得下次执行测试用例时候准备数据时冲突或者失败
1 parent e0b3ea4 commit d36e869

52 files changed

Lines changed: 645 additions & 165 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 12 additions & 1 deletion

‎pom.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<artifactId>spring-boot-starter-test</artifactId>
4848
<scope>test</scope>
4949
</dependency>
50+
<dependency>
51+
<groupId>org.bouncycastle</groupId>
52+
<artifactId>bcprov-jdk15</artifactId>
53+
<version>1.46</version>
54+
</dependency>
5055
<!--七牛云存储-->
5156
<dependency>
5257
<groupId>com.qiniu</groupId>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.javabaas.server.admin.controller;
2+
3+
import com.javabaas.server.admin.entity.Account;
4+
import com.javabaas.server.admin.entity.AccountType;
5+
import com.javabaas.server.admin.service.AccountService;
6+
import com.javabaas.server.common.entity.SimpleCode;
7+
import com.javabaas.server.common.entity.SimpleError;
8+
import com.javabaas.server.common.entity.SimpleResult;
9+
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.web.bind.annotation.*;
11+
12+
import javax.validation.Valid;
13+
14+
/**
15+
* Created by test on 2017/6/19.
16+
*/
17+
@RestController
18+
@RequestMapping(value = "/api/master/account")
19+
public class AccountController {
20+
@Autowired
21+
private AccountService accountService;
22+
23+
/**
24+
* 设置推送账号信息
25+
*
26+
* @param appId 应用id
27+
* @param account 推送账号信息
28+
* @return 结果
29+
* @throws SimpleError
30+
*/
31+
@RequestMapping(value = "/setAccount", method = RequestMethod.PUT)
32+
@ResponseBody
33+
public SimpleResult setAccount(@RequestHeader(value = "JB-AppId") String appId,
34+
@PathVariable int type,
35+
@Valid @RequestBody Account account) {
36+
AccountType accountType = AccountType.getType(type);
37+
if (accountType == null) {
38+
throw new SimpleError(SimpleCode.APP_ACCOUNT_ERROR);
39+
}
40+
accountService.setAccount(appId,accountType, account);
41+
return SimpleResult.success();
42+
}
43+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.javabaas.server.admin.entity;
2+
3+
import java.util.LinkedHashMap;
4+
5+
/**
6+
* Created by test on 2017/6/15.
7+
*/
8+
public class Account extends LinkedHashMap<String, Object> {
9+
10+
public Account(){
11+
super();
12+
}
13+
14+
public void setKey(String id) {
15+
put("key", id);
16+
}
17+
18+
public String getKey() {
19+
return (String) get("key");
20+
}
21+
22+
public void setSecret(String id) {
23+
put("secret", id);
24+
}
25+
26+
public String getSecret() {
27+
return (String) get("secret");
28+
}
29+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.javabaas.server.admin.entity;
2+
3+
/**
4+
* Created by test on 2017/6/19.
5+
*/
6+
public enum AccountType {
7+
PUSH(1, "push"),
8+
WEBAPP(2, "webapp");
9+
10+
private int code;
11+
private String value;
12+
13+
AccountType(int code, String value) {
14+
this.code = code;
15+
this.value = value;
16+
}
17+
18+
public int getCode() {
19+
return this.code;
20+
}
21+
22+
public String getValue() {
23+
return this.value;
24+
}
25+
26+
public static AccountType getType(int code) {
27+
for (AccountType accountType : AccountType.values()) {
28+
if (accountType.code == code) {
29+
return accountType;
30+
}
31+
}
32+
return null;
33+
}
34+
35+
@Override
36+
public String toString() {
37+
return super.toString() + " code:" + this.code + " value:" + this.value;
38+
}
39+
}

‎src/main/java/com/javabaas/server/admin/entity/App.java‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.javabaas.server.admin.entity;
22

3-
import com.javabaas.server.push.entity.PushAccount;
43
import com.javabaas.server.cloud.entity.CloudSetting;
54
import org.springframework.data.mongodb.core.mapping.Document;
65

@@ -15,7 +14,7 @@ public class App {
1514
private String key;
1615
private String masterKey;
1716
private CloudSetting cloudSetting;
18-
private PushAccount pushAccount;
17+
private AppAccounts appAccounts;
1918

2019
public String getId() {
2120
return id;
@@ -57,11 +56,11 @@ public void setCloudSetting(CloudSetting cloudSetting) {
5756
this.cloudSetting = cloudSetting;
5857
}
5958

60-
public PushAccount getPushAccount() {
61-
return pushAccount;
59+
public AppAccounts getAppAccounts() {
60+
return appAccounts;
6261
}
6362

64-
public void setPushAccount(PushAccount pushAccount) {
65-
this.pushAccount = pushAccount;
63+
public void setAppAccounts(AppAccounts appAccounts) {
64+
this.appAccounts = appAccounts;
6665
}
6766
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.javabaas.server.admin.entity;
2+
3+
import java.util.LinkedHashMap;
4+
5+
/**
6+
* Created by test on 2017/6/15.
7+
*/
8+
public class AppAccounts extends LinkedHashMap<String, Account> {
9+
public AppAccounts() {
10+
super();
11+
}
12+
13+
public Account getAccount(AccountType accountType) {
14+
return get(accountType.getValue());
15+
}
16+
17+
public void setAccount(AccountType accountType, Account account) {
18+
put(accountType.getValue(), account);
19+
}
20+
}

‎src/main/java/com/javabaas/server/admin/entity/dto/AppExport.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.javabaas.server.admin.entity.dto;
22

3-
import com.javabaas.server.push.entity.PushAccount;
3+
import com.javabaas.server.admin.entity.AppAccounts;
44
import com.javabaas.server.cloud.entity.CloudSetting;
55

66
import java.util.List;
@@ -16,7 +16,7 @@ public class AppExport {
1616
private String masterKey;
1717
private CloudSetting cloudSetting;
1818
private List<ClazzExport> clazzs;
19-
private PushAccount pushAccount;
19+
private AppAccounts appAccounts;
2020

2121
public String getId() {
2222
return id;
@@ -66,11 +66,11 @@ public void setClazzs(List<ClazzExport> clazzs) {
6666
this.clazzs = clazzs;
6767
}
6868

69-
public PushAccount getPushAccount() {
70-
return pushAccount;
69+
public AppAccounts getAppAccounts() {
70+
return appAccounts;
7171
}
7272

73-
public void setPushAccount(PushAccount pushAccount) {
74-
this.pushAccount = pushAccount;
73+
public void setAppAccounts(AppAccounts appAccounts) {
74+
this.appAccounts = appAccounts;
7575
}
7676
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.javabaas.server.admin.service;
2+
3+
import com.javabaas.server.admin.entity.Account;
4+
import com.javabaas.server.admin.entity.AccountType;
5+
import org.apache.commons.logging.Log;
6+
import org.apache.commons.logging.LogFactory;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.stereotype.Service;
9+
10+
/**
11+
* Created by test on 2017/6/19.
12+
*/
13+
@Service
14+
public class AccountService {
15+
16+
private Log log = LogFactory.getLog(getClass());
17+
@Autowired
18+
private AppService appService;
19+
20+
21+
22+
/**
23+
* 查询账号信息
24+
*
25+
* @param appId 应用id
26+
* @return 推送账号信息
27+
*/
28+
public Account getAccount(String appId, AccountType accountType) {
29+
return appService.get(appId).getAppAccounts().getAccount(accountType);
30+
}
31+
32+
/**
33+
* 设置账号信息
34+
*
35+
* @param appId appId
36+
* @param accountType type
37+
* @param account account
38+
*/
39+
public void setAccount(String appId,AccountType accountType, Account account) {
40+
appService.setAccount(appId, accountType, account);
41+
log.info("App:" + appId + " " + accountType.getValue() + "账号设置成功");
42+
}
43+
44+
}

‎src/main/java/com/javabaas/server/admin/service/AppService.java‎

Lines changed: 17 additions & 11 deletions

0 commit comments

Comments
 (0)