jiapeng 8 years ago
commit
03d5b9b17d
36 changed files with 1634 additions and 0 deletions
  1. 4 0
      .gitignore
  2. 7 0
      config-dev.properties
  3. 7 0
      config-product.properties
  4. 7 0
      config-test-dev.properties
  5. 7 0
      config-test.properties
  6. 138 0
      pom.xml
  7. 14 0
      src/main/java/com/ekexiu/console/basepo/CreateTimeSupported.java
  8. 12 0
      src/main/java/com/ekexiu/console/basepo/DescpSupported.java
  9. 11 0
      src/main/java/com/ekexiu/console/basepo/ModifyTimeSupported.java
  10. 47 0
      src/main/java/com/ekexiu/console/system/dao/RightDao.java
  11. 43 0
      src/main/java/com/ekexiu/console/system/dao/RoleDao.java
  12. 32 0
      src/main/java/com/ekexiu/console/system/dao/SysResourceDao.java
  13. 30 0
      src/main/java/com/ekexiu/console/system/dao/UserConfigDao.java
  14. 59 0
      src/main/java/com/ekexiu/console/system/dao/UserDao.java
  15. 33 0
      src/main/java/com/ekexiu/console/system/dao/UserRoleDao.java
  16. 63 0
      src/main/java/com/ekexiu/console/system/po/Role.java
  17. 92 0
      src/main/java/com/ekexiu/console/system/po/SysResource.java
  18. 46 0
      src/main/java/com/ekexiu/console/system/po/SysRight.java
  19. 129 0
      src/main/java/com/ekexiu/console/system/po/User.java
  20. 38 0
      src/main/java/com/ekexiu/console/system/po/UserConfig.java
  21. 28 0
      src/main/java/com/ekexiu/console/system/po/UserRole.java
  22. 72 0
      src/main/java/com/ekexiu/console/system/service/RightService.java
  23. 134 0
      src/main/java/com/ekexiu/console/system/service/RoleService.java
  24. 70 0
      src/main/java/com/ekexiu/console/system/service/SysResourceService.java
  25. 80 0
      src/main/java/com/ekexiu/console/system/service/UserConfigService.java
  26. 43 0
      src/main/java/com/ekexiu/console/system/service/UserRoleService.java
  27. 63 0
      src/main/java/com/ekexiu/console/system/service/UserService.java
  28. 34 0
      src/main/java/com/ekexiu/console/system/vo/ConsoleAuthRole.java
  29. 71 0
      src/main/java/com/ekexiu/console/system/vo/ConsoleAuthUser.java
  30. 41 0
      src/main/java/com/ekexiu/console/system/vo/UserMenu.java
  31. 24 0
      src/main/resources/log4j.properties
  32. 32 0
      src/main/resources/project-dev.properties
  33. 31 0
      src/main/resources/project-test-dev.properties
  34. 31 0
      src/main/resources/project-test.properties
  35. 31 0
      src/main/resources/project.properties
  36. 30 0
      src/main/webapp/WEB-INF/web.xml

+ 4 - 0
.gitignore

@ -0,0 +1,4 @@
1
/target/
2
/.settings/
3
/.classpath
4
/.project

+ 7 - 0
config-dev.properties

@ -0,0 +1,7 @@
1
ajax.prefixLen=6
2
main.config=project-dev.properties
3
#\u8d44\u6e90\u9644\u4ef6\u4e0a\u4f20\u76ee\u5f55
4
#accessoryFolder=D:/tmp
5
#log4j\u65e5\u5fd7\u6587\u4ef6\u5b58\u653e\u8def\u5f84
6
dlog.file=D:/tmp/log.log
7
elog.file=D:/tmp/error.log

+ 7 - 0
config-product.properties

@ -0,0 +1,7 @@
1
ajax.prefixLen=14
2
main.config=project.properties
3
#资源附件上传目录
4
#accessoryFolder=/kexiu/www/html/accessory
5
#log4j日志文件存放路径
6
dlog.file= /home/tomcat/apache-tomcat-7.0.73/webapps/logs/log.log
7
elog.file=/home/tomcat/apache-tomcat-7.0.73/webapps/logs/error.log

+ 7 - 0
config-test-dev.properties

@ -0,0 +1,7 @@
1
ajax.prefixLen=14
2
main.config=project-test-dev.properties
3
#资源附件上传目录
4
#accessoryFolder=/kexiu/www/html1/accessory
5
#log4j日志文件存放路径
6
dlog.file= /home/tomcat1/apache-tomcat-7.0.73/webapps/logs/log.log
7
elog.file=/home/tomcat1/apache-tomcat-7.0.73/webapps/logs/error.log

+ 7 - 0
config-test.properties

@ -0,0 +1,7 @@
1
ajax.prefixLen=14
2
main.config=project-test.properties
3
#资源附件上传目录
4
accessoryFolder=/kexiu/www/html/accessory
5
#log4j日志文件存放路径
6
dlog.file= /home/tomcat/apache-tomcat-7.0.73/webapps/logs/log.log
7
elog.file=/home/tomcat/apache-tomcat-7.0.73/webapps/logs/error.log

+ 138 - 0
pom.xml

@ -0,0 +1,138 @@
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
	<modelVersion>4.0.0</modelVersion>
4
	<groupId>com.ekexiu</groupId>
5
	<artifactId>console-web</artifactId>
6
	<version>0.0.1-SNAPSHOT</version>
7
	<packaging>war</packaging>
8
	<properties>
9
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10
		<maven.compiler.source>1.7</maven.compiler.source>
11
		<maven.compiler.target>1.7</maven.compiler.target>
12
		<maven.war.filteringDeploymentDescriptors>true</maven.war.filteringDeploymentDescriptors>
13
	</properties>
14
	<profiles>
15
		<profile>
16
			<id>dev</id>
17
			<activation>
18
				<activeByDefault>true</activeByDefault>
19
			</activation>
20
			<properties>
21
				<maven.compiler.debug>true</maven.compiler.debug>
22
				<maven.compiler.debugLevel>vars,lines,source</maven.compiler.debugLevel>
23
			</properties>
24
			<build>
25
				<filters>
26
					<filter>config-dev.properties</filter>
27
				</filters>
28
			</build>
29
		</profile>
30
		<profile>
31
			<id>test-dev</id>
32
			<build>
33
				<filters>
34
					<filter>config-test-dev.properties</filter>
35
				</filters>
36
			</build>
37
		</profile>
38
		<profile>
39
			<id>test</id>
40
			<build>
41
				<filters>
42
					<filter>config-test.properties</filter>
43
				</filters>
44
			</build>
45
		</profile>
46
		<profile>
47
			<id>product</id>
48
			<build>
49
				<filters>
50
					<filter>config-product.properties</filter>
51
				</filters>
52
			</build>
53
		</profile>
54
	</profiles>
55
	<dependencies>
56
		<dependency>
57
			<groupId>org.postgresql</groupId>
58
			<artifactId>postgresql</artifactId>
59
			<version>9.4.1207.jre7</version>
60
		</dependency>
61
		<dependency>
62
			<groupId>org.jfw</groupId>
63
			<artifactId>jfwApt</artifactId>
64
			<version>0.0.2-SNAPSHOT</version>
65
			<optional>true</optional>
66
		</dependency>
67
		<dependency>
68
			<groupId>org.jfw</groupId>
69
			<artifactId>jfwAptOrm</artifactId>
70
			<version>0.0.2-SNAPSHOT</version>
71
			<optional>true</optional>
72
		</dependency>
73
		<dependency>
74
			<groupId>org.jfw</groupId>
75
			<artifactId>jfwAptWeb</artifactId>
76
			<version>0.0.2-SNAPSHOT</version>
77
			<optional>true</optional>
78
		</dependency>
79
		<dependency>
80
			<groupId>org.jfw</groupId>
81
			<artifactId>jfwUtil</artifactId>
82
			<version>0.0.2-SNAPSHOT</version>
83
		</dependency>
84
		<dependency>
85
			<groupId>org.jfw</groupId>
86
			<artifactId>jfwWebUtil</artifactId>
87
			<version>0.0.2-SNAPSHOT</version>
88
		</dependency>
89
		<dependency>
90
			<groupId>javax.servlet</groupId>
91
			<artifactId>servlet-api</artifactId>
92
			<scope>provided</scope>
93
			<version>2.5</version>
94
		</dependency>
95
		<dependency>
96
			<groupId>com.alibaba</groupId>
97
			<artifactId>druid</artifactId>
98
			<version>1.0.20</version>
99
		</dependency>
100
		<dependency>
101
			<groupId>javax.mail</groupId>
102
			<artifactId>mail</artifactId>
103
			<version>1.4</version>
104
		</dependency>
105
		<dependency>
106
			<groupId>org.slf4j</groupId>
107
			<artifactId>slf4j-log4j12</artifactId>
108
			<version>1.7.21</version>
109
		</dependency>
110
	</dependencies>
111
	<build>
112
		<resources>
113
			<resource>
114
				<directory>src/main/resources</directory>
115
				<includes>
116
					<include>log4j.properties</include>
117
					<include>project.properties</include>
118
					<include>project-dev.properties</include>
119
					<include>project-test-dev.properties</include>
120
					<include>project-test.properties</include>
121
				</includes>
122
				<filtering>true</filtering>
123
			</resource>
124
		</resources>
125
		<plugins>
126
			<plugin>
127
				<groupId>org.mortbay.jetty</groupId>
128
				<artifactId>jetty-maven-plugin</artifactId>
129
				<version>8.1.0.RC5</version>
130
				<configuration>
131
					<stopPort>9966</stopPort>
132
					<stopKey>foo</stopKey>
133
				</configuration>
134
			</plugin>
135
		</plugins>
136
		<finalName>console</finalName>
137
	</build>
138
</project>

+ 14 - 0
src/main/java/com/ekexiu/console/basepo/CreateTimeSupported.java

@ -0,0 +1,14 @@
1
package com.ekexiu.console.basepo;
2
3
import org.jfw.apt.annotation.JfwAptConfig;
4
import org.jfw.apt.orm.annotation.entry.Column;
5
import org.jfw.apt.orm.annotation.entry.VirtualTable;
6
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
7
8
@JfwAptConfig("DB:PostgreSQL")
9
@VirtualTable
10
public interface CreateTimeSupported {
11
	@Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithInsert = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = false)
12
	String getCreateTime();
13
	void setCreateTime(String createTime);
14
}

+ 12 - 0
src/main/java/com/ekexiu/console/basepo/DescpSupported.java

@ -0,0 +1,12 @@
1
package com.ekexiu.console.basepo;
2
3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.VirtualTable;
5
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
6
7
@VirtualTable
8
public interface DescpSupported {
9
	@Column(handlerClass=StringHandler.class,dbType="TEXT",insertable=true,nullable=true,renewable=true,queryable=true)
10
	String getDescp();
11
	void setDescp(String descp);
12
}

+ 11 - 0
src/main/java/com/ekexiu/console/basepo/ModifyTimeSupported.java

@ -0,0 +1,11 @@
1
package com.ekexiu.console.basepo;
2
3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.VirtualTable;
5
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
6
@VirtualTable
7
public interface ModifyTimeSupported {
8
	@Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithInsert = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", fixSqlValueWithUpdate = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = true)
9
	String getModifyTime();
10
	void setModifyTime(String modifyTime);
11
}

+ 47 - 0
src/main/java/com/ekexiu/console/system/dao/RightDao.java

@ -0,0 +1,47 @@
1
package com.ekexiu.console.system.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.List;
6

7
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.orm.annotation.dao.Batch;
9
import org.jfw.apt.orm.annotation.dao.DAO;
10
import org.jfw.apt.orm.annotation.dao.method.From;
11
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
12
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
13
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
14
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
15
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
16

17
import com.ekexiu.console.system.po.SysRight;
18

19
@DAO
20
public interface RightDao {
21

22
	@Insert
23
	int insert(Connection con, SysRight right) throws SQLException;
24

25
	@Nullable
26
	@SelectOne
27
	SysRight query(Connection con, int id) throws SQLException;
28

29
	@SelectList
30
	List<SysRight> query(Connection con) throws SQLException;
31

32
	@SelectList
33
	List<SysRight> query(Connection con, String type) throws SQLException;
34

35
	@Update
36
	int update(Connection con, SysRight right) throws SQLException;
37

38
	@DeleteWith
39
	@From(SysRight.class)
40
	int delete(Connection con, int id) throws SQLException;
41

42
	@Batch
43
	@DeleteWith
44
	@From(SysRight.class)
45
	int[] delete(Connection con, @Batch int[] id) throws SQLException;
46

47
}

+ 43 - 0
src/main/java/com/ekexiu/console/system/dao/RoleDao.java

@ -0,0 +1,43 @@
1
package com.ekexiu.console.system.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.List;
6

7
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.orm.annotation.dao.DAO;
9
import org.jfw.apt.orm.annotation.dao.method.From;
10
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
11
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
12
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
13
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
14
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
15
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
16
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
17

18
import com.ekexiu.console.system.po.Role;
19

20
@DAO
21
public interface RoleDao {
22

23
	@Insert
24
	int insert(Connection con,Role role)throws SQLException;
25
	
26
	@Update 
27
	int update(Connection con,Role role)throws SQLException;
28
	
29
	@DeleteWith
30
	@From(Role.class)
31
	int delete(Connection con,String id)throws SQLException;
32
	
33
	
34
	@Nullable
35
	@SelectOne
36
	Role query(Connection con, String id)throws SQLException;
37
	@SelectList
38
	List<Role> query(Connection con)throws SQLException;
39

40
	@SelectList
41
	List<Role> queryByUser(Connection con , @SqlColumn(handlerClass=StringHandler.class,value="id in (SELECT ROLEID FROM USER_ROLE WHERE USER_ID=?")  String userid) throws SQLException;
42
	
43
}

+ 32 - 0
src/main/java/com/ekexiu/console/system/dao/SysResourceDao.java

@ -0,0 +1,32 @@
1
package com.ekexiu.console.system.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.List;
6

7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
10
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
11
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
12
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
13

14
import com.ekexiu.console.system.po.SysResource;
15

16
@DAO
17
public interface SysResourceDao {
18

19
	@Insert
20
	int insert(Connection con,SysResource res) throws SQLException;
21
	
22
	@Update
23
	int update(Connection con, SysResource res)throws SQLException;
24
	
25
	@DeleteWith
26
	@From(SysResource.class)
27
	int delete(Connection con ,String id)throws SQLException;
28
	
29
	@SelectList
30
	List<SysResource> query(Connection con)throws SQLException;	
31
	
32
}

+ 30 - 0
src/main/java/com/ekexiu/console/system/dao/UserConfigDao.java

@ -0,0 +1,30 @@
1
package com.ekexiu.console.system.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.annotation.Nullable;
7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
10
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
11
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
12

13
import com.ekexiu.console.system.po.UserConfig;
14

