mirror of https://github.com/Rekoe/rk_svnadmin
pull/1/head
parent
2d25b3440f
commit
b5c4e2ef8a
216
pom.xml
216
pom.xml
|
@ -3,8 +3,8 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.rekoe</groupId>
|
||||
<artifactId>rk_svnadmin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>3.0</version>
|
||||
<packaging>war</packaging>
|
||||
<version>1.0</version>
|
||||
<name>rk_svnadmin</name>
|
||||
<url>http://www.rekoe.com</url>
|
||||
<properties>
|
||||
|
@ -27,7 +27,7 @@
|
|||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.0.16</version>
|
||||
<version>1.0.17</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jconsole</artifactId>
|
||||
|
@ -39,6 +39,31 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutz-plugins-views</artifactId>
|
||||
<version>1.r.54.r2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutz</artifactId>
|
||||
<version>1.r.54.r5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutz-web</artifactId>
|
||||
<version>1.b.49</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.restfb</groupId>
|
||||
<artifactId>restfb</artifactId>
|
||||
<version>1.6.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
<version>2.3.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
|
@ -59,92 +84,6 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutz-plugins-views</artifactId>
|
||||
<version>1.r.54.r2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutz</artifactId>
|
||||
<version>1.r.56.r1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutz-web</artifactId>
|
||||
<version>1.b.49</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.restfb</groupId>
|
||||
<artifactId>restfb</artifactId>
|
||||
<version>1.6.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-all</artifactId>
|
||||
<version>1.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.oltu.oauth2</groupId>
|
||||
<artifactId>org.apache.oltu.oauth2.authzserver</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.oltu.oauth2</groupId>
|
||||
<artifactId>org.apache.oltu.oauth2.resourceserver</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.oltu.oauth2</groupId>
|
||||
<artifactId>org.apache.oltu.oauth2.common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.apis</groupId>
|
||||
<artifactId>google-api-services-androidpublisher</artifactId>
|
||||
<version>v2-rev22-1.21.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.http-client</groupId>
|
||||
<artifactId>google-http-client</artifactId>
|
||||
<version>1.21.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.apis</groupId>
|
||||
<artifactId>google-api-services-oauth2</artifactId>
|
||||
<version>v2-rev101-1.21.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.api-client</groupId>
|
||||
<artifactId>google-api-client</artifactId>
|
||||
<version>1.21.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava-jdk5</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.apis</groupId>
|
||||
<artifactId>google-api-services-plus</artifactId>
|
||||
<version>v1-rev327-1.21.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
<version>2.3.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
|
@ -165,17 +104,6 @@
|
|||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutz-integration-quartz</artifactId>
|
||||
<version>1.b.53</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>c3p0</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.cloopen</groupId>
|
||||
<artifactId>ccp_rest_sdk</artifactId>
|
||||
<version>2.7.r</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
|
@ -186,17 +114,17 @@
|
|||
<groupId>commons-email</groupId>
|
||||
<artifactId>commons-email</artifactId>
|
||||
<version>1.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>activation</artifactId>
|
||||
<groupId>javax.activation</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutz-integration-shiro</artifactId>
|
||||
<version>1.b.53</version>
|
||||
<version>1.b.53.r2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
|
@ -239,21 +167,6 @@
|
|||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-vfs2</artifactId>
|
||||
<version>2.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>maven-scm-api</artifactId>
|
||||
<groupId>org.apache.maven.scm</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>maven-scm-provider-svnexe</artifactId>
|
||||
<groupId>org.apache.maven.scm</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.brickred</groupId>
|
||||
<artifactId>socialauth</artifactId>
|
||||
|
@ -281,20 +194,39 @@
|
|||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>com/rekoe/web/freemarker/*.*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.js</include>
|
||||
<include>com/rekoe/mvc/*.*</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<finalName>rk_svnadmin</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>prepare-package</phase>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>src/main/resources/**/*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
|
@ -305,6 +237,30 @@
|
|||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<archiveClasses>true</archiveClasses>
|
||||
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
|
||||
<warSourceExcludes>WEB-INF/classes/com/**</warSourceExcludes>
|
||||
<webResources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<targetPath>WEB-INF/classes</targetPath>
|
||||
<includes>
|
||||
<include>msg/**/*</include>
|
||||
<include>log4j.properties</include>
|
||||
<include>oauth_consumer.properties</include>
|
||||
<include>quartz.properties</include>
|
||||
<include>shiro.ini</include>
|
||||
<include>ehcache.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</webResources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.rekoe;
|
||||
|
||||
import org.nutz.mvc.annotation.ChainBy;
|
||||
import org.nutz.mvc.annotation.Encoding;
|
||||
import org.nutz.mvc.annotation.Fail;
|
||||
import org.nutz.mvc.annotation.IocBy;
|
||||
import org.nutz.mvc.annotation.Localization;
|
||||
import org.nutz.mvc.annotation.Modules;
|
||||
import org.nutz.mvc.annotation.SetupBy;
|
||||
import org.nutz.mvc.annotation.Views;
|
||||
import org.nutz.mvc.ioc.provider.ComboIocProvider;
|
||||
import org.nutz.plugins.view.freemarker.FreemarkerViewMaker;
|
||||
|
||||
@Modules(scanPackage = true, packages = { "com.rekoe.module" })
|
||||
@IocBy(type = ComboIocProvider.class, args = { "*json", "/ioc", "*anno", "com.rekoe", "*tx", "*org.nutz.integration.quartz.QuartzIocLoader", "*org.nutz.plugins.view.freemarker.FreemarkerIocLoader", "*async" })
|
||||
@SetupBy(MvcSetup.class)
|
||||
@Fail(">>:/admin/common/unauthorized.rk")
|
||||
@Encoding(input = "UTF-8", output = "UTF-8")
|
||||
@ChainBy(args = "com/rekoe/mvc/mvc-chains.js")
|
||||
@Views({ FreemarkerViewMaker.class })
|
||||
@Localization(value = "msg/", defaultLocalizationKey = "zh-CN")
|
||||
public class MainModule {
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.rekoe;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.shiro.crypto.RandomNumberGenerator;
|
||||
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
|
||||
import org.apache.shiro.crypto.hash.Sha256Hash;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.impl.FileSqlManager;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.ioc.Ioc;
|
||||
import org.nutz.mvc.NutConfig;
|
||||
import org.nutz.mvc.Setup;
|
||||
import org.nutz.plugins.view.freemarker.FreeMarkerConfigurer;
|
||||
|
||||
import com.rekoe.domain.User;
|
||||
import com.rekoe.service.UserService;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
|
||||
/**
|
||||
* @author 科技㊣²º¹³ <br />
|
||||
* 2014年2月3日 下午4:48:45<br />
|
||||
* http://www.rekoe.com <br />
|
||||
* QQ:5382211
|
||||
*/
|
||||
public class MvcSetup implements Setup {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Override
|
||||
public void init(NutConfig config) {
|
||||
Ioc ioc = config.getIoc();
|
||||
// 加载freemarker自定义标签 自定义宏路径
|
||||
ioc.get(Configuration.class).setAutoImports(new HashMap<String, String>(2) {
|
||||
{
|
||||
put("p", "/ftl/pony/index.ftl");
|
||||
put("s", "/ftl/spring.ftl");
|
||||
}
|
||||
});
|
||||
ioc.get(FreeMarkerConfigurer.class, "mapTags");
|
||||
Dao dao = ioc.get(Dao.class);
|
||||
// dao.clear(OAuthUser.class);
|
||||
Daos.createTablesInPackage(dao, User.class.getPackage().getName(), false);
|
||||
if (0 == dao.count(User.class)) {
|
||||
FileSqlManager fm = new FileSqlManager("init_system_h2.sql");
|
||||
List<Sql> sqlList = fm.createCombo(fm.keys());
|
||||
dao.execute(sqlList.toArray(new Sql[sqlList.size()]));
|
||||
List<User> userList = dao.query(User.class, null);
|
||||
for (User user : userList) {
|
||||
RandomNumberGenerator rng = new SecureRandomNumberGenerator();
|
||||
String salt = rng.nextBytes().toBase64();
|
||||
String hashedPasswordBase64 = new Sha256Hash("123", salt, 1024).toBase64();
|
||||
user.setSalt(salt);
|
||||
user.setPassword(hashedPasswordBase64);
|
||||
dao.update(user);
|
||||
}
|
||||
}
|
||||
UserService userService = ioc.get(UserService.class);
|
||||
userService.initFormPackages("com.rekoe");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy(NutConfig config) {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
public enum AuthType {
|
||||
|
||||
DEFAULT("DEFAULT"), TOKEN("TOKEN"), QQ_HTML5("QQ_HTML5");
|
||||
|
||||
public String display;
|
||||
|
||||
AuthType(String display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
return display;
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.EL;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.Prev;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
|
||||
/**
|
||||
* @author 科技㊣²º¹³<br />
|
||||
* 2014年4月19日 上午8:54:23<br />
|
||||
* http://www.rekoe.com<br />
|
||||
* QQ:5382211<br />
|
||||
*/
|
||||
@Table("cdkey_category")
|
||||
public class CdkeyCategory implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7685127380108984960L;
|
||||
@Name
|
||||
@Prev(els = { @EL("uuid()") })
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
private String name;
|
||||
|
||||
@Column(hump = true)
|
||||
private int cdkeyType;
|
||||
|
||||
public CdkeyCategory() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CdkeyCategory(String name, int cdkeyType) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.cdkeyType = cdkeyType;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getCdkeyType() {
|
||||
return cdkeyType;
|
||||
}
|
||||
|
||||
public void setCdkeyType(int cdkeyType) {
|
||||
this.cdkeyType = cdkeyType;
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Id;
|
||||
import org.nutz.dao.entity.annotation.Index;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.entity.annotation.TableIndexes;
|
||||
|
||||
@Table("cdkey_${taskid}")
|
||||
@TableIndexes({ @Index(name = "cdk_${taskid}_index", fields = { "cdkey" }, unique = true), @Index(name = "cdk_${taskid}_used_index", fields = { "used" }, unique = false) })
|
||||
public class CdkeyEntity {
|
||||
|
||||
@Id
|
||||
private long id;
|
||||
@Column
|
||||
private String cdkey;
|
||||
|
||||
@Column("is_used")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean used;
|
||||
|
||||
@Column(hump = true)
|
||||
@ColDefine(type = ColType.TIMESTAMP)
|
||||
private Date createTime;
|
||||
|
||||
public boolean isUsed() {
|
||||
return used;
|
||||
}
|
||||
|
||||
public void setUsed(boolean used) {
|
||||
this.used = used;
|
||||
}
|
||||
|
||||
public CdkeyEntity() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CdkeyEntity(String cdkey, Date createTime) {
|
||||
super();
|
||||
this.cdkey = cdkey;
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.EL;
|
||||
import org.nutz.dao.entity.annotation.Id;
|
||||
import org.nutz.dao.entity.annotation.Prev;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
|
||||
@Table("cdkey_log")
|
||||
public class CdkeyLog implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6797252917202955579L;
|
||||
|
||||
@Id
|
||||
private long id;
|
||||
@Column
|
||||
private int pid;
|
||||
@Column(hump = true)
|
||||
private String providerId;
|
||||
@Column
|
||||
private String mac;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.TIMESTAMP)
|
||||
@Prev(els = @EL("$me.now()"))
|
||||
private Date createTime;
|
||||
|
||||
public CdkeyLog() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CdkeyLog(int pid, String providerId, String mac) {
|
||||
super();
|
||||
this.pid = pid;
|
||||
this.providerId = providerId;
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public Date now() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getProviderId() {
|
||||
return providerId;
|
||||
}
|
||||
|
||||
public void setProviderId(String providerId) {
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public String getMac() {
|
||||
return mac;
|
||||
}
|
||||
|
||||
public void setMac(String mac) {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,222 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Comment;
|
||||
import org.nutz.dao.entity.annotation.Default;
|
||||
import org.nutz.dao.entity.annotation.Id;
|
||||
import org.nutz.dao.entity.annotation.Index;
|
||||
import org.nutz.dao.entity.annotation.Many;
|
||||
import org.nutz.dao.entity.annotation.ManyMany;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.entity.annotation.TableIndexes;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import com.rekoe.valueadaptor.NutMapValueAdaptor;
|
||||
import com.rekoe.valueadaptor.StringJsonAdaptor;
|
||||
|
||||
@Table("system_server")
|
||||
@TableIndexes({ @Index(name = "g_pid_index", fields = { "pid" }, unique = true) })
|
||||
public class GameServer implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4391955362256919755L;
|
||||
|
||||
@Id
|
||||
private int id;
|
||||
|
||||
@Column(hump = true)
|
||||
@Comment("平台名称")
|
||||
private String platformName;
|
||||
|
||||
@Column("platform_id")
|
||||
@Comment("平台编号")
|
||||
private int pid;
|
||||
|
||||
@Column("is_open")
|
||||
@Comment("是否开启")
|
||||
private boolean open;
|
||||
|
||||
@Column(hump = true)
|
||||
@Comment("充值地址")
|
||||
@ColDefine(width = 225)
|
||||
private String payUrl;
|
||||
|
||||
@Column(hump = true)
|
||||
@Comment("登陆服地址")
|
||||
@ColDefine(width = 225)
|
||||
private String loginUrl;
|
||||
|
||||
@ManyMany(target = User.class, relation = "system_user_server", from = "SERVERID", to = "USERID")
|
||||
private List<User> users;
|
||||
|
||||
@Many(target = OfficialServer.class, field = "pid")
|
||||
private List<OfficialServer> officialServers;
|
||||
|
||||
@Column("ver")
|
||||
@Comment("当前版本号")
|
||||
private String version;
|
||||
|
||||
@Column
|
||||
@Comment("是否提审")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean verify;
|
||||
|
||||
@Column("is_black_open")
|
||||
@Comment("是否开启白名单")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean blackOpen;
|
||||
|
||||
@Column("black_list")
|
||||
@Comment("白名单列表")
|
||||
@ColDefine(type = ColType.TEXT, adaptor = StringJsonAdaptor.class)
|
||||
private List<String> items = new ArrayList<String>();
|
||||
|
||||
@Column(hump = true)
|
||||
private String clientSecret;
|
||||
|
||||
@Column(hump = true)
|
||||
@Comment("认证方式")
|
||||
@Default("DEFAULT")
|
||||
protected AuthType authType;
|
||||
|
||||
@Column(hump = true)
|
||||
@ColDefine(type = ColType.TEXT, adaptor = NutMapValueAdaptor.class)
|
||||
private NutMap mobileAuth;
|
||||
|
||||
public NutMap getMobileAuth() {
|
||||
if (mobileAuth == null) {
|
||||
mobileAuth = NutMap.NEW();
|
||||
}
|
||||
return mobileAuth;
|
||||
}
|
||||
|
||||
public void setMobileAuth(NutMap config) {
|
||||
this.mobileAuth = config;
|
||||
}
|
||||
|
||||
public GameServer addMobileAuth(String id, NutMap config) {
|
||||
this.mobileAuth.addv(id, config);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isBlackOpen() {
|
||||
return blackOpen;
|
||||
}
|
||||
|
||||
public String getClientSecret() {
|
||||
return clientSecret;
|
||||
}
|
||||
|
||||
public void setClientSecret(String clientSecret) {
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
|
||||
public void setBlackOpen(boolean black) {
|
||||
this.blackOpen = black;
|
||||
}
|
||||
|
||||
public List<String> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public AuthType getAuthType() {
|
||||
return authType;
|
||||
}
|
||||
|
||||
public void setAuthType(AuthType authType) {
|
||||
this.authType = authType;
|
||||
}
|
||||
|
||||
public void setItems(List<String> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public boolean isVerify() {
|
||||
return verify;
|
||||
}
|
||||
|
||||
public void setVerify(boolean verify) {
|
||||
this.verify = verify;
|
||||
}
|
||||
|
||||
public List<OfficialServer> getOfficialServers() {
|
||||
return officialServers;
|
||||
}
|
||||
|
||||
public void setOfficialServers(List<OfficialServer> officialServers) {
|
||||
this.officialServers = officialServers;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPlatformName() {
|
||||
return platformName;
|
||||
}
|
||||
|
||||
public void setPlatformName(String platformName) {
|
||||
this.platformName = platformName;
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return open;
|
||||
}
|
||||
|
||||
public void setOpen(boolean open) {
|
||||
this.open = open;
|
||||
}
|
||||
|
||||
public List<User> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(List<User> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getPayUrl() {
|
||||
return payUrl;
|
||||
}
|
||||
|
||||
public void setPayUrl(String payUrl) {
|
||||
this.payUrl = payUrl;
|
||||
}
|
||||
|
||||
public String getLoginUrl() {
|
||||
return loginUrl;
|
||||
}
|
||||
|
||||
public void setLoginUrl(String loginUrl) {
|
||||
this.loginUrl = loginUrl;
|
||||
}
|
||||
|
||||
public boolean isUseMobileAuth() {
|
||||
return getMobileAuth().getBoolean("mobileAuth", false);
|
||||
}
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Default;
|
||||
import org.nutz.dao.entity.annotation.Id;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.json.JsonField;
|
||||
|
||||
/**
|
||||
* @author 科技㊣²º¹³<br/>
|
||||
* 2014年2月3日 下午4:48:45<br/>
|
||||
* http://www.rekoe.com<br/>
|
||||
* QQ:5382211
|
||||
*/
|
||||
@Table("sg_notice")
|
||||
public class Notice implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1566985676414681818L;
|
||||
|
||||
@Id(auto=true)
|
||||
private long id;
|
||||
|
||||
@Column(hump = true)
|
||||
@ColDefine(type = ColType.TIMESTAMP)
|
||||
@JsonField(ignore = true)
|
||||
private Date createDate;
|
||||
|
||||
@Column
|
||||
@Default("#FF0000")
|
||||
private String color;
|
||||
|
||||
@Column(hump = true)
|
||||
@ColDefine(type = ColType.TIMESTAMP)
|
||||
@JsonField(ignore = true)
|
||||
private Date modifyDate;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
@JsonField(ignore = true)
|
||||
private String content;
|
||||
|
||||
@Column("is_publication")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@JsonField(ignore = true)
|
||||
private boolean publication;
|
||||
|
||||
@Column("is_top")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@JsonField(ignore = true)
|
||||
private boolean top;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String title;
|
||||
|
||||
@Column
|
||||
@Default("1001")
|
||||
@JsonField(ignore = true)
|
||||
private int pid;
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public Date getModifyDate() {
|
||||
return modifyDate;
|
||||
}
|
||||
|
||||
public void setModifyDate(Date modifyDate) {
|
||||
this.modifyDate = modifyDate;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public boolean isPublication() {
|
||||
return publication;
|
||||
}
|
||||
|
||||
public void setPublication(boolean publication) {
|
||||
this.publication = publication;
|
||||
}
|
||||
|
||||
public boolean isTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public void setTop(boolean top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Id;
|
||||
import org.nutz.dao.entity.annotation.Index;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.entity.annotation.TableIndexes;
|
||||
|
||||
@Table("sg_oauth_client")
|
||||
@TableIndexes({ @Index(name = "sg_oauth_client_index", fields = { "clientName" }, unique = true), @Index(name = "sg_oc_secret_index", fields = { "clientId", "clientSecret" }, unique = false) })
|
||||
public class OAuthClient implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2345879369118031587L;
|
||||
@Id
|
||||
private long id;
|
||||
|
||||
@Column(hump = true)
|
||||
private String clientName;
|
||||
|
||||
@Column(hump = true)
|
||||
private String clientId;
|
||||
|
||||
@Column(hump = true)
|
||||
private String clientSecret;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getClientName() {
|
||||
return clientName;
|
||||
}
|
||||
|
||||
public void setClientName(String clientName) {
|
||||
this.clientName = clientName;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getClientSecret() {
|
||||
return clientSecret;
|
||||
}
|
||||
|
||||
public void setClientSecret(String clientSecret) {
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Client{" + "id=" + id + ", clientName='" + clientName + '\'' + ", clientId='" + clientId + '\'' + ", clientSecret='" + clientSecret + '\'' + '}';
|
||||
}
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Comment;
|
||||
import org.nutz.dao.entity.annotation.Default;
|
||||
import org.nutz.dao.entity.annotation.EL;
|
||||
import org.nutz.dao.entity.annotation.Index;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.Prev;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.entity.annotation.TableIndexes;
|
||||
import org.nutz.json.JsonField;
|
||||
|
||||
@Table("sg_oauth_user")
|
||||
@TableIndexes({ @Index(name = "sg_user_data_index", fields = { "userName" }, unique = true), @Index(name = "sg_user_phone_index", fields = { "userName", "phoneCode" }, unique = false) })
|
||||
public class OAuthUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2879607754801933480L;
|
||||
|
||||
@Name
|
||||
@Prev(els = @EL("uuid()"))
|
||||
@JsonField(ignore = true)
|
||||
private String id;
|
||||
|
||||
@Column(hump = true)
|
||||
@JsonField(value = "name")
|
||||
private String userName;
|
||||
|
||||
@Column
|
||||
@JsonField(ignore = true)
|
||||
private String password;
|
||||
|
||||
@Column
|
||||
@JsonField(ignore = true)
|
||||
private String salt;
|
||||
|
||||
@Column(hump = true)
|
||||
@ColDefine(type = ColType.INT, width = 16)
|
||||
@JsonField(ignore = true)
|
||||
private long phoneCode;
|
||||
|
||||
@Column(hump = true)
|
||||
@ColDefine(type = ColType.INT, width = 16)
|
||||
@JsonField(value = "uid")
|
||||
private long userId;
|
||||
|
||||
@Column("is_locked")
|
||||
@JsonField(value = "locked")
|
||||
private boolean locked;
|
||||
|
||||
@Column("is_bind")
|
||||
@JsonField(ignore = true)
|
||||
@Default("0")
|
||||
private boolean bind;
|
||||
|
||||
@Column(hump = true)
|
||||
@Comment("绑定前的渠道")
|
||||
private String bindProviderId;
|
||||
|
||||
public String getBindProviderId() {
|
||||
return bindProviderId;
|
||||
}
|
||||
|
||||
public void setBindProviderId(String bindProviderId) {
|
||||
this.bindProviderId = bindProviderId;
|
||||
}
|
||||
|
||||
public boolean isBind() {
|
||||
return bind;
|
||||
}
|
||||
|
||||
public void setBind(boolean bind) {
|
||||
this.bind = bind;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
public void setSalt(String salt) {
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
public long getPhoneCode() {
|
||||
return phoneCode;
|
||||
}
|
||||
|
||||
public void setPhoneCode(long phoneCode) {
|
||||
this.phoneCode = phoneCode;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public void setLocked(boolean locked) {
|
||||
this.locked = locked;
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Comment;
|
||||
import org.nutz.dao.entity.annotation.Default;
|
||||
import org.nutz.dao.entity.annotation.Id;
|
||||
import org.nutz.dao.entity.annotation.Index;
|
||||
import org.nutz.dao.entity.annotation.One;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.entity.annotation.TableIndexes;
|
||||
|
||||
/**
|
||||
* 正式服
|
||||
*
|
||||
* @author kouxian
|
||||
*
|
||||
*/
|
||||
@Table("official_server")
|
||||
@TableIndexes({ @Index(name = "g_sid_pid_index", fields = { "pid", "sid" }, unique = true) })
|
||||
public class OfficialServer implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6978032147399501026L;
|
||||
|
||||
@Id
|
||||
private long id;
|
||||
|
||||
@Column
|
||||
private int sid;
|
||||
|
||||
@Column
|
||||
@ColDefine(width = 225)
|
||||
private String url;
|
||||
|
||||
@Column
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
private short status;
|
||||
|
||||
@Column("pid")
|
||||
private int pid;
|
||||
|
||||
@One(target = GameServer.class, field = "pid")
|
||||
private GameServer gameServer;
|
||||
|
||||
@Column(hump = true)
|
||||
@Default("0")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否开启白名单")
|
||||
private boolean openWhiteList;
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public GameServer getGameServer() {
|
||||
return gameServer;
|
||||
}
|
||||
|
||||
public void setGameServer(GameServer gameServer) {
|
||||
this.gameServer = gameServer;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public void setSid(int sid) {
|
||||
this.sid = sid;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public boolean isOpenWhiteList() {
|
||||
return openWhiteList;
|
||||
}
|
||||
|
||||
public void setOpenWhiteList(boolean openWhiteList) {
|
||||
this.openWhiteList = openWhiteList;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Comment;
|
||||
import org.nutz.dao.entity.annotation.EL;
|
||||
import org.nutz.dao.entity.annotation.Index;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.Prev;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.entity.annotation.TableIndexes;
|
||||
|
||||
@Table("pay_refund")
|
||||
@TableIndexes({ @Index(name = "pay_refund_index", fields = { "paymentid" }, unique = false), @Index(name = "pay_status_index", fields = { "status" }, unique = false) })
|
||||
public class PayRefund implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6311504223475095588L;
|
||||
@Name
|
||||
@Comment("ID主键")
|
||||
@Prev(els = { @EL("uuid()") })
|
||||
private String id;
|
||||
@Column
|
||||
@ColDefine(type = ColType.TIMESTAMP)
|
||||
@Comment("创建时间")
|
||||
private Date createTime;
|
||||
@Column
|
||||
private String passportid;
|
||||
@Column("payment_id")
|
||||
private String paymentid;
|
||||
@Column
|
||||
private String name;
|
||||
@Column(hump = true)
|
||||
private String requestId;
|
||||
|
||||
@Column(hump = true)
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String changedFields;
|
||||
|
||||
@Column("do_status")
|
||||
@Comment("订单处理状态")
|
||||
private boolean status;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getPassportid() {
|
||||
return passportid;
|
||||
}
|
||||
|
||||
public void setPassportid(String passportid) {
|
||||
this.passportid = passportid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPaymentid() {
|
||||
return paymentid;
|
||||
}
|
||||
|
||||
public void setPaymentid(String paymentid) {
|
||||
this.paymentid = paymentid;
|
||||
}
|
||||
|
||||
public String getRequestId() {
|
||||
return requestId;
|
||||
}
|
||||
|
||||
public void setRequestId(String requestId) {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
|
||||
public boolean isStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getChangedFields() {
|
||||
return changedFields;
|
||||
}
|
||||
|
||||
public void setChangedFields(String changedFields) {
|
||||
this.changedFields = changedFields;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Comment;
|
||||
import org.nutz.dao.entity.annotation.EL;
|
||||
import org.nutz.dao.entity.annotation.Index;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.Prev;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.entity.annotation.TableIndexes;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import com.rekoe.valueadaptor.NutMapValueAdaptor;
|
||||
|
||||
@Table("platform_config")
|
||||
@TableIndexes({ @Index(name = "p_pid_index", fields = { "sid", "provider" }, unique = true) })
|
||||
public class PlatformConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4694161925835479316L;
|
||||
|
||||
@Name
|
||||
@Prev(els = @EL("uuid()"))
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
private int sid;
|
||||
|
||||
@Column
|
||||
@Comment("平台")
|
||||
private String provider;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.TEXT, adaptor = NutMapValueAdaptor.class)
|
||||
private NutMap config;
|
||||
|
||||
public PlatformConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PlatformConfig(int sid, NutMap config) {
|
||||
super();
|
||||
this.sid = sid;
|
||||
this.provider = config.getString("provider");
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public void setSid(int sid) {
|
||||
this.sid = sid;
|
||||
}
|
||||
|
||||
public String getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public void setProvider(String provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public NutMap getConfig() {
|
||||
if (config == null) {
|
||||
config = NutMap.NEW();
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(NutMap config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public PlatformConfig addPlatform(String id, NutMap config) {
|
||||
this.config.addv(id, config);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Comment;
|
||||
import org.nutz.dao.entity.annotation.Default;
|
||||
import org.nutz.dao.entity.annotation.Id;
|
||||
import org.nutz.dao.entity.annotation.Index;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.entity.annotation.TableIndexes;
|
||||
import org.nutz.lang.Times;
|
||||
|
||||
@Table("platform_user")
|
||||
@TableIndexes({ @Index(name = "passportid_pfid_pid_index", fields = { "passportid", "pfid", "pid" }, unique = true) })
|
||||
public class PlatformUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2735176124180310964L;
|
||||
|
||||
@Id
|
||||
private long id;
|
||||
|
||||
@Column
|
||||
private String passportid;
|
||||
|
||||
@Column(hump = true)
|
||||
@ColDefine(type = ColType.TIMESTAMP, insert = true)
|
||||
private Date createTime;
|
||||
|
||||
@Column("is_locked")
|
||||
private boolean locked;
|
||||
|
||||
@Column
|
||||
private long openid;
|
||||
|
||||
@Column("pfid")
|
||||
@Comment("渠道号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String pfid;
|
||||
|
||||
@Column("pid")
|
||||
@Comment("平台号")
|
||||
private int pid;
|
||||
|
||||
@Column
|
||||
@Comment("IP")
|
||||
@Default("127.0.0.1")
|
||||
private String addr;
|
||||
|
||||
public PlatformUser() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PlatformUser(int pid, String passportid, long openid, String pfid, String addr) {
|
||||
this.pid = pid;
|
||||
this.passportid = passportid;
|
||||
this.createTime = Times.now();
|
||||
this.openid = openid;
|
||||
this.pfid = pfid;
|
||||
this.addr = addr;
|
||||
}
|
||||
|
||||
public PlatformUser(int pid, String passportid, long openid, String pfid) {
|
||||
this.pid = pid;
|
||||
this.passportid = passportid;
|
||||
this.createTime = Times.now();
|
||||
this.openid = openid;
|
||||
this.pfid = pfid;
|
||||
}
|
||||
|
||||
public long getOpenid() {
|
||||
return openid;
|
||||
}
|
||||
|
||||
public String getAddr() {
|
||||
return addr;
|
||||
}
|
||||
|
||||
public void setAddr(String addr) {
|
||||
this.addr = addr;
|
||||
}
|
||||
|
||||
public void setOpenid(long openid) {
|
||||
this.openid = openid;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPassportid() {
|
||||
return passportid;
|
||||
}
|
||||
|
||||
public void setPassportid(String passportid) {
|
||||
this.passportid = passportid;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public void setLocked(boolean locked) {
|
||||
this.locked = locked;
|
||||
}
|
||||
|
||||
public String getPfid() {
|
||||
return pfid;
|
||||
}
|
||||
|
||||
public void setPfid(String pfid) {
|
||||
this.pfid = pfid;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.EL;
|
||||
import org.nutz.dao.entity.annotation.Index;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.Prev;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.entity.annotation.TableIndexes;
|
||||
|
||||
@Table("sg_report_ads")
|
||||
@TableIndexes({ @Index(name = "report_ads_index", fields = { "pid", "pfid" }, unique = false) })
|
||||
public class ReportAds implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8361228159606140014L;
|
||||
|
||||
@Name
|
||||
@Prev(els = { @EL("uuid()") })
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
private int pid;
|
||||
|
||||
@Column
|
||||
private String pfid;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String idfa;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String idfv;
|
||||
|
||||
@Column(hump = true)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String talkingDataId;
|
||||
|
||||
public ReportAds() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ReportAds(int pid, String pfid, String idfa, String idfv, String talkingDataId) {
|
||||
super();
|
||||
this.pid = pid;
|
||||
this.pfid = pfid;
|
||||
this.idfa = idfa;
|
||||
this.idfv = idfv;
|
||||
this.talkingDataId = talkingDataId;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getPfid() {
|
||||
return pfid;
|
||||
}
|
||||
|
||||
public void setPfid(String pfid) {
|
||||
this.pfid = pfid;
|
||||
}
|
||||
|
||||
public String getIdfa() {
|
||||
return idfa;
|
||||
}
|
||||
|
||||
public void setIdfa(String idfa) {
|
||||
this.idfa = idfa;
|
||||
}
|
||||
|
||||
public String getIdfv() {
|
||||
return idfv;
|
||||
}
|
||||
|
||||
public void setIdfv(String idfv) {
|
||||
this.idfv = idfv;
|
||||
}
|
||||
|
||||
public String getTalkingDataId() {
|
||||
return talkingDataId;
|
||||
}
|
||||
|
||||
public void setTalkingDataId(String talkingDataId) {
|
||||
this.talkingDataId = talkingDataId;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Id;
|
||||
import org.nutz.dao.entity.annotation.Index;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.entity.annotation.TableIndexes;
|
||||
import org.nutz.lang.Times;
|
||||
|
||||
@Table("server_history")
|
||||
@TableIndexes({ @Index(name = "passportid_pid_index", fields = { "openid", "pid", "sid" }, unique = false) })
|
||||
public class ServerHistory implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4746739180924296807L;
|
||||
|
||||
@Id
|
||||
private long id;
|
||||
|
||||
@Column
|
||||
private int pid;
|
||||
|
||||
@Column(hump = true)
|
||||
@ColDefine(type = ColType.TIMESTAMP)
|
||||
private Date createTime;
|
||||
|
||||
@Column(hump = true)
|
||||
@ColDefine(type = ColType.TIMESTAMP)
|
||||
private Date modifyTime;
|
||||
|
||||
@Column
|
||||
private long openid;
|
||||
|
||||
@Column
|
||||
private int sid;
|
||||
|
||||
public ServerHistory(long openid, int pid, int sid) {
|
||||
super();
|
||||
this.pid = pid;
|
||||
this.openid = openid;
|
||||
this.createTime = Times.now();
|
||||
this.modifyTime = this.createTime;
|
||||
this.sid = sid;
|
||||
}
|
||||
|
||||
public ServerHistory() {
|
||||
super();
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public long getOpenid() {
|
||||
return openid;
|
||||
}
|
||||
|
||||
public void setOpenid(long openid) {
|
||||
this.openid = openid;
|
||||
}
|
||||
|
||||
public Date getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
public int getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public void setSid(int sid) {
|
||||
this.sid = sid;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,6 @@ package com.rekoe.domain;
|
|||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
|
@ -15,10 +14,7 @@ import org.nutz.dao.entity.annotation.Table;
|
|||
import org.nutz.dao.entity.annotation.TableIndexes;
|
||||
|
||||
/**
|
||||
* @author 科技㊣²º¹³
|
||||
* 2014年2月3日 下午4:48:45
|
||||
* http://www.rekoe.com
|
||||
* QQ:5382211
|
||||
* @author 科技㊣²º¹³ 2014年2月3日 下午4:48:45 http://www.rekoe.com QQ:5382211
|
||||
*/
|
||||
@Table("system_user")
|
||||
@TableIndexes({ @Index(name = "user_name", fields = { "name" }, unique = true), @Index(name = "user_openid", fields = { "openid" }, unique = true) })
|
||||
|
@ -62,9 +58,6 @@ public class User implements Serializable {
|
|||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean system;
|
||||
|
||||
@ManyMany(target = GameServer.class, relation = "system_user_server", from = "USERID", to = "SERVERID", key = "id")
|
||||
private Map<Integer, GameServer> servers;
|
||||
|
||||
public String getProviderid() {
|
||||
return providerid;
|
||||
}
|
||||
|
@ -161,12 +154,4 @@ public class User implements Serializable {
|
|||
this.system = system;
|
||||
}
|
||||
|
||||
public Map<Integer, GameServer> getServers() {
|
||||
return servers;
|
||||
}
|
||||
|
||||
public void setServers(Map<Integer, GameServer> servers) {
|
||||
this.servers = servers;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,111 +0,0 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Comment;
|
||||
import org.nutz.dao.entity.annotation.EL;
|
||||
import org.nutz.dao.entity.annotation.Index;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.One;
|
||||
import org.nutz.dao.entity.annotation.Prev;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.entity.annotation.TableIndexes;
|
||||
|
||||
/**
|
||||
* 提审服
|
||||
*
|
||||
* @author kouxian
|
||||
*
|
||||
*/
|
||||
@Table("verify_server")
|
||||
@TableIndexes({ @Index(name = "g_sid_index", fields = { "pid" }, unique = true) })
|
||||
public class VerifyServer implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2235259090910419768L;
|
||||
|
||||
@Name
|
||||
@Prev(els = { @EL("uuid()") })
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(width = 225)
|
||||
private String url;
|
||||
|
||||
@Column
|
||||
private String name;
|
||||
|
||||
@Column(hump = true)
|
||||
@Comment("登陆服地址")
|
||||
@ColDefine(width = 225)
|
||||
private String loginUrl;
|
||||
|
||||
@Column(hump = true)
|
||||
@Comment("充值地址")
|
||||
@ColDefine(width = 225)
|
||||
private String payUrl;
|
||||
|
||||
@Column("pid")
|
||||
private int pid;
|
||||
|
||||
@One(target = GameServer.class, field = "pid")
|
||||
private GameServer gameServer;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLoginUrl() {
|
||||
return loginUrl;
|
||||
}
|
||||
|
||||
public void setLoginUrl(String loginUrl) {
|
||||
this.loginUrl = loginUrl;
|
||||
}
|
||||
|
||||
public String getPayUrl() {
|
||||
return payUrl;
|
||||
}
|
||||
|
||||
public void setPayUrl(String payUrl) {
|
||||
this.payUrl = payUrl;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public GameServer getGameServer() {
|
||||
return gameServer;
|
||||
}
|
||||
|
||||
public void setGameServer(GameServer gameServer) {
|
||||
this.gameServer = gameServer;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package com.rekoe.filter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.integration.shiro.NutShiro;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.mvc.ActionContext;
|
||||
import org.nutz.mvc.ActionFilter;
|
||||
import org.nutz.mvc.View;
|
||||
import org.nutz.mvc.view.UTF8JsonView;
|
||||
import org.nutz.mvc.view.ViewWrapper;
|
||||
import org.nutz.plugins.view.freemarker.FreeMarkerConfigurer;
|
||||
import org.nutz.plugins.view.freemarker.FreemarkerView;
|
||||
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.domain.GameServer;
|
||||
import com.rekoe.service.GameServerService;
|
||||
|
||||
@IocBean
|
||||
public class ChectServerExitsActionFilter implements ActionFilter {
|
||||
|
||||
@Inject
|
||||
private FreeMarkerConfigurer freeMarkerConfigurer;
|
||||
|
||||
@Inject
|
||||
private GameServerService gameServerService;
|
||||
|
||||
public View match(final ActionContext ctx) {
|
||||
HttpServletRequest req = ctx.getRequest();
|
||||
String pid = req.getParameter("pid");
|
||||
if (StringUtils.isNotBlank(pid)) {
|
||||
GameServer gameServer = gameServerService.fetch(Cnd.where("pid", "=", pid));
|
||||
if (Lang.isEmpty(gameServer)) {
|
||||
if (NutShiro.isAjax(ctx.getRequest())) {
|
||||
ctx.getResponse().setHeader("loginStatus", getResStatus());
|
||||
return new ViewWrapper(UTF8JsonView.COMPACT, getResStatus());
|
||||
}
|
||||
return getErrView(ctx.getRequest());
|
||||
} else {
|
||||
req.getSession().setAttribute("sid", gameServer.getId());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getResStatus() {
|
||||
return "server_not_exits";
|
||||
}
|
||||
|
||||
public View getErrView(HttpServletRequest req) {
|
||||
return new ViewWrapper(new FreemarkerView(freeMarkerConfigurer, "template/admin/common/error"), Message.error("server_not_exits", req));
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
package com.rekoe.filter;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.nutz.integration.shiro.NutShiro;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.mvc.ActionContext;
|
||||
import org.nutz.mvc.ActionFilter;
|
||||
import org.nutz.mvc.View;
|
||||
import org.nutz.mvc.view.UTF8JsonView;
|
||||
import org.nutz.mvc.view.ViewWrapper;
|
||||
import org.nutz.plugins.view.freemarker.FreeMarkerConfigurer;
|
||||
import org.nutz.plugins.view.freemarker.FreemarkerView;
|
||||
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.domain.GameServer;
|
||||
import com.rekoe.domain.User;
|
||||
|
||||
@IocBean
|
||||
public class ServerPermisionActionFilter implements ActionFilter {
|
||||
|
||||
@Inject
|
||||
private FreeMarkerConfigurer freeMarkerConfigurer;
|
||||
|
||||
public View match(final ActionContext ctx) {
|
||||
HttpServletRequest req = ctx.getRequest();
|
||||
Object sid = req.getParameter("platformid");
|
||||
if (Lang.isEmpty(sid)) {
|
||||
return getErrView(req, ctx.getResponse());
|
||||
}
|
||||
boolean isRight = false;
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
if (subject.getPrincipal() instanceof User) {
|
||||
User user = (User) subject.getPrincipal();
|
||||
Map<Integer, GameServer> servers = user.getServers();
|
||||
if (user.isSystem()) {
|
||||
isRight = true;
|
||||
} else if (!Lang.isEmpty(servers)) {
|
||||
int pid = NumberUtils.toInt(sid.toString());
|
||||
Collection<GameServer> games = servers.values();
|
||||
for (GameServer game : games) {
|
||||
if (game.getPid() == pid) {
|
||||
isRight = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isRight) {
|
||||
return null;
|
||||
}
|
||||
return getErrView(req, ctx.getResponse());
|
||||
}
|
||||
|
||||
public String getResStatus() {
|
||||
return "unauthorized";
|
||||
}
|
||||
|
||||
public View getErrView(HttpServletRequest req, HttpServletResponse resp) {
|
||||
if (NutShiro.isAjax(req)) {
|
||||
resp.setHeader("loginStatus", getResStatus());
|
||||
return new ViewWrapper(UTF8JsonView.COMPACT, getResStatus());
|
||||
}
|
||||
return new ViewWrapper(new FreemarkerView(freeMarkerConfigurer, "template/admin/common/error"), Message.error(getResStatus(), req));
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package com.rekoe.mobile;
|
||||
|
||||
public abstract class AbstractParam {
|
||||
|
||||
public abstract String getProviderId();
|
||||
|
||||
public abstract int getPid();
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package com.rekoe.mobile;
|
||||
|
||||
public abstract class AuthProvider<T extends AbstractParam> {
|
||||
|
||||
public abstract String getProviderId();
|
||||
|
||||
public abstract Profile verifyResponse(T param) throws Exception;
|
||||
|
||||
public abstract Class<T> getEntityClass();
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package com.rekoe.mobile;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
public class Profile implements Serializable {
|
||||
|
||||
public static final String TOKEN = "token";
|
||||
private static final long serialVersionUID = -3916223452935420808L;
|
||||
|
||||
private String providerId;
|
||||
private String passportid;
|
||||
private int pid;
|
||||
private NutMap pros = NutMap.NEW();
|
||||
|
||||
public Profile(String providerId, String passportid, int pid) {
|
||||
super();
|
||||
this.providerId = providerId;
|
||||
this.passportid = passportid;
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public Profile(String providerId, long passportid, int pid) {
|
||||
super();
|
||||
this.providerId = providerId;
|
||||
this.passportid = String.valueOf(passportid);
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return pros.getString(TOKEN);
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public String getProviderId() {
|
||||
return providerId;
|
||||
}
|
||||
|
||||
public void setProviderId(String providerId) {
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public String getPassportid() {
|
||||
return passportid;
|
||||
}
|
||||
|
||||
public void setPassportid(String passportid) {
|
||||
this.passportid = passportid;
|
||||
}
|
||||
|
||||
public Profile addv(String key, Object obj) {
|
||||
pros.addv(key, obj);
|
||||
return this;
|
||||
}
|
||||
|
||||
public NutMap getPros() {
|
||||
return pros;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (c) 2010 BrickRed Technologies Limited
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sub-license, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
===========================================================================
|
||||
|
||||
*/
|
||||
package com.rekoe.mobile.exception;
|
||||
|
||||
public class SignatureException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -3832456866408848000L;
|
||||
|
||||
public SignatureException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public SignatureException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
*/
|
||||
public SignatureException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @param cause
|
||||
*/
|
||||
public SignatureException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (c) 2010 BrickRed Technologies Limited
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sub-license, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
===========================================================================
|
||||
|
||||
*/
|
||||
package com.rekoe.mobile.exception;
|
||||
|
||||
public class SocialAuthConfigurationException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 477153534655510364L;
|
||||
|
||||
public SocialAuthConfigurationException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public SocialAuthConfigurationException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
*/
|
||||
public SocialAuthConfigurationException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @param cause
|
||||
*/
|
||||
public SocialAuthConfigurationException(final String message,
|
||||
final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (c) 2010 BrickRed Technologies Limited
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sub-license, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
===========================================================================
|
||||
|
||||
*/
|
||||
package com.rekoe.mobile.exception;
|
||||
|
||||
public class SocialAuthException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -1873507695230807487L;
|
||||
|
||||
public SocialAuthException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public SocialAuthException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
*/
|
||||
public SocialAuthException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @param cause
|
||||
*/
|
||||
public SocialAuthException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (c) 2010 BrickRed Technologies Limited
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sub-license, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
===========================================================================
|
||||
|
||||
*/
|
||||
package com.rekoe.mobile.exception;
|
||||
|
||||
public class SocialAuthManagerStateException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -4089035676676970803L;
|
||||
private static final String errorMessage = "This is not the same SocailAuthManager object that was used for login.";
|
||||
private static final String resolution = "Please check if you have called getAuthenticationUrl() method before calling connect()";
|
||||
|
||||
public SocialAuthManagerStateException() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return errorMessage + resolution;
|
||||
}
|
||||
}
|
|
@ -1,199 +0,0 @@
|
|||
package com.rekoe.mobile.provider;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.nutz.http.Http;
|
||||
import org.nutz.http.Request;
|
||||
import org.nutz.http.Request.METHOD;
|
||||
import org.nutz.http.Response;
|
||||
import org.nutz.http.Sender;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Mirror;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
|
||||
import com.rekoe.domain.PlatformConfig;
|
||||
import com.rekoe.mobile.AbstractParam;
|
||||
import com.rekoe.mobile.AuthProvider;
|
||||
import com.rekoe.service.PlatformConfigService;
|
||||
|
||||
public abstract class AbstractProvider<T extends AbstractParam> extends AuthProvider<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3293830764207197084L;
|
||||
|
||||
private Mirror<T> mirror;
|
||||
|
||||
private static final Log log = Logs.get();
|
||||
|
||||
@Inject
|
||||
private PlatformConfigService platformConfigService;
|
||||
|
||||
/**
|
||||
* 本抽象类能提供一些帮助方法,减少重复写实体类型的麻烦
|
||||
*/
|
||||
public AbstractProvider() {
|
||||
try {
|
||||
Class<T> entryClass = Mirror.getTypeParam(getClass(), 0);
|
||||
mirror = Mirror.me(entryClass);
|
||||
if (log.isDebugEnabled())
|
||||
log.debugf("Get TypeParams for self : %s", entryClass.getName());
|
||||
} catch (Throwable e) {
|
||||
if (log.isWarnEnabled())
|
||||
log.warn("!!!Fail to get TypeParams for self!", e);
|
||||
}
|
||||
}
|
||||
|
||||
public PlatformConfig getPlatformConfig(int pid) {
|
||||
PlatformConfig pc = platformConfigService.getPlatformConfig(pid, getProviderId());
|
||||
if (Lang.isEmpty(pc)) {
|
||||
throw Lang.makeThrow(NullPointerException.class, "Can`t find %s PlatformConfig", getProviderId());
|
||||
}
|
||||
return pc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实体类型
|
||||
*
|
||||
* @return 实体类型
|
||||
*/
|
||||
public Class<T> getEntityClass() {
|
||||
return mirror.getType();
|
||||
}
|
||||
|
||||
public String HttpGet(String url) {
|
||||
return HttpGet(url, def_num);
|
||||
}
|
||||
|
||||
private String HttpGet(String url, int num) {
|
||||
try {
|
||||
return Http.get(url).getContent();
|
||||
} catch (Exception e) {
|
||||
log.errorf("net Connect Err,url=%s", url);
|
||||
if (num > 0 && num < max) {
|
||||
num--;
|
||||
HttpGet(url, num);
|
||||
}
|
||||
}
|
||||
return "{}";
|
||||
}
|
||||
|
||||
public String httpPost(String url, Map<String, Object> params) {
|
||||
return httpPost(url, params, def_num);
|
||||
}
|
||||
|
||||
private String httpPost(String url, Map<String, Object> params, int num) {
|
||||
try {
|
||||
Response res = Http.post2(url, params, 6000);
|
||||
if (res.isOK()) {
|
||||
return res.getContent();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.errorf("net Connect Err,url=%s", url);
|
||||
if (num > 0 && num < max) {
|
||||
num--;
|
||||
httpPost(url, params, num);
|
||||
}
|
||||
}
|
||||
return "{}";
|
||||
}
|
||||
|
||||
public String HttpsGet(String url) {
|
||||
return HttpsGet(url, def_num);
|
||||
}
|
||||
|
||||
private String HttpsGet(String url, int num) {
|
||||
try {
|
||||
Http.disableJvmHttpsCheck();
|
||||
return Http.get(url).getContent();
|
||||
} catch (Exception e) {
|
||||
log.errorf("net Connect Err,url=%s", url);
|
||||
if (num > 0 && num < max) {
|
||||
num--;
|
||||
HttpsGet(url, num);
|
||||
}
|
||||
}
|
||||
return "{}";
|
||||
}
|
||||
|
||||
public String httpsPost(String url, Map<String, Object> params) {
|
||||
return httpsPost(url, params, def_num);
|
||||
}
|
||||
|
||||
private String httpsPost(String url, Map<String, Object> params, int num) {
|
||||
try {
|
||||
Http.disableJvmHttpsCheck();
|
||||
Response res = Http.post2(url, params, 6000);
|
||||
if (res.isOK()) {
|
||||
return res.getContent();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.errorf("net Connect Err,url=%s", url);
|
||||
if (num > 0 && num < max) {
|
||||
num--;
|
||||
httpsPost(url, params, num);
|
||||
}
|
||||
}
|
||||
return "{}";
|
||||
}
|
||||
|
||||
public String httpsPostBody(String url, String data) {
|
||||
return httpsPostBody(url, data, def_num);
|
||||
}
|
||||
|
||||
public String httpPostBody(String url, String data) {
|
||||
return httpPostBody(url, data, def_num);
|
||||
}
|
||||
|
||||
private String httpPostBody(String url, String data, int num) {
|
||||
Request req = Request.create(url, METHOD.POST);
|
||||
req.getHeader().set("Content-Type", "application/json:charset=utf-8 ");
|
||||
req.setData(data);
|
||||
try {
|
||||
Response resp = Sender.create(req).send();
|
||||
return resp.getContent();
|
||||
} catch (Exception e) {
|
||||
log.errorf("net Connect Err,url=%s", url);
|
||||
if (num > 0 && num < max) {
|
||||
num--;
|
||||
httpPostBody(url, data, num);
|
||||
}
|
||||
}
|
||||
return "{}";
|
||||
}
|
||||
|
||||
private String httpsPostBody(String url, String data, int num) {
|
||||
Http.disableJvmHttpsCheck();
|
||||
Request req = Request.create(url, METHOD.POST);
|
||||
req.getHeader().set("Content-Type", "application/json:charset=utf-8 ");
|
||||
req.setData(data);
|
||||
try {
|
||||
Response resp = Sender.create(req).send();
|
||||
return resp.getContent();
|
||||
} catch (Exception e) {
|
||||
log.errorf("net Connect Err,url=%s", url);
|
||||
if (num > 0 && num < max) {
|
||||
num--;
|
||||
httpsPostBody(url, data, num);
|
||||
}
|
||||
}
|
||||
return "{}";
|
||||
}
|
||||
|
||||
public <B> Map<String, B> result2Json(String jsonStr, Class<B> eleType) throws Exception {
|
||||
if (Strings.isBlank(jsonStr)) {
|
||||
throw Lang.makeThrow("%s callBack is Blank", getProviderId());
|
||||
}
|
||||
return Json.fromJsonAsMap(eleType, jsonStr);
|
||||
}
|
||||
|
||||
public <B> Map<String, B> result2Json(String jsonStr, Class<B> eleType, String def) throws Exception {
|
||||
return Json.fromJsonAsMap(eleType, Strings.isBlank(jsonStr) ? def : jsonStr);
|
||||
}
|
||||
|
||||
private final int max = 5;
|
||||
private final int def_num = 1;
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package com.rekoe.mobile.provider;
|
||||
|
||||
public class PlatformProvider {
|
||||
|
||||
private final String providerId;
|
||||
private final String name;
|
||||
private final String pfid;
|
||||
|
||||
public PlatformProvider(final String providerId, final String name, final String pfid) {
|
||||
this.providerId = providerId;
|
||||
this.name = name;
|
||||
this.pfid = pfid;
|
||||
}
|
||||
|
||||
public String getProviderId() {
|
||||
return providerId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getPfid() {
|
||||
return pfid;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package com.rekoe.mobile.provider;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.nutz.lang.Lang;
|
||||
|
||||
public class PlatformProviderFactory {
|
||||
|
||||
private Map<String, PlatformProvider> platforms = new HashMap<String, PlatformProvider>();
|
||||
|
||||
public void setPlatformProviders(List<List<String>> platformProviders) {
|
||||
int len = platformProviders.size();
|
||||
for (int i = 0; i < len; i++) {
|
||||
List<String> args = platformProviders.get(i);
|
||||
int j = args.size();
|
||||
if (j != 3) {
|
||||
continue;
|
||||
}
|
||||
platforms.put(args.get(1), new PlatformProvider(args.get(0), args.get(2), args.get(1)));
|
||||
}
|
||||
}
|
||||
|
||||
public PlatformProvider getPlatformProvider(String pfid) {
|
||||
PlatformProvider pf = platforms.get(pfid);
|
||||
if (Lang.isEmpty(pf)) {
|
||||
Lang.makeThrow("Can`t define type[%s]", pfid);
|
||||
}
|
||||
return pf;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.rekoe.mobile.provider.a91;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.rekoe.mobile.AbstractParam;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
public class A91Param extends AbstractParam implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -4493840542767841651L;
|
||||
private String sessionid;
|
||||
private int pid;
|
||||
|
||||
public void setSessionid(int pid, String sessionid) {
|
||||
this.sessionid = sessionid;
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getSessionid() {
|
||||
return sessionid;
|
||||
}
|
||||
|
||||
public void setSessionid(String sessionid) {
|
||||
this.sessionid = sessionid;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId(){
|
||||
return Constants.A91;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package com.rekoe.mobile.provider.a91;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.repo.Base64;
|
||||
|
||||
import com.rekoe.annotation.PlatformProvider;
|
||||
import com.rekoe.domain.PlatformConfig;
|
||||
import com.rekoe.mobile.Profile;
|
||||
import com.rekoe.mobile.provider.AbstractProvider;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@PlatformProvider(name = Constants.A91)
|
||||
public class A91Provider extends AbstractProvider<A91Param> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Log log = Logs.get();
|
||||
private final String VALID_TOKEN_ADDR = "http://querysdkapi.91.com/CpLoginStateQuery.ashx";// 接口地址
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.A91;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile verifyResponse(A91Param param) throws Exception {
|
||||
PlatformConfig platformConfig = getPlatformConfig(param.getPid());
|
||||
String str = platformConfig.getConfig().getString("appid") + param.getSessionid() + platformConfig.getConfig().getString("secret");// 签名
|
||||
String sign = Lang.md5(str);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("AppID", platformConfig.getConfig().getString("appid"));
|
||||
params.put("AccessToken", param.getSessionid());
|
||||
params.put("Sign", sign.toLowerCase());
|
||||
String result = httpPost(VALID_TOKEN_ADDR, params);
|
||||
A91ReturnParam ret = Json.fromJson(A91ReturnParam.class, result);
|
||||
if (ret.getResultCode() == 1) {
|
||||
String con = URLDecoder.decode(ret.getContent(), "utf-8");
|
||||
String temp = platformConfig.getConfig().getString("appid") + ret.getResultCode() + con + platformConfig.getConfig().getString("secret");
|
||||
String sign1 = Lang.md5(temp);
|
||||
if (sign1.equalsIgnoreCase(ret.getSign())) {
|
||||
A91UserInfo info = Json.fromJson(A91UserInfo.class, new String(Base64.decode(con)));
|
||||
return new Profile(getProviderId(), info.getUID(), param.getPid());
|
||||
}
|
||||
} else {
|
||||
log.error(result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package com.rekoe.mobile.provider.a91;
|
||||
|
||||
import org.nutz.json.JsonField;
|
||||
|
||||
public class A91ReturnParam {
|
||||
|
||||
@JsonField("AppID")
|
||||
private int appID;
|
||||
@JsonField("ResultCode")
|
||||
private int resultCode;
|
||||
@JsonField("ResultMsg")
|
||||
private String resultMsg;
|
||||
@JsonField("Sign")
|
||||
private String sign;
|
||||
@JsonField("Content")
|
||||
private String content;
|
||||
|
||||
|
||||
|
||||
public int getAppID() {
|
||||
return appID;
|
||||
}
|
||||
public void setAppID(int appID) {
|
||||
this.appID = appID;
|
||||
}
|
||||
public int getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
public void setResultCode(int resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
public String getResultMsg() {
|
||||
return resultMsg;
|
||||
}
|
||||
public void setResultMsg(String resultMsg) {
|
||||
this.resultMsg = resultMsg;
|
||||
}
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package com.rekoe.mobile.provider.a91;
|
||||
|
||||
public class A91UserInfo {
|
||||
private String UID;
|
||||
|
||||
public String getUID() {
|
||||
return UID;
|
||||
}
|
||||
|
||||
public void setUID(String uID) {
|
||||
UID = uID;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package com.rekoe.mobile.provider.google;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.rekoe.mobile.provider.googlep.GooglePParam;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
public class GoogleParam extends GooglePParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1122775243733543089L;
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.GOOGLE;
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package com.rekoe.mobile.provider.google;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import com.rekoe.annotation.PlatformProvider;
|
||||
import com.rekoe.mobile.provider.googlep.GooglePProvider;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@PlatformProvider(name = Constants.GOOGLE)
|
||||
public class GoogleProvider extends GooglePProvider {
|
||||
|
||||
private static final long serialVersionUID = 7944880275608182543L;
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.GOOGLE;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package com.rekoe.mobile.provider.googlep;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.rekoe.mobile.AbstractParam;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
public class GooglePParam extends AbstractParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1122775243733543089L;
|
||||
|
||||
private String token;
|
||||
|
||||
private int pid;
|
||||
|
||||
public GooglePParam() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.GOOGLE_PLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
package com.rekoe.mobile.provider.googlep;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.http.Request;
|
||||
import org.nutz.http.Request.METHOD;
|
||||
import org.nutz.http.Sender;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.json.JsonFormat;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
|
||||
import com.google.api.client.http.HttpTransport;
|
||||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
import com.google.api.services.oauth2.Oauth2;
|
||||
import com.google.api.services.oauth2.model.Tokeninfo;
|
||||
import com.rekoe.annotation.PlatformProvider;
|
||||
import com.rekoe.domain.PlatformConfig;
|
||||
import com.rekoe.mobile.Profile;
|
||||
import com.rekoe.mobile.provider.AbstractProvider;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@PlatformProvider(name = Constants.GOOGLE_PLAY)
|
||||
public class GooglePProvider extends AbstractProvider<GooglePParam> {
|
||||
|
||||
private static final long serialVersionUID = 7944880275608182543L;
|
||||
private final static Log log = Logs.get();
|
||||
|
||||
private final HttpTransport TRANSPORT = new NetHttpTransport();
|
||||
private final JacksonFactory JSON_FACTORY = new JacksonFactory();
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.GOOGLE_PLAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://developers.google.com/identity/sign-in/android/offline-access
|
||||
*/
|
||||
@Override
|
||||
public Profile verifyResponse(GooglePParam param) throws Exception {
|
||||
TokenStatus info = validToken(param);
|
||||
if (info.isValid()) {
|
||||
Profile profile = new Profile(getProviderId(), info.getGplus_id(), param.getPid());
|
||||
profile.addv(Profile.TOKEN, param.getToken());
|
||||
return profile;
|
||||
}
|
||||
log.errorf("Err message %s", info.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
private TokenStatus validToken(GooglePParam param) throws IOException {
|
||||
PlatformConfig platformConfig = getPlatformConfig(param.getPid());
|
||||
String client_id = platformConfig.getConfig().getString("client_id");
|
||||
String applicationName = platformConfig.getConfig().getString("application_name", "zsdpay-1203");
|
||||
String accessToken = param.getToken();
|
||||
TokenStatus accessStatus = new TokenStatus();
|
||||
if (StringUtils.isNotBlank(accessToken)) {
|
||||
try {
|
||||
GoogleCredential credential = new GoogleCredential().setAccessToken(accessToken);
|
||||
Oauth2 oauth2 = new Oauth2.Builder(TRANSPORT, JSON_FACTORY, credential).setApplicationName(applicationName).build();
|
||||
Tokeninfo tokenInfo = oauth2.tokeninfo().setAccessToken(accessToken).execute();
|
||||
if (tokenInfo.containsKey("error")) {
|
||||
accessStatus.setValid(false);
|
||||
accessStatus.setId("");
|
||||
accessStatus.setMessage("Invalid Access Token.");
|
||||
} else if (!Lang.equals(client_id, tokenInfo.getIssuedTo())) {
|
||||
accessStatus.setValid(false);
|
||||
accessStatus.setId("");
|
||||
accessStatus.setMessage("Access Token not meant for this app.");
|
||||
} else {
|
||||
accessStatus.setValid(true);
|
||||
accessStatus.setId(tokenInfo.getUserId());
|
||||
accessStatus.setMessage("Access Token is valid.");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
accessStatus.setValid(false);
|
||||
accessStatus.setId("");
|
||||
accessStatus.setMessage("Invalid Access Token.");
|
||||
}
|
||||
} else {
|
||||
accessStatus.setMessage("Access Token not provided");
|
||||
}
|
||||
return accessStatus;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
HttpTransport TRANSPORT = new NetHttpTransport();
|
||||
JacksonFactory JSON_FACTORY = new JacksonFactory();
|
||||
String applicationName = "zsdpay-1203";
|
||||
String token = "ya29.fgLVUDBWXuM91LAtvMdBXXWhCmKctjb44SK7Th8BO1yQ3DLfe3n_85Xi7PeLtQFsGEGOpQ";
|
||||
String client_id = "232182541248-8guj6heku6vpgdb7a3shmco33ns69lpm.apps.googleusercontent.com";
|
||||
String accessToken = token;
|
||||
TokenStatus accessStatus = new TokenStatus();
|
||||
if (StringUtils.isNotBlank(accessToken)) {
|
||||
try {
|
||||
GoogleCredential credential = new GoogleCredential().setAccessToken(accessToken);
|
||||
Oauth2 oauth2 = new Oauth2.Builder(TRANSPORT, JSON_FACTORY, credential).setApplicationName(applicationName).build();
|
||||
Tokeninfo tokenInfo = oauth2.tokeninfo().setAccessToken(accessToken).execute();
|
||||
if (tokenInfo.containsKey("error")) {
|
||||
accessStatus.setValid(false);
|
||||
accessStatus.setId("");
|
||||
accessStatus.setMessage("Invalid Access Token.");
|
||||
} else if (!Lang.equals(client_id, tokenInfo.getIssuedTo())) {
|
||||
accessStatus.setValid(false);
|
||||
accessStatus.setId("");
|
||||
accessStatus.setMessage("Access Token not meant for this app.");
|
||||
} else {
|
||||
accessStatus.setValid(true);
|
||||
accessStatus.setId(tokenInfo.getUserId());
|
||||
accessStatus.setMessage("Access Token is valid.");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
accessStatus.setValid(false);
|
||||
accessStatus.setId("");
|
||||
accessStatus.setMessage("Invalid Access Token.");
|
||||
}
|
||||
} else {
|
||||
accessStatus.setMessage("Access Token not provided");
|
||||
}
|
||||
System.out.println(Json.toJson(accessStatus));
|
||||
}
|
||||
|
||||
public static void main1(String[] args) {
|
||||
Request req = Request.create("http://127.0.0.1:8080/api/list?pfid=1006200110011004", METHOD.POST);
|
||||
req.getHeader().set("Content-Type", "application/octet-stream;charset=UTF-8");
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pid", 1001);
|
||||
params.put("token", "ya29.dgJTpUrOQ9g1RHfXKXimjWHNSTKW5OPpb9--W51L_J5_u8anU_je2gAFFa4br_0NsRJY5g");
|
||||
req.setData(Json.toJson(params, JsonFormat.compact()));
|
||||
Sender.create(req).setTimeout(6000).send();
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package com.rekoe.mobile.provider.googlep;
|
||||
|
||||
public class TokenStatus {
|
||||
|
||||
private boolean valid;
|
||||
private String gplus_id;
|
||||
private String message;
|
||||
|
||||
public TokenStatus() {
|
||||
valid = false;
|
||||
gplus_id = "";
|
||||
message = "";
|
||||
}
|
||||
|
||||
public void setValid(boolean v) {
|
||||
this.valid = v;
|
||||
}
|
||||
|
||||
public void setId(String gplus_id) {
|
||||
this.gplus_id = gplus_id;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getGplus_id() {
|
||||
return gplus_id;
|
||||
}
|
||||
|
||||
public void setGplus_id(String gplus_id) {
|
||||
this.gplus_id = gplus_id;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return valid;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package com.rekoe.mobile.provider.guest;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.rekoe.mobile.AbstractParam;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
public class GuestParam extends AbstractParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1240692439054026809L;
|
||||
private String openid;
|
||||
private int pid;
|
||||
|
||||
public GuestParam() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GuestParam(int pid, String passportid) {
|
||||
super();
|
||||
this.openid = passportid;
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getOpenid() {
|
||||
return openid;
|
||||
}
|
||||
|
||||
public void setOpenid(String openid) {
|
||||
this.openid = openid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.GUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPid() {
|
||||
return this.pid;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package com.rekoe.mobile.provider.guest;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import com.rekoe.annotation.PlatformProvider;
|
||||
import com.rekoe.mobile.Profile;
|
||||
import com.rekoe.mobile.provider.AbstractProvider;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@PlatformProvider(name = Constants.GUEST)
|
||||
public class GuestProvider extends AbstractProvider<GuestParam> {
|
||||
|
||||
private static final long serialVersionUID = 2882126009485835543L;
|
||||
|
||||
@Override
|
||||
public Profile verifyResponse(GuestParam param) throws Exception {
|
||||
return new Profile(getProviderId(), param.getOpenid(), param.getPid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.GUEST;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package com.rekoe.mobile.provider.hw;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.rekoe.mobile.AbstractParam;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
public class HwParam extends AbstractParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1122775243733543089L;
|
||||
private String accessToken;
|
||||
private int pid;
|
||||
|
||||
public HwParam() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.HW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package com.rekoe.mobile.provider.hw;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
|
||||
import com.rekoe.annotation.PlatformProvider;
|
||||
import com.rekoe.mobile.Profile;
|
||||
import com.rekoe.mobile.provider.AbstractProvider;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@PlatformProvider(name = Constants.HW)
|
||||
public class HwProvider extends AbstractProvider<HwParam> {
|
||||
|
||||
private static final long serialVersionUID = 7944880275608182543L;
|
||||
private final static Log log = Logs.get();
|
||||
// 验证accessToken地址
|
||||
private static final String VALID_TOKEN_ADDR = "https://api.vmall.com/rest.php";
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.HW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile verifyResponse(HwParam param) throws Exception {
|
||||
UserInfo info = validToken(param);
|
||||
if (!Lang.isEmpty(info) && !Strings.isBlank(info.getUserID())) {
|
||||
return new Profile(getProviderId(), info.getUserID(), param.getPid());
|
||||
} else {
|
||||
log.errorf("Can`t find user info on platform %s", getProviderId());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private UserInfo validToken(HwParam param) throws IOException {
|
||||
if (Lang.isEmpty(param)) {
|
||||
log.errorf("Can`t get %s Param", getProviderId());
|
||||
return null;
|
||||
}
|
||||
String accessToken = param.getAccessToken();
|
||||
if (!Strings.isBlank(accessToken)) {
|
||||
String postBody = "nsp_svc=OpenUP.User.getInfo&nsp_ts=";
|
||||
postBody += String.valueOf(System.currentTimeMillis() / 1000);
|
||||
postBody += "&access_token=" + java.net.URLEncoder.encode(accessToken, "utf-8");
|
||||
|
||||
String result = httpsPostBody(VALID_TOKEN_ADDR, postBody);
|
||||
return Json.fromJson(UserInfo.class, result);
|
||||
} else {
|
||||
log.errorf("%s access token is missing %s", getProviderId(), accessToken);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package com.rekoe.mobile.provider.hw;
|
||||
|
||||
public class UserInfo {
|
||||
private String userID;
|
||||
|
||||
private String userName;
|
||||
|
||||
private String languageCode;
|
||||
|
||||
private int userState;
|
||||
|
||||
private int userValidStatus;
|
||||
|
||||
/**
|
||||
* @return the userID
|
||||
*/
|
||||
public String getUserID(){
|
||||
return userID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userID the userID to set
|
||||
*/
|
||||
public void setUserID(String userID){
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the userName
|
||||
*/
|
||||
public String getUserName(){
|
||||
return userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userName the userName to set
|
||||
*/
|
||||
public void setUserName(String userName){
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the languageCode
|
||||
*/
|
||||
public String getLanguageCode(){
|
||||
return languageCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param languageCode the languageCode to set
|
||||
*/
|
||||
public void setLanguageCode(String languageCode){
|
||||
this.languageCode = languageCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the userState
|
||||
*/
|
||||
public int getUserState(){
|
||||
return userState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userState the userState to set
|
||||
*/
|
||||
public void setUserState(int userState){
|
||||
this.userState = userState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the userValidStatus
|
||||
*/
|
||||
public int getUserValidStatus(){
|
||||
return userValidStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userValidStatus the userValidStatus to set
|
||||
*/
|
||||
public void setUserValidStatus(int userValidStatus){
|
||||
this.userValidStatus = userValidStatus;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package com.rekoe.mobile.provider.msdk;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.rekoe.mobile.AbstractParam;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
public class MSDKParam extends AbstractParam implements Serializable {
|
||||
private static final long serialVersionUID = -8345954529141180606L;
|
||||
private String openid;
|
||||
private String ip;
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
private int pid;
|
||||
|
||||
public String getOpenid() {
|
||||
return openid;
|
||||
}
|
||||
|
||||
public void setOpenid(String openid) {
|
||||
this.openid = openid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.MSDK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package com.rekoe.mobile.provider.msdk;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.json.JsonFormat;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
|
||||
import com.rekoe.annotation.PlatformProvider;
|
||||
import com.rekoe.domain.PlatformConfig;
|
||||
import com.rekoe.mobile.Profile;
|
||||
import com.rekoe.mobile.provider.AbstractProvider;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kouxian
|
||||
*
|
||||
*/
|
||||
@IocBean
|
||||
@PlatformProvider(name = Constants.MSDK)
|
||||
public class MSDKProvider extends AbstractProvider<MSDKParam> {
|
||||
|
||||
private static final long serialVersionUID = 2882126009485835543L;
|
||||
|
||||
private final static Log log = Logs.get();
|
||||
|
||||
public final static String MSDK_PROFILE = "MSDK_PROFILE";
|
||||
public final static String MSDK_PARAM = "MSDK_PARAM";
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.MSDK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile verifyResponse(MSDKParam p) throws Exception {
|
||||
PlatformConfig platformConfig = getPlatformConfig(p.getPid());
|
||||
NutMap config = platformConfig.getConfig();
|
||||
String appkey = config.getString("appkey");
|
||||
long appid = config.getAs("appid", Long.class);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("appid", appid);
|
||||
params.put("openid", p.getOpenid());
|
||||
params.put("openkey", appkey);
|
||||
params.put("userip", p.getIp());
|
||||
String uri = makeUri(p.getOpenid(), appid, appkey);
|
||||
String url = config.getString("valid_token_url") + uri;
|
||||
String data = Json.toJson(params, JsonFormat.compact());
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debugf("url >> %s", url);
|
||||
}
|
||||
String res = httpPostBody(url, data);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debugf("back >> %s", res);
|
||||
}
|
||||
try {
|
||||
MSDKUserInfo userInfo = Json.fromJson(MSDKUserInfo.class, res);
|
||||
if (userInfo.getRet() == 0) {
|
||||
Profile profile = new Profile(getProviderId(), p.getOpenid(), p.getPid());
|
||||
profile.addv(MSDK_PROFILE, p);
|
||||
profile.addv(MSDK_PARAM, userInfo);
|
||||
profile.addv(Profile.TOKEN, p.getOpenid());
|
||||
return profile;
|
||||
} else {
|
||||
log.error(res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String makeUri(String openid, long appid, String appkey) {
|
||||
long timestamp = System.currentTimeMillis();
|
||||
String sig = Lang.md5(appkey + timestamp);
|
||||
return new StringBuilder().append("/?timestamp=").append(timestamp).append("&appid=").append(appid).append("&sig=").append(sig).append("&openid=").append(openid).append("&encode=1").toString();
|
||||
}
|
||||
}
|
|
@ -1,204 +0,0 @@
|
|||
package com.rekoe.mobile.provider.msdk;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.nutz.json.JsonField;
|
||||
|
||||
public class MSDKUserInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 580303315270742465L;
|
||||
|
||||
private int ret = -1;
|
||||
@JsonField(value = "is_lost")
|
||||
private int isLost = 1;
|
||||
private String nickname;
|
||||
private String gender;
|
||||
private String country;
|
||||
private String province;
|
||||
private String city;
|
||||
private String figureurl;
|
||||
@JsonField(value = "is_yellow_vip")
|
||||
private int isYellowVip;
|
||||
@JsonField(value = "is_yellow_year_vip")
|
||||
private int isYellowYearVip;
|
||||
@JsonField(value = "yellow_vip_level")
|
||||
private int yellowVipLevel;
|
||||
@JsonField(value = "is_yellow_high_vip")
|
||||
private int isYellowHighVip;
|
||||
@JsonField(value = "is_blue_vip")
|
||||
private boolean isBlueVip;
|
||||
@JsonField(value = "is_blue_year_vip")
|
||||
private boolean isBlueYearVip;
|
||||
@JsonField(value = "is_super_blue_vip")
|
||||
private boolean isSuperBlueVip;
|
||||
@JsonField(value = "blue_vip_level")
|
||||
private int blueVipLevel;
|
||||
@JsonField(value = "a3366_level")
|
||||
private int a3366Level;
|
||||
@JsonField(value = "a3366_level_name")
|
||||
private String a3366LevelName;
|
||||
@JsonField(value = "a3366_grow_level")
|
||||
private int a3366GrowLevel;
|
||||
@JsonField(value = "a3366_grow_value")
|
||||
private int a3366GrowValue;
|
||||
|
||||
public int getRet() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setRet(int ret) {
|
||||
this.ret = ret;
|
||||
}
|
||||
|
||||
public int getIsLost() {
|
||||
return isLost;
|
||||
}
|
||||
|
||||
public void setIsLost(int isLost) {
|
||||
this.isLost = isLost;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getFigureurl() {
|
||||
return figureurl;
|
||||
}
|
||||
|
||||
public void setFigureurl(String figureurl) {
|
||||
this.figureurl = figureurl;
|
||||
}
|
||||
|
||||
public int getIsYellowVip() {
|
||||
return isYellowVip;
|
||||
}
|
||||
|
||||
public void setIsYellowVip(int isYellowVip) {
|
||||
this.isYellowVip = isYellowVip;
|
||||
}
|
||||
|
||||
public int getIsYellowYearVip() {
|
||||
return isYellowYearVip;
|
||||
}
|
||||
|
||||
public void setIsYellowYearVip(int isYellowYearVip) {
|
||||
this.isYellowYearVip = isYellowYearVip;
|
||||
}
|
||||
|
||||
public int getYellowVipLevel() {
|
||||
return yellowVipLevel;
|
||||
}
|
||||
|
||||
public void setYellowVipLevel(int yellowVipLevel) {
|
||||
this.yellowVipLevel = yellowVipLevel;
|
||||
}
|
||||
|
||||
public int getIsYellowHighVip() {
|
||||
return isYellowHighVip;
|
||||
}
|
||||
|
||||
public void setIsYellowHighVip(int isYellowHighVip) {
|
||||
this.isYellowHighVip = isYellowHighVip;
|
||||
}
|
||||
|
||||
public boolean isBlueVip() {
|
||||
return isBlueVip;
|
||||
}
|
||||
|
||||
public void setBlueVip(boolean isBlueVip) {
|
||||
this.isBlueVip = isBlueVip;
|
||||
}
|
||||
|
||||
public boolean isBlueYearVip() {
|
||||
return isBlueYearVip;
|
||||
}
|
||||
|
||||
public void setBlueYearVip(boolean isBlueYearVip) {
|
||||
this.isBlueYearVip = isBlueYearVip;
|
||||
}
|
||||
|
||||
public boolean isSuperBlueVip() {
|
||||
return isSuperBlueVip;
|
||||
}
|
||||
|
||||
public void setSuperBlueVip(boolean isSuperBlueVip) {
|
||||
this.isSuperBlueVip = isSuperBlueVip;
|
||||
}
|
||||
|
||||
public int getBlueVipLevel() {
|
||||
return blueVipLevel;
|
||||
}
|
||||
|
||||
public void setBlueVipLevel(int blueVipLevel) {
|
||||
this.blueVipLevel = blueVipLevel;
|
||||
}
|
||||
|
||||
public int getA3366Level() {
|
||||
return a3366Level;
|
||||
}
|
||||
|
||||
public void setA3366Level(int a3366Level) {
|
||||
this.a3366Level = a3366Level;
|
||||
}
|
||||
|
||||
public String getA3366LevelName() {
|
||||
return a3366LevelName;
|
||||
}
|
||||
|
||||
public void setA3366LevelName(String a3366LevelName) {
|
||||
this.a3366LevelName = a3366LevelName;
|
||||
}
|
||||
|
||||
public int getA3366GrowLevel() {
|
||||
return a3366GrowLevel;
|
||||
}
|
||||
|
||||
public void setA3366GrowLevel(int a3366GrowLevel) {
|
||||
this.a3366GrowLevel = a3366GrowLevel;
|
||||
}
|
||||
|
||||
public int getA3366GrowValue() {
|
||||
return a3366GrowValue;
|
||||
}
|
||||
|
||||
public void setA3366GrowValue(int a3366GrowValue) {
|
||||
this.a3366GrowValue = a3366GrowValue;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.rekoe.mobile.provider.qihu360;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.rekoe.mobile.AbstractParam;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
public class QiHu360Param extends AbstractParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4558333251854028360L;
|
||||
private String sessionid;
|
||||
private int pid;
|
||||
|
||||
public String getSessionid() {
|
||||
return sessionid;
|
||||
}
|
||||
|
||||
public void setSessionid(int pid, String sessionid) {
|
||||
this.sessionid = sessionid;
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public void setSessionid(String sessionid) {
|
||||
this.sessionid = sessionid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.QIHU360;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package com.rekoe.mobile.provider.qihu360;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
|
||||
import com.rekoe.annotation.PlatformProvider;
|
||||
import com.rekoe.mobile.Profile;
|
||||
import com.rekoe.mobile.provider.AbstractProvider;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@PlatformProvider(name = Constants.QIHU360)
|
||||
public class QiHu360Provider extends AbstractProvider<QiHu360Param> {
|
||||
|
||||
private static final long serialVersionUID = 2882126009485835543L;
|
||||
|
||||
private static final Map<String, String> ENDPOINTS;
|
||||
|
||||
static {
|
||||
ENDPOINTS = new HashMap<String, String>();
|
||||
ENDPOINTS.put(Constants.OAUTH_AUTHORIZATION_URL, "https://openapi.360.cn/user/me.json?access_token=");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.QIHU360;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile verifyResponse(QiHu360Param param) throws Exception {
|
||||
String params = HttpsGet((ENDPOINTS.get(Constants.OAUTH_AUTHORIZATION_URL) + param.getSessionid()));
|
||||
if (!Strings.isBlank(params)) {
|
||||
Map<String, String> result = result2Json(params, String.class);
|
||||
String userId = result.get("id");
|
||||
if (!Strings.isBlank(params)) {
|
||||
return new Profile(getProviderId(), userId, param.getPid());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package com.rekoe.mobile.provider.qq;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.rekoe.mobile.AbstractParam;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
public class QQParam extends AbstractParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4898427425935858898L;
|
||||
private String openid;
|
||||
private String openkey;
|
||||
private String pf;
|
||||
private String platform;
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getPf() {
|
||||
return pf;
|
||||
}
|
||||
|
||||
public void setPf(String pf) {
|
||||
this.pf = pf;
|
||||
}
|
||||
|
||||
private int pid;
|
||||
|
||||
public String getOpenid() {
|
||||
return openid;
|
||||
}
|
||||
|
||||
public void setOpenid(String openid) {
|
||||
this.openid = openid;
|
||||
}
|
||||
|
||||
public String getOpenkey() {
|
||||
return openkey;
|
||||
}
|
||||
|
||||
public void setOpenkey(String openkey) {
|
||||
this.openkey = openkey;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.QQ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
package com.rekoe.mobile.provider.qq;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.json.JsonFormat;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.repo.Base64;
|
||||
|
||||
import com.rekoe.annotation.PlatformProvider;
|
||||
import com.rekoe.domain.PlatformConfig;
|
||||
import com.rekoe.mobile.Profile;
|
||||
import com.rekoe.mobile.provider.AbstractProvider;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@PlatformProvider(name = Constants.QQ)
|
||||
public class QQProvider extends AbstractProvider<QQParam> {
|
||||
|
||||
private static final long serialVersionUID = 2882126009485835543L;
|
||||
|
||||
private final static Log log = Logs.get();
|
||||
|
||||
public final static String QQPARAM_KEY = "param";
|
||||
public final static String USERINFO_KEY = "userinfo";
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.QQ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile verifyResponse(QQParam p) throws Exception {
|
||||
PlatformConfig platformConfig = getPlatformConfig(p.getPid());
|
||||
String appkey = platformConfig.getConfig().getString("appkey");
|
||||
String appid = platformConfig.getConfig().getString("appid");
|
||||
String validateUrl = platformConfig.getConfig().getString("validate_url");
|
||||
String uri = paramEncode("/v3/user/get_info");
|
||||
String param = "appid=" + appid + "&format=json&openid=" + p.getOpenid() + "&openkey=" + p.getOpenkey() + "&pf=" + p.getPf();
|
||||
String get = "GET&" + uri + "&" + paramEncode(param);
|
||||
String sig = getSignature(get, appkey);
|
||||
String url = validateUrl + "/v3/user/get_info?openid=" + paramEncode(p.getOpenid()) + "&openkey=" + paramEncode(p.getOpenkey()) + "&appid=" + appid + "&sig=" + paramEncode(sig) + "&pf=" + paramEncode(p.getPf()) + "&format=" + paramEncode("json");
|
||||
String qqRes = HttpGet(url);
|
||||
QQUserInfo userInf = Json.fromJson(QQUserInfo.class, qqRes);
|
||||
if (userInf.getRet() == 0) {// ,
|
||||
Profile profile = new Profile(getProviderId(), p.getOpenid(), p.getPid());
|
||||
profile.addv(USERINFO_KEY, userInf);
|
||||
profile.addv(QQPARAM_KEY, p);
|
||||
return profile;
|
||||
} else {
|
||||
log.errorf("ProviderId >> %s,Param >> %s", getProviderId(), Json.toJson(p, JsonFormat.compact()));
|
||||
log.error(qqRes);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String paramEncode(String param) throws UnsupportedEncodingException {
|
||||
return URLEncoder.encode(Strings.isBlank(param) ? "" : param, "UTF-8");
|
||||
}
|
||||
|
||||
private final String HMAC_SHA1 = "HmacSHA1";
|
||||
|
||||
public String getSignature(String data, String key) throws Exception {
|
||||
key += "&";
|
||||
data = encodeCompnentURL(data);
|
||||
byte[] keyBytes = key.getBytes();
|
||||
SecretKeySpec signingKey = new SecretKeySpec(keyBytes, HMAC_SHA1);
|
||||
Mac mac = Mac.getInstance(HMAC_SHA1);
|
||||
mac.init(signingKey);
|
||||
byte[] rawHmac = mac.doFinal(data.getBytes());
|
||||
return Base64.encodeToString(rawHmac, false);
|
||||
}
|
||||
|
||||
private String encodeCompnentURL(String url) throws UnsupportedEncodingException {
|
||||
String temp = url.replace("*", "%2A");
|
||||
return temp;
|
||||
}
|
||||
}
|
|
@ -1,208 +0,0 @@
|
|||
package com.rekoe.mobile.provider.qq;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class QQUserInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6009549946309845409L;
|
||||
private int ret = -1;
|
||||
private int is_lost = 1;
|
||||
private String nickname;
|
||||
private String gender;
|
||||
private String country;
|
||||
private String province;
|
||||
private String city;
|
||||
private String figureurl;
|
||||
private int is_yellow_vip;
|
||||
private int is_yellow_year_vip;
|
||||
private int yellow_vip_level;
|
||||
private int is_yellow_high_vip;
|
||||
// 是否蓝钻,是返回蓝钻等级,不是返回-1
|
||||
private boolean is_blue_vip;
|
||||
// 是否年费蓝钻
|
||||
private boolean is_blue_year_vip;
|
||||
// 也许是豪华蓝钻
|
||||
private boolean is_super_blue_vip;
|
||||
// 蓝钻等级
|
||||
private int blue_vip_level;
|
||||
private int a3366_level;
|
||||
private String a3366_level_name;
|
||||
private int a3366_grow_level;
|
||||
private int a3366_grow_value;
|
||||
|
||||
public int getA3366_level() {
|
||||
return a3366_level;
|
||||
}
|
||||
|
||||
public void setA3366_level(int a3366_level) {
|
||||
this.a3366_level = a3366_level;
|
||||
}
|
||||
|
||||
public String getA3366_level_name() {
|
||||
return a3366_level_name;
|
||||
}
|
||||
|
||||
public void setA3366_level_name(String a3366_level_name) {
|
||||
this.a3366_level_name = a3366_level_name;
|
||||
}
|
||||
|
||||
public int getA3366_grow_level() {
|
||||
return a3366_grow_level;
|
||||
}
|
||||
|
||||
public void setA3366_grow_level(int a3366_grow_level) {
|
||||
this.a3366_grow_level = a3366_grow_level;
|
||||
}
|
||||
|
||||
public int getA3366_grow_value() {
|
||||
return a3366_grow_value;
|
||||
}
|
||||
|
||||
public void setA3366_grow_value(int a3366_grow_value) {
|
||||
this.a3366_grow_value = a3366_grow_value;
|
||||
}
|
||||
|
||||
public int getRet() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setRet(int ret) {
|
||||
this.ret = ret;
|
||||
}
|
||||
|
||||
public int getIs_lost() {
|
||||
return is_lost;
|
||||
}
|
||||
|
||||
public void setIs_lost(int is_lost) {
|
||||
this.is_lost = is_lost;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
if (!checkName(nickname))
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getFigureurl() {
|
||||
return figureurl;
|
||||
}
|
||||
|
||||
public void setFigureurl(String figureurl) {
|
||||
this.figureurl = figureurl;
|
||||
}
|
||||
|
||||
public int getIs_yellow_vip() {
|
||||
return is_yellow_vip;
|
||||
}
|
||||
|
||||
public void setIs_yellow_vip(int is_yellow_vip) {
|
||||
this.is_yellow_vip = is_yellow_vip;
|
||||
}
|
||||
|
||||
public int getIs_yellow_year_vip() {
|
||||
return is_yellow_year_vip;
|
||||
}
|
||||
|
||||
public void setIs_yellow_year_vip(int is_yellow_year_vip) {
|
||||
this.is_yellow_year_vip = is_yellow_year_vip;
|
||||
}
|
||||
|
||||
public int getYellow_vip_level() {
|
||||
return yellow_vip_level;
|
||||
}
|
||||
|
||||
public void setYellow_vip_level(int yellow_vip_level) {
|
||||
this.yellow_vip_level = yellow_vip_level;
|
||||
}
|
||||
|
||||
public int getIs_yellow_high_vip() {
|
||||
return is_yellow_high_vip;
|
||||
}
|
||||
|
||||
public void setIs_yellow_high_vip(int is_yellow_high_vip) {
|
||||
this.is_yellow_high_vip = is_yellow_high_vip;
|
||||
}
|
||||
|
||||
public boolean isIs_blue_vip() {
|
||||
return is_blue_vip;
|
||||
}
|
||||
|
||||
public void setIs_blue_vip(boolean is_blue_vip) {
|
||||
this.is_blue_vip = is_blue_vip;
|
||||
}
|
||||
|
||||
public boolean isIs_blue_year_vip() {
|
||||
return is_blue_year_vip;
|
||||
}
|
||||
|
||||
public void setIs_blue_year_vip(boolean is_blue_year_vip) {
|
||||
this.is_blue_year_vip = is_blue_year_vip;
|
||||
}
|
||||
|
||||
public boolean isIs_super_blue_vip() {
|
||||
return is_super_blue_vip;
|
||||
}
|
||||
|
||||
public void setIs_super_blue_vip(boolean is_super_blue_vip) {
|
||||
this.is_super_blue_vip = is_super_blue_vip;
|
||||
}
|
||||
|
||||
public int getBlue_vip_level() {
|
||||
return blue_vip_level;
|
||||
}
|
||||
|
||||
public void setBlue_vip_level(int blue_vip_level) {
|
||||
this.blue_vip_level = blue_vip_level;
|
||||
}
|
||||
|
||||
public static boolean checkName(String name) {
|
||||
if (isMatches("[\\w]*", name))
|
||||
return false;
|
||||
return isMatches("[\u1F601-\u1F64F]+", name);
|
||||
}
|
||||
|
||||
public static boolean isMatches(String regex, String str) {
|
||||
Pattern p = Pattern.compile(regex);
|
||||
Matcher m = p.matcher(str);
|
||||
boolean b = m.matches();
|
||||
return b;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.rekoe.mobile.provider.rk;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.rekoe.mobile.AbstractParam;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
public class RKParam extends AbstractParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1240692439054026809L;
|
||||
private String code;
|
||||
|
||||
private int pid;
|
||||
|
||||
public RKParam() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.RK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPid() {
|
||||
return this.pid;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package com.rekoe.mobile.provider.rk;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.http.Http;
|
||||
import org.nutz.http.Response;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
|
||||
import com.rekoe.annotation.PlatformProvider;
|
||||
import com.rekoe.domain.PlatformConfig;
|
||||
import com.rekoe.mobile.Profile;
|
||||
import com.rekoe.mobile.provider.AbstractProvider;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@PlatformProvider(name = Constants.RK)
|
||||
public class RKProvider extends AbstractProvider<RKParam> {
|
||||
|
||||
private static final long serialVersionUID = 2882126009485835543L;
|
||||
|
||||
private final static Log log = Logs.get();
|
||||
|
||||
private final static String TOKEN_VALIDATE = "/oauth/accessToken";
|
||||
private final static String TOKEN_FOR_USER = "/v1/openapi/userinfo?access_token=";
|
||||
|
||||
@Override
|
||||
public Profile verifyResponse(RKParam param) throws Exception {
|
||||
String code = param.getCode();
|
||||
PlatformConfig platformConfig = getPlatformConfig(param.getPid());
|
||||
String clientId = platformConfig.getConfig().getString("client_id");
|
||||
String grantType = platformConfig.getConfig().getString("grant_type");
|
||||
String clientSecret = platformConfig.getConfig().getString("client_secret");
|
||||
String redirectUri = platformConfig.getConfig().getString("redirect_uri");
|
||||
String validateUrl = platformConfig.getConfig().getString("validate_url");
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("client_id", clientId);
|
||||
params.put("grant_type", grantType);
|
||||
params.put("client_secret", clientSecret);
|
||||
params.put("code", code);
|
||||
params.put("redirect_uri", redirectUri);
|
||||
try {
|
||||
Response res = Http.post2(validateUrl + TOKEN_VALIDATE, params, 60);
|
||||
if (res.isOK()) {
|
||||
String resultToken = res.getContent();
|
||||
NutMap map = Json.fromJson(NutMap.class, resultToken);
|
||||
String accessToken = map.getString("access_token");
|
||||
params.clear();
|
||||
if (StringUtils.isNotBlank(accessToken)) {
|
||||
params.put("access_token", accessToken);
|
||||
String resultvValidateToken = Http.get(validateUrl + TOKEN_FOR_USER + accessToken).getContent();
|
||||
NutMap userInfo = Json.fromJson(NutMap.class, resultvValidateToken);
|
||||
return new Profile(getProviderId(), userInfo.getString("uid"), param.getPid());
|
||||
}
|
||||
log.error(resultToken);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.errorf("url:[%s]", validateUrl);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.RK;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package com.rekoe.mobile.provider.sg;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.rekoe.mobile.AbstractParam;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
public class SGParam extends AbstractParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1240692439054026809L;
|
||||
private String openid;
|
||||
private int pid;
|
||||
|
||||
public SGParam() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SGParam(int pid, String passportid) {
|
||||
super();
|
||||
this.openid = passportid;
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getOpenid() {
|
||||
return openid;
|
||||
}
|
||||
|
||||
public void setOpenid(String openid) {
|
||||
this.openid = openid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.SG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPid() {
|
||||
return this.pid;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package com.rekoe.mobile.provider.sg;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import com.rekoe.annotation.PlatformProvider;
|
||||
import com.rekoe.mobile.Profile;
|
||||
import com.rekoe.mobile.provider.AbstractProvider;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@PlatformProvider(name = Constants.SG)
|
||||
public class SGProvider extends AbstractProvider<SGParam> {
|
||||
|
||||
private static final long serialVersionUID = 2882126009485835543L;
|
||||
|
||||
@Override
|
||||
public Profile verifyResponse(SGParam param) throws Exception {
|
||||
return new Profile(getProviderId(), param.getOpenid(), param.getPid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.SG;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package com.rekoe.mobile.provider.uc;
|
||||
|
||||
public class UCResponse {
|
||||
|
||||
private UCResponseState state;
|
||||
private UCResponseData data;
|
||||
|
||||
public UCResponse(UCResponseState state, UCResponseData data) {
|
||||
this.state = state;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public UCResponse(UCResponseState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public UCResponseState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public UCResponseData getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(UCResponseData data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package com.rekoe.mobile.provider.uc;
|
||||
|
||||
public class UCResponseData {
|
||||
private String accountId;
|
||||
private String nickName;
|
||||
|
||||
public String getAccountId(){
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(String accountId){
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public String getNickName(){
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName){
|
||||
this.nickName = nickName;
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package com.rekoe.mobile.provider.uc;
|
||||
|
||||
public class UCResponseState {
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package com.rekoe.mobile.provider.uc;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.rekoe.mobile.AbstractParam;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
public class UcParam extends AbstractParam implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -2473883638175694140L;
|
||||
private String sid;
|
||||
private int pid;
|
||||
|
||||
public String getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public UcParam() {
|
||||
}
|
||||
|
||||
public UcParam(int pid, String sid) {
|
||||
this.sid = sid;
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public void setSid(String sid) {
|
||||
this.sid = sid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.UC;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
package com.rekoe.mobile.provider.uc;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.nutz.http.Request;
|
||||
import org.nutz.http.Request.METHOD;
|
||||
import org.nutz.http.Response;
|
||||
import org.nutz.http.Sender;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.json.JsonFormat;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
|
||||
import com.rekoe.annotation.PlatformProvider;
|
||||
import com.rekoe.domain.PlatformConfig;
|
||||
import com.rekoe.mobile.Profile;
|
||||
import com.rekoe.mobile.provider.AbstractProvider;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@PlatformProvider(name = Constants.UC)
|
||||
public class UcProvider extends AbstractProvider<UcParam> {
|
||||
|
||||
private static final long serialVersionUID = 2882126009485835543L;
|
||||
private final static Log log = Logs.get();
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.UC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile verifyResponse(UcParam param) throws Exception {
|
||||
PlatformConfig platformConfig = getPlatformConfig(param.getPid());
|
||||
String appkey = platformConfig.getConfig().getString("appkey");
|
||||
int appid = platformConfig.getConfig().getInt("appid");
|
||||
int secret = platformConfig.getConfig().getInt("secret");
|
||||
String validateUrl = platformConfig.getConfig().getString("validate_url");
|
||||
UCResponse response = response2(param.getSid(), appid, appkey, secret, validateUrl);
|
||||
if (response.getState().getCode() == 1) {
|
||||
Profile profile = new Profile(getProviderId(), response.getData().getAccountId(), param.getPid());
|
||||
profile.addv("token", param.getSid());
|
||||
return profile;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public UCResponse response(String sid, int appid, String appKey, String validateUrl) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("id", System.currentTimeMillis());
|
||||
params.put("service", "ucid.bind.create");
|
||||
params.put("sign", Lang.md5("gameUser=" + sid + appKey));
|
||||
Map<String, Integer> gameParams = new HashMap<>();
|
||||
gameParams.put("gameId", appid);
|
||||
params.put("game", gameParams);
|
||||
Map<String, String> dataParams = new HashMap<>();
|
||||
params.put("data", dataParams);
|
||||
dataParams.put("gameUser", sid);
|
||||
String json = httpPostBody(validateUrl, Json.toJson(params, JsonFormat.compact()));
|
||||
Map<String, Object> m = Json.fromJsonAsMap(Object.class, json);
|
||||
Object obj = m.get("state");
|
||||
UCResponseState state = Lang.map2Object((Map<?, ?>) obj, UCResponseState.class);
|
||||
UCResponse res = new UCResponse(state);
|
||||
if (state.getCode() == 1) {
|
||||
res.setData(Lang.map2Object((Map<?, ?>) m.get("data"), UCResponseData.class));
|
||||
} else {
|
||||
log.error(json);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private UCResponse response2(String sid, int appid, String appKey, int secret, String validateUrl) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("id", System.currentTimeMillis());
|
||||
params.put("service", "ucid.user.sidInfo");
|
||||
params.put("encrypt", "md5");
|
||||
params.put("sign", Lang.md5(secret + "sid=" + sid + appKey));
|
||||
Map<String, Integer> gameParams = new HashMap<>();
|
||||
gameParams.put("cpId", secret);
|
||||
gameParams.put("gameId", appid);
|
||||
gameParams.put("channelId", 2);
|
||||
gameParams.put("serverId", 0);
|
||||
params.put("game", gameParams);
|
||||
Map<String, String> dataParams = new HashMap<>();
|
||||
dataParams.put("sid", sid);
|
||||
params.put("data", dataParams);
|
||||
Request req = Request.create(validateUrl, METHOD.POST);
|
||||
req.getHeader().set("Content-Type", "application/json:charset=utf-8 ");
|
||||
req.setData(Json.toJson(params, JsonFormat.compact()));
|
||||
Response resp = Sender.create(req).send();
|
||||
String json = resp.getContent();
|
||||
Map<String, Object> m = Json.fromJsonAsMap(Object.class, json);
|
||||
Object obj = m.get("state");
|
||||
UCResponseState state = Lang.map2Object((Map<?, ?>) obj, UCResponseState.class);
|
||||
UCResponse res = new UCResponse(state);
|
||||
if (state.getCode() == 1) {
|
||||
res.setData(Lang.map2Object((Map<?, ?>) m.get("data"), UCResponseData.class));
|
||||
} else {
|
||||
log.error(json);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package com.rekoe.mobile.provider.xiaomi;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.rekoe.mobile.AbstractParam;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
public class XiaoMiParam extends AbstractParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5138092630114580043L;
|
||||
private String uid;
|
||||
private String token;
|
||||
private int pid;
|
||||
|
||||
public XiaoMiParam() {
|
||||
super();
|
||||
}
|
||||
|
||||
public XiaoMiParam(int pid, String uid, String token) {
|
||||
super();
|
||||
this.uid = uid;
|
||||
this.uid = token;
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.XIAOMI;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package com.rekoe.mobile.provider.xiaomi;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
|
||||
import com.rekoe.annotation.PlatformProvider;
|
||||
import com.rekoe.domain.PlatformConfig;
|
||||
import com.rekoe.mobile.Profile;
|
||||
import com.rekoe.mobile.provider.AbstractProvider;
|
||||
import com.rekoe.utils.Constants;
|
||||
import com.rekoe.utils.HmacSHA1Encryption;
|
||||
|
||||
@IocBean
|
||||
@PlatformProvider(name = Constants.XIAOMI)
|
||||
public class XiaoMiProvider extends AbstractProvider<XiaoMiParam> {
|
||||
|
||||
private static final long serialVersionUID = 2882126009485835543L;
|
||||
|
||||
private final static Log log = Logs.get();
|
||||
|
||||
private final static String PARAM_URL_STR = "appId={0}&session={1}&uid={2}&signature={3}";
|
||||
private final static String ENCRYPT_TEXT = "appId={0}&session={1}&uid={2}";
|
||||
private static final Map<String, String> ENDPOINTS;
|
||||
|
||||
private final String ERROR_CODE = "{\"errcode\":-1}";
|
||||
static {
|
||||
ENDPOINTS = new HashMap<String, String>();
|
||||
ENDPOINTS.put(Constants.OAUTH_AUTHORIZATION_URL, "http://mis.migc.xiaomi.com/api/biz/service/verifySession.do?");
|
||||
}
|
||||
|
||||
public Map<String, Integer> checkUserAndroidMiLogin(String sdkUin, String sdkToken, String appid, String secret) throws Exception {
|
||||
String encryptText = MessageFormat.format(ENCRYPT_TEXT, appid, sdkToken, sdkUin);
|
||||
String signature = HmacSHA1Encryption.HmacSHA1Encrypt(encryptText, secret);
|
||||
String getUrl = ENDPOINTS.get(Constants.OAUTH_AUTHORIZATION_URL) + MessageFormat.format(PARAM_URL_STR, appid, sdkToken, sdkUin, signature);
|
||||
return result2Json(HttpGet(getUrl), Integer.class, ERROR_CODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return Constants.XIAOMI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile verifyResponse(XiaoMiParam param) throws Exception {
|
||||
PlatformConfig platformConfig = getPlatformConfig(param.getPid());
|
||||
Map<String, Integer> params = checkUserAndroidMiLogin(param.getUid(), param.getToken(), platformConfig.getConfig().getString("appid"), platformConfig.getConfig().getString("secret"));
|
||||
if (params.get("errcode") == 200) {
|
||||
return new Profile(getProviderId(), param.getUid(), param.getPid());
|
||||
} else {
|
||||
log.errorf("ProviderId:%s,errCode:%s", getProviderId(), params);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
package com.rekoe.module;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.oltu.oauth2.as.issuer.MD5Generator;
|
||||
import org.apache.oltu.oauth2.as.issuer.OAuthIssuer;
|
||||
import org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl;
|
||||
import org.apache.oltu.oauth2.as.request.OAuthTokenRequest;
|
||||
import org.apache.oltu.oauth2.as.response.OAuthASResponse;
|
||||
import org.apache.oltu.oauth2.common.OAuth;
|
||||
import org.apache.oltu.oauth2.common.error.OAuthError;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
|
||||
import org.apache.oltu.oauth2.common.message.OAuthResponse;
|
||||
import org.apache.oltu.oauth2.common.message.types.GrantType;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.By;
|
||||
import org.nutz.mvc.annotation.Filters;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.POST;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import com.rekoe.filter.OauthCrossOriginFilter;
|
||||
import com.rekoe.service.OAuthService;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@At("/oauth")
|
||||
public class AccessTokenModule {
|
||||
|
||||
@Inject
|
||||
private OAuthService oAuthService;
|
||||
|
||||
/**
|
||||
* @api {post} /oauth/accessToken 换取accessToken
|
||||
*
|
||||
* @apiGroup User
|
||||
* @apiVersion 1.0.0
|
||||
* @apiSampleRequest http://warlogin.shanggame.com/oauth/accessToken
|
||||
*
|
||||
* @apiParam {String} client_id 应用id
|
||||
* @apiParam {String} client_secret 应用secret
|
||||
*
|
||||
* @apiParam {String} grant_type=authorization_code 用于传递授权码的参数名
|
||||
* @apiParam {String} code 用户登录授权后的授权码
|
||||
* @apiParam {String} [redirect_uri=http://www.rekoe.com] 回调地址
|
||||
*
|
||||
* @apiSuccess {int} expires_in=3600 accessToken过期时间 单位(秒)
|
||||
* @apiSuccess {String} access_token accessToken值
|
||||
*
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {"expires_in":3600,"access_token":"223ae05dfbb0794396fb60a0960c197e"}
|
||||
*/
|
||||
|
||||
@At
|
||||
@Ok("raw:json")
|
||||
@Filters(@By(type = OauthCrossOriginFilter.class))
|
||||
public String accessToken(HttpServletRequest request) throws URISyntaxException, OAuthSystemException {
|
||||
try {
|
||||
// 构建OAuth请求
|
||||
OAuthTokenRequest oauthRequest = new OAuthTokenRequest(request);
|
||||
// 检查提交的客户端id是否正确
|
||||
if (!oAuthService.checkClientId(oauthRequest.getClientId())) {
|
||||
OAuthResponse response = OAuthASResponse.errorResponse(HttpServletResponse.SC_BAD_REQUEST).setError(OAuthError.TokenResponse.INVALID_CLIENT).setErrorDescription(Constants.INVALID_CLIENT_ID).buildJSONMessage();
|
||||
return response.getBody();
|
||||
}
|
||||
// 检查客户端安全KEY是否正确
|
||||
if (!oAuthService.checkClientSecret(oauthRequest.getClientSecret())) {
|
||||
OAuthResponse response = OAuthASResponse.errorResponse(HttpServletResponse.SC_UNAUTHORIZED).setError(OAuthError.TokenResponse.UNAUTHORIZED_CLIENT).setErrorDescription(Constants.INVALID_CLIENT_ID).buildJSONMessage();
|
||||
return response.getBody();
|
||||
}
|
||||
String authCode = oauthRequest.getParam(OAuth.OAUTH_CODE);
|
||||
// 检查验证类型,此处只检查AUTHORIZATION_CODE类型,其他的还有PASSWORD或REFRESH_TOKEN
|
||||
if (oauthRequest.getParam(OAuth.OAUTH_GRANT_TYPE).equals(GrantType.AUTHORIZATION_CODE.toString())) {
|
||||
if (!oAuthService.checkAuthCode(authCode)) {
|
||||
OAuthResponse response = OAuthASResponse.errorResponse(HttpServletResponse.SC_BAD_REQUEST).setError(OAuthError.TokenResponse.INVALID_GRANT).setErrorDescription(Constants.INVALID_AUTH_CODE).buildJSONMessage();
|
||||
return response.getBody();
|
||||
}
|
||||
}
|
||||
// 生成Access Token
|
||||
OAuthIssuer oauthIssuerImpl = new OAuthIssuerImpl(new MD5Generator());
|
||||
final String accessToken = oauthIssuerImpl.accessToken();
|
||||
oAuthService.addAccessToken(accessToken, oAuthService.getUsernameByAuthCode(authCode));
|
||||
// 生成OAuth响应
|
||||
OAuthResponse response = OAuthASResponse.tokenResponse(HttpServletResponse.SC_OK).setAccessToken(accessToken).setExpiresIn(String.valueOf(oAuthService.getExpireIn())).buildJSONMessage();
|
||||
// 根据OAuthResponse生成ResponseEntity
|
||||
return response.getBody();
|
||||
} catch (OAuthProblemException e) {
|
||||
// 构建错误响应
|
||||
OAuthResponse res = OAuthASResponse.errorResponse(HttpServletResponse.SC_BAD_REQUEST).error(e).buildJSONMessage();
|
||||
return res.getBody();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证accessToken
|
||||
*
|
||||
* @param accessToken
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@POST
|
||||
public void checkAccessToken(@Param("accessToken") String accessToken, HttpServletResponse res) {
|
||||
boolean b = oAuthService.checkAccessToken(accessToken);
|
||||
if (b) {
|
||||
res.setStatus(HttpServletResponse.SC_OK);
|
||||
} else {
|
||||
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
package com.rekoe.module;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.oltu.oauth2.as.issuer.MD5Generator;
|
||||
import org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl;
|
||||
import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest;
|
||||
import org.apache.oltu.oauth2.common.OAuth;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
|
||||
import org.apache.oltu.oauth2.common.message.types.ResponseType;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.By;
|
||||
import org.nutz.mvc.annotation.Filters;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.POST;
|
||||
|
||||
import com.rekoe.domain.OAuthUser;
|
||||
import com.rekoe.filter.OauthCrossOriginFilter;
|
||||
import com.rekoe.utils.CommonUtils;
|
||||
|
||||
/**
|
||||
* @apiDefine TOKEN_ERROR
|
||||
* @apiError 403 The <code>accesstoken</code> is invaild
|
||||
*/
|
||||
/**
|
||||
* @apiDefine TOKEN
|
||||
* @apiParam {String} accesstoken 访问凭证
|
||||
*
|
||||
*/
|
||||
@At("/api/v1/")
|
||||
@IocBean
|
||||
@Filters(@By(type = OauthCrossOriginFilter.class))
|
||||
public class AuthorizeAction {
|
||||
|
||||
private final static Log log = Logs.get();
|
||||
|
||||
@Inject
|
||||
private com.rekoe.service.OAuthService oAuthService;
|
||||
@Inject
|
||||
private com.rekoe.service.OAuthClientService oAuthClientService;
|
||||
@Inject
|
||||
private com.rekoe.service.OAuthUserService oAuthUserService;
|
||||
|
||||
/**
|
||||
* @apiDefine CODE_200
|
||||
* @apiSuccess (Reponse 200) {number} code 200
|
||||
* @apiSuccess (Reponse 200) {json} [data='""'] 如果有数据返回
|
||||
* @apiSuccessExample {json} Response 200
|
||||
* {
|
||||
* "code":200,
|
||||
* "feedback":0,
|
||||
* "msg","Ok"
|
||||
* }
|
||||
*/
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/authorize 请求授权码
|
||||
* @apiSampleRequest http://warlogin.shanggame.com/api/v1/authorize
|
||||
* @apiDescription 用户输入正确的用户名和密码以POST方式提交后会重定向到用户所填的回调地址并在地址后携带授权码.
|
||||
* @apiGroup User
|
||||
* @apiVersion 1.0.0
|
||||
*
|
||||
* @apiParam {String} username 用户名
|
||||
* @apiParam {String} password 密码
|
||||
* @apiParam {String} client_id 应用id
|
||||
* @apiParam {String} response_type=code 返回授权码的标识
|
||||
*
|
||||
* @apiSuccess (成功返回值) {int} feedback 响应状态 0 为成功
|
||||
* @apiSuccess (成功返回值) {String} msg 错误描述
|
||||
* @apiSuccess (成功返回值) {String} code 授权码
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {
|
||||
* "code":"c1b0a32d71101d00f4c96a134ec6bd42",
|
||||
* "feedback": 0,
|
||||
* "msg": "Ok"
|
||||
* }
|
||||
*/
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@POST
|
||||
public NutMap authorize(HttpServletRequest request, HttpServletResponse res) throws URISyntaxException, OAuthSystemException {
|
||||
try {
|
||||
// 构建OAuth 授权请求
|
||||
OAuthAuthzRequest oauthRequest = new OAuthAuthzRequest(request);
|
||||
// 检查传入的客户端id是否正确
|
||||
if (!oAuthService.checkClientId(oauthRequest.getClientId())) {
|
||||
return NutMap.NEW().addv("feedback", 2);
|
||||
}
|
||||
|
||||
// 如果用户没有登录,跳转到登陆页面
|
||||
if (!login(request)) {// 登录失败时跳转到登陆页面
|
||||
return NutMap.NEW().addv("feedback", 3).addv("msg", "登陆失败");
|
||||
}
|
||||
|
||||
String username = request.getParameter("username"); // 获取用户名
|
||||
// responseType目前仅支持CODE,另外还有TOKEN
|
||||
NutMap map = NutMap.NEW();
|
||||
String responseType = oauthRequest.getParam(OAuth.OAUTH_RESPONSE_TYPE);
|
||||
if (responseType.equals(ResponseType.CODE.toString())) {
|
||||
OAuthIssuerImpl oauthIssuerImpl = new OAuthIssuerImpl(new MD5Generator());
|
||||
String authorizationCode = oauthIssuerImpl.authorizationCode();
|
||||
oAuthService.addAuthCode(authorizationCode, username);
|
||||
map.addv("code", authorizationCode);
|
||||
} else {
|
||||
return map.addv("feedback", 4).addv("msg", "参数错误");
|
||||
}
|
||||
map.addv("feedback", 0).addv("msg", "Ok");
|
||||
return map;
|
||||
} catch (OAuthProblemException e) {
|
||||
log.error(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean login(HttpServletRequest request) {
|
||||
NutMap parames = CommonUtils.getRequestParametersMap(request);
|
||||
String username = parames.getString("username");
|
||||
String password = parames.getString("password");
|
||||
if (Strings.isEmpty(username) || Strings.isEmpty(password)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
OAuthUser user = oAuthUserService.findByUsername(username);
|
||||
if (user != null) {
|
||||
if (!oAuthUserService.checkUser(username, password, user.getSalt(), user.getPassword())) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,34 +13,19 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.entity.Record;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.web.ajax.AjaxReturn;
|
||||
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.domain.GameServer;
|
||||
import com.rekoe.service.GameServerService;
|
||||
|
||||
public class BaseAction {
|
||||
private final static Log log = Logs.get();
|
||||
|
||||
@Inject
|
||||
public GameServerService gameServerService;
|
||||
|
||||
protected Message responseMessage(AjaxReturn result, HttpServletRequest req) {
|
||||
return result.isOk() ? Message.success("admin.common.ok", req) : Message.error(StringUtils.defaultString(result.getMsg(), "admin.common.resopnse.error"), req);
|
||||
}
|
||||
|
||||
public GameServer getServer(int id) {
|
||||
GameServer server = gameServerService.getServer(id);
|
||||
return server;
|
||||
}
|
||||
|
||||
public List<Integer> getAllServerIDs() {
|
||||
return gameServerService.getAllIds();
|
||||
}
|
||||
|
||||
public int getPage(Integer page) {
|
||||
return page == null ? 1 : page.intValue();
|
||||
}
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
package com.rekoe.module;
|
||||
|
||||
public class CdkeyBean {
|
||||
|
||||
private String sign;
|
||||
private String cdkey;
|
||||
private String mac;
|
||||
private int pid;
|
||||
private String providerId;
|
||||
|
||||
public CdkeyBean() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CdkeyBean(String sign, String cdkey, String mac, int pid, String providerId) {
|
||||
super();
|
||||
this.sign = sign;
|
||||
this.cdkey = cdkey;
|
||||
this.mac = mac;
|
||||
this.pid = pid;
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
public String getMac() {
|
||||
return mac;
|
||||
}
|
||||
|
||||
public void setMac(String mac) {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getProviderId() {
|
||||
return providerId;
|
||||
}
|
||||
|
||||
public void setProviderId(String providerId) {
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public String getCdkey() {
|
||||
return cdkey;
|
||||
}
|
||||
|
||||
public void setCdkey(String cdkey) {
|
||||
this.cdkey = cdkey;
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package com.rekoe.module;
|
||||
|
||||
import org.nutz.ioc.impl.PropertiesProxy;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.adaptor.JsonAdaptor;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.POST;
|
||||
|
||||
import com.rekoe.domain.CdkeyLog;
|
||||
import com.rekoe.service.CdKeyCategoryService;
|
||||
import com.rekoe.service.CdKeyLogService;
|
||||
import com.rekoe.service.CdKeyService;
|
||||
|
||||
@IocBean
|
||||
@At("/excharge")
|
||||
public class ExchargeAction {
|
||||
|
||||
private final static Log log = Logs.get();
|
||||
@Inject
|
||||
private CdKeyService cdKeyService;
|
||||
|
||||
@Inject
|
||||
private CdKeyCategoryService cdKeyCategoryService;
|
||||
|
||||
@Inject
|
||||
private CdKeyLogService cdKeyLogService;
|
||||
|
||||
@Inject
|
||||
private PropertiesProxy conf;
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@POST
|
||||
@AdaptBy(type = JsonAdaptor.class)
|
||||
public NutMap cdk(CdkeyBean bean) {
|
||||
StringBuffer sb = new StringBuffer("cdk.");
|
||||
sb.append(bean.getPid()).append(".secret");
|
||||
String secret = conf.get(sb.toString());
|
||||
String sign = Lang.md5(bean.getCdkey() + "|" + bean.getMac() + "|" + bean.getPid() + "|" + secret);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debugf("secretKey : %s", sb);
|
||||
log.debugf("secret : %s", secret);
|
||||
log.debugf("Cdkey : %s", bean.getCdkey());
|
||||
log.debugf("Mac : %s", bean.getMac());
|
||||
log.debugf("Pid : %s", bean.getPid());
|
||||
log.debugf("Sign : %s", bean.getSign());
|
||||
log.debugf("P_Sign : %s", sign);
|
||||
}
|
||||
|
||||
if (Lang.equals(sign, bean.getSign())) {
|
||||
int type = cdKeyCategoryService.getType(bean.getCdkey());
|
||||
if (cdKeyCategoryService.isExists(type)) {
|
||||
if (cdKeyService.use(bean.getCdkey(), type)) {
|
||||
cdKeyLogService.insert(new CdkeyLog(bean.getPid(), bean.getProviderId(), bean.getMac()));
|
||||
return NutMap.NEW().addv("feedback", 0).addv("mesage", "ok");
|
||||
}
|
||||
return NutMap.NEW().addv("feedback", 92).addv("mesage", "已失效");
|
||||
}
|
||||
return NutMap.NEW().addv("feedback", 93).addv("mesage", "不存在");
|
||||
}
|
||||
return NutMap.NEW().addv("feedback", 61).addv("mesage", "签名失败");
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
package com.rekoe.module;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.By;
|
||||
import org.nutz.mvc.annotation.Filters;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import com.rekoe.domain.Notice;
|
||||
import com.rekoe.filter.OauthCrossOriginFilter;
|
||||
import com.rekoe.service.NoticeService;
|
||||
|
||||
@IocBean
|
||||
@At("/notice")
|
||||
@Filters(@By(type = OauthCrossOriginFilter.class))
|
||||
public class NoticeModule {
|
||||
|
||||
@Inject
|
||||
private NoticeService noticeService;
|
||||
|
||||
/**
|
||||
* @api {post} /notice/:pid/list 获得公告列表
|
||||
* @apiParam {Number} pid 申请的游戏编码ID
|
||||
* @apiGroup notice
|
||||
* @apiVersion 1.0.0
|
||||
* @apiSampleRequest http://warlogin.shanggame.com/notice/:pid/list
|
||||
* @apiSuccess {Object[]} notices List of notice.
|
||||
* @apiSuccess {String} notices.color 公告标题颜色.
|
||||
* @apiSuccess {String} notices.title 公告标题.
|
||||
* @apiSuccess {number} notices.id 公告ID.
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* [
|
||||
* {
|
||||
* "color": "#FFFFF", "title": "xxxx" ,"id":1
|
||||
* }
|
||||
* ]
|
||||
*/
|
||||
|
||||
@At("/?/list")
|
||||
@Ok("json")
|
||||
public Object list(int pid) {
|
||||
List<Notice> list = noticeService.query(Cnd.where("pid", "=", pid).and("publication", "=", true).desc("top"), null);
|
||||
if (Lang.isEmpty(list)) {
|
||||
return new ArrayList<Notice>();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /notice/view/:id 公告内容详细
|
||||
*
|
||||
* @apiParam {Number} id ID.
|
||||
*
|
||||
* @apiGroup notice
|
||||
* @apiVersion 1.0.0
|
||||
* @apiSampleRequest http://warlogin.shanggame.com/notice/view/:id
|
||||
*/
|
||||
|
||||
@At("/view/?")
|
||||
@Ok("raw")
|
||||
public String view(long id,HttpServletRequest req) throws IOException {
|
||||
Notice article =noticeService.fetch(id);
|
||||
if (Lang.isEmpty(article)) {
|
||||
return "empty";
|
||||
}
|
||||
return article.getContent();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,324 +0,0 @@
|
|||
package com.rekoe.module;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.oltu.oauth2.as.issuer.MD5Generator;
|
||||
import org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
|
||||
import org.nutz.castor.Castors;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.By;
|
||||
import org.nutz.mvc.annotation.Filters;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.POST;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import com.rekoe.domain.GameServer;
|
||||
import com.rekoe.domain.OAuthUser;
|
||||
import com.rekoe.domain.PlatformUser;
|
||||
import com.rekoe.filter.OauthCrossOriginFilter;
|
||||
import com.rekoe.mobile.provider.PlatformProviderFactory;
|
||||
import com.rekoe.service.GameServerService;
|
||||
import com.rekoe.service.IdWorkerService;
|
||||
import com.rekoe.service.OAuthService;
|
||||
import com.rekoe.service.OAuthUserService;
|
||||
import com.rekoe.service.PlatformUserService;
|
||||
import com.rekoe.utils.CommonUtils;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@At("/auth")
|
||||
@Filters(@By(type = OauthCrossOriginFilter.class))
|
||||
public class OAuthUserAction {
|
||||
|
||||
private final static String PHONE_KEY = "rk_phone_key";
|
||||
private final static String PHONE_NUMBER = "rk_phone_number";
|
||||
private final static String OAUTH_USER_KEY = "rk_oauth_user_key";
|
||||
|
||||
@Inject
|
||||
private OAuthUserService oAuthUserService;
|
||||
|
||||
@Inject
|
||||
private OAuthService oAuthService;
|
||||
|
||||
@Inject
|
||||
private GameServerService gameServerService;
|
||||
|
||||
/**
|
||||
* @api {post} /auth/user/create 创建账号并获取授权码
|
||||
*
|
||||
* @apiGroup User
|
||||
* @apiVersion 1.0.0
|
||||
* @apiSampleRequest http://warlogin.shanggame.com/auth/user/create
|
||||
* @apiParam {String} name 用户名
|
||||
* @apiParam {String} password 密码
|
||||
* @apiParam {String} captcha 手机收到的验证码
|
||||
* @apiParamExample {String} Request-Example:
|
||||
* user.name=xxx&user.password=xxx&captcha=xxx
|
||||
* @apiSuccess {int} feedback 响应状态 0 为成功 1 账号被占用
|
||||
* @apiSuccess {String} code 授权码
|
||||
*/
|
||||
|
||||
/**
|
||||
* 普通注册
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
* @throws OAuthSystemException
|
||||
*/
|
||||
@At("/user/create")
|
||||
@Ok("json")
|
||||
@POST
|
||||
public NutMap create(HttpServletRequest req) throws OAuthSystemException {
|
||||
HttpSession session = req.getSession();
|
||||
Object phoneCodeObj = session.getAttribute(PHONE_KEY);
|
||||
Object phoneObj = session.getAttribute(PHONE_NUMBER);
|
||||
if (Lang.isEmpty(phoneCodeObj) || Lang.isEmpty(phoneObj)) {
|
||||
return NutMap.NEW().addv("feedback", 404);
|
||||
}
|
||||
NutMap parames = CommonUtils.getRequestParametersMap(req);
|
||||
int captcha = parames.getInt("captcha",0);
|
||||
String name = parames.getString("name");
|
||||
String pwd = parames.getString("password");
|
||||
|
||||
int phoneCode = Castors.me().castTo(phoneCodeObj,int.class);
|
||||
if (StringUtils.isBlank(pwd) || StringUtils.isBlank(name) || captcha != phoneCode) {
|
||||
return NutMap.NEW().addv("feedback", 1);
|
||||
}
|
||||
long phone = Castors.me().castTo(phoneObj, long.class);
|
||||
NutMap map = NutMap.NEW();
|
||||
if (checkOauthUser(name)) {
|
||||
OAuthIssuerImpl oauthIssuerImpl = new OAuthIssuerImpl(new MD5Generator());
|
||||
String authorizationCode = oauthIssuerImpl.authorizationCode();
|
||||
oAuthService.addAuthCode(authorizationCode, name);
|
||||
map.addv("code", authorizationCode);
|
||||
OAuthUser user = new OAuthUser();
|
||||
user.setPhoneCode(phone);
|
||||
user.setPassword(pwd);
|
||||
user.setUserName(name);
|
||||
oAuthUserService.createUser(user);
|
||||
session.setAttribute(PHONE_KEY, null);
|
||||
session.setAttribute(PHONE_NUMBER, null);
|
||||
} else {
|
||||
return map.addv("feedback", 1);
|
||||
}
|
||||
return map.addv("feedback", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /auth/rest/pwd 密码重置
|
||||
*
|
||||
* @apiGroup User
|
||||
* @apiVersion 1.0.0
|
||||
* @apiSampleRequest http://warlogin.shanggame.com/auth/rest/pwd
|
||||
*
|
||||
* @apiParam {String} captcha 手机收到的验证码
|
||||
* @apiParam {String} password 需要重置的新密码
|
||||
*
|
||||
* @apiSuccess {int} feedback 响应状态 0 为成功
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* { "feedback": 0 }
|
||||
*/
|
||||
|
||||
@At("/rest/pwd")
|
||||
@Ok("json")
|
||||
@POST
|
||||
public NutMap restpwd(HttpServletRequest req) throws OAuthSystemException {
|
||||
HttpSession session = req.getSession();
|
||||
Object phoneCodeObj = session.getAttribute(PHONE_KEY);
|
||||
Object nameObj = session.getAttribute(OAUTH_USER_KEY);
|
||||
if (Lang.isEmpty(phoneCodeObj) || Lang.isEmpty(nameObj)) {
|
||||
return NutMap.NEW().addv("feedback", 404);
|
||||
}
|
||||
NutMap parames = CommonUtils.getRequestParametersMap(req);
|
||||
int captcha = parames.getInt("captcha",0);
|
||||
String pwd = parames.getString("password");
|
||||
String name = Castors.me().castToString(nameObj);
|
||||
int phoneCode = Castors.me().castTo(phoneCodeObj,int.class);
|
||||
if (StringUtils.isBlank(pwd) || captcha!=phoneCode) {
|
||||
return NutMap.NEW().addv("feedback", 1);
|
||||
}
|
||||
|
||||
OAuthIssuerImpl oauthIssuerImpl = new OAuthIssuerImpl(new MD5Generator());
|
||||
String authorizationCode = oauthIssuerImpl.authorizationCode();
|
||||
oAuthService.addAuthCode(authorizationCode, name);
|
||||
oAuthUserService.updateByChain(name, pwd);
|
||||
session.setAttribute(PHONE_KEY, null);
|
||||
session.setAttribute(OAUTH_USER_KEY, null);
|
||||
return NutMap.NEW().addv("feedback", 0).addv("code", authorizationCode);
|
||||
}
|
||||
|
||||
private boolean checkOauthUser(String name) {
|
||||
if (CommonUtils.isUsername(name) && StringUtils.isNotBlank(name) && Lang.isEmpty(oAuthUserService.findByUsername(name))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /auth/phone/captcha 获取手机验证码
|
||||
*
|
||||
* @apiGroup User
|
||||
* @apiVersion 1.0.0
|
||||
* @apiSampleRequest http://warlogin.shanggame.com/auth/phone/captcha
|
||||
*
|
||||
* @apiParam {Number} phone 手机号
|
||||
* @apiParam {Number} pid 引用所属游戏平台编号
|
||||
*
|
||||
* @apiSuccess {int} feedback 响应状态 0 为成功, 100手机号非法, 101未注册的游戏平台
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* { "feedback": 0 }
|
||||
*/
|
||||
|
||||
@At("/phone/captcha")
|
||||
@Ok("raw:json")
|
||||
@POST
|
||||
public String regCaptcha(@Param("phone") String phone, @Param("pid") int pid, HttpSession session) {
|
||||
if (!NumberUtils.isNumber(phone) || phone.length() != 11) {
|
||||
return "{\"feedback\":100}";
|
||||
}
|
||||
GameServer gameServer = gameServerService.getByPid(pid);
|
||||
if (Lang.isEmpty(gameServer)) {
|
||||
return "{\"feedback\":101}";
|
||||
}
|
||||
int code = CommonUtils.nextInt(1000, 9999);
|
||||
boolean isRight = gameServerService.sendPhoneMail(gameServer, phone, "29337", code + "", "30");
|
||||
if (isRight) {
|
||||
session.setAttribute(PHONE_KEY, code);
|
||||
session.setAttribute(PHONE_NUMBER, phone);
|
||||
return "{\"feedback\":0,\"session\":\"" + session.getId() + "\"}";
|
||||
}
|
||||
return "{\"feedback\":102}";
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /auth/rest/captcha 获取手机验证码-密码重置
|
||||
*
|
||||
* @apiGroup User
|
||||
* @apiVersion 1.0.0
|
||||
* @apiSampleRequest http://warlogin.shanggame.com/auth/rest/captcha
|
||||
*
|
||||
* @apiParam {String} name 用户名
|
||||
* @apiParam {Number} phone 手机号
|
||||
* @apiParam {Number} pid 引用所属游戏平台编号
|
||||
*
|
||||
* @apiSuccess {int} feedback 响应状态 0 为成功, 100手机号非法, 101未注册的游戏平台
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* { "feedback": 0 }
|
||||
*/
|
||||
|
||||
@At("/rest/captcha")
|
||||
@Ok("raw:json")
|
||||
@POST
|
||||
public String restCaptcha(@Param("phone") String phone, @Param("name") String name, @Param("pid") int pid, HttpSession session) {
|
||||
if (!NumberUtils.isNumber(phone) || phone.length() != 11) {
|
||||
return "{\"feedback\":100}";
|
||||
}
|
||||
GameServer gameServer = gameServerService.getByPid(pid);
|
||||
if (Lang.isEmpty(gameServer)) {
|
||||
return "{\"feedback\":101}";
|
||||
}
|
||||
boolean isOk = oAuthUserService.checkRestPwd(name, NumberUtils.toLong(phone));
|
||||
if (isOk) {
|
||||
int code = CommonUtils.nextInt(100000, 999999);
|
||||
boolean isRight = gameServerService.sendPhoneMail(gameServer, phone, "29337", code + "", "30");
|
||||
if (isRight) {
|
||||
session.setAttribute(PHONE_KEY, code);
|
||||
session.setAttribute(OAUTH_USER_KEY, name);
|
||||
return "{\"feedback\":0,\"session\":\"" + session.getId() + "\"}";
|
||||
}
|
||||
}
|
||||
return "{\"feedback\":102}";
|
||||
}
|
||||
|
||||
@Inject
|
||||
private PlatformUserService platformUserService;
|
||||
|
||||
@Inject
|
||||
private PlatformProviderFactory platformProviderFactory;
|
||||
|
||||
@Inject
|
||||
private IdWorkerService idFactory;
|
||||
|
||||
private final Object obj = new Object();
|
||||
|
||||
/**
|
||||
* @api {post} /auth/account/bind 账号绑定
|
||||
*
|
||||
* @apiGroup User
|
||||
* @apiVersion 1.0.0
|
||||
* @apiSampleRequest http://warlogin.shanggame.com/auth/account/bind
|
||||
*
|
||||
* @apiParam {String} name 用户名
|
||||
* @apiParam {String} password 密码
|
||||
* @apiParam {Number} pid 引用所属游戏平台编号
|
||||
* @apiParam {String} captcha 手机收到的验证码
|
||||
* @apiParam {String} guestid 需要绑定的游客ID
|
||||
*
|
||||
* @apiSuccess {int} feedback 响应状态 0 为成功, 100手机号非法, 101未注册的游戏平台
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* { "feedback": 0 }
|
||||
*/
|
||||
|
||||
@At("/account/bind")
|
||||
@Ok("json")
|
||||
@POST
|
||||
public NutMap bindAccount(HttpServletRequest req) {
|
||||
HttpSession session = req.getSession();
|
||||
Object phoneCodeObj = session.getAttribute(PHONE_KEY);
|
||||
Object phoneObj = session.getAttribute(PHONE_NUMBER);
|
||||
if (Lang.isEmpty(phoneCodeObj) || Lang.isEmpty(phoneObj)) {
|
||||
return NutMap.NEW().addv("feedback", 404);
|
||||
}
|
||||
NutMap parames = CommonUtils.getRequestParametersMap(req);
|
||||
int pid = parames.getInt("pid", -1);
|
||||
String pwd = parames.getString("password");
|
||||
if (StringUtils.isBlank(pwd)) {
|
||||
return NutMap.NEW().addv("feedback", 501).addv("msg", "密码不可以为空");
|
||||
}
|
||||
int captcha = parames.getInt("captcha", 0);
|
||||
int phoneCode = Castors.me().castTo(phoneCodeObj, int.class);
|
||||
if (captcha != phoneCode) {
|
||||
return NutMap.NEW().addv("feedback", 502).addv("msg", "验证码错误");
|
||||
}
|
||||
String guestid = parames.getString("guestid");
|
||||
if (StringUtils.isBlank(guestid)) {
|
||||
return NutMap.NEW().addv("feedback", 503).addv("msg", "游客ID不可以为空");
|
||||
}
|
||||
PlatformUser platformUser = platformUserService.getPlatformUser(pid, guestid, Constants.GUEST);
|
||||
if (Lang.isEmpty(platformUser)) {
|
||||
return NutMap.NEW().addv("feedback", 405).addv("msg", "未找到此游客记录");
|
||||
}
|
||||
long phone = Castors.me().castTo(phoneObj, long.class);
|
||||
String name = parames.getString("name");
|
||||
if (checkOauthUser(name)) {
|
||||
// 创建账号
|
||||
long newOpenid = idFactory.nextId();
|
||||
synchronized (obj) {
|
||||
OAuthUser user = new OAuthUser();
|
||||
user.setPhoneCode(phone);
|
||||
user.setPassword(pwd);
|
||||
user.setUserName(name);
|
||||
user.setBind(true);
|
||||
user.setBindProviderId(platformUser.getPfid());
|
||||
user = oAuthUserService.createUser(user, platformUser.getOpenid());
|
||||
platformUser.setOpenid(newOpenid);
|
||||
platformUserService.update(Chain.make("openid", newOpenid), Cnd.where("id", "=", platformUser.getId()));
|
||||
session.setAttribute(PHONE_KEY, null);
|
||||
session.setAttribute(PHONE_NUMBER, null);
|
||||
}
|
||||
} else {
|
||||
return NutMap.NEW().addv("feedback", 504).addv("msg", "账号已被占用");
|
||||
}
|
||||
return NutMap.NEW().addv("feedback", 0);
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package com.rekoe.module;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.By;
|
||||
import org.nutz.mvc.annotation.Filters;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.POST;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import com.rekoe.domain.ReportAds;
|
||||
import com.rekoe.filter.OauthCrossOriginFilter;
|
||||
import com.rekoe.service.ReportAdsService;
|
||||
|
||||
@At("/report")
|
||||
@IocBean
|
||||
@Filters(@By(type = OauthCrossOriginFilter.class))
|
||||
public class ReportAdsModule {
|
||||
|
||||
@Inject
|
||||
private ReportAdsService reportAdsService;
|
||||
|
||||
/**
|
||||
* @api {POST} /report/ads 数据汇报
|
||||
* @apiSampleRequest http://warlogin.shanggame.com/report/ads
|
||||
* @apiGroup report
|
||||
* @apiVersion 1.0.0
|
||||
*
|
||||
*
|
||||
* @apiParam {Number} pid 申请的游戏编号
|
||||
* @apiParam {String} pfid 接入的平台编号
|
||||
* @apiParam {String} idfa idfa
|
||||
* @apiParam {String} idfv idfv
|
||||
* @apiParam {String} talkingDataId talkingDataId
|
||||
*
|
||||
* @apiSuccess {json} msg OK
|
||||
*
|
||||
*/
|
||||
|
||||
@At
|
||||
@Ok("raw:json")
|
||||
@POST
|
||||
public String ads(@Param("pid") int pid, @Param("pfid") String pfid, @Param("idfa") String idfa,
|
||||
@Param("idfv") String idfv, @Param("talkingDataId") String talkingDataId) {
|
||||
reportAdsService.add(new ReportAds(pid, pfid, idfa, idfv, talkingDataId));
|
||||
return "{\"msg\":\"ok\"}";
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package com.rekoe.module;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Status implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7767253096192148313L;
|
||||
private int code;
|
||||
|
||||
private String msg;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
package com.rekoe.module;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Streams;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.By;
|
||||
import org.nutz.mvc.annotation.Filters;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import com.rekoe.filter.OauthCrossOriginFilter;
|
||||
|
||||
@IocBean
|
||||
@At("/api/v2")
|
||||
@Filters(@By(type = OauthCrossOriginFilter.class))
|
||||
public class Test {
|
||||
|
||||
/**
|
||||
* @api {POST} /api/v2/hello/:id
|
||||
* @apiGroup Account
|
||||
* @apiVersion 1.0.3
|
||||
* @apiDescription just a test
|
||||
* @apiPermission anyone
|
||||
* @apiSampleRequest http://106.2.185.120:8080/api/v2/hello/:id
|
||||
*
|
||||
* @apiParam {String} name object
|
||||
* @apiParam {Number} age object
|
||||
* @apiSuccess {json} result User object
|
||||
*
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* { "firstname": "test", lastname": "sails", "country":"cn" }
|
||||
*
|
||||
* @apiParamExample {json} Request
|
||||
* { "firstname": "test", "lastname": "sails", "country":"cn" }
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @api {POST} /api/v2/hello/:id
|
||||
* @apiGroup Account
|
||||
* @apiVersion 1.0.4
|
||||
* @apiDescription just a test
|
||||
* @apiPermission anyone
|
||||
* @apiSampleRequest http://106.2.185.120:8080/api/v2/hello/:id
|
||||
*
|
||||
* @apiParam {String} name object
|
||||
* @apiParam {Number} age object
|
||||
* @apiSuccess {json} result User object
|
||||
*
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* { "firstname": "test", lastname": "sails", "country":"cn" }
|
||||
*
|
||||
* @apiParamExample {json} Request
|
||||
* { "firstname": "test", "lastname": "sails", "country":"cn" }
|
||||
*
|
||||
*/
|
||||
@At("/hello/?")
|
||||
@Ok("raw:json")
|
||||
public String hello(long id,InputStream is) throws IOException {
|
||||
System.out.println(id);
|
||||
Reader reader = Streams.utf8r(is);
|
||||
return Streams.readAndClose(reader);
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
package com.rekoe.module;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.oltu.oauth2.common.OAuth;
|
||||
import org.apache.oltu.oauth2.common.error.OAuthError;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
|
||||
import org.apache.oltu.oauth2.common.message.OAuthResponse;
|
||||
import org.apache.oltu.oauth2.common.message.types.ParameterStyle;
|
||||
import org.apache.oltu.oauth2.common.utils.OAuthUtils;
|
||||
import org.apache.oltu.oauth2.rs.request.OAuthAccessResourceRequest;
|
||||
import org.apache.oltu.oauth2.rs.response.OAuthRSResponse;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.By;
|
||||
import org.nutz.mvc.annotation.Filters;
|
||||
import org.nutz.mvc.annotation.GET;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import com.rekoe.domain.OAuthUser;
|
||||
import com.rekoe.filter.OauthCrossOriginFilter;
|
||||
import com.rekoe.service.OAuthService;
|
||||
import com.rekoe.service.OAuthUserService;
|
||||
import com.rekoe.utils.Constants;
|
||||
|
||||
@IocBean
|
||||
@At("/v1/openapi")
|
||||
public class UserInfoAction {
|
||||
|
||||
@Inject
|
||||
private OAuthService oAuthService;
|
||||
|
||||
@Inject
|
||||
private OAuthUserService oAuthUserService;
|
||||
|
||||
/**
|
||||
* @api {get} /v1/openapi/userinfo 获取账号详细
|
||||
*@apiSampleRequest http://warlogin.shanggame.com/v1/openapi/userinfo
|
||||
* @apiGroup User
|
||||
* @apiVersion 1.0.0
|
||||
*
|
||||
*
|
||||
* @apiParam {String} access_token 为上一步获取的access_token
|
||||
*
|
||||
* @apiSuccess {long} uid 用户id
|
||||
* @apiSuccess {String} name 用户名
|
||||
* @apiSuccess {boolean} [locked] 是否锁定
|
||||
*
|
||||
*/
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@GET
|
||||
@Filters(@By(type = OauthCrossOriginFilter.class))
|
||||
public Object userinfo(HttpServletRequest request, HttpServletResponse res) throws OAuthSystemException, OAuthProblemException {
|
||||
return checkAccessToken(request, res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 不校验accessToken
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @throws OAuthSystemException
|
||||
* @throws OAuthProblemException
|
||||
*/
|
||||
public OAuthUser nocheckAccessToken(HttpServletRequest request) throws OAuthSystemException, OAuthProblemException {
|
||||
// 构建OAuth资源请求
|
||||
OAuthAccessResourceRequest oauthRequest = new OAuthAccessResourceRequest(request, ParameterStyle.QUERY);
|
||||
// 获取Access Token
|
||||
String accessToken = oauthRequest.getAccessToken();
|
||||
// 获取用户名
|
||||
String username = oAuthService.getUsernameByAccessToken(accessToken);
|
||||
OAuthUser user = oAuthUserService.findByUsername(username);
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验accessToken
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @throws OAuthSystemException
|
||||
*/
|
||||
private Object checkAccessToken(HttpServletRequest request, HttpServletResponse res) throws OAuthSystemException {
|
||||
try {
|
||||
// 构建OAuth资源请求
|
||||
OAuthAccessResourceRequest oauthRequest = new OAuthAccessResourceRequest(request, ParameterStyle.QUERY);
|
||||
// 获取Access Token
|
||||
String accessToken = oauthRequest.getAccessToken();
|
||||
// 验证Access Token
|
||||
if (!oAuthService.checkAccessToken(accessToken)) {
|
||||
// 如果不存在/过期了,返回未验证错误,需重新验证
|
||||
OAuthResponse oauthResponse = OAuthRSResponse.errorResponse(HttpServletResponse.SC_UNAUTHORIZED).setRealm(Constants.RESOURCE_SERVER_NAME).setError(OAuthError.ResourceResponse.INVALID_TOKEN).buildHeaderMessage();
|
||||
res.addHeader("Content-Type", "application/json; charset=utf-8");
|
||||
Status status = new Status();
|
||||
status.setCode(Constants.HTTPSTATUS_UNAUTHORIZED);
|
||||
status.setMsg(Constants.INVALID_ACCESS_TOKEN);
|
||||
res.setStatus(oauthResponse.getResponseStatus());
|
||||
return status;
|
||||
}
|
||||
// 获取用户名
|
||||
String username = oAuthService.getUsernameByAccessToken(accessToken);
|
||||
OAuthUser user = oAuthUserService.findByUsername(username);
|
||||
return user;
|
||||
} catch (OAuthProblemException e) {
|
||||
// 检查是否设置了错误码
|
||||
String errorCode = e.getError();
|
||||
if (OAuthUtils.isEmpty(errorCode)) {
|
||||
OAuthResponse oauthResponse = OAuthRSResponse.errorResponse(HttpServletResponse.SC_UNAUTHORIZED).setRealm(Constants.RESOURCE_SERVER_NAME).buildHeaderMessage();
|
||||
res.addHeader(OAuth.HeaderType.WWW_AUTHENTICATE, oauthResponse.getHeader(OAuth.HeaderType.WWW_AUTHENTICATE));
|
||||
res.setStatus(Constants.HTTPSTATUS_UNAUTHORIZED);
|
||||
return null;
|
||||
}
|
||||
OAuthResponse oauthResponse = OAuthRSResponse.errorResponse(HttpServletResponse.SC_UNAUTHORIZED).setRealm(Constants.RESOURCE_SERVER_NAME).setError(e.getError()).setErrorDescription(e.getDescription()).setErrorUri(e.getUri()).buildHeaderMessage();
|
||||
res.addHeader(OAuth.HeaderType.WWW_AUTHENTICATE, oauthResponse.getHeader(OAuth.HeaderType.WWW_AUTHENTICATE));
|
||||
res.setStatus(Constants.HTTPSTATUS_BAD_REQUEST);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import com.rekoe.annotation.PermissionTag;
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.service.PlatformUserService;
|
||||
|
||||
@IocBean
|
||||
@At("/admin/app/account")
|
||||
public class AdminAccountAct {
|
||||
|
||||
@Inject
|
||||
private PlatformUserService platformUserService;
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.app.account.list")
|
||||
@RequiresPermissions({ "app.account:view" })
|
||||
@PermissionTag(name = "账号浏览", tag = "平台用户", enable = true)
|
||||
public Pagination list(@Param(value = "pageNumber", df = "1") Integer pageNumber, @Param("keyword") String keyword, @Param("type") int type, HttpServletRequest req) {
|
||||
req.setAttribute("keyword", keyword);
|
||||
req.setAttribute("type", type);
|
||||
switch (type) {
|
||||
case 1:
|
||||
return platformUserService.getPlatformUserListPagerByPid(pageNumber, 20, keyword);
|
||||
default:
|
||||
return platformUserService.getPlatformUserListPagerByOpenid(pageNumber, 20, NumberUtils.toLong(keyword));
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions({ "app.account:lock" })
|
||||
@PermissionTag(name = "账号锁定", tag = "平台用户", enable = true)
|
||||
public Message lock(@Param("id") String id, @Param("lock") boolean lock, HttpServletRequest req) {
|
||||
platformUserService.lock(id, lock);
|
||||
return Message.success("admin.message.success", req);
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.entity.Record;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import com.rekoe.annotation.PermissionTag;
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.CdkeyCategory;
|
||||
import com.rekoe.module.BaseAction;
|
||||
import com.rekoe.service.CdKeyCategoryService;
|
||||
import com.rekoe.service.CdKeyService;
|
||||
|
||||
@IocBean
|
||||
@At("/admin/cdkey/")
|
||||
public class AdminCdKeyCategoryAct extends BaseAction {
|
||||
|
||||
@Inject
|
||||
private CdKeyCategoryService cdKeyCategoryService;
|
||||
@Inject
|
||||
private CdKeyService cdKeyService;
|
||||
|
||||
@At("/category/list")
|
||||
@Ok("fm:template.admin.cdkey.category_list")
|
||||
@RequiresPermissions("system.cdkey:category.view")
|
||||
@PermissionTag(name = "分类浏览", tag = "CDK分类", enable = true)
|
||||
public Pagination category_list(@Param(value = "pageNumber", df = "1") int pageNumber) {
|
||||
return cdKeyCategoryService.getCategoryListByPager(pageNumber);
|
||||
}
|
||||
|
||||
@At("/category/add")
|
||||
@Ok("fm:template.admin.cdkey.category_add")
|
||||
@RequiresPermissions("system.cdkey:category.add")
|
||||
@PermissionTag(name = "添加分类", tag = "CDK分类", enable = true)
|
||||
public void category_add() {
|
||||
}
|
||||
|
||||
@At("/category/save")
|
||||
@Ok("json")
|
||||
@RequiresPermissions("system.cdkey:category.add")
|
||||
@PermissionTag(name = "添加分类", tag = "CDK分类", enable = false)
|
||||
public Message category_save(@Param("name") String name, @Param("type") int type, HttpServletRequest req) {
|
||||
if (cdKeyCategoryService.isNotExists(type)) {
|
||||
cdKeyCategoryService.insert(new CdkeyCategory(name, type));
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
return Message.error("error.type.exists", req);
|
||||
}
|
||||
|
||||
@At("/category/edit")
|
||||
@Ok("fm:template.admin.cdkey.category_edit")
|
||||
@RequiresPermissions("system.cdkey:category.edit")
|
||||
@PermissionTag(name = "编辑分类", tag = "CDK分类", enable = true)
|
||||
public CdkeyCategory category_edit(@Param("id") String id) {
|
||||
return cdKeyCategoryService.fetchByID(id);
|
||||
}
|
||||
|
||||
@At("/category/update")
|
||||
@Ok("json")
|
||||
@RequiresPermissions("system.cdkey:category.edit")
|
||||
@PermissionTag(name = "编辑分类", tag = "CDK分类", enable = false)
|
||||
public Message category_update(@Param("::cc.") CdkeyCategory cc, HttpServletRequest req) {
|
||||
cdKeyCategoryService.update(cc);
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.cdkey.add")
|
||||
@RequiresPermissions("system.cdkey:add")
|
||||
@PermissionTag(name = "添加CDK", tag = "CDK", enable = true)
|
||||
public String add(@Param("type") String type, HttpServletRequest req) {
|
||||
req.setAttribute("rule", type.length());
|
||||
return type;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("system.cdkey:add")
|
||||
@PermissionTag(name = "添加CDK", tag = "CDK", enable = false)
|
||||
public Message save(@Param("type") String taskid, @Param("num") int num, @Param("len") int len, HttpServletRequest req) {
|
||||
if ((taskid).length() > len) {
|
||||
return Message.error("长度不能小于" + taskid.length(), req);
|
||||
}
|
||||
cdKeyService.addCdkey(taskid, num, len);
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("down")
|
||||
@RequiresPermissions("system.cdkey:down")
|
||||
@PermissionTag(name = "下载CDK", tag = "CDK", enable = true)
|
||||
public ByteArrayOutputStream down(@Param("type") int type) throws IOException {
|
||||
List<Record> records = cdKeyService.searchDown(type, false);
|
||||
return loadDown(records);
|
||||
}
|
||||
}
|
|
@ -1,165 +0,0 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresUser;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Attr;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.web.Webs;
|
||||
|
||||
import com.rekoe.annotation.PermissionTag;
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.common.PlatformVO;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.AuthType;
|
||||
import com.rekoe.domain.GameServer;
|
||||
import com.rekoe.domain.User;
|
||||
import com.rekoe.service.GameServerService;
|
||||
import com.rekoe.service.UserService;
|
||||
|
||||
@IocBean(create = "init")
|
||||
@At("/admin/server")
|
||||
public class AdminGameServerAct {
|
||||
|
||||
@Inject
|
||||
private GameServerService gameServerService;
|
||||
|
||||
@Inject
|
||||
private UserService userService;
|
||||
|
||||
private List<PlatformVO> authTypeList = new ArrayList<>();
|
||||
|
||||
public void init() {
|
||||
authTypeList.add(new PlatformVO(AuthType.TOKEN.getDisplay(), AuthType.TOKEN.getDisplay()));
|
||||
authTypeList.add(new PlatformVO(AuthType.DEFAULT.getDisplay(), AuthType.DEFAULT.getDisplay()));
|
||||
authTypeList.add(new PlatformVO(AuthType.QQ_HTML5.getDisplay(), AuthType.QQ_HTML5.getDisplay()));
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.server.list")
|
||||
@RequiresPermissions("server:view")
|
||||
@PermissionTag(name = "应用浏览", tag = "游戏应用", enable = true)
|
||||
public Pagination list(@Param(value = "pageNumber", df = "1") int pageNumber) {
|
||||
return gameServerService.getObjectListByPager(pageNumber, 20);
|
||||
}
|
||||
|
||||
@At("/change/?")
|
||||
@Ok("json")
|
||||
@RequiresUser
|
||||
public Message select(@Param("id") int id, @Attr(Webs.ME) User user, HttpServletRequest req, HttpSession session) {
|
||||
GameServer server = user.getServers().get(id);
|
||||
if (!Lang.isEmpty(server)) {
|
||||
session.setAttribute("sid", id);
|
||||
return Message.success("button.submit.success", req);
|
||||
}
|
||||
return Message.error("admin.message.error", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.server.add")
|
||||
@RequiresPermissions("server:add")
|
||||
@PermissionTag(name = "添加应用", tag = "游戏应用", enable = true)
|
||||
public List<PlatformVO> add() {
|
||||
return authTypeList;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("server:add")
|
||||
@PermissionTag(name = "添加应用", tag = "游戏应用", enable = false)
|
||||
public Message o_save(@Param("::p.") GameServer server, HttpServletRequest req, @Param("..") NutMap map) {
|
||||
if (gameServerService.canAdd(server.getPid())) {
|
||||
gameServerService.insert(server);
|
||||
return Message.success("button.submit.success", req);
|
||||
}
|
||||
Iterator<Entry<String, Object>> iterator = map.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entry<String, Object> entry = iterator.next();
|
||||
String key = entry.getKey();
|
||||
if (key.startsWith("p.")) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
server.setMobileAuth(map);
|
||||
return Message.error("admin.message.error", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.server.edit")
|
||||
@RequiresPermissions("server:edit")
|
||||
@PermissionTag(name = "编辑应用", tag = "游戏应用", enable = true)
|
||||
public GameServer edit(@Param("id") int id, HttpServletRequest request) throws Throwable {
|
||||
GameServer server = gameServerService.getServer(id);
|
||||
if (Lang.isEmpty(server)) {
|
||||
throw new Throwable();
|
||||
}
|
||||
request.setAttribute("authTypes", authTypeList);
|
||||
return server;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok(">>:/admin/game_server/list")
|
||||
@RequiresPermissions("server:edit")
|
||||
@PermissionTag(name = "编辑应用", tag = "游戏应用", enable = false)
|
||||
public void update(@Param("::server.") GameServer server, @Param("..") NutMap map) {
|
||||
gameServerService.update(server);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.server.servers_edit")
|
||||
@RequiresUser
|
||||
public void v_servers_edit(@Param("id") long id, HttpServletRequest request) {
|
||||
User user = userService.view(id);
|
||||
List<Integer> list = gameServerService.getAllIds();
|
||||
List<GameServer> servers = new ArrayList<GameServer>();
|
||||
for (Integer iid : list) {
|
||||
GameServer server = gameServerService.getServer(iid.intValue());
|
||||
if (!Lang.isEmpty(server)) {
|
||||
servers.add(server);
|
||||
}
|
||||
}
|
||||
List<Integer> userServeridList = new ArrayList<Integer>();
|
||||
Map<Integer, GameServer> serverMap = user.getServers();
|
||||
if (!Lang.isEmpty(serverMap)) {
|
||||
Iterator<Integer> userlist = serverMap.keySet().iterator();
|
||||
while (userlist.hasNext()) {
|
||||
int serverid = userlist.next();
|
||||
userServeridList.add(serverid);
|
||||
}
|
||||
}
|
||||
request.setAttribute("serverList", servers);
|
||||
request.setAttribute("serverIds", userServeridList);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("server:add")
|
||||
@PermissionTag(name = "添加应用", tag = "游戏应用", enable = false)
|
||||
public Message o_update(@Param("::p.") GameServer server, HttpServletRequest req, @Param("..") NutMap map) {
|
||||
Iterator<Entry<String, Object>> iterator = map.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entry<String, Object> entry = iterator.next();
|
||||
String key = entry.getKey();
|
||||
if (key.startsWith("p.")) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
server.setMobileAuth(map);
|
||||
gameServerService.update(server);
|
||||
return Message.success("button.submit.success", req);
|
||||
}
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresUser;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Files;
|
||||
import org.nutz.lang.Times;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Fail;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.POST;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
import org.nutz.mvc.upload.UploadAdaptor;
|
||||
import org.nutz.mvc.view.HttpStatusView;
|
||||
|
||||
import com.rekoe.annotation.PermissionTag;
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.GameServer;
|
||||
import com.rekoe.domain.Notice;
|
||||
import com.rekoe.service.GameServerService;
|
||||
import com.rekoe.service.NoticeService;
|
||||
|
||||
/**
|
||||
* @author 科技㊣²º¹³<br />
|
||||
* 2014年2月3日 下午4:48:45<br />
|
||||
* http://www.rekoe.com<br />
|
||||
* QQ:5382211 <br />
|
||||
* 公告系统
|
||||
*/
|
||||
@IocBean
|
||||
@At("/admin/notice")
|
||||
public class AdminNoticeAct {
|
||||
|
||||
@Inject
|
||||
private NoticeService noticeService;
|
||||
|
||||
@Inject
|
||||
private GameServerService gameServerService;
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.notice.list")
|
||||
@RequiresPermissions("system.notice")
|
||||
@PermissionTag(name = "浏览公告", tag = "游戏公告", enable = false)
|
||||
public Pagination list(@Param(value = "pageNumber", df = "1") int pageNumber) {
|
||||
return noticeService.getObjListByPager(pageNumber, 20, null);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.notice.add")
|
||||
@RequiresPermissions("system.notice:add")
|
||||
@PermissionTag(name = "添加公告", tag = "游戏公告", enable = true)
|
||||
public List<GameServer> add() {
|
||||
return gameServerService.list();
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("system.notice:add")
|
||||
@PermissionTag(name = "添加公告", tag = "游戏公告", enable = false)
|
||||
public Message save(@Param("::notice.") Notice notice, HttpServletRequest req) {
|
||||
Date now = Times.now();
|
||||
notice.setCreateDate(now);
|
||||
notice.setModifyDate(now);
|
||||
noticeService.insert(notice);
|
||||
return Message.success("button.submit.success", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.notice.edit")
|
||||
@RequiresPermissions("system.notice:edit")
|
||||
@PermissionTag(name = "编辑公告", tag = "游戏公告", enable = true)
|
||||
public List<GameServer> edit(long id, HttpServletRequest req) {
|
||||
Notice art = noticeService.fetch(id);
|
||||
req.setAttribute("notice", art);
|
||||
return gameServerService.list();
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("system.notice:edit")
|
||||
@PermissionTag(name = "编辑公告", tag = "游戏公告", enable = false)
|
||||
public Message update(@Param("::notice.") Notice notice, HttpServletRequest req) {
|
||||
notice.setModifyDate(Times.now());
|
||||
noticeService.update(notice);
|
||||
return Message.success("button.submit.success", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("system.notice:delete")
|
||||
@PermissionTag(name = "删除公告", tag = "游戏公告", enable = true)
|
||||
public Message delete(@Param("id") long id, HttpServletRequest req) {
|
||||
noticeService.delete(id);
|
||||
return Message.success("button.submit.success", req);
|
||||
}
|
||||
|
||||
@Inject("java:$conf.get('topic.image.dir')")
|
||||
protected String imageDir;
|
||||
private final static String NEWS_FILE_PATH = "/upload/notice/";
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@AdaptBy(type = UploadAdaptor.class, args = { "${app.root}/WEB-INF/tmp2" })
|
||||
@POST
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresUser
|
||||
public Object upload(@Param("file") TempFile tmp, HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||||
resp.setContentType("application/json");
|
||||
NutMap jsonrpc = new NutMap();
|
||||
if (tmp == null || tmp.getSize() == 0) {
|
||||
return jsonrpc.setv("msg", "空文件");
|
||||
}
|
||||
if (tmp.getSize() > 2 * 1024 * 1024) {
|
||||
return jsonrpc.setv("msg", "文件太大了");
|
||||
}
|
||||
String id = R.UU32();
|
||||
String path = "/" + id.substring(0, 2) + "/" + id.substring(2);
|
||||
File f = new File(imageDir + NEWS_FILE_PATH + path);
|
||||
Files.createNewFile(f);
|
||||
Files.copyFile(tmp.getFile(), f);
|
||||
jsonrpc.setv("url", req.getRequestURI() + path);
|
||||
jsonrpc.setv("success", true);
|
||||
return jsonrpc;
|
||||
}
|
||||
|
||||
@Ok("raw:jpg")
|
||||
@At("/upload/?/?")
|
||||
@Fail("http:404")
|
||||
public Object image(String p, String p2) throws IOException {
|
||||
if ((p + p2).contains("."))
|
||||
return HttpStatusView.HTTP_404;
|
||||
File f = new File(imageDir + NEWS_FILE_PATH, p + "/" + p2);
|
||||
return f;
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.POST;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import com.rekoe.annotation.PermissionTag;
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.OAuthClient;
|
||||
import com.rekoe.service.OAuthClientService;
|
||||
|
||||
@IocBean
|
||||
@At("/admin/oauth/client")
|
||||
public class AdminOauthClientAct {
|
||||
|
||||
@Inject
|
||||
private OAuthClientService oAuthClientService;
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.oauth_client.list")
|
||||
@RequiresPermissions({ "oauth.client:view" })
|
||||
@PermissionTag(name = "浏览", tag = "OauthClient", enable = true)
|
||||
public Pagination list(@Param(value = "pageNumber", df = "1") int page) {
|
||||
return oAuthClientService.getListPager(page);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.oauth_client.add")
|
||||
@PermissionTag(name = "添加", tag = "OauthClient", enable = true)
|
||||
@RequiresPermissions({ "oauth.client:add" })
|
||||
public void add() {
|
||||
}
|
||||
|
||||
@At
|
||||
@POST
|
||||
@Ok("json")
|
||||
@RequiresPermissions({ "oauth.client:add" })
|
||||
@PermissionTag(name = "浏览", tag = "OauthClient", enable = false)
|
||||
public Message o_save(@Param("::client.") OAuthClient client, HttpServletRequest req) {
|
||||
if (StringUtils.isBlank(client.getClientName())) {
|
||||
return Message.error("error.code.name.empty", req);
|
||||
}
|
||||
if (oAuthClientService.check(client.getClientName())) {
|
||||
oAuthClientService.createClient(client);
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
/** 被占用 **/
|
||||
return Message.error("error.code.name.occupied", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.oauth_client.edit")
|
||||
@RequiresPermissions({ "oauth.client:edit" })
|
||||
@PermissionTag(name = "编辑", tag = "OauthClient", enable = true)
|
||||
public OAuthClient edit(@Param("id") long id) {
|
||||
return oAuthClientService.findOne(id);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@POST
|
||||
@RequiresPermissions({ "oauth.client:edit" })
|
||||
@PermissionTag(name = "编辑", tag = "OauthClient", enable = false)
|
||||
public Message o_update(@Param("::client.") OAuthClient client, HttpServletRequest req) {
|
||||
oAuthClientService.updateClient(client);
|
||||
return Message.success("OK", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@POST
|
||||
@Ok("json")
|
||||
@RequiresPermissions({ "oauth.client:delete" })
|
||||
@PermissionTag(name = "删除", tag = "OauthClient", enable = true)
|
||||
public Message delete(long id, HttpServletRequest req) {
|
||||
oAuthClientService.deleteClient(id);
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.POST;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import com.rekoe.annotation.PermissionTag;
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.OAuthUser;
|
||||
import com.rekoe.service.OAuthUserService;
|
||||
|
||||
@IocBean
|
||||
@At("/admin/oauth/user")
|
||||
public class AdminOauthUserAct {
|
||||
|
||||
@Inject
|
||||
private OAuthUserService oAuthUserService;
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.oauth_user.list")
|
||||
@RequiresPermissions({ "oauth.user:view" })
|
||||
@PermissionTag(name = "浏览", tag = "OauthUser", enable = true)
|
||||
public Pagination list(@Param(value = "pageNumber", df = "1") int page) {
|
||||
return oAuthUserService.getListPager(page);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.oauth_user.edit")
|
||||
@RequiresPermissions({ "oauth.user:edit" })
|
||||
@PermissionTag(name = "浏览", tag = "OauthUser", enable = true)
|
||||
public OAuthUser edit(@Param("id") long id) {
|
||||
return oAuthUserService.findOne(id);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@POST
|
||||
@RequiresPermissions({ "oauth.user:edit" })
|
||||
@PermissionTag(name = "浏览", tag = "OauthUser", enable = false)
|
||||
public Message o_update(@Param("::user.") OAuthUser user, HttpServletRequest req) {
|
||||
//oAuthUserService.updateUser(user);
|
||||
return Message.success("OK", req);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresUser;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.mvc.Scope;
|
||||
import org.nutz.mvc.View;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Attr;
|
||||
import org.nutz.mvc.annotation.By;
|
||||
import org.nutz.mvc.annotation.Filters;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.view.ViewWrapper;
|
||||
import org.nutz.plugins.view.freemarker.FreeMarkerConfigurer;
|
||||
import org.nutz.plugins.view.freemarker.FreemarkerView;
|
||||
import org.nutz.web.Webs;
|
||||
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.GameServer;
|
||||
import com.rekoe.domain.OfficialServer;
|
||||
import com.rekoe.domain.User;
|
||||
import com.rekoe.domain.VerifyServer;
|
||||
import com.rekoe.filter.ChectServerExitsActionFilter;
|
||||
import com.rekoe.filter.SelectServerActionFilter;
|
||||
import com.rekoe.service.GameServerService;
|
||||
import com.rekoe.service.OfficialServerService;
|
||||
import com.rekoe.service.VerifyServerService;
|
||||
|
||||
@IocBean
|
||||
@At("/admin/official_server")
|
||||
public class AdminOfficialAct {
|
||||
|
||||
@Inject
|
||||
private VerifyServerService verifyServerService;
|
||||
|
||||
@Inject
|
||||
private OfficialServerService officialServerService;
|
||||
|
||||
@Inject
|
||||
private FreeMarkerConfigurer freeMarkerConfigurer;
|
||||
|
||||
@Inject
|
||||
private GameServerService gameServerService;
|
||||
|
||||
@At
|
||||
@Filters(@By(type = SelectServerActionFilter.class, args = { "ioc:selectServerActionFilter" }))
|
||||
public View view(@Attr(scope = Scope.SESSION, value = Webs.ME) User user, @Param("pid") int pid) {
|
||||
VerifyServer verifyServer = verifyServerService.fetch(Cnd.where("pid", "=", pid));
|
||||
GameServer server = gameServerService.fetch(Cnd.where("pid", "=", pid));
|
||||
if (Lang.isEmpty(server)) {
|
||||
throw Lang.makeThrow("Not Fond PID[%s] Server", pid);
|
||||
}
|
||||
GameServer userServer = user.getServers().get(server.getId());
|
||||
if (Lang.isEmpty(userServer)) {
|
||||
throw Lang.makeThrow("You Not Have This Server[%s] Permission ", server.getPlatformName());
|
||||
}
|
||||
if (Lang.isEmpty(verifyServer)) {
|
||||
return new ViewWrapper(new FreemarkerView(freeMarkerConfigurer, "template/admin/game_server/server/verify/add"), server);
|
||||
}
|
||||
verifyServer.setGameServer(server);
|
||||
return new ViewWrapper(new FreemarkerView(freeMarkerConfigurer, "template/admin/game_server/server/verify/edit"), verifyServer);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
//@Filters(@By(type = SelectServerActionFilter.class, args = { "ioc:selectServerActionFilter" }))
|
||||
@RequiresUser
|
||||
public Message o_save(@Attr(scope = Scope.SESSION, value = "sid") int sid, @Param("::p.") OfficialServer vserver, HttpServletRequest req) {
|
||||
GameServer gameServer = gameServerService.fetch(sid);
|
||||
OfficialServer verifyServer = officialServerService.fetch(Cnd.where("pid", "=", gameServer.getPid()).and("sid", "=", vserver.getSid()));
|
||||
if (!Lang.isEmpty(verifyServer)) {
|
||||
throw Lang.makeThrow("Not Fond PID[%s] Server", vserver.getPid());
|
||||
}
|
||||
vserver.setPid(gameServer.getPid());
|
||||
boolean isRight = officialServerService.insert(vserver);
|
||||
if (isRight) {
|
||||
return Message.success("button.submit.success", req);
|
||||
}
|
||||
return Message.error("admin.message.error", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@Filters(@By(type = SelectServerActionFilter.class, args = { "ioc:selectServerActionFilter" }))
|
||||
public Message o_update(@Param("::p.") OfficialServer vserver, HttpServletRequest req) {
|
||||
OfficialServer verifyServer = officialServerService.fetch(Cnd.where("pid", "=", vserver.getPid()));
|
||||
if (Lang.isEmpty(verifyServer)) {
|
||||
throw Lang.makeThrow("Not Fond PID[%s] Server", vserver.getPid());
|
||||
}
|
||||
officialServerService.update(vserver);
|
||||
return Message.success("button.submit.success", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.server.official.list")
|
||||
@Filters(@By(type = ChectServerExitsActionFilter.class, args = { "ioc:chectServerExitsActionFilter" }))
|
||||
public Pagination list(@Attr(scope = Scope.SESSION, value = "sid") int sid, @Param("pageNumber") Integer pageNumber) {
|
||||
GameServer gameServer = gameServerService.fetch(sid);
|
||||
return list_view(gameServer.getPid(), pageNumber);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.server.official.list_view")
|
||||
@Filters(@By(type = ChectServerExitsActionFilter.class, args = { "ioc:chectServerExitsActionFilter" }))
|
||||
public Pagination list_view(@Param("pid") int pid, @Param(value="pageNumber",df="1") Integer pageNumber) {
|
||||
return officialServerService.getObjListByPager(pageNumber, Cnd.where("pid", "=", pid).desc("sid"));
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.server.official.add")
|
||||
@RequiresUser
|
||||
public void add() {
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.server.official.edit")
|
||||
@RequiresUser
|
||||
public OfficialServer edit(@Param("id") String id) {
|
||||
return officialServerService.fetch(Cnd.where("id", "=", id));
|
||||
}
|
||||
}
|
|
@ -1,185 +0,0 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.Mvcs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.By;
|
||||
import org.nutz.mvc.annotation.Filters;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import com.rekoe.annotation.PermissionTag;
|
||||
import com.rekoe.common.AppleVO;
|
||||
import com.rekoe.common.GooglePVO;
|
||||
import com.rekoe.common.GoogleVO;
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.PlatformConfig;
|
||||
import com.rekoe.filter.ServerPermisionActionFilter;
|
||||
import com.rekoe.service.PlatformConfigService;
|
||||
|
||||
@IocBean
|
||||
@At("/admin/platform_config")
|
||||
@Filters(@By(type = ServerPermisionActionFilter.class, args = { "ioc:serverPermisionActionFilter" }))
|
||||
public class AdminPlatformConfigAction {
|
||||
|
||||
@Inject
|
||||
private PlatformConfigService platformConfigService;
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.server.platform.list")
|
||||
@RequiresPermissions("admin.platform")
|
||||
@PermissionTag(name = "浏览列表", tag = "平台接入", enable = false)
|
||||
public Pagination list(@Param("platformid") int sid, @Param(value = "pageNumber", df = "1") int pageNumber) {
|
||||
Mvcs.getReq().setAttribute("platformid", sid);
|
||||
return platformConfigService.getListByPager(pageNumber, sid);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.server.platform.add")
|
||||
@RequiresPermissions("admin.platform:add")
|
||||
@PermissionTag(name = "添加平台", tag = "平台接入", enable = true)
|
||||
public int add(@Param("platformid") int sid) {
|
||||
return sid;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.server.platform.edit")
|
||||
@RequiresPermissions("admin.platform:edit")
|
||||
@PermissionTag(name = "编辑平台", tag = "平台接入")
|
||||
public PlatformConfig edit(@Param("platformid") int sid, @Param("id") String id) {
|
||||
return platformConfigService.fetch(Cnd.where("id", "=", id));
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.server.platform.${obj}.add_${obj}")
|
||||
@RequiresPermissions("admin.platform")
|
||||
@PermissionTag(name = "浏览列表", tag = "平台接入", enable = false)
|
||||
public String add_view(@Param("platformid") int sid, @Param(value = "provider", df = "uc") String provider) {
|
||||
Mvcs.getReq().setAttribute("platformid", sid);
|
||||
return provider;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("admin.platform:add")
|
||||
@PermissionTag(name = "添加平台", tag = "平台接入", enable = false)
|
||||
public Message o_save(@Param("platformid") int sid, @Param("..") NutMap map, HttpServletRequest req) {
|
||||
PlatformConfig platformConfig = platformConfigService.fetch(Cnd.where("sid", "=", sid).and("provider", "=", map.getString("provider")));
|
||||
if (Lang.isEmpty(platformConfig)) {
|
||||
platformConfigService.insert(new PlatformConfig(sid, map));
|
||||
} else {
|
||||
return Message.error("duplate.data", req);
|
||||
}
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("admin.platform:edit")
|
||||
@PermissionTag(name = "编辑平台", tag = "平台接入", enable = false)
|
||||
public Message o_update(@Param("platformid") int sid, @Param("id") String id, @Param("..") NutMap map, HttpServletRequest req) {
|
||||
map.remove("platformid");
|
||||
map.remove("id");
|
||||
PlatformConfig platformConfig = platformConfigService.fetch(Cnd.where("id", "=", id));
|
||||
platformConfig.setConfig(map);
|
||||
platformConfigService.update(platformConfig);
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
@At("/googleP/o_update")
|
||||
@Ok("json")
|
||||
@RequiresPermissions("admin.platform:edit")
|
||||
@PermissionTag(name = "编辑平台", tag = "平台接入", enable = false)
|
||||
public Message google_play_update(@Param("platformid") int sid, @Param("id") String id, @Param("::p.") GooglePVO googlePVO, HttpServletRequest req) {
|
||||
PlatformConfig platformConfig = platformConfigService.fetch(Cnd.where("id", "=", id));
|
||||
platformConfig.setConfig(Lang.obj2nutmap(googlePVO));
|
||||
platformConfigService.update(platformConfig);
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
@At("/googleP/o_save")
|
||||
@Ok("json")
|
||||
@RequiresPermissions("admin.platform:add")
|
||||
@PermissionTag(name = "添加平台", tag = "平台接入", enable = false)
|
||||
public Message google_play_save(@Param("platformid") int sid, @Param("provider") String provider, @Param("::p.") GooglePVO googlePVO, HttpServletRequest req) {
|
||||
PlatformConfig platformConfig = platformConfigService.fetch(Cnd.where("sid", "=", sid).and("provider", "=", provider));
|
||||
if (Lang.isEmpty(platformConfig)) {
|
||||
NutMap map = Lang.obj2nutmap(googlePVO);
|
||||
map.put("provider", provider);
|
||||
platformConfigService.insert(new PlatformConfig(sid, map));
|
||||
} else {
|
||||
return Message.error("duplate.data", req);
|
||||
}
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
/**
|
||||
* google
|
||||
*/
|
||||
|
||||
@At("/google/o_update")
|
||||
@Ok("json")
|
||||
@RequiresPermissions("admin.platform:edit")
|
||||
@PermissionTag(name = "编辑平台", tag = "平台接入", enable = false)
|
||||
public Message google_update(@Param("platformid") int sid, @Param("id") String id, @Param("::p.") GoogleVO googleVO, HttpServletRequest req) {
|
||||
PlatformConfig platformConfig = platformConfigService.fetch(Cnd.where("id", "=", id));
|
||||
platformConfig.setConfig(Lang.obj2nutmap(googleVO));
|
||||
platformConfigService.update(platformConfig);
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
@At("/google/o_save")
|
||||
@Ok("json")
|
||||
@RequiresPermissions("admin.platform:add")
|
||||
@PermissionTag(name = "添加平台", tag = "平台接入", enable = false)
|
||||
public Message google_save(@Param("platformid") int sid, @Param("provider") String provider, @Param("::p.") GoogleVO googleVO, HttpServletRequest req) {
|
||||
PlatformConfig platformConfig = platformConfigService.fetch(Cnd.where("sid", "=", sid).and("provider", "=", provider));
|
||||
if (Lang.isEmpty(platformConfig)) {
|
||||
NutMap map = Lang.obj2nutmap(googleVO);
|
||||
map.put("provider", provider);
|
||||
platformConfigService.insert(new PlatformConfig(sid, map));
|
||||
} else {
|
||||
return Message.error("duplate.data", req);
|
||||
}
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
/**
|
||||
* apple
|
||||
*/
|
||||
|
||||
@At("/apple/o_update")
|
||||
@Ok("json")
|
||||
@RequiresPermissions("admin.platform:edit")
|
||||
@PermissionTag(name = "编辑平台", tag = "平台接入", enable = false)
|
||||
public Message apple_update(@Param("platformid") int sid, @Param("id") String id, @Param("::p.") AppleVO appleVO, HttpServletRequest req) {
|
||||
PlatformConfig platformConfig = platformConfigService.fetch(Cnd.where("id", "=", id));
|
||||
platformConfig.setConfig(Lang.obj2nutmap(appleVO));
|
||||
platformConfigService.update(platformConfig);
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
@At("/apple/o_save")
|
||||
@Ok("json")
|
||||
@RequiresPermissions("admin.platform:add")
|
||||
@PermissionTag(name = "添加平台", tag = "平台接入", enable = false)
|
||||
public Message apple_save(@Param("platformid") int sid, @Param("provider") String provider, @Param("::p.") AppleVO appleVO, HttpServletRequest req) {
|
||||
PlatformConfig platformConfig = platformConfigService.fetch(Cnd.where("sid", "=", sid).and("provider", "=", provider));
|
||||
if (Lang.isEmpty(platformConfig)) {
|
||||
NutMap map = Lang.obj2nutmap(appleVO);
|
||||
map.put("provider", provider);
|
||||
platformConfigService.insert(new PlatformConfig(sid, map));
|
||||
} else {
|
||||
return Message.error("duplate.data", req);
|
||||
}
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Attr;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.web.Webs;
|
||||
|
||||
import com.rekoe.annotation.PermissionTag;
|
||||
import com.rekoe.domain.GameServer;
|
||||
import com.rekoe.domain.User;
|
||||
import com.rekoe.module.BaseAction;
|
||||
import com.rekoe.service.GameServerService;
|
||||
import com.rekoe.service.ReportAdsService;
|
||||
|
||||
@IocBean
|
||||
@At("/admin/report/ads")
|
||||
public class AdminReportAdsAct extends BaseAction {
|
||||
|
||||
@Inject
|
||||
private ReportAdsService reportAdsService;
|
||||
|
||||
@Inject
|
||||
private GameServerService gameServerService;
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.report.ads.search")
|
||||
@RequiresPermissions({ "report:ads" })
|
||||
@PermissionTag(name = "设备号汇报搜索", tag = "数据统计")
|
||||
public Collection<GameServer> search(@Attr(Webs.ME) User user) {
|
||||
return user.getServers().values();
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("down")
|
||||
@RequiresPermissions({ "report:ads.down" })
|
||||
@PermissionTag(name = "设备号数据下载", tag = "数据统计")
|
||||
public ByteArrayOutputStream down(@Param("pid") int pid) throws IOException {
|
||||
return loadDown(reportAdsService.getList(pid));
|
||||
}
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
@ -33,10 +31,8 @@ import com.alibaba.druid.util.DruidWebUtils;
|
|||
import com.rekoe.annotation.PermissionTag;
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.GameServer;
|
||||
import com.rekoe.domain.Role;
|
||||
import com.rekoe.domain.User;
|
||||
import com.rekoe.service.GameServerService;
|
||||
import com.rekoe.service.RoleService;
|
||||
import com.rekoe.service.UserService;
|
||||
|
||||
|
@ -55,9 +51,6 @@ public class AdminUserAct {
|
|||
@Inject
|
||||
private RoleService roleService;
|
||||
|
||||
@Inject
|
||||
private GameServerService gameServerService;
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.common.main")
|
||||
@RequiresAuthentication
|
||||
|
@ -132,12 +125,6 @@ public class AdminUserAct {
|
|||
if (isSupper) {
|
||||
roleList = roleService.list();
|
||||
}
|
||||
List<GameServer> serverList = gameServerService.loadAll();
|
||||
int systemSize = serverList.size();
|
||||
int userSize = editUser.getServers().size();
|
||||
boolean allServer = userSize >= systemSize;
|
||||
req.setAttribute("allServer", allServer);
|
||||
req.setAttribute("serverList", serverList);
|
||||
req.setAttribute("roleList", roleList);
|
||||
return editUser;
|
||||
}
|
||||
|
@ -148,28 +135,6 @@ public class AdminUserAct {
|
|||
public Object update(@Param("id") long id, @Param("allServer") Boolean allServer, @Param("serverIds") Integer[] serverIds, @Param("roleIds") Integer[] roleIds) {
|
||||
User user = userService.fetch(id);
|
||||
userService.removeUserUpdata(user);
|
||||
allServer = user.isSystem() ? true : allServer;
|
||||
if (allServer) {
|
||||
List<GameServer> serverList = gameServerService.loadAll();
|
||||
Map<Integer, GameServer> serverMap = user.getServers();
|
||||
if (Lang.isEmpty(serverMap)) {
|
||||
serverMap = new HashMap<>();
|
||||
user.setServers(serverMap);
|
||||
}
|
||||
for (GameServer server : serverList) {
|
||||
serverMap.put(server.getId(), server);
|
||||
}
|
||||
} else {
|
||||
List<GameServer> serverList = gameServerService.loadAllByIds(serverIds);
|
||||
Map<Integer, GameServer> serverMap = user.getServers();
|
||||
if (Lang.isEmpty(serverMap)) {
|
||||
serverMap = new HashMap<>();
|
||||
user.setServers(serverMap);
|
||||
}
|
||||
for (GameServer server : serverList) {
|
||||
serverMap.put(server.getId(), server);
|
||||
}
|
||||
}
|
||||
user.setRoles(roleService.loadRoles(roleIds));
|
||||
userService.insertRelations(user);
|
||||
return user;
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresUser;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.mvc.View;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Attr;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.view.ViewWrapper;
|
||||
import org.nutz.plugins.view.freemarker.FreeMarkerConfigurer;
|
||||
import org.nutz.plugins.view.freemarker.FreemarkerView;
|
||||
import org.nutz.web.Webs;
|
||||
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.domain.GameServer;
|
||||
import com.rekoe.domain.User;
|
||||
import com.rekoe.domain.VerifyServer;
|
||||
import com.rekoe.service.GameServerService;
|
||||
import com.rekoe.service.VerifyServerService;
|
||||
|
||||
/**
|
||||
* 提审服务器配置
|
||||
* @author kouxian
|
||||
*
|
||||
*/
|
||||
@IocBean
|
||||
@At("/admin/verify")
|
||||
public class AdminVerifyAct {
|
||||
|
||||
@Inject
|
||||
private VerifyServerService verifyServerService;
|
||||
|
||||
@Inject
|
||||
private FreeMarkerConfigurer freeMarkerConfigurer;
|
||||
|
||||
@Inject
|
||||
private GameServerService gameServerService;
|
||||
|
||||
@At
|
||||
@RequiresUser
|
||||
public View view(@Attr(Webs.ME) User user, @Param("pid") int pid) {
|
||||
VerifyServer verifyServer = verifyServerService.fetch(Cnd.where("pid", "=", pid));
|
||||
GameServer server = gameServerService.fetch(Cnd.where("pid", "=", pid));
|
||||
if (Lang.isEmpty(server)) {
|
||||
throw Lang.makeThrow("Not Fond PID[%s] Server", pid);
|
||||
}
|
||||
GameServer userServer = user.getServers().get(server.getId());
|
||||
if (Lang.isEmpty(userServer)) {
|
||||
throw Lang.makeThrow("You Not Have This Server[%s] Permission ", server.getPlatformName());
|
||||
}
|
||||
if (Lang.isEmpty(verifyServer)) {
|
||||
return new ViewWrapper(new FreemarkerView(freeMarkerConfigurer, "template/admin/server/verify/add"), server);
|
||||
}
|
||||
verifyServer.setGameServer(server);
|
||||
return new ViewWrapper(new FreemarkerView(freeMarkerConfigurer, "template/admin/server/verify/edit"), verifyServer);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresUser
|
||||
public Message o_save(@Param("::p.") VerifyServer vserver, HttpServletRequest req) {
|
||||
VerifyServer verifyServer = verifyServerService.fetch(Cnd.where("pid", "=", vserver.getPid()));
|
||||
if (!Lang.isEmpty(verifyServer)) {
|
||||
throw Lang.makeThrow("Not Fond PID[%s] Server", vserver.getPid());
|
||||
}
|
||||
vserver.setPid(vserver.getPid());
|
||||
boolean isRight = verifyServerService.insert(vserver);
|
||||
if (isRight) {
|
||||
return Message.success("button.submit.success", req);
|
||||
}
|
||||
return Message.error("admin.message.error", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresUser
|
||||
public Message o_update(@Param("::p.") VerifyServer vserver, HttpServletRequest req) {
|
||||
VerifyServer verifyServer = verifyServerService.fetch(Cnd.where("pid", "=", vserver.getPid()));
|
||||
if (Lang.isEmpty(verifyServer)) {
|
||||
throw Lang.makeThrow("Not Fond PID[%s] Server", vserver.getPid());
|
||||
}
|
||||
verifyServerService.update(vserver);
|
||||
return Message.success("button.submit.success", req);
|
||||
}
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.impl.PropertiesProxy;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import com.rekoe.annotation.PermissionTag;
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.PayRefund;
|
||||
import com.rekoe.domain.PlatformUser;
|
||||
import com.rekoe.module.facebook.pay.Order;
|
||||
import com.rekoe.service.PayFefundService;
|
||||
import com.rekoe.service.PlatformUserService;
|
||||
import com.restfb.Parameter;
|
||||
import com.restfb.batch.BatchRequest;
|
||||
import com.restfb.batch.BatchRequest.BatchRequestBuilder;
|
||||
import com.restfb.batch.BatchResponse;
|
||||
|
||||
@IocBean
|
||||
@At("/admin/pay_refund")
|
||||
public class PayRefundAct {
|
||||
|
||||
private final static Log log = Logs.get();
|
||||
/**
|
||||
* /PAYMENT_ID/refunds
|
||||
*/
|
||||
@Inject
|
||||
private PayFefundService payFefundService;
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.pay_refund.list")
|
||||
@RequiresPermissions("admin.pay:refund")
|
||||
@PermissionTag(name = "退单管理", tag = "退单管理", enable = true)
|
||||
public Pagination list(@Param(value = "pageNumber", df = "1") Integer pageNumber) {
|
||||
return payFefundService.getPayRefundListByPager(pageNumber);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.pay_refund.view")
|
||||
@RequiresPermissions("admin.pay:refund")
|
||||
@PermissionTag(name = "退单管理", tag = "退单管理", enable = false)
|
||||
public Order view(@Param("id") String id, @Param("appid") String appid, HttpServletRequest req) throws Exception {
|
||||
return edit(id, appid, req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.pay_refund.edit")
|
||||
@RequiresPermissions("admin.pay:refund")
|
||||
@PermissionTag(name = "退单管理", tag = "退单管理", enable = false)
|
||||
public Order edit(@Param("id") String id, @Param("appid") String appid, HttpServletRequest req) throws Exception {
|
||||
req.setAttribute("appid", appid);
|
||||
return Json.fromJson(Order.class, payFefundService.facebookFetch(id));
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("admin.pay:refund")
|
||||
@PermissionTag(name = "退单管理", tag = "退单管理", enable = false)
|
||||
public Message refund(@Param("appid") String appid, @Param("id") String id, @Param("currency") String currency, @Param("amount") String amount, @Param("reason") String reason, HttpServletRequest req) throws Exception {
|
||||
BatchRequest postRequest = new BatchRequestBuilder(id + "/refunds").method("POST").body(Parameter.with("reason", reason), Parameter.with("currency", currency), Parameter.with("amount", amount)).build();
|
||||
List<BatchResponse> list = payFefundService.getFacebookClient().executeBatch(postRequest);
|
||||
BatchResponse res = list.get(0);
|
||||
String result = res.getBody();
|
||||
disputeResult disputeResult = Json.fromJson(disputeResult.class, result);
|
||||
if (!Lang.isEmpty(disputeResult) && disputeResult.isSuccess()) {
|
||||
PayRefund payRefund = payFefundService.fetchByKeyId(appid);
|
||||
payRefund.setStatus(true);
|
||||
payFefundService.update(payRefund);
|
||||
return Message.success("admin.message.success", req);
|
||||
}
|
||||
com.rekoe.module.facebook.pay.Error pay = Json.fromJson(com.rekoe.module.facebook.pay.Error.class, result);
|
||||
return Message.error(pay.getError().getMessage(), req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("admin.pay:refund")
|
||||
@PermissionTag(name = "退单管理", tag = "退单管理", enable = false)
|
||||
public Message dispute(@Param("appid") String appid, @Param("id") String id, @Param("reason") String reason, HttpServletRequest req) throws Exception {
|
||||
BatchRequest postRequest = new BatchRequestBuilder(id + "/dispute").method("POST").body(Parameter.with("reason", reason)).build();
|
||||
List<BatchResponse> list = payFefundService.getFacebookClient().executeBatch(postRequest);
|
||||
BatchResponse res = list.get(0);
|
||||
String result = res.getBody();
|
||||
log.infof("dispute res[%s]", result);
|
||||
disputeResult disputeResult = Json.fromJson(disputeResult.class, result);
|
||||
if (!Lang.isEmpty(disputeResult) && disputeResult.isSuccess()) {
|
||||
PayRefund payRefund = payFefundService.fetchByKeyId(appid);
|
||||
payRefund.setStatus(true);
|
||||
payFefundService.update(payRefund);
|
||||
return Message.success("admin.message.success", req);
|
||||
}
|
||||
com.rekoe.module.facebook.pay.Error pay = Json.fromJson(com.rekoe.module.facebook.pay.Error.class, result);
|
||||
return Message.error(pay.getError().getMessage(), req);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String json = "[{\"success\":true}]";
|
||||
List<disputeResult> rest = Json.fromJsonAsList(disputeResult.class, json);
|
||||
System.out.println(rest.get(0).isSuccess());
|
||||
}
|
||||
|
||||
public static class disputeResult {
|
||||
private boolean success;
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
private PlatformUserService platformUserService;
|
||||
@Inject
|
||||
private PropertiesProxy conf;
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("admin.pay:refund")
|
||||
@PermissionTag(name = "退单管理", tag = "退单管理", enable = false)
|
||||
public Message update(@Param("id") String id, HttpServletRequest req) {
|
||||
PayRefund payRefund = payFefundService.fetchByID(id);
|
||||
if (Lang.isEmpty(payRefund)) {
|
||||
return Message.error("admin.common.error.notfund", req);
|
||||
}
|
||||
String passportid = payRefund.getPassportid();
|
||||
PlatformUser platformUser = platformUserService.getPlatformUser(conf.getInt("facebook.pid"), passportid, conf.get("facebook.pfid"));
|
||||
if (Lang.isEmpty(platformUser)) {
|
||||
return Message.error("admin.common.error.notfund", req);
|
||||
}
|
||||
platformUser.setLocked(true);
|
||||
platformUserService.update(Chain.make("is_locked", true), Cnd.where("id", "=", platformUser.getId()));
|
||||
return Message.success("admin.message.success", req);
|
||||
}
|
||||
}
|
|
@ -1,20 +1,12 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresUser;
|
||||
import org.nutz.castor.Castors;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import com.rekoe.domain.GameServer;
|
||||
import com.rekoe.domain.User;
|
||||
import com.rekoe.module.BaseAction;
|
||||
|
||||
@IocBean
|
||||
|
@ -29,15 +21,6 @@ public class WelcomeAct extends BaseAction {
|
|||
@Ok("fm:template.admin.top")
|
||||
@RequiresUser
|
||||
public boolean top(HttpServletRequest req) {
|
||||
Object obj = SecurityUtils.getSubject().getPrincipal();
|
||||
if (obj instanceof User) {
|
||||
User user = Castors.me().castTo(obj, User.class);
|
||||
Collection<GameServer> servers = Lang.isEmpty(user.getServers()) ? (new ArrayList<GameServer>()) : ((User) obj).getServers().values();
|
||||
req.setAttribute("servers", servers);
|
||||
return Lang.equals("local", user.getProviderid());
|
||||
} else {
|
||||
req.setAttribute("servers", new ArrayList<GameServer>());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,179 +0,0 @@
|
|||
package com.rekoe.module.facebook;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.brickred.socialauth.util.OAuthConfig;
|
||||
import org.nutz.ioc.impl.PropertiesProxy;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Times;
|
||||
import org.nutz.mvc.View;
|
||||
import org.nutz.mvc.adaptor.JsonAdaptor;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.view.ViewWrapper;
|
||||
import org.nutz.mvc.view.VoidView;
|
||||
import org.nutz.plugins.view.freemarker.FreeMarkerConfigurer;
|
||||
import org.nutz.plugins.view.freemarker.FreemarkerView;
|
||||
import org.nutz.web.ajax.Ajax;
|
||||
import org.nutz.web.ajax.AjaxReturn;
|
||||
|
||||
import com.rekoe.domain.OfficialServer;
|
||||
import com.rekoe.domain.PlatformUser;
|
||||
import com.rekoe.domain.ServerHistory;
|
||||
import com.rekoe.module.facebook.pay.PayObject;
|
||||
import com.rekoe.service.IdWorkerService;
|
||||
import com.rekoe.service.OfficialServerService;
|
||||
import com.rekoe.service.PayFefundService;
|
||||
import com.rekoe.service.PlatformUserService;
|
||||
import com.rekoe.service.ServerHistoryService;
|
||||
import com.restfb.DefaultFacebookClient;
|
||||
import com.restfb.FacebookClient;
|
||||
import com.restfb.types.User;
|
||||
|
||||
@IocBean
|
||||
@At("/facebook")
|
||||
public class FaceBookLoginAct {
|
||||
|
||||
public static final String OAUTH_ID = "facebook";
|
||||
private final String FB_URL = "https://apps.facebook.com/";
|
||||
private final String FB_TYPE_USER = "me";
|
||||
@Inject("java:conf.get('facebook.pid')")
|
||||
private static int PLARFORM_ID = 1002;
|
||||
@Inject("java:conf.get('facebook.pfid')")
|
||||
private static String PFID;
|
||||
@Inject("java:conf.get('facebook.namespace')")
|
||||
private static String NAMESPACE;
|
||||
@Inject("java:conf.get('facebook.feed.upstream.url')")
|
||||
private static String FEED_UPSTREAM_URL;
|
||||
@Inject
|
||||
private PlatformUserService platformUserService;
|
||||
|
||||
@Inject
|
||||
private IdWorkerService idFactory;
|
||||
|
||||
@Inject
|
||||
private FreeMarkerConfigurer freeMarkerConfigurer;
|
||||
|
||||
@Inject
|
||||
private ServerHistoryService serverHistoryService;
|
||||
|
||||
@Inject
|
||||
private OfficialServerService officialServerService;
|
||||
|
||||
@Inject
|
||||
private PropertiesProxy conf;
|
||||
@Inject
|
||||
private PayFefundService payFefundService;
|
||||
|
||||
@At
|
||||
public View login(@Param("signed_request") String code, HttpServletRequest req, HttpServletResponse res, HttpSession session) throws Exception {
|
||||
OAuthConfig oAuthConfig = payFefundService.getConfig().getProviderConfig(OAUTH_ID);
|
||||
String appId = oAuthConfig.get_consumerKey();
|
||||
boolean isRight = true;
|
||||
if (StringUtils.isBlank(code)) {
|
||||
isRight = false;
|
||||
}
|
||||
if (isRight) {
|
||||
FacebookSignedRequest facebookSR = FacebookSignedRequest.getFacebookSignedRequest(code, FacebookSignedRequest.class);
|
||||
String accessToken = facebookSR.getOauth_token();
|
||||
if (StringUtils.isBlank(accessToken)) {
|
||||
isRight = false;
|
||||
} else {
|
||||
OfficialServer server = officialServerService.getRecommendServer(PLARFORM_ID);
|
||||
FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
|
||||
User user = facebookClient.fetchObject(FB_TYPE_USER, User.class);
|
||||
PlatformUser platformUser = platformUserService.getPlatformUser(PLARFORM_ID, user.getId(), PFID);
|
||||
if (Lang.isEmpty(platformUser)) {
|
||||
long openid = idFactory.nextId();
|
||||
platformUser = platformUserService.add(PLARFORM_ID, user.getId(), openid, PFID);
|
||||
ServerHistory entity = new ServerHistory(platformUser.getOpenid(), PLARFORM_ID, server.getSid());
|
||||
serverHistoryService.add(entity);
|
||||
req.setAttribute("sid", server.getSid());
|
||||
} else {
|
||||
if (platformUser.isLocked()) {
|
||||
return new ViewWrapper(new FreemarkerView(freeMarkerConfigurer, "template/admin/common/lock"), "");
|
||||
}
|
||||
ServerHistory entity = serverHistoryService.getLastLoginServer(platformUser.getOpenid(), PLARFORM_ID);
|
||||
if (!Lang.isEmpty(entity)) {
|
||||
req.setAttribute("sid", entity.getSid());
|
||||
}
|
||||
}
|
||||
ServerHistory hisroty = serverHistoryService.getLoginServerList(platformUser.getOpenid(), PLARFORM_ID, 1);
|
||||
req.setAttribute("top", server);
|
||||
req.setAttribute("userHistory", hisroty);
|
||||
req.setAttribute("user", user);
|
||||
req.setAttribute("code", code);
|
||||
req.setAttribute("ads", req.getQueryString());
|
||||
req.setAttribute("zone", server);
|
||||
}
|
||||
}
|
||||
if (isRight) {
|
||||
res.addHeader("P3P", "CP=CAO PSA OUR IDC DSP COR ADM DEVi TAIi PSD IVAi IVDi CONi HIS IND CNT");
|
||||
List<OfficialServer> zones = officialServerService.getShowList(PLARFORM_ID);
|
||||
req.setAttribute("zones", zones);
|
||||
req.setAttribute("namespace", NAMESPACE);
|
||||
req.setAttribute("appId", appId);
|
||||
req.setAttribute("feed_upstream_url", FEED_UPSTREAM_URL);
|
||||
return new ViewWrapper(new FreemarkerView(freeMarkerConfigurer, "template/front/zone/in"), zones);
|
||||
} else {
|
||||
String url = "http://www.facebook.com/dialog/oauth?client_id=" + appId + "&scope=email,publish_actions&redirect_uri=" + FB_URL + NAMESPACE + "/?" + req.getQueryString();
|
||||
res.setContentType("text/html");
|
||||
PrintWriter writer = res.getWriter();
|
||||
writer.print("<script> top.location.href='" + url + "'</script>");
|
||||
writer.close();
|
||||
return new VoidView();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/change/?/?")
|
||||
@Ok("json")
|
||||
public AjaxReturn change(int sid, String passportid) {
|
||||
PlatformUser platformUser = platformUserService.getPlatformUser(PLARFORM_ID, passportid, PFID);
|
||||
if (Lang.isEmpty(platformUser)) {
|
||||
return Ajax.fail();
|
||||
}
|
||||
if (platformUser.isLocked()) {
|
||||
return Ajax.fail();
|
||||
}
|
||||
OfficialServer officialServer = officialServerService.getOfficialServer(PLARFORM_ID, sid);
|
||||
if (Lang.isEmpty(officialServer)) {
|
||||
return Ajax.fail();
|
||||
}
|
||||
ServerHistory entity = serverHistoryService.getServerHistory(platformUser.getOpenid(), PLARFORM_ID, sid);
|
||||
if (Lang.isEmpty(entity)) {
|
||||
entity = new ServerHistory(platformUser.getOpenid(), PLARFORM_ID, sid);
|
||||
serverHistoryService.add(entity);
|
||||
} else {
|
||||
entity.setModifyTime(Times.now());
|
||||
serverHistoryService.update(entity);
|
||||
}
|
||||
return Ajax.ok().setData(officialServer);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("redirect:${obj}")
|
||||
public String upstream() {
|
||||
return "https://apps.facebook.com/" + NAMESPACE + "/";
|
||||
}
|
||||
|
||||
@At
|
||||
@AdaptBy(type = JsonAdaptor.class)
|
||||
@Ok("raw")
|
||||
public String refund(PayObject pay, @Param("::hub.") ReFund reFund) {
|
||||
payFefundService.push(pay);
|
||||
if (Lang.isEmpty(reFund)) {
|
||||
return "ok";
|
||||
}
|
||||
return reFund.getChallenge();
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
package com.rekoe.module.facebook;
|
||||
|
||||
import org.nutz.json.Json;
|
||||
public class FacebookSignedRequest {
|
||||
|
||||
private String algorithm;
|
||||
private Long expires;
|
||||
private Long issued_at;
|
||||
private String oauth_token;
|
||||
private Long user_id;
|
||||
private FacebookSignedRequestUser user;
|
||||
|
||||
public static <T extends FacebookSignedRequest> T getFacebookSignedRequest(String signedRequest, Class<T> clazz) throws Exception {
|
||||
String payload = signedRequest.split("[.]", 2)[1];
|
||||
payload = payload.replace("-", "+").replace("_", "/").trim();
|
||||
String jsonString = new String(org.nutz.repo.Base64.decodeFast(payload.getBytes()));
|
||||
return Json.fromJson(clazz, jsonString);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String payload = "eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjE0MDI5MDIwMDAsImlzc3VlZF9hdCI6MTQwMjg5Njk3MSwib2F1dGhfdG9rZW4iOiJDQUFVZVZjb25FWkJrQkFIdFJtdjJOTVpBRUdvU3NGOENzb1lNYlZxZTVmNXRtYU9jRHdGWkF4QklKUHRaQWVYM3JEajlJVmVZVE5OcmJ6SkdaQmhNUU1oRW80enpXUGI2QTlLTnJVWkFXWkFjUjF2S0Y2WGhFdlNmWkJJbUNoSERHOEt4SVhiRlQ0VkNNSEFTZXNoblVnWkFSc3p3R3RqS0hodHJKZlVjM0ZaQkRoT295OGJUeEEzbFpCbG1xRlhaQU44REUyWVA4aUFxcFhWTlB3WkRaRCIsInVzZXIiOnsiY291bnRyeSI6InVzIiwibG9jYWxlIjoiemhfQ04iLCJhZ2UiOnsibWluIjoyMX19LCJ1c2VyX2lkIjoiMTAwMDAxNzI4NTc5ODU4In0";
|
||||
//{"algorithm":"HMAC-SHA256","expires":1402902000,"issued_at":1402896971,"oauth_token":"CAAUeVconEZBkBAHtRmv2NMZAEGoSsF8CsoYMbVqe5f5tmaOcDwFZAxBIJPtZAeX3rDj9IVeYTNNrbzJGZBhMQMhEo4zzWPb6A9KNrUZAWZAcR1vKF6XhEvSfZBImChHDG8KxIXbFT4VCMHASeshnUgZARszwGtjKHhtrJfUc3FZBDhOoy8bTxA3lZBlmqFXZAN8DE2YP8iAqpXVNPwZDZD","user":{"country":"us","locale":"zh_CN","age":{"min":21}},"user_id":"100001728579858"}
|
||||
String jsonString = new String(org.nutz.repo.Base64.decodeFast(payload.getBytes()));
|
||||
System.out.println(jsonString);}
|
||||
public String getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
public void setAlgorithm(String algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
|
||||
public Long getExpires() {
|
||||
return expires;
|
||||
}
|
||||
|
||||
public void setExpires(Long expires) {
|
||||
this.expires = expires;
|
||||
}
|
||||
|
||||
public Long getIssued_at() {
|
||||
return issued_at;
|
||||
}
|
||||
|
||||
public void setIssued_at(Long issued_at) {
|
||||
this.issued_at = issued_at;
|
||||
}
|
||||
|
||||
public String getOauth_token() {
|
||||
return oauth_token;
|
||||
}
|
||||
|
||||
public void setOauth_token(String oauth_token) {
|
||||
this.oauth_token = oauth_token;
|
||||
}
|
||||
|
||||
public Long getUser_id() {
|
||||
return user_id;
|
||||
}
|
||||
|
||||
public void setUser_id(Long user_id) {
|
||||
this.user_id = user_id;
|
||||
}
|
||||
|
||||
public FacebookSignedRequestUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(FacebookSignedRequestUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public static class FacebookSignedRequestUser {
|
||||
|
||||
private String country;
|
||||
private String locale;
|
||||
private FacebookSignedRequestUserAge age;
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public FacebookSignedRequestUserAge getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(FacebookSignedRequestUserAge age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public static class FacebookSignedRequestUserAge {
|
||||
private int min;
|
||||
private int max;
|
||||
|
||||
public int getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public void setMin(int min) {
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public void setMax(int max) {
|
||||
this.max = max;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package com.rekoe.module.facebook;
|
||||
|
||||
/**
|
||||
* @author 科技㊣²º¹³<br />
|
||||
* 2014年6月15日 下午8:35:20<br />
|
||||
* http://www.rekoe.com<br />
|
||||
* QQ:5382211<br />
|
||||
*/
|
||||
public class ReFund {
|
||||
|
||||
private String challenge;
|
||||
private String mode;
|
||||
private String verify_token;
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(String mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public String getVerify_token() {
|
||||
return verify_token;
|
||||
}
|
||||
|
||||
public void setVerify_token(String verify_token) {
|
||||
this.verify_token = verify_token;
|
||||
}
|
||||
|
||||
public String getChallenge() {
|
||||
return challenge;
|
||||
}
|
||||
|
||||
public void setChallenge(String challenge) {
|
||||
this.challenge = challenge;
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
package com.rekoe.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.pager.Pager;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.CdkeyCategory;
|
||||
|
||||
@IocBean(fields = { "dao" })
|
||||
public class CdKeyCategoryService extends BaseService<CdkeyCategory> {
|
||||
public List<CdkeyCategory> list() {
|
||||
List<CdkeyCategory> list = query(null, null);
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean insert(CdkeyCategory cdkeycategory) {
|
||||
dao().insert(cdkeycategory);
|
||||
return true;
|
||||
}
|
||||
|
||||
public CdkeyCategory fetchByID(String id) {
|
||||
return dao().fetch(getEntityClass(), Cnd.where("id", "=", id));
|
||||
}
|
||||
|
||||
public CdkeyCategory view(String id) {
|
||||
return fetchByID(id);
|
||||
}
|
||||
|
||||
public void update(CdkeyCategory cdkeycategory) {
|
||||
dao().update(cdkeycategory, "(name)$");
|
||||
}
|
||||
|
||||
public boolean isNotExists(int type) {
|
||||
return Lang.isEmpty(dao().fetch(getEntityClass(), Cnd.where("cdkeyType", "=", type)));
|
||||
}
|
||||
|
||||
protected int getPageNumber(Integer pageNumber) {
|
||||
return Lang.isEmpty(pageNumber) ? 1 : pageNumber;
|
||||
}
|
||||
|
||||
public Pagination getCategoryListByPager(Integer pageNumber) {
|
||||
int pageSize = 20;
|
||||
pageNumber = getPageNumber(pageNumber);
|
||||
Pager pager = dao().createPager(pageNumber, pageSize);
|
||||
List<CdkeyCategory> list = dao().query(CdkeyCategory.class, null, pager);
|
||||
pager.setRecordCount(dao().count(CdkeyCategory.class, null));
|
||||
return new Pagination(pageNumber, pageSize, pager.getRecordCount(), list);
|
||||
}
|
||||
|
||||
public boolean isExists(int type) {
|
||||
return !isNotExists(type);
|
||||
}
|
||||
|
||||
private String getDigit(String text) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
Pattern p = Pattern.compile("(\\d+)");
|
||||
Matcher m = p.matcher(text);
|
||||
while (m.find()) {
|
||||
String find = m.group(1);
|
||||
sb.append(find);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public int getType(String cdk) {
|
||||
return NumberUtils.toInt(getDigit(cdk), -1);
|
||||
}
|
||||
|
||||
public boolean isExists(String cdkey) {
|
||||
int type = NumberUtils.toInt(getDigit(cdkey), -1);
|
||||
return !isNotExists(type);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package com.rekoe.service;
|
||||
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import com.rekoe.domain.CdkeyLog;
|
||||
|
||||
@IocBean(fields = { "dao" })
|
||||
public class CdKeyLogService extends BaseService<CdkeyLog> {
|
||||
|
||||
public CdKeyLogService() {
|
||||
}
|
||||
|
||||
public CdKeyLogService(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,197 +0,0 @@
|
|||
package com.rekoe.service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.ConnCallback;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.entity.Record;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.sql.SqlCallback;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Times;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
|
||||
import com.rekoe.domain.CdkeyCategory;
|
||||
import com.rekoe.domain.CdkeyEntity;
|
||||
import com.rekoe.utils.StringGenerator;
|
||||
|
||||
@IocBean(fields = { "dao" }, create = "init")
|
||||
public class CdKeyService extends BaseService<CdkeyEntity> {
|
||||
|
||||
private final static String CDKEY_SUFFIX = "cdkey_";
|
||||
|
||||
private final static Log log = Logs.get();
|
||||
private final Map<String, Boolean> CDKEY_PROCESS_STATUS_ON = new HashMap<String, Boolean>();
|
||||
private Object lock = new Object();
|
||||
|
||||
private ExecutorService executorService;
|
||||
|
||||
public CdKeyService() {
|
||||
}
|
||||
|
||||
public CdKeyService(Dao dao) {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
||||
/**
|
||||
* 修复下表结构
|
||||
*/
|
||||
Sql sql = Sqls.create("select cdkey_type from $table");
|
||||
sql.setEntity(dao().getEntity(CdkeyCategory.class));
|
||||
sql.vars().set("table", sql.getEntity().getTableName());
|
||||
final List<Integer> typeList = new ArrayList<>();
|
||||
sql.setCallback(new SqlCallback() {
|
||||
|
||||
@Override
|
||||
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
|
||||
while (rs.next()) {
|
||||
typeList.add(rs.getInt(1));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
dao().execute(sql);
|
||||
for (int id : typeList) {
|
||||
Daos.migration(dao(), CdkeyEntity.class, true, true, id);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean use(String cdkey, int taskid) {
|
||||
Dao dao = Daos.ext(dao(), taskid);
|
||||
return dao.update(CdkeyEntity.class, Chain.make("is_used", true), Cnd.where("cdkey", "=", cdkey).and("is_used", "=", false)) > 0;
|
||||
}
|
||||
|
||||
public boolean addCdkey(final String taskid, final int num, final int len) {
|
||||
synchronized (lock) {
|
||||
Boolean isRight = CDKEY_PROCESS_STATUS_ON.get(taskid);
|
||||
if (Lang.isEmpty(isRight) || !isRight) {
|
||||
CDKEY_PROCESS_STATUS_ON.put(taskid, true);
|
||||
executorService.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Date now = Times.now();
|
||||
List<String> linkd = new ArrayList<String>();
|
||||
Dao dao = Daos.ext(dao(), taskid);
|
||||
boolean exists = dao.exists(CdkeyEntity.class);
|
||||
Set<String> temp = new HashSet<>();
|
||||
Set<String> set = new HashSet<String>();
|
||||
if (!exists) {
|
||||
dao.create(CdkeyEntity.class, false);
|
||||
} else {
|
||||
Sql sql = Sqls.create("select cdkey from $table");
|
||||
sql.setEntity(dao.getEntity(CdkeyEntity.class));
|
||||
sql.vars().set("table", sql.getEntity().getTableName() + taskid);
|
||||
sql.setCallback(Sqls.callback.strList());
|
||||
dao.execute(sql);
|
||||
List<String> list = sql.getList(String.class);
|
||||
linkd.addAll(list);
|
||||
for (String str : list) {
|
||||
temp.add(str.toLowerCase());
|
||||
}
|
||||
}
|
||||
int count = 0;
|
||||
int safeCount = 0;
|
||||
BlockingQueue<CdkeyEntity> queue = new LinkedBlockingQueue<CdkeyEntity>();
|
||||
StringGenerator sg = new StringGenerator(len, len);
|
||||
while (true) {
|
||||
String key = sg.next();
|
||||
String newStrKey = getRandomStr(key, taskid);
|
||||
if (temp.contains(newStrKey.toLowerCase())) {
|
||||
safeCount++;
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
if (count > num) {
|
||||
break;
|
||||
}
|
||||
if (safeCount > 10000) {
|
||||
break;
|
||||
}
|
||||
set.add(newStrKey);
|
||||
}
|
||||
for (String $key : set) {
|
||||
queue.add(new CdkeyEntity($key, now));
|
||||
linkd.add($key);
|
||||
}
|
||||
List<CdkeyEntity> list = new ArrayList<>();
|
||||
while (true) {
|
||||
if (queue.size() >= 100) {
|
||||
queue.drainTo(list, 100);
|
||||
dao.fastInsert(list);
|
||||
list.clear();
|
||||
} else if (queue.size() != 0) {
|
||||
queue.drainTo(list, 50);
|
||||
dao.fastInsert(list);
|
||||
list.clear();
|
||||
} else {
|
||||
list.clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
CDKEY_PROCESS_STATUS_ON.put(taskid, false);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> cdkTables() {
|
||||
final List<String> tables = new ArrayList<String>();
|
||||
dao().run(new ConnCallback() {
|
||||
@Override
|
||||
public void invoke(java.sql.Connection conn) throws Exception {
|
||||
String showTables = "show tables";
|
||||
java.sql.PreparedStatement ppstat = conn.prepareStatement(showTables);
|
||||
ResultSet rest = ppstat.executeQuery();
|
||||
while (rest.next()) {
|
||||
String table = rest.getString(1);
|
||||
if (StringUtils.contains(table, CDKEY_SUFFIX)) {
|
||||
if (!StringUtils.containsOnly(table, CDKEY_SUFFIX)) {
|
||||
tables.add(table);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return tables;
|
||||
}
|
||||
|
||||
public List<Record> searchDown(int taskid, boolean used) {
|
||||
Dao dao = Daos.ext(dao(), taskid);
|
||||
Sql sql = Sqls.create("select * from $table $condition");
|
||||
sql.setEntity(dao.getEntity(CdkeyEntity.class));
|
||||
sql.vars().set("table", sql.getEntity().getTableName() + taskid);
|
||||
sql.setCondition(used ? Cnd.where("used", "=", true) : null);
|
||||
sql.setCallback(Sqls.callback.records());
|
||||
dao.execute(sql);
|
||||
return sql.getList(Record.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,179 +0,0 @@
|
|||
package com.rekoe.service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.ehcache.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.nutz.aop.interceptor.async.Async;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Condition;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.sql.SqlCallback;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
|
||||
import com.cloopen.rest.sdk.CCPRestSDK;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.GameServer;
|
||||
import com.rekoe.domain.OAuthUser;
|
||||
|
||||
@IocBean(args = { "refer:dao" })
|
||||
public class GameServerService extends BaseService<GameServer> {
|
||||
|
||||
private final static Log log = Logs.get();
|
||||
|
||||
private ConcurrentHashMap<Integer, CCPRestSDK> ccpSDKMaps = new ConcurrentHashMap<Integer, CCPRestSDK>(5);
|
||||
|
||||
public GameServerService() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Async
|
||||
public boolean sendPhoneMail(GameServer server, OAuthUser user, String templateId, String... str) {
|
||||
boolean isRight = sendPhoneMail(server, user.getPhoneCode() + "", templateId, str);
|
||||
return isRight;
|
||||
}
|
||||
|
||||
public boolean sendPhoneMail(GameServer server, String phone, String templateId, String ...str) {
|
||||
int pid = server.getPid();
|
||||
CCPRestSDK temp = ccpSDKMaps.get(pid);
|
||||
if (Lang.isEmpty(temp)) {
|
||||
NutMap config = server.getMobileAuth();
|
||||
String accountSid = config.getString("accountSid","");
|
||||
String accountToken = config.getString("accountToken","");
|
||||
String AppId = config.getString("AppId");
|
||||
String serverIP = config.getString("serverIP");
|
||||
String serverPort = config.getString("serverPort");
|
||||
CCPRestSDK restAPI = new CCPRestSDK();
|
||||
restAPI.init(serverIP, serverPort);
|
||||
restAPI.setAccount(accountSid, accountToken);
|
||||
restAPI.setAppId(AppId);
|
||||
ccpSDKMaps.putIfAbsent(pid, restAPI);
|
||||
}
|
||||
CCPRestSDK restAPI = ccpSDKMaps.get(pid);
|
||||
if (!Lang.isEmpty(restAPI) && server.isUseMobileAuth()) {
|
||||
//Map<String, Object> result = restAPI.sendTemplateSMS("13691366833", "29337", new String[]{"91366","30"});
|
||||
Map<String, Object> result = restAPI.sendTemplateSMS(phone, templateId, str);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(result);
|
||||
}
|
||||
String res = result.get("statusCode").toString();
|
||||
boolean isRight = "000000".equalsIgnoreCase(res);
|
||||
return isRight;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String accountSid = "aaf98f894ecd7d6a014ed7b7ccd30fbb";
|
||||
String accountToken = "9951c6eacb424918a36e2c6d4185c491";
|
||||
String AppId = "aaf98f894ecd7d6a014ed7bb0e8d0fce";
|
||||
String serverIP = "app.cloopen.com";
|
||||
String serverPort = "8883";
|
||||
CCPRestSDK restAPI = new CCPRestSDK();
|
||||
restAPI.init(serverIP, serverPort);
|
||||
restAPI.setAccount(accountSid, accountToken);
|
||||
restAPI.setAppId(AppId);
|
||||
//Map<String, Object> result = restAPI.sendTemplateSMS("13810275348", "29337", new String[]{"91366","30"});
|
||||
Map<String, Object> result = restAPI.sendTemplateSMS("13691366833", "29337", new String[]{"91366","30"});
|
||||
System.out.println(result);
|
||||
}
|
||||
public GameServerService(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
public List<GameServer> list(Condition cdn) {
|
||||
List<GameServer> list = query(cdn, null);
|
||||
return list;
|
||||
}
|
||||
|
||||
public void update(GameServer server) {
|
||||
if (server.getItems() == null) {
|
||||
server.setItems(new ArrayList<String>());
|
||||
}
|
||||
if (server.isUseMobileAuth()) {
|
||||
NutMap config = server.getMobileAuth();
|
||||
String accountSid = config.getString("accountSid");
|
||||
String accountToken = config.getString("accountToken");
|
||||
String AppId = config.getString("AppId");
|
||||
String serverIP = config.getString("serverIP");
|
||||
String serverPort = config.getString("serverPort");
|
||||
CCPRestSDK restAPI = new CCPRestSDK();
|
||||
restAPI.init(serverIP, serverPort);
|
||||
// restAPI.init("app.cloopen.com", "8883");
|
||||
restAPI.setAccount(accountSid, accountToken);
|
||||
restAPI.setAppId(AppId);
|
||||
ccpSDKMaps.putIfAbsent(server.getPid(), restAPI);
|
||||
}
|
||||
dao().update(server, "(platformName|open|payUrl|loginUrl|version|verify|blackOpen|blackList|clientSecret|authType|mobileAuth)$");
|
||||
}
|
||||
|
||||
public boolean insert(GameServer server) {
|
||||
return super.insert(server);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得所有的服务器ID
|
||||
*/
|
||||
public List<Integer> getAllIds() {
|
||||
Dao dao = dao();
|
||||
Sql sql = Sqls.create("select id from system_server $condition");
|
||||
sql.setCondition(Cnd.where("is_open", "=", true));
|
||||
sql.setCallback(new SqlCallback() {
|
||||
@Override
|
||||
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
|
||||
List<Integer> results = new ArrayList<Integer>();
|
||||
while (rs.next()) {
|
||||
results.add(rs.getInt(1));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
});
|
||||
dao.execute(sql);
|
||||
return sql.getList(Integer.class);
|
||||
}
|
||||
|
||||
public GameServer getServer(int serverid) {
|
||||
GameServer server = dao().fetch(GameServer.class, Cnd.where("id", "=", serverid));
|
||||
return server;
|
||||
}
|
||||
|
||||
public Pagination getObjectListByPager(Integer pageNumber, int pageSize) {
|
||||
return getObjListByPager(dao(), pageNumber, pageSize, null);
|
||||
}
|
||||
|
||||
public List<GameServer> loadAll() {
|
||||
List<GameServer> gss = dao().query(getEntityClass(), Cnd.where("is_open", "=", true));
|
||||
return gss;
|
||||
}
|
||||
|
||||
public List<GameServer> loadAllByIds(Integer[] serverIds) {
|
||||
List<GameServer> gss = dao().query(getEntityClass(), Cnd.where("id", "iN", serverIds));
|
||||
return gss;
|
||||
}
|
||||
|
||||
public boolean canAdd(int pid) {
|
||||
return Lang.isEmpty(dao().fetch(getEntityClass(), Cnd.where("pid", "=", pid)));
|
||||
}
|
||||
|
||||
public GameServer getByPid(int pid) {
|
||||
GameServer server = dao().fetch(getEntityClass(), Cnd.where("pid", "=", pid));
|
||||
return server;
|
||||
}
|
||||
|
||||
public List<GameServer> list() {
|
||||
List<GameServer> gss = dao().query(getEntityClass(), null);
|
||||
return gss;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package com.rekoe.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Condition;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.FieldFilter;
|
||||
import org.nutz.dao.pager.Pager;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.Notice;
|
||||
|
||||
/**
|
||||
* @author 科技㊣²º¹³<br />
|
||||
* 2014年2月3日 下午4:48:45<br />
|
||||
* http://www.rekoe.com<br />
|
||||
* QQ:5382211
|
||||
*/
|
||||
@IocBean(fields = { "dao" })
|
||||
public class NoticeService extends BaseService<Notice> {
|
||||
public NoticeService() {
|
||||
super();
|
||||
}
|
||||
|
||||
public NoticeService(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
public List<Notice> list() {
|
||||
return query(null, null);
|
||||
}
|
||||
|
||||
public List<Notice> getIndexNewList(int limit, String desc) {
|
||||
return getListByCnd(Cnd.NEW().limit(1, limit).desc(desc));
|
||||
}
|
||||
|
||||
public List<Notice> getListByCnd(Condition cnd) {
|
||||
return dao().query(getEntityClass(), cnd);
|
||||
}
|
||||
|
||||
public void update(final Notice art) {
|
||||
Daos.ext(dao(), FieldFilter.create(Notice.class, null, "^(createDate)$", true)).update(art);
|
||||
}
|
||||
|
||||
public Pagination getObjListByPager(int pageNumber, String keyWorld) {
|
||||
Pager pager = dao().createPager(pageNumber, 10);
|
||||
Cnd cnd = Cnd.where("title", "like", "%" + keyWorld + "%");
|
||||
List<Notice> list = dao().query(getEntityClass(), cnd, pager);
|
||||
pager.setRecordCount(dao().count(getEntityClass(), cnd));
|
||||
Pagination pagination = new Pagination(pageNumber, 10, pager.getRecordCount(), list);
|
||||
return pagination;
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package com.rekoe.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.OAuthClient;
|
||||
|
||||
public interface OAuthClientService {
|
||||
|
||||
public OAuthClient createClient(OAuthClient client);
|
||||
|
||||
public OAuthClient updateClient(OAuthClient client);
|
||||
|
||||
public void deleteClient(Long clientId);
|
||||
|
||||
public OAuthClient findOne(Long clientId);
|
||||
|
||||
public List<OAuthClient> findAll();
|
||||
|
||||
public OAuthClient findByClientId(String clientId);
|
||||
|
||||
public OAuthClient findByClientSecret(String clientSecret);
|
||||
|
||||
public Pagination getListPager(int pageNumber);
|
||||
|
||||
public boolean check(String name);
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package com.rekoe.service;
|
||||
|
||||
public interface OAuthService {
|
||||
|
||||
//添加 auth code
|
||||
public void addAuthCode(String authCode, String username);
|
||||
//添加 access token
|
||||
public void addAccessToken(String accessToken, String username);
|
||||
|
||||
//验证auth code是否有效
|
||||
boolean checkAuthCode(String authCode);
|
||||
//验证access token是否有效
|
||||
boolean checkAccessToken(String accessToken);
|
||||
|
||||
String getUsernameByAuthCode(String authCode);
|
||||
String getUsernameByAccessToken(String accessToken);
|
||||
|
||||
|
||||
//auth code / access token 过期时间
|
||||
long getExpireIn();
|
||||
|
||||
|
||||
public boolean checkClientId(String clientId);
|
||||
|
||||
public boolean checkClientSecret(String clientSecret);
|
||||
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package com.rekoe.service;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.repo.cache.simple.LRUCache;
|
||||
|
||||
@IocBean(name = "oAuthService")
|
||||
public class OAuthServiceImpl implements OAuthService {
|
||||
|
||||
private LRUCache<String, String> cache = new LRUCache<String, String>(1024);
|
||||
|
||||
@Inject
|
||||
private OAuthClientService oAuthClientService;
|
||||
|
||||
@Override
|
||||
public void addAuthCode(String authCode, String username) {
|
||||
cache.put(authCode, username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAccessToken(String accessToken, String username) {
|
||||
cache.put(accessToken, username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsernameByAuthCode(String authCode) {
|
||||
return cache.get(authCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsernameByAccessToken(String accessToken) {
|
||||
return cache.get(accessToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkAuthCode(String authCode) {
|
||||
return cache.get(authCode) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkAccessToken(String accessToken) {
|
||||
return cache.get(accessToken) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientId(String clientId) {
|
||||
return oAuthClientService.findByClientId(clientId) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientSecret(String clientSecret) {
|
||||
return oAuthClientService.findByClientSecret(clientSecret) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getExpireIn() {
|
||||
return 3600L;
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package com.rekoe.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.OAuthUser;
|
||||
|
||||
public interface OAuthUserService {
|
||||
/**
|
||||
* 创建用户
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
public OAuthUser createUser(OAuthUser user);
|
||||
public OAuthUser createUser(OAuthUser user, long userid);
|
||||
public OAuthUser updateUser(OAuthUser user);
|
||||
|
||||
public boolean updateByChain(String name, String pwd);
|
||||
|
||||
public void deleteUser(String userId);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param userId
|
||||
* @param newPassword
|
||||
*/
|
||||
public void changePassword(String userId, String newPassword);
|
||||
|
||||
OAuthUser findOne(long userId);
|
||||
|
||||
List<OAuthUser> findAll();
|
||||
|
||||
/**
|
||||
* 根据用户名查找用户
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
public OAuthUser findByUsername(String username);
|
||||
|
||||
/**
|
||||
* 验证登录
|
||||
*
|
||||
* @param username
|
||||
* 用户名
|
||||
* @param password
|
||||
* 密码
|
||||
* @param salt
|
||||
* 盐
|
||||
* @param encryptpwd
|
||||
* 加密后的密码
|
||||
* @return
|
||||
*/
|
||||
boolean checkUser(String username, String password, String salt, String encryptpwd);
|
||||
|
||||
public boolean checkRestPwd(String name, long phone);
|
||||
|
||||
public Pagination getListPager(int pageNumber);
|
||||
public String getRandomCode();
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue