-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from xljiadahao/wechat-littleprogram
Wechat littleprogram with multi-tenant feature
- Loading branch information
Showing
35 changed files
with
1,105 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,57 @@ | ||
/** | ||
* Author: xulei | ||
* Created: Nov 06, 2016 | ||
* Updated on Nov 15 2017 for multi-tenant by xulei | ||
* Updated on Nov 17 2017 for group certificate one-many relationship | ||
*/ | ||
|
||
CREATE DATABASE hellocrypto; | ||
|
||
USE hellocrypto; | ||
|
||
-- --------------------------------------------------------------- | ||
-- Table group | ||
-- Store the group information with admin functionality | ||
-- --------------------------------------------------------------- | ||
CREATE TABLE `group` ( | ||
`IDENTIFIER` varchar(10) NOT NULL UNIQUE, | ||
`ORG_NAME` varchar(50) NOT NULL, | ||
`ACTIVITY_NAME` varchar(50) NOT NULL, | ||
`MAX_COUNT` int DEFAULT NULL, | ||
`IS_ACTIVATED` tinyint(1) NOT NULL, | ||
`TIMESTAMP` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
PRIMARY KEY (`IDENTIFIER`), | ||
CHECK(`IS_ACTIVATED` in(0,1)) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
-- --------------------------------------------------------------- | ||
-- Table certificate | ||
-- Store the certificate or public key for each client | ||
-- --------------------------------------------------------------- | ||
CREATE TABLE `certificate` ( | ||
`ID` int(11) NOT NULL AUTO_INCREMENT, | ||
`NAME` varchar(100) NOT NULL UNIQUE, | ||
`NAME` varchar(50) NOT NULL, | ||
`PUB_KEY_FINGERPRINT` varchar(100) NOT NULL UNIQUE, | ||
`CERTIFICATE_BINARY` blob NOT NULL, | ||
`TYPE` varchar(10) NOT NULL, | ||
`TIMESTAMP` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
PRIMARY KEY (`ID`) | ||
`GROUP_ID` varchar(10) NOT NULL, | ||
PRIMARY KEY (`ID`), | ||
constraint GROUP_IDENTIFIER_FK foreign key(`GROUP_ID`) | ||
references `group`(`IDENTIFIER`) on delete cascade | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
-- --------------------------------------------------------------- | ||
-- Table group_certificate_mapping (@Deprecated), | ||
-- due to group certificate one-many relationship | ||
-- Store the relationship for the client under specific group | ||
-- --------------------------------------------------------------- | ||
-- CREATE TABLE `group_certificate_mapping` ( | ||
-- `GROUP_ID` varchar(10) NOT NULL, | ||
-- `CERTIFICATE_ID` int(11) NOT NULL, | ||
-- constraint GROUP_IDENTIFIER_FK foreign key(`GROUP_ID`) | ||
-- references `group`(`IDENTIFIER`) on delete cascade, | ||
-- constraint CERTIFICATE_ID_FK foreign key(`CERTIFICATE_ID`) | ||
-- references `certificate`(`ID`) on delete cascade, | ||
-- CONSTRAINT COMPOSITE_PK PRIMARY KEY(`GROUP_ID`,`CERTIFICATE_ID`) | ||
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/hellocrypto/bo/EncryptionTransitionBo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.hellocrypto.bo; | ||
|
||
/** | ||
* | ||
* @author xulei | ||
*/ | ||
public class EncryptionTransitionBo { | ||
|
||
private String name; | ||
private String encryptText; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getEncryptText() { | ||
return encryptText; | ||
} | ||
|
||
public void setEncryptText(String encryptText) { | ||
this.encryptText = encryptText; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.hellocrypto.bo; | ||
|
||
/** | ||
* | ||
* @author xulei | ||
*/ | ||
public class GroupGenBo { | ||
|
||
private String groupIdentifier; | ||
private long createTime; | ||
|
||
public String getGroupIdentifier() { | ||
return groupIdentifier; | ||
} | ||
|
||
public void setGroupIdentifier(String groupIdentifier) { | ||
this.groupIdentifier = groupIdentifier; | ||
} | ||
|
||
public long getCreateTime() { | ||
return createTime; | ||
} | ||
|
||
public void setCreateTime(long createTime) { | ||
this.createTime = createTime; | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/com/hellocrypto/bo/GroupParticipationBo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.hellocrypto.bo; | ||
|
||
/** | ||
* | ||
* @author xulei | ||
*/ | ||
public class GroupParticipationBo { | ||
|
||
private String name; | ||
private String secureKey; | ||
private String groupIdentifier; | ||
private String orgName; | ||
private String activityName; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getSecureKey() { | ||
return secureKey; | ||
} | ||
|
||
public void setSecureKey(String secureKey) { | ||
this.secureKey = secureKey; | ||
} | ||
|
||
public String getGroupIdentifier() { | ||
return groupIdentifier; | ||
} | ||
|
||
public void setGroupIdentifier(String groupIdentifier) { | ||
this.groupIdentifier = groupIdentifier; | ||
} | ||
|
||
public String getOrgName() { | ||
return orgName; | ||
} | ||
|
||
public void setOrgName(String orgName) { | ||
this.orgName = orgName; | ||
} | ||
|
||
public String getActivityName() { | ||
return activityName; | ||
} | ||
|
||
public void setActivityName(String activityName) { | ||
this.activityName = activityName; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,37 @@ | ||
package com.hellocrypto.cache; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.apache.log4j.Logger; | ||
|
||
/** | ||
* | ||
* @author leixu2 | ||
* @author xulei | ||
*/ | ||
public class LuckyDrawResult { | ||
|
||
private static List<String> luckDrawResults = null; | ||
private static final Logger logger = Logger.getLogger(LuckyDrawResult.class); | ||
|
||
private static Map<String, List<String>> luckDrawResults = new HashMap<String, List<String>>(); | ||
|
||
public static List<String> getLuckDrawResults() { | ||
return luckDrawResults; | ||
public static List<String> getLuckDrawResults(String groupIdentifier) { | ||
return luckDrawResults.get(groupIdentifier); | ||
} | ||
|
||
public static void setDrawResult(String groupIdentifier, List<String> list) { | ||
luckDrawResults.put(groupIdentifier, list); | ||
} | ||
|
||
public static void setLuckDrawResults(List<String> luckDrawResults) { | ||
LuckyDrawResult.luckDrawResults = luckDrawResults; | ||
public static boolean cleanLuckDrawResults(String groupIdentifier) { | ||
List<String> cleanList = luckDrawResults.remove(groupIdentifier); | ||
if (cleanList == null) { | ||
logger.warn("cannot find the result for group identifier: " + groupIdentifier); | ||
return false; | ||
} else { | ||
logger.info("cleanLuckDrawResults, group id: " + groupIdentifier + ", result size: " + cleanList.size()); | ||
return true; | ||
} | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/hellocrypto/constant/GeneralConstant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.hellocrypto.constant; | ||
|
||
/** | ||
* | ||
* @author xulei | ||
*/ | ||
public class GeneralConstant { | ||
|
||
public static final String AUTH = "hellocrypto"; | ||
public static final String SECURITY_CONTEXT = "HelloCrypto-Security-Context"; | ||
|
||
// group identifier has 5 characters, so the adhoc key need to be different from it | ||
public static final String ADHOC_KEY = "ad-hoc"; | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/hellocrypto/constant/ResponseMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.hellocrypto.constant; | ||
|
||
/** | ||
* | ||
* @author xulei | ||
*/ | ||
public class ResponseMessage { | ||
|
||
/** | ||
* general response | ||
*/ | ||
public static final String BAD_REQ = "The request is invalid, please try it again"; | ||
public static final String INTERNAL_SERVER_ERROR = "Oops, sorry, we got some problems, " | ||
+ "our engineers are working on it, please come back later"; | ||
|
||
/** | ||
* business logic response | ||
*/ | ||
public static final String BAD_DECRYPTION = "Oops, bad decryption, try next time!"; | ||
|
||
} |
Oops, something went wrong.