15
@DAO
16
public interface UserConfigDao {
17
	
18
	@DeleteWith
19
	@From(UserConfig.class)
20
	int delete(Connection con,String userid,String cfkey)throws SQLException;
21
	@DeleteWith
22
	@From(UserConfig.class)
23
	int delete(Connection con,String userid)throws SQLException;	
24
	@Insert
25
	int insert(Connection con,UserConfig uc)throws SQLException;
26
	
27
	@SelectOne
28
	@Nullable
29
	UserConfig query(Connection con,String userid,String cfkey)throws SQLException;
30
}

+ 59 - 0
src/main/java/com/ekexiu/console/system/dao/UserDao.java

@ -0,0 +1,59 @@
1
package com.ekexiu.console.system.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.annotation.Nullable;
7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.IncludeFixSet;
10
import org.jfw.apt.orm.annotation.dao.method.Or;
11
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
12
import org.jfw.apt.orm.annotation.dao.method.Where;
13
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
14
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
15
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
16
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
17
import org.jfw.apt.orm.annotation.dao.param.Alias;
18
import org.jfw.apt.orm.annotation.dao.param.Set;
19

20
import com.ekexiu.console.system.po.User;
21

22
@DAO
23
public interface UserDao {
24
	
25
	@Insert
26
	int insert(Connection con,User user)throws SQLException;
27

28
	@Nullable
29
	@SelectOne
30
	User queryById(Connection con, String id) throws SQLException;
31

32
	@Or
33
	@Nullable
34
	@SelectOne
35
	User queryByLoginKey(Connection con, @Alias({ "mobile", "email" }) String key) throws SQLException;
36

37
	@Update
38
	int update(Connection con, User user) throws SQLException;
39

40
	@IncludeFixSet("modifyTime")
41
	@UpdateWith
42
	@From(User.class)
43
	int update(Connection con, String id, @Set String authinfo) throws SQLException;
44

45
	@Where("ACTIVED<>'1'")
46
	@SetSentence("ACTIVED='1'")
47
	@IncludeFixSet("modifyTime")
48
	@From(User.class)
49
	@UpdateWith
50
	int enable(Connection con, String id) throws SQLException;
51

52
	@Where("ACTIVED='1'")
53
	@SetSentence("ACTIVED='0'")
54
	@IncludeFixSet("modifyTime")
55
	@From(User.class)
56
	@UpdateWith
57
	int dsiable(Connection con, String id) throws SQLException;
58

59
}

+ 33 - 0
src/main/java/com/ekexiu/console/system/dao/UserRoleDao.java

@ -0,0 +1,33 @@
1
package com.ekexiu.console.system.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.orm.annotation.dao.Batch;
7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.operator.Delete;
10
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
11
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
12

13
import com.ekexiu.console.system.po.UserRole;
14

15
@DAO
16
public interface UserRoleDao {
17

18
	@Batch
19
	@Insert
20
	int[] insert(Connection con,UserRole[] urs)throws SQLException;
21
	
22
	@Batch
23
	@Delete
24
	int[] delete(Connection con,UserRole[] urs)throws SQLException;
25
	
26
	@DeleteWith
27
	@From(UserRole.class)
28
	int deleteByUserId(Connection con,String userid)throws SQLException;
29
	@DeleteWith
30
	@From(UserRole.class)
31
	int deleteByRoleId(Connection con,String roleid)throws SQLException;
32
	
33
}

+ 63 - 0
src/main/java/com/ekexiu/console/system/po/Role.java

@ -0,0 +1,63 @@
1
package com.ekexiu.console.system.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
import com.ekexiu.console.basepo.CreateTimeSupported;
9
import com.ekexiu.console.basepo.DescpSupported;
10
import com.ekexiu.console.basepo.ModifyTimeSupported;
11

12
@PrimaryKey("id")
13
@Table
14
public class Role implements CreateTimeSupported,ModifyTimeSupported,DescpSupported{
15
	private String id;
16
	private String name;
17
	private String authinfo;
18
	private String descp;
19
	private String createTime;
20
	private String modifyTime;
21
	@Column(DE.id_32)
22
	public String getId() {
23
		return id;
24
	}
25
	public void setId(String id) {
26
		this.id = id;
27
	}
28
	@Column(DE.string_de)
29
	public String getName() {
30
		return name;
31
	}
32
	public void setName(String name) {
33
		this.name = name;
34
	}
35
	@Column(DE.string_de)
36
	public String getAuthinfo() {
37
		return authinfo;
38
	}
39
	public void setAuthinfo(String authinfo) {
40
		this.authinfo = authinfo;
41
	}
42
	public String getDescp() {
43
		return descp;
44
	}
45
	public void setDescp(String descp) {
46
		this.descp = descp;
47
	}
48

49
	public String getCreateTime() {
50
		return createTime;
51
	}
52
	public void setCreateTime(String createTime) {
53
		this.createTime = createTime;
54
	}
55
	public String getModifyTime() {
56
		return modifyTime;
57
	}
58
	public void setModifyTime(String modifyTime) {
59
		this.modifyTime = modifyTime;
60
	}
61
	
62

63
}

+ 92 - 0
src/main/java/com/ekexiu/console/system/po/SysResource.java

@ -0,0 +1,92 @@
1
package com.ekexiu.console.system.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
@PrimaryKey("id")
9
@Table
10
public class SysResource {
11
	private String id;
12
	private String uri;
13
	private String css;
14
	private String script;
15
	private boolean modal;
16
	private boolean main;
17
	private int authRight = 0;
18
	private String type;
19

20
	@Column(DE.string_de)
21
	public String getType() {
22
		return type;
23
	}
24

25
	public void setType(String type) {
26
		this.type = type;
27
	}
28

29
	@Column(DE.string_de)
30
	public String getId() {
31
		return id;
32
	}
33

34
	public void setId(String id) {
35
		this.id = id;
36
	}
37

38
	@Column(DE.string_de)
39
	public String getUri() {
40
		return uri;
41
	}
42

43
	public void setUri(String uri) {
44
		this.uri = uri;
45
	}
46

47
	@Column(DE.String_de)
48
	public String getCss() {
49
		return css;
50
	}
51

52
	public void setCss(String css) {
53
		this.css = css;
54
	}
55

56
	@Column(DE.String_de)
57
	public String getScript() {
58
		return script;
59
	}
60

61
	public void setScript(String script) {
62
		this.script = script;
63
	}
64

65
	@Column(DE.boolean_de)
66
	public boolean isModal() {
67
		return modal;
68
	}
69

70
	public void setModal(boolean modal) {
71
		this.modal = modal;
72
	}
73

74
	@Column(DE.boolean_de)
75
	public boolean isMain() {
76
		return main;
77
	}
78

79
	public void setMain(boolean main) {
80
		this.main = main;
81
	}
82

83
	@Column(DE.int_de)
84
	public int getAuthRight() {
85
		return authRight;
86
	}
87

88
	public void setAuthRight(int authRight) {
89
		this.authRight = authRight;
90
	}
91

92
}

+ 46 - 0
src/main/java/com/ekexiu/console/system/po/SysRight.java

@ -0,0 +1,46 @@
1
package com.ekexiu.console.system.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
import com.ekexiu.console.basepo.DescpSupported;
9

10
@PrimaryKey("id")
11
@Table
12
public class SysRight implements DescpSupported {
13
	private int id;
14
	private String name;
15
	private String descp;
16
	private String type;
17
	
18
	@Column(DE.int_de)
19
	public int getId() {
20
		return id;
21
	}
22
	public void setId(int id) {
23
		this.id = id;
24
	}
25
	@Column(DE.string_de)
26
	public String getName() {
27
		return name;
28
	}
29
	public void setName(String name) {
30
		this.name = name;
31
	}
32

33
	public String getDescp() {
34
		return descp;
35
	}
36
	public void setDescp(String descp) {
37
		this.descp = descp;
38
	}
39
	@Column(DE.string_de)
40
	public String getType() {
41
		return type;
42
	}
43
	public void setType(String type) {
44
		this.type = type;
45
	}
46
}

+ 129 - 0
src/main/java/com/ekexiu/console/system/po/User.java

@ -0,0 +1,129 @@
1
package com.ekexiu.console.system.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.annotation.entry.Unique;
7
import org.jfw.apt.orm.annotation.entry.Uniques;
8
import org.jfw.apt.orm.core.defaultImpl.BooleanHandler;
9
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
10
import org.jfw.apt.orm.core.enums.DE;
11

12
import com.ekexiu.console.basepo.CreateTimeSupported;
13
import com.ekexiu.console.basepo.DescpSupported;
14
import com.ekexiu.console.basepo.ModifyTimeSupported;
15

16
@PrimaryKey("id")
17
@Uniques({ @Unique(name = "UN_LUSER_MOBILE", clolumns = "mobile"), @Unique(name = "UN_LUSER_EMAIL", clolumns = "email") })
18
@Table("LUSER")
19
public class User implements CreateTimeSupported, ModifyTimeSupported, DescpSupported {
20

21
	private String id;
22
	private String loginPassword;
23
	private String mobile;
24
	private String createTime;
25
	private String modifyTime;
26
	private String descp;
27
	private String name;
28
	private String email;
29
	private String head;
30
	private String authinfo;
31
	private boolean actived = true;
32

33
	@Column(DE.id_32)
34
	public String getId() {
35
		return id;
36
	}
37

38
	public void setId(String id) {
39
		this.id = id;
40
	}
41

42
	@Column(DE.md5_de)
43
	public String getLoginPassword() {
44
		return loginPassword;
45
	}
46

47
	public void setLoginPassword(String loginPassword) {
48
		this.loginPassword = loginPassword;
49
	}
50

51
	@Column(dbType = "CHAR(11)", handlerClass = StringHandler.class, nullable = true)
52
	public String getMobile() {
53
		return mobile;
54
	}
55

56
	public void setMobile(String mobile) {
57
		this.mobile = mobile;
58
	}
59

60
	public String getCreateTime() {
61
		return createTime;
62
	}
63

64
	public void setCreateTime(String createTime) {
65
		this.createTime = createTime;
66
	}
67

68
	public String getModifyTime() {
69
		return modifyTime;
70
	}
71

72
	public void setModifyTime(String modifyTime) {
73
		this.modifyTime = modifyTime;
74
	}
75

76
	public String getDescp() {
77
		return descp;
78
	}
79

80
	public void setDescp(String descp) {
81
		this.descp = descp;
82
	}
83

84
	@Column(DE.string_de)
85
	public String getName() {
86
		return name;
87
	}
88

89
	public void setName(String name) {
90
		this.name = name;
91
	}
92

93
	@Column(DE.string_de)
94
	public String getEmail() {
95
		return email;
96
	}
97

98
	public void setEmail(String email) {
99
		this.email = email;
100
	}
101

102
	@Column(DE.String_de)
103
	public String getHead() {
104
		return head;
105
	}
106

107
	public void setHead(String head) {
108
		this.head = head;
109
	}
110

111
	@Column(dbType = "TEXT", handlerClass = StringHandler.class, renewable = false)
112
	public String getAuthinfo() {
113
		return authinfo;
114
	}
115

116
	public void setAuthinfo(String authinfo) {
117
		this.authinfo = authinfo;
118
	}
119

120
	@Column(dbType="CHAR(1)",handlerClass=BooleanHandler.class,nullable = false, renewable=false)
121
	public boolean isActived() {
122
		return actived;
123
	}
124

125
	public void setActived(boolean actived) {
126
		this.actived = actived;
127
	}
128

129
}

+ 38 - 0
src/main/java/com/ekexiu/console/system/po/UserConfig.java

@ -0,0 +1,38 @@
1
package com.ekexiu.console.system.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
@PrimaryKey({"userid","cfkey"})
9
@Table
10
public class UserConfig {
11
	private String userid;
12
	private String cfkey;
13
	private String cfval;
14
	
15
	@Column(DE.id_32)
16
	public String getUserid() {
17
		return userid;
18
	}
19
	public void setUserid(String userid) {
20
		this.userid = userid;
21
	}
22
	@Column(DE.string_de)
23
	public String getCfkey() {
24
		return cfkey;
25
	}
26

27
	public void setCfkey(String cfkey) {
28
		this.cfkey = cfkey;
29
	}
30
	@Column(DE.string_de)
31
	public String getCfval() {
32
		return cfval;
33
	}
34
	public void setCfval(String cfval) {
35
		this.cfval = cfval;
36
	}
37
	
38
}

+ 28 - 0
src/main/java/com/ekexiu/console/system/po/UserRole.java

@ -0,0 +1,28 @@
1
package com.ekexiu.console.system.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
@PrimaryKey({"userid","roleid"})
9
@Table
10
public class UserRole{
11
	
12
	private String userid;
13
	private String roleid;
14
	@Column(DE.id_32)
15
	public String getUserid() {
16
		return userid;
17
	}
18
	public void setUserid(String userid) {
19
		this.userid = userid;
20
	}
21
	@Column(DE.id_32)
22
	public String getRoleid() {
23
		return roleid;
24
	}
25
	public void setRoleid(String roleid) {
26
		this.roleid = roleid;
27
	}
28
}

+ 72 - 0
src/main/java/com/ekexiu/console/system/service/RightService.java

@ -0,0 +1,72 @@
1
package com.ekexiu.console.system.service;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.List;
6

7
import org.jfw.apt.annotation.Autowrie;
8
import org.jfw.apt.orm.annotation.dao.method.operator.Delete;
9
import org.jfw.apt.web.annotation.Path;
10
import org.jfw.apt.web.annotation.operate.Get;
11
import org.jfw.apt.web.annotation.operate.Post;
12
import org.jfw.apt.web.annotation.operate.Put;
13
import org.jfw.apt.web.annotation.param.JdbcConn;
14
import org.jfw.apt.web.annotation.param.PathVar;
15
import org.jfw.apt.web.annotation.param.RequestBody;
16

17
import com.ekexiu.console.system.dao.RightDao;
18
import com.ekexiu.console.system.po.SysRight;
19

20
@Path("/sys/right")
21
public class RightService {
22

23
	@Autowrie
24
	private RightDao rightDao;
25

26
	public RightDao getRightDao() {
27
		return rightDao;
28
	}
29

30
	public void setRightDao(RightDao rightDao) {
31
		this.rightDao = rightDao;
32
	}
33
	
34
	
35

36
	@Get
37
	@Path("/all")
38
	public List<SysRight> query(@JdbcConn Connection con) throws SQLException {
39
		return this.rightDao.query(con);
40
	}
41

42
	@Get
43
	@Path("/type/{type}")
44
	public List<SysRight> queryByType(@JdbcConn Connection con, @PathVar String type) throws SQLException {
45
		return this.rightDao.query(con, type);
46
	}
47

48
	@Get
49
	@Path("/id/{id}")
50
	public SysRight queryById(@JdbcConn Connection con, @PathVar int id) throws SQLException {
51
		return this.rightDao.query(con, id);
52
	}
53

54
	@Post
55
	@Path()
56
	public void insert(@JdbcConn(true) Connection con, SysRight right) throws SQLException {
57
		this.rightDao.insert(con, right);
58
	}
59

60
	@Put
61
	@Path()
62
	public void update(@JdbcConn(true) Connection con, @RequestBody SysRight right) throws SQLException {
63
		this.rightDao.insert(con, right);
64
	}
65

66
	@Path("/{id}")
67
	@Delete
68
	public void delete(@JdbcConn(true) Connection con, @PathVar int id) throws SQLException {
69
		this.rightDao.delete(con, id);
70
	}
71

72
}

+ 134 - 0
src/main/java/com/ekexiu/console/system/service/RoleService.java

@ -0,0 +1,134 @@
1
package com.ekexiu.console.system.service;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.ArrayList;
6
import java.util.List;
7
import java.util.ListIterator;
8

9
import org.jfw.apt.annotation.Autowrie;
10
import org.jfw.apt.web.annotation.Path;
11
import org.jfw.apt.web.annotation.operate.Delete;
12
import org.jfw.apt.web.annotation.operate.Get;
13
import org.jfw.apt.web.annotation.operate.Post;
14
import org.jfw.apt.web.annotation.operate.Put;
15
import org.jfw.apt.web.annotation.param.JdbcConn;
16
import org.jfw.apt.web.annotation.param.PathVar;
17
import org.jfw.apt.web.annotation.param.RequestBody;
18
import org.jfw.util.StringUtil;
19
import org.jfw.util.auth.AuthUtil;
20

21
import com.ekexiu.console.system.dao.RoleDao;
22
import com.ekexiu.console.system.dao.UserRoleDao;
23
import com.ekexiu.console.system.po.Role;
24
import com.ekexiu.console.system.vo.ConsoleAuthRole;
25

26
@Path("/sys/role")
27
public class RoleService {
28
	
29
	public static final String EMPTY_AUTH_STR = AuthUtil.serialAuth(new int[]{0});
30
	
31
	@Autowrie
32
	private RoleDao roleDao;
33
	@Autowrie
34
	private UserRoleDao userRoleDao;
35

36
	public UserRoleDao getUserRoleDao() {
37
		return userRoleDao;
38
	}
39

40
	public void setUserRoleDao(UserRoleDao userRoleDao) {
41
		this.userRoleDao = userRoleDao;
42
	}
43

44
	public RoleDao getRoleDao() {
45
		return roleDao;
46
	}
47

48
	public void setRoleDao(RoleDao roleDao) {
49
		this.roleDao = roleDao;
50
	}
51
	
52
	
53
	
54
	@Post
55
	@Path
56
	public void insert(@JdbcConn(true) Connection con,ConsoleAuthRole role)throws SQLException{
57
		Role r = new Role();
58
		r.setId(StringUtil.buildUUID());
59
		r.setName(role.getName());
60
		r.setDescp(role.getDescp());
61
		int[] auths = role.getAuths();
62
		if(auths==null || auths.length==0){
63
			r.setAuthinfo(EMPTY_AUTH_STR);
64
		}else{
65
			r.setAuthinfo(AuthUtil.serialAuth(AuthUtil.compress(auths)));
66
		}
67
		this.roleDao.insert(con, r);
68
	}
69
	@Put
70
	@Path
71
	public void update(@JdbcConn(true) Connection con,@RequestBody ConsoleAuthRole role)throws SQLException{
72
		Role r = new Role();
73
		r.setName(role.getName());
74
		r.setDescp(role.getDescp());
75
		int[] auths = role.getAuths();
76
		if(auths==null || auths.length==0){
77
			r.setAuthinfo(EMPTY_AUTH_STR);
78
		}else{
79
			r.setAuthinfo(AuthUtil.serialAuth(AuthUtil.compress(auths)));
80
		}
81
		this.roleDao.update(con, r);
82
	}
83
	
84
	@Path("/{id}")
85
	@Delete
86
	public void delete(@JdbcConn(true) Connection con,@PathVar String id)throws SQLException{
87
		 this.userRoleDao.deleteByRoleId(con, id);		 
88
		 this.roleDao.delete(con, id);
89
	}
90
	
91
	@Path("/all")
92
	@Get
93
	public List<ConsoleAuthRole> queryAll(@JdbcConn Connection con)throws SQLException{
94
		List<Role> roles= this.roleDao.query(con);
95
		ArrayList<ConsoleAuthRole> ret = new ArrayList<ConsoleAuthRole>(roles.size());
96
		for(ListIterator<Role> it = roles.listIterator(); it.hasNext();){
97
			ret.add(conver(it.next()));
98
		}
99
		return ret;
100
	}
101
	@Path("/id/{id}")
102
	@Get
103
	public ConsoleAuthRole queryById(@JdbcConn Connection con ,@PathVar String id ) throws SQLException{
104
	  return conver(this.roleDao.query(con, id));
105
	}
106
	@Path("/byUserid/{userid}")
107
	@Get
108
	public List<ConsoleAuthRole> queryByUserId(@JdbcConn Connection con,@PathVar String userid)throws SQLException{
109
		List<Role> roles= this.roleDao.queryByUser(con, userid);
110
		ArrayList<ConsoleAuthRole> ret = new ArrayList<ConsoleAuthRole>(roles.size());
111
		for(ListIterator<Role> it = roles.listIterator(); it.hasNext();){
112
			ret.add(conver(it.next()));
113
		}
114
		return ret;
115
	}
116

117
	
118
	
119
	
120
	
121
	
122
	
123
	
124
	
125
	public static ConsoleAuthRole conver(Role role){
126
		if(null == role) return null;
127
		ConsoleAuthRole cr = new ConsoleAuthRole();
128
		cr.setDescp(role.getDescp());
129
		cr.setId(role.getId());
130
		cr.setName(role.getName());
131
		cr.setAuths(AuthUtil.unCompress(AuthUtil.deSerialAuth(role.getAuthinfo())));
132
		return cr;
133
	}
134
}

+ 70 - 0
src/main/java/com/ekexiu/console/system/service/SysResourceService.java

@ -0,0 +1,70 @@
1
package com.ekexiu.console.system.service;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.ArrayList;
6
import java.util.List;
7

8
import org.jfw.apt.annotation.Autowrie;
9
import org.jfw.apt.web.annotation.LoginUser;
10
import org.jfw.apt.web.annotation.Path;
11
import org.jfw.apt.web.annotation.operate.Delete;
12
import org.jfw.apt.web.annotation.operate.Get;
13
import org.jfw.apt.web.annotation.operate.Post;
14
import org.jfw.apt.web.annotation.operate.Put;
15
import org.jfw.apt.web.annotation.param.JdbcConn;
16
import org.jfw.apt.web.annotation.param.PathVar;
17

18
import com.ekexiu.console.system.dao.SysResourceDao;
19
import com.ekexiu.console.system.po.SysResource;
20
import com.ekexiu.console.system.vo.ConsoleAuthUser;
21

22
@Path("/sys/resource")
23
public class SysResourceService {
24
	
25
	@Autowrie
26
	private SysResourceDao sysResourceDao;
27

28
	public SysResourceDao getSysResourceDao() {
29
		return sysResourceDao;
30
	}
31

32
	public void setSysResourceDao(SysResourceDao sysResourceDao) {
33
		this.sysResourceDao = sysResourceDao;
34
	}
35
	
36
	@Get
37
	@Path("/all")
38
	public List<SysResource> query(@JdbcConn Connection con)throws SQLException{
39
		return this.sysResourceDao.query(con);
40
	}
41
	
42
	@Post
43
	@Path
44
	public void insert(@JdbcConn(true) Connection con,SysResource sres)throws SQLException{
45
		this.sysResourceDao.insert(con, sres);
46
	}
47
	
48
	@Put
49
	@Path
50
	public void update(@JdbcConn(true) Connection con,SysResource sres) throws SQLException{
51
		this.sysResourceDao.update(con, sres);
52
	}
53
	@Delete
54
	@Path("/{id}")
55
	public void delete(@JdbcConn(true) Connection con ,@PathVar String id)throws SQLException{
56
		this.sysResourceDao.delete(con, id);
57
	}
58
	
59
	@Get
60
	@Path("/byLoginUser")
61
	public List<SysResource> query(@JdbcConn Connection con,@LoginUser ConsoleAuthUser user )throws SQLException{
62
		List<SysResource> ret = new ArrayList<SysResource>();
63
		for(SysResource res:this.query(con)){
64
			if(user.hasAuthority(res.getAuthRight())){
65
				ret.add(res);
66
			}
67
		}
68
		return ret;
69
	}
70
}

+ 80 - 0
src/main/java/com/ekexiu/console/system/service/UserConfigService.java

@ -0,0 +1,80 @@
1
package com.ekexiu.console.system.service;
2

3
import java.io.IOException;
4
import java.io.InputStream;
5
import java.lang.reflect.Type;
6
import java.sql.Connection;
7
import java.sql.SQLException;
8
import java.util.List;
9

10
import org.jfw.apt.annotation.Autowrie;
11
import org.jfw.apt.web.annotation.LoginUser;
12
import org.jfw.apt.web.annotation.Path;
13
import org.jfw.apt.web.annotation.operate.Get;
14
import org.jfw.apt.web.annotation.operate.Put;
15
import org.jfw.apt.web.annotation.param.JdbcConn;
16
import org.jfw.apt.web.annotation.param.PathVar;
17
import org.jfw.util.ConstData;
18
import org.jfw.util.io.IoUtil;
19
import org.jfw.util.json.JsonService;
20
import org.jfw.util.reflect.TypeReference;
21

22
import com.ekexiu.console.system.dao.UserConfigDao;
23
import com.ekexiu.console.system.po.UserConfig;
24
import com.ekexiu.console.system.vo.ConsoleAuthUser;
25
import com.ekexiu.console.system.vo.UserMenu;
26

27
@Path("/user/config")
28
public class UserConfigService {
29

30
	@Autowrie
31
	private UserConfigDao userConfigDao;
32

33
	public UserConfigDao getUserConfigDao() {
34
		return userConfigDao;
35
	}
36

37
	public void setUserConfigDao(UserConfigDao userConfigDao) {
38
		this.userConfigDao = userConfigDao;
39
	}
40

41
	@Put
42
	@Path("/{cfgkey}")
43
	public void insert(@LoginUser ConsoleAuthUser user, @JdbcConn(true) Connection con, @PathVar String cfgkey, InputStream in)
44
			throws SQLException, IOException {
45
		byte[] bs = IoUtil.readStream(in, true);
46
		this.userConfigDao.delete(con, user.getId(), cfgkey);
47
		if (bs.length > 0) {
48
			UserConfig uc = new UserConfig();
49
			uc.setCfkey(cfgkey);
50
			uc.setCfval(new String(bs, ConstData.UTF8));
51
			uc.setUserid(user.getId());
52
			this.userConfigDao.insert(con, uc);
53
		}
54
	}
55

56
	public <T> T load(Connection con, String userid, String cfkey, Type t) throws SQLException {
57
		UserConfig uc = this.userConfigDao.query(con, userid, cfkey);
58
		if (uc != null) {
59
			String v = uc.getCfval();
60
			if (v != null && v.length() > 0)
61
				return JsonService.fromJson(v, t);
62
		}
63
		return null;
64
	}
65

66
	private final static Type MENU_TYPE = new TypeReference<List<UserMenu>>() {
67
	}.getType();
68

69
	@Get
70
	@Path("/menu")
71
	public List<UserMenu> menu(@JdbcConn Connection con,@LoginUser() ConsoleAuthUser user)throws SQLException{
72
		List<UserMenu> ret = this.load(con,user.getId(),"menu",MENU_TYPE);
73
		if(null==ret){
74
			//TODO: impl load default
75
		}
76
		//TODO: test del trigger deploy
77
		return	 JsonService.fromJson("[{\"caption\":\"组织机构\",\"children\":[{\"caption\":\"机构管理\",\"res\":\"sys_org_index\"}]}]", MENU_TYPE);
78
	}
79

80
}

+ 43 - 0
src/main/java/com/ekexiu/console/system/service/UserRoleService.java

@ -0,0 +1,43 @@
1
package com.ekexiu.console.system.service;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.annotation.Autowrie;
7
import org.jfw.apt.web.annotation.Path;
8
import org.jfw.apt.web.annotation.param.JdbcConn;
9

10
import com.ekexiu.console.system.dao.UserRoleDao;
11
import com.ekexiu.console.system.po.UserRole;
12

13
@Path("/sys/userRole")
14
public class UserRoleService {
15

16
	@Autowrie
17
	private UserRoleDao userRoleDao;
18
	
19
	
20
	public UserRoleDao getUserRoleDao() {
21
		return userRoleDao;
22
	}
23

24

25
	public void setUserRoleDao(UserRoleDao userRoleDao) {
26
		this.userRoleDao = userRoleDao;
27
	}
28

29

30
	public void insert(@JdbcConn(true) Connection con,String userid,String[] role)throws SQLException{
31
		this.userRoleDao.deleteByUserId(con, userid);
32
		UserRole[] urs = new UserRole[role.length];
33
		int ind = 0;
34
		for(String r:role){
35
			UserRole ur = new UserRole();
36
			ur.setRoleid(r);
37
			ur.setUserid(userid);
38
			urs[ind++]= ur;
39
		}
40
		this.userRoleDao.insert(con, urs);
41
	}
42
	
43
}

+ 63 - 0
src/main/java/com/ekexiu/console/system/service/UserService.java

@ -0,0 +1,63 @@
1
package com.ekexiu.console.system.service;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.ArrayList;
6

7
import org.jfw.apt.annotation.Autowrie;
8
import org.jfw.apt.web.annotation.Path;
9
import org.jfw.apt.web.annotation.method.SetSession;
10
import org.jfw.apt.web.annotation.param.JdbcConn;
11
import org.jfw.util.StringUtil;
12
import org.jfw.util.auth.AuthUtil;
13

14
import com.ekexiu.console.system.dao.RoleDao;
15
import com.ekexiu.console.system.dao.UserDao;
16
import com.ekexiu.console.system.po.Role;
17
import com.ekexiu.console.system.po.User;
18
import com.ekexiu.console.system.vo.ConsoleAuthUser;
19

20
@Path("/sys/user")
21
public class UserService {
22

23
	@Autowrie
24
	private UserDao userDao;
25
	@Autowrie
26
	RoleDao roleDao;
27

28
	public RoleDao getRoleDao() {
29
		return roleDao;
30
	}
31

32
	public void setRoleDao(RoleDao roleDao) {
33
		this.roleDao = roleDao;
34
	}
35

36
	public UserDao getUserDao() {
37
		return userDao;
38
	}
39

40
	public void setUserDao(UserDao userDao) {
41
		this.userDao = userDao;
42
	}
43

44
	@SetSession("JFW_SESSION_LOGIN_USER=result")
45
	@Path("/login")
46
	public ConsoleAuthUser login(@JdbcConn Connection con, String key, String pw) throws SQLException {
47
		User user = userDao.queryByLoginKey(con, key);
48
		if (user != null && StringUtil.md5(pw).equals(user.getLoginPassword()) && user.isActived()) {
49
			ConsoleAuthUser cau = new ConsoleAuthUser(user);
50
			cau.setHead(user.getHead());
51
			cau.setId(user.getId());
52
			cau.setName(user.getName());
53
			ArrayList<int[]> list = new ArrayList<int[]>(1);
54
			list.add(AuthUtil.deSerialAuth(user.getAuthinfo()));
55
			for(Role role:this.roleDao.queryByUser(con,user.getId())){
56
				list.add(AuthUtil.deSerialAuth(role.getAuthinfo()));
57
			}
58
			cau.setAuths(AuthUtil.merge(list.toArray(new int[0][0])));
59
			return cau;
60
		}
61
		return null;
62
	}
63
}

+ 34 - 0
src/main/java/com/ekexiu/console/system/vo/ConsoleAuthRole.java

@ -0,0 +1,34 @@
1
package com.ekexiu.console.system.vo;
2

3
public class ConsoleAuthRole {
4
	private String id;
5
	private String name;
6
	private int[] auths;
7
	private String descp;
8
	public String getId() {
9
		return id;
10
	}
11
	public void setId(String id) {
12
		this.id = id;
13
	}
14
	public String getName() {
15
		return name;
16
	}
17
	public void setName(String name) {
18
		this.name = name;
19
	}
20
	public int[] getAuths() {
21
		return auths;
22
	}
23
	public void setAuths(int[] auths) {
24
		this.auths = auths;
25
	}
26
	public String getDescp() {
27
		return descp;
28
	}
29
	public void setDescp(String descp) {
30
		this.descp = descp;
31
	}
32
	
33
	
34
}

+ 71 - 0
src/main/java/com/ekexiu/console/system/vo/ConsoleAuthUser.java

@ -0,0 +1,71 @@
1
package com.ekexiu.console.system.vo;
2

3
import org.jfw.util.auth.AuthUser;
4
import org.jfw.util.auth.AuthUtil;
5

6
import com.ekexiu.console.system.po.User;
7

8
public class ConsoleAuthUser implements AuthUser {
9

10
	private String id;
11
	private String name;
12
	private String head;
13
	
14
	private transient int[] auths;
15

16
	public ConsoleAuthUser() {
17
	}
18

19
	public ConsoleAuthUser(User user) {
20
		this.id = user.getId();
21
		this.name = user.getName();
22
		this.head = user.getHead();
23
		//this.auths = AuthUtil.deSerialAuth(user.getAuthinfo());
24
	}
25

26
	public String getId() {
27
		return id;
28
	}
29

30
	public void setId(String id) {
31
		this.id = id;
32
	}
33

34
	public String getName() {
35
		return name;
36
	}
37

38
	public void setName(String name) {
39
		this.name = name;
40
	}
41

42
	public String getHead() {
43
		return head;
44
	}
45

46
	public void setHead(String head) {
47
		this.head = head;
48
	}
49

50
	public int[] getAuths() {
51
		return auths;
52
	}
53

54
	public void setAuths(int[] auths) {
55
		this.auths = auths;
56
	}
57

58
	public boolean hasAuthority(int auth) {
59
		return auth ==0 || ( this.auths != null && AuthUtil.hasAuthority(this.auths, auth));
60
	}
61

62
	public static void main(String[] args) throws Exception {
63
		ConsoleAuthUser user = new ConsoleAuthUser();
64
		user.setId("aaa");
65
		user.setName("dfsafas");
66
		user.setHead("=========");
67
		user.setAuths(new int[8]);
68
		System.out.println(org.jfw.util.json.JsonService.toJson(user));
69
	}
70

71
}

+ 41 - 0
src/main/java/com/ekexiu/console/system/vo/UserMenu.java

@ -0,0 +1,41 @@
1
package com.ekexiu.console.system.vo;
2

3
import java.util.List;
4

5
public class UserMenu {
6
	private String icon;
7
	private String res;
8
	private String caption;
9
	private Boolean modal;
10
	private List<UserMenu> children;
11
	public String getIcon() {
12
		return icon;
13
	}
14
	public void setIcon(String icon) {
15
		this.icon = icon;
16
	}
17
	public String getRes() {
18
		return res;
19
	}
20
	public void setRes(String res) {
21
		this.res = res;
22
	}
23
	public String getCaption() {
24
		return caption;
25
	}
26
	public void setCaption(String caption) {
27
		this.caption = caption;
28
	}
29
	public Boolean getModal() {
30
		return modal;
31
	}
32
	public void setModal(Boolean modal) {
33
		this.modal = modal;
34
	}
35
	public List<UserMenu> getChildren() {
36
		return children;
37
	}
38
	public void setChildren(List<UserMenu> children) {
39
		this.children = children;
40
	}
41
}

+ 24 - 0
src/main/resources/log4j.properties

@ -0,0 +1,24 @@
1
### \u8bbe\u7f6e###
2
log4j.rootLogger = debug,stdout,D,E
3

4
### \u8f93\u51fa\u4fe1\u606f\u5230\u63a7\u5236\u62ac ###
5
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
6
log4j.appender.stdout.Target = System.out
7
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
8
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
9

10
### \u8f93\u51faDEBUG \u7ea7\u522b\u4ee5\u4e0a\u7684\u65e5\u5fd7\u5230=E://logs/log.log ###
11
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
12
log4j.appender.D.File =${dlog.file}
13
log4j.appender.D.Append = true
14
log4j.appender.D.Threshold = DEBUG 
15
log4j.appender.D.layout = org.apache.log4j.PatternLayout
16
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %l%m%n
17

18
### \u8f93\u51faERROR \u7ea7\u522b\u4ee5\u4e0a\u7684\u65e5\u5fd7\u5230=E://logs/error.log ###
19
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
20
log4j.appender.E.File =${elog.file}
21
log4j.appender.E.Append = true
22
log4j.appender.E.Threshold = ERROR 
23
log4j.appender.E.layout = org.apache.log4j.PatternLayout
24
log4j.appender.E.layout.ConversionPattern =%-d{yyyy-MM-dd HH\:mm\:ss}  [ %t\:%r ] - [ %p ]  %l%m%n

+ 32 - 0
src/main/resources/project-dev.properties

@ -0,0 +1,32 @@
1
dataSource=com.alibaba.druid.pool.DruidDataSource
2
#数据库连接地址、名称、密码
3
dataSource.url=jdbc:postgresql://192.168.3.233:5432/console_dev
4
#dataSource.url=jdbc:postgresql://www.ekexiu.com:5432/ekexiu
5
dataSource.username=postgres
6
dataSource.password=postgres
7
#连接池启动时的初始值(初始化连接)
8
dataSource.initialSize::int=1
9
#最小空闲连接值
10
dataSource.minIdle::int=1 
11
#连接池的最大值(最大连接数量)
12
dataSource.maxActive::int=1
13
#超时等待时间(maxWait代表当Connection用尽了,多久之后进行回收丢失连接)
14
dataSource.maxWait::long=60000
15
#连接超时任务的时间间隔
16
dataSource.timeBetweenEvictionRunsMillis::long=60000
17
#连接的超时时间
18
dataSource.minEvictableIdleTimeMillis::long=300000  
19
#用来验证从连接池取出的连接
20
dataSource.validationQuery=SELECT 1  
21
#指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败则连接将被从池中去除
22
dataSource.testWhileIdle::boolean=true
23
#在从池中取出连接前进行检验,如果检验失败则从池中去除连接并尝试取出另一个
24
dataSource.testOnBorrow::boolean=true
25
#指明是否在归还到池中前进行检验
26
dataSource.testOnReturn::boolean=true   
27
#开启池的prepared statement 池功能
28
dataSource.poolPreparedStatements::boolean=true 
29
#statement池能够同时分配的打开的statements的最大数量
30
dataSource.maxPoolPreparedStatementPerConnectionSize::int=20
31
#默认的SQL语句自动提交状态(开启或关闭)设置由连接池本身设置(false由连接池定)
32
dataSource.defaultAutoCommit::boolean=false

+ 31 - 0
src/main/resources/project-test-dev.properties

@ -0,0 +1,31 @@
1
dataSource=com.alibaba.druid.pool.DruidDataSource
2
#数据库连接地址、名称、密码
3
dataSource.url=jdbc:postgresql://192.168.3.233:5432/ekexiu_dev
4
dataSource.username=postgres
5
dataSource.password=postgres
6
#连接池启动时的初始值(初始化连接)
7
dataSource.initialSize::int=1
8
#最小空闲连接值
9
dataSource.minIdle::int=1 
10
#连接池的最大值(最大连接数量)
11
dataSource.maxActive::int=1
12
#超时等待时间(maxWait代表当Connection用尽了,多久之后进行回收丢失连接)
13
dataSource.maxWait::long=60000
14
#连接超时任务的时间间隔
15
dataSource.timeBetweenEvictionRunsMillis::long=60000
16
#连接的超时时间
17
dataSource.minEvictableIdleTimeMillis::long=300000  
18
#用来验证从连接池取出的连接
19
dataSource.validationQuery=SELECT 1  
20
#指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败则连接将被从池中去除
21
dataSource.testWhileIdle::boolean=true
22
#在从池中取出连接前进行检验,如果检验失败则从池中去除连接并尝试取出另一个
23
dataSource.testOnBorrow::boolean=true
24
#指明是否在归还到池中前进行检验
25
dataSource.testOnReturn::boolean=true   
26
#开启池的prepared statement 池功能
27
dataSource.poolPreparedStatements::boolean=true 
28
#statement池能够同时分配的打开的statements的最大数量
29
dataSource.maxPoolPreparedStatementPerConnectionSize::int=20
30
#默认的SQL语句自动提交状态(开启或关闭)设置由连接池本身设置(false由连接池定)
31
dataSource.defaultAutoCommit::boolean=false

+ 31 - 0
src/main/resources/project-test.properties

@ -0,0 +1,31 @@
1
dataSource=com.alibaba.druid.pool.DruidDataSource
2
#数据库连接地址、名称、密码
3
dataSource.url=jdbc:postgresql://192.168.3.233:5432/ekexiu
4
dataSource.username=postgres
5
dataSource.password=postgres
6
#连接池启动时的初始值(初始化连接)
7
dataSource.initialSize::int=1
8
#最小空闲连接值
9
dataSource.minIdle::int=1 
10
#连接池的最大值(最大连接数量)
11
dataSource.maxActive::int=1
12
#超时等待时间(maxWait代表当Connection用尽了,多久之后进行回收丢失连接)
13
dataSource.maxWait::long=60000
14
#连接超时任务的时间间隔
15
dataSource.timeBetweenEvictionRunsMillis::long=60000
16
#连接的超时时间
17
dataSource.minEvictableIdleTimeMillis::long=300000  
18
#用来验证从连接池取出的连接
19
dataSource.validationQuery=SELECT 1  
20
#指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败则连接将被从池中去除
21
dataSource.testWhileIdle::boolean=true
22
#在从池中取出连接前进行检验,如果检验失败则从池中去除连接并尝试取出另一个
23
dataSource.testOnBorrow::boolean=true
24
#指明是否在归还到池中前进行检验
25
dataSource.testOnReturn::boolean=true   
26
#开启池的prepared statement 池功能
27
dataSource.poolPreparedStatements::boolean=true 
28
#statement池能够同时分配的打开的statements的最大数量
29
dataSource.maxPoolPreparedStatementPerConnectionSize::int=20
30
#默认的SQL语句自动提交状态(开启或关闭)设置由连接池本身设置(false由连接池定)
31
dataSource.defaultAutoCommit::boolean=false

+ 31 - 0
src/main/resources/project.properties

@ -0,0 +1,31 @@
1
dataSource=com.alibaba.druid.pool.DruidDataSource
2
#数据库连接地址、名称、密码
3
dataSource.url=jdbc:postgresql://121.42.53.174:5432/ekexiu
4
dataSource.username=postgres
5
dataSource.password=postgres
6
#连接池启动时的初始值(初始化连接)
7
dataSource.initialSize::int=1
8
#最小空闲连接值
9
dataSource.minIdle::int=1 
10
#连接池的最大值(最大连接数量)
11
dataSource.maxActive::int=1
12
#超时等待时间(maxWait代表当Connection用尽了,多久之后进行回收丢失连接)
13
dataSource.maxWait::long=60000
14
#连接超时任务的时间间隔
15
dataSource.timeBetweenEvictionRunsMillis::long=60000
16
#连接的超时时间
17
dataSource.minEvictableIdleTimeMillis::long=300000  
18
#用来验证从连接池取出的连接
19
dataSource.validationQuery=SELECT 1  
20
#指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败则连接将被从池中去除
21
dataSource.testWhileIdle::boolean=true
22
#在从池中取出连接前进行检验,如果检验失败则从池中去除连接并尝试取出另一个
23
dataSource.testOnBorrow::boolean=true
24
#指明是否在归还到池中前进行检验
25
dataSource.testOnReturn::boolean=true   
26
#开启池的prepared statement 池功能
27
dataSource.poolPreparedStatements::boolean=true 
28
#statement池能够同时分配的打开的statements的最大数量
29
dataSource.maxPoolPreparedStatementPerConnectionSize::int=20
30
#默认的SQL语句自动提交状态(开启或关闭)设置由连接池本身设置(false由连接池定)
31
dataSource.defaultAutoCommit::boolean=false

+ 30 - 0
src/main/webapp/WEB-INF/web.xml

@ -0,0 +1,30 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
3
  <servlet>
4
    <servlet-name>ajax</servlet-name>
5
    <servlet-class>org.jfw.web.servlet.core.FilenameConfigServlet</servlet-class>
6
    <init-param>
7
      <param-name>prefixLen</param-name>
8
      <param-value>${ajax.prefixLen}</param-value>
9
    </init-param>
10
    <init-param>
11
      <param-name>viewType</param-name>
12
      <param-value>1</param-value>
13
    </init-param>
14
    <init-param>
15
      <param-name>configFileName</param-name>
16
      <param-value>beanConfig.properties,${main.config}</param-value>
17
    </init-param>
18
<!--     <init-param>
19
    	<param-name>afterBeanFactory</param-name>
20
    	<param-value>com.ekexiu.portal.job.SchJob,com.ekexiu.portal.job.TaskJob</param-value>
21
    </init-param> -->
22
    <load-on-startup>1</load-on-startup>
23
  </servlet>
24
  
25
  <servlet-mapping>
26
    <servlet-name>ajax</servlet-name>
27
    <url-pattern>/ajax/*</url-pattern>
28
  </servlet-mapping>
29
 
30
</web-app>