Browse Source

init by jiapeng

jiapeng 6 years ago
commit
115c35a876
28 changed files with 2608 additions and 0 deletions
  1. 85 0
      pom.xml
  2. 37 0
      src/main/java/com/ekexiu/project/job/TaskJob.java
  3. 118 0
      src/main/java/com/ekexiu/project/platform/article/Article.java
  4. 33 0
      src/main/java/com/ekexiu/project/platform/article/ArticleDao.java
  5. 59 0
      src/main/java/com/ekexiu/project/platform/article/ArticleService.java
  6. 66 0
      src/main/java/com/ekexiu/project/platform/article/InvalidArticle.java
  7. 21 0
      src/main/java/com/ekexiu/project/platform/base/po/BaseTable.java
  8. 14 0
      src/main/java/com/ekexiu/project/platform/base/po/ManagedBaseTable.java
  9. 126 0
      src/main/java/com/ekexiu/project/platform/mail/MailService.java
  10. 36 0
      src/main/java/com/ekexiu/project/platform/mobile/MobilePhoneResult.java
  11. 20 0
      src/main/java/com/ekexiu/project/platform/mobile/MobilePhoneResultEntry.java
  12. 312 0
      src/main/java/com/ekexiu/project/platform/mobile/MobilePhoneService.java
  13. 48 0
      src/main/java/com/ekexiu/project/platform/professor/po/Professor.java
  14. 43 0
      src/main/java/com/ekexiu/project/platform/system/dao/DictDao.java
  15. 100 0
      src/main/java/com/ekexiu/project/platform/system/dao/UserDao.java
  16. 88 0
      src/main/java/com/ekexiu/project/platform/system/po/DictItem.java
  17. 148 0
      src/main/java/com/ekexiu/project/platform/system/po/Manager.java
  18. 22 0
      src/main/java/com/ekexiu/project/platform/system/po/SysRight.java
  19. 140 0
      src/main/java/com/ekexiu/project/platform/system/po/User.java
  20. 29 0
      src/main/java/com/ekexiu/project/platform/system/po/UserLoginLog.java
  21. 263 0
      src/main/java/com/ekexiu/project/platform/system/service/CommonUtilService.java
  22. 164 0
      src/main/java/com/ekexiu/project/platform/system/service/DictService.java
  23. 395 0
      src/main/java/com/ekexiu/project/platform/system/service/SysService.java
  24. 20 0
      src/main/java/com/ekexiu/project/platform/system/vo/ManagerInfo.java
  25. 114 0
      src/main/java/com/ekexiu/project/platform/system/vo/SessionUser.java
  26. 42 0
      src/main/java/com/ekexiu/project/vo/UploadFile.java
  27. 1 0
      src/main/resources/.gitignore
  28. 64 0
      src/main/webapp/web.xml

+ 85 - 0
pom.xml

@ -0,0 +1,85 @@
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.project</groupId>
5
	<artifactId>platformConsole</artifactId>
6
	<version>0.0.1</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
		<maven.tomcat.path>/</maven.tomcat.path>
14
	</properties>
15
	<dependencies>
16
		<dependency>
17
			<groupId>org.postgresql</groupId>
18
			<artifactId>postgresql</artifactId>
19
			<version>9.4.1207.jre7</version>
20
		</dependency>
21
		<dependency>
22
			<groupId>org.jfw</groupId>
23
			<artifactId>jfwApt</artifactId>
24
			<version>0.0.2-SNAPSHOT</version>
25
			<optional>true</optional>
26
		</dependency>
27
		<dependency>
28
			<groupId>org.jfw</groupId>
29
			<artifactId>jfwAptOrm</artifactId>
30
			<version>0.0.2-SNAPSHOT</version>
31
			<optional>true</optional>
32
		</dependency>
33
		<dependency>
34
			<groupId>org.jfw</groupId>
35
			<artifactId>jfwAptWeb</artifactId>
36
			<version>0.0.2-SNAPSHOT</version>
37
			<optional>true</optional>
38
		</dependency>
39
		<dependency>
40
			<groupId>org.jfw</groupId>
41
			<artifactId>jfwUtil</artifactId>
42
			<version>0.0.2-SNAPSHOT</version>
43
		</dependency>
44
		<dependency>
45
			<groupId>org.jfw</groupId>
46
			<artifactId>jfwWebUtil</artifactId>
47
			<version>0.0.2-SNAPSHOT</version>
48
		</dependency>
49
		<dependency>
50
			<groupId>javax.servlet</groupId>
51
			<artifactId>servlet-api</artifactId>
52
			<scope>provided</scope>
53
			<version>2.5</version>
54
		</dependency>
55
		<dependency>
56
			<groupId>com.alibaba</groupId>
57
			<artifactId>druid</artifactId>
58
			<version>1.0.20</version>
59
		</dependency>
60
		<dependency>
61
			<groupId>javax.mail</groupId>
62
			<artifactId>mail</artifactId>
63
			<version>1.4</version>
64
		</dependency>
65
	</dependencies>
66
	<build>
67
		<plugins>
68
			<plugin>
69
				<groupId>org.mortbay.jetty</groupId>
70
				<artifactId>jetty-maven-plugin</artifactId>
71
				<version>8.1.0.RC5</version>
72
				<configuration>
73
					<stopPort>9966</stopPort>
74
					<stopKey>foo</stopKey>
75
					<webAppConfig>
76
						<contextPath>/platformConsole</contextPath>
77
					</webAppConfig>
78
                    <reload>automatic</reload>
79
                    <scanIntervalSeconds>3</scanIntervalSeconds>
80
				</configuration>
81
			</plugin>
82
		</plugins>
83
		<finalName>platformConsole</finalName>
84
	</build>
85
</project>

+ 37 - 0
src/main/java/com/ekexiu/project/job/TaskJob.java

@ -0,0 +1,37 @@
1
package com.ekexiu.project.job;
2

3
import java.sql.Connection;
4
import java.util.concurrent.ScheduledExecutorService;
5

6
import javax.sql.DataSource;
7

8
import org.jfw.util.bean.AfterBeanFactory;
9
import org.jfw.util.bean.BeanFactory;
10
import org.jfw.util.context.JfwAppContext;
11
import org.jfw.util.jdbc.JdbcUtil;
12

13
import com.ekexiu.project.platform.system.service.DictService;
14

15

16

17
public class TaskJob implements AfterBeanFactory {
18
	private ScheduledExecutorService service;
19
	private DataSource dataSource;
20

21
	@Override
22
	public void handle(BeanFactory bf) throws Throwable {
23
		this.service = JfwAppContext.getScheduledExecutorService();
24
		this.dataSource =(DataSource) bf.getBean("dataSource");
25
		Connection con  = this.dataSource.getConnection();
26
		try{
27
		
28
		DictService ds = (DictService) bf.getBean("com_ekexiu_project_platform_system_service_DictService");
29
		ds.load(con);
30
		
31
		}finally{
32
			JdbcUtil.close(con);
33
		}
34
	}
35

36

37
}

+ 118 - 0
src/main/java/com/ekexiu/project/platform/article/Article.java

@ -0,0 +1,118 @@
1
package com.ekexiu.project.platform.article;
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.project.platform.base.po.ManagedBaseTable;
9

10
@PrimaryKey("id")
11
@Table
12
public class Article implements ManagedBaseTable {
13

14
	private String id;
15
	private long shareId;
16
	private String catalog;
17
	private String title;
18
	private String source;
19
	private String imgUrl;
20
	private String cnt;
21
	private boolean published;
22
	private boolean actived;
23
	private String createTime;
24
	private String modifyTime;
25
	private String creator;
26
	private String modifier;
27
	
28
	@Column(DE.id_32)
29
	public String getId() {
30
		return id;
31
	}
32
	public void setId(String id) {
33
		this.id = id;
34
	}
35
	@Column(value=DE.long_de,insertable = false,renewable = false)
36
	public long getShareId() {
37
		return shareId;
38
	}
39
	public void setShareId(long shareId) {
40
		this.shareId = shareId;
41
	}
42
	@Column(DE.Text_de)
43
	public String getCatalog() {
44
		return catalog;
45
	}
46
	public void setCatalog(String catalog) {
47
		this.catalog = catalog;
48
	}
49
	@Column(DE.text_de)
50
	public String getTitle() {
51
		return title;
52
	}
53
	public void setTitle(String title) {
54
		this.title = title;
55
	}
56
	@Column(DE.Text_de)
57
	public String getSource() {
58
		return source;
59
	}
60
	public void setSource(String source) {
61
		this.source = source;
62
	}
63
	@Column(DE.Text_de)
64
	public String getImgUrl() {
65
		return imgUrl;
66
	}
67
	public void setImgUrl(String imgUrl) {
68
		this.imgUrl = imgUrl;
69
	}
70
	@Column(DE.Text_de)
71
	public String getCnt() {
72
		return cnt;
73
	}
74
	public void setCnt(String cnt) {
75
		this.cnt = cnt;
76
	}
77
	@Column(DE.boolean_de)
78
	public boolean isPublished() {
79
		return published;
80
	}
81
	public void setPublished(boolean published) {
82
		this.published = published;
83
	}
84
	@Column(DE.boolean_de)
85
	public boolean isActived() {
86
		return actived;
87
	}
88
	public void setActived(boolean actived) {
89
		this.actived = actived;
90
	}
91
	public String getCreateTime() {
92
		return createTime;
93
	}
94
	public void setCreateTime(String createTime) {
95
		this.createTime = createTime;
96
	}
97
	public String getModifyTime() {
98
		return modifyTime;
99
	}
100
	public void setModifyTime(String modifyTime) {
101
		this.modifyTime = modifyTime;
102
	}
103
	public String getCreator() {
104
		return creator;
105
	}
106
	public void setCreator(String creator) {
107
		this.creator = creator;
108
	}
109
	public String getModifier() {
110
		return modifier;
111
	}
112
	public void setModifier(String modifier) {
113
		this.modifier = modifier;
114
	}
115

116
	
117
	
118
}

+ 33 - 0
src/main/java/com/ekexiu/project/platform/article/ArticleDao.java

@ -0,0 +1,33 @@
1
package com.ekexiu.project.platform.article;
2

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

6
import org.jfw.apt.orm.annotation.dao.DAO;
7
import org.jfw.apt.orm.annotation.dao.method.From;
8
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
9
import org.jfw.apt.orm.annotation.dao.method.Where;
10
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
11
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
12

13
@DAO
14
public interface ArticleDao {
15

16
	
17
	@UpdateWith
18
	@From(Article.class)
19
	@Where("ACTIVED ='1'")
20
	@SetSentence("ACTIVED='0'")
21
	int invalid(Connection con,String id)throws SQLException;
22
	
23
	
24
	@UpdateWith
25
	@From(Article.class)
26
	@Where("ACTIVED ='0'")
27
	@SetSentence("ACTIVED='1'")
28
	int valid(Connection con,String id)throws SQLException;
29
	
30
	@DeleteWith
31
	@From(InvalidArticle.class)
32
	int delete(Connection con,String id)throws SQLException;
33
}

+ 59 - 0
src/main/java/com/ekexiu/project/platform/article/ArticleService.java

@ -0,0 +1,59 @@
1
package com.ekexiu.project.platform.article;
2

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

7
import org.jfw.apt.annotation.Autowrie;
8
import org.jfw.apt.web.annotation.LoginUser;
9
import org.jfw.apt.web.annotation.Path;
10
import org.jfw.apt.web.annotation.operate.Post;
11
import org.jfw.apt.web.annotation.param.JdbcConn;
12
import org.jfw.util.auth.AuthUser;
13
import org.jfw.util.jdbc.JdbcUtil;
14
import org.jfw.util.jdbc.PreparedStatementConfig;
15

16
@Path("/article")
17
public class ArticleService {
18

19
	@Autowrie
20

21
	private ArticleDao articleDao;
22

23
	public ArticleDao getArticleDao() {
24
		return articleDao;
25
	}
26

27
	public void setArticleDao(ArticleDao articleDao) {
28
		this.articleDao = articleDao;
29
	}
30

31
	@Path("/invalid")
32
	@Post
33
	public int invalid(@JdbcConn(true) Connection con, final String id, final @LoginUser AuthUser user) throws SQLException {
34
		if (articleDao.invalid(con, id) != 0) {
35
			JdbcUtil.execute(con, "INSERT INVALID_ARTICLE (ID,TITLE,CREATOR,CREATE_TIME,INVALID_TIME,INVALID_OPERATOR) "
36
					+ "SELECT ID,TITLE,CREATOR,CREATE_TIME,TO_CHAR(NOW(),'YYYYMMDDHH24MISS'),? FROM ARTICLE WHERE ID=?", new PreparedStatementConfig() {
37
						@Override
38
						public void config(PreparedStatement ps) throws SQLException {
39
							ps.setString(1, user.getId());
40
							ps.setString(2, id);
41

42
						}
43
					});
44
			return 1;
45
		}
46
		return 0;
47
	}
48
	
49
	@LoginUser
50
	@Path("/valid")
51
	@Post
52
	public int valid(@JdbcConn(true) Connection con, final String id) throws SQLException {
53
		if(articleDao.valid(con, id)!=0){
54
			articleDao.delete(con, id);
55
			return 1;
56
		}
57
		return 0;
58
	}
59
}

+ 66 - 0
src/main/java/com/ekexiu/project/platform/article/InvalidArticle.java

@ -0,0 +1,66 @@
1
package com.ekexiu.project.platform.article;
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 InvalidArticle {
11
	
12
	private String id;
13
	private String title;
14
	private String creator;
15
	private String createTime;
16
	private String invalidTime;
17
	private String invalidOperator;
18
	
19
	@Column(DE.text_de)
20
	public String getId() {
21
		return id;
22
	}
23
	
24
	public void setId(String id) {
25
		this.id = id;
26
	}
27
	@Column(DE.text_de)
28
	public String getTitle() {
29
		return title;
30
	}
31
	public void setTitle(String title) {
32
		this.title = title;
33
	}
34
	@Column(DE.text_de)
35
	public String getCreator() {
36
		return creator;
37
	}
38
	public void setCreator(String creator) {
39
		this.creator = creator;
40
	}
41
	@Column(DE.text_de)
42
	public String getCreateTime() {
43
		return createTime;
44
	}
45
	public void setCreateTime(String createTime) {
46
		this.createTime = createTime;
47
	}
48
	@Column(DE.text_de)
49
	public String getInvalidTime() {
50
		return invalidTime;
51
	}
52
	public void setInvalidTime(String invalidTime) {
53
		this.invalidTime = invalidTime;
54
	}
55
	@Column(DE.text_de)
56
	public String getInvalidOperator() {
57
		return invalidOperator;
58
	}
59
	public void setInvalidOperator(String invalidOperator) {
60
		this.invalidOperator = invalidOperator;
61
	}
62
	
63
	
64
	
65

66
}

+ 21 - 0
src/main/java/com/ekexiu/project/platform/base/po/BaseTable.java

@ -0,0 +1,21 @@
1
package com.ekexiu.project.platform.base.po;
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 BaseTable {
11
	@Column(descp="创建时间(YYYYMMDDHH24MISS)不可修改", 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

15
	@Column(descp="最后修改时间(YYYYMMDDHH24MISS),初始值:20000101010101", handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithInsert = "'20000101010101'", fixSqlValueWithUpdate = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = true)
16
	String getModifyTime();
17
	void setModifyTime(String modifyTime);
18

19

20
	
21
}

+ 14 - 0
src/main/java/com/ekexiu/project/platform/base/po/ManagedBaseTable.java

@ -0,0 +1,14 @@
1
package com.ekexiu.project.platform.base.po;
2

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

6
public interface ManagedBaseTable extends BaseTable {
7
	@Column(descp="创建人ID",value= DE.id_32)
8
	String getCreator();
9
	void setCreator(String creator);
10
	
11
	@Column(descp="最后修改人ID",value=DE.refid_32)
12
	String getModifier();
13
	void setModifier(String modifier);
14
}

+ 126 - 0
src/main/java/com/ekexiu/project/platform/mail/MailService.java

@ -0,0 +1,126 @@
1
package com.ekexiu.project.platform.mail;
2
3
import org.jfw.apt.annotation.Bean;
4
5
import javax.mail.Message;
6
import javax.mail.MessagingException;
7
import javax.mail.Session;
8
import javax.mail.Transport;
9
import javax.mail.internet.AddressException;
10
import javax.mail.internet.InternetAddress;
11
import javax.mail.internet.MimeMessage;
12
import java.io.UnsupportedEncodingException;
13
import java.util.Map;
14
import java.util.Properties;
15
16
@Bean
17
public class MailService {
18
	private Properties sessionProperties = new Properties();;
19
	private String mailHost;
20
	private int port;
21
	private String username;
22
	private String password;
23
	private Session session;
24
	private String from;
25
	private String nick;
26
27
	public void setNick(String nick) {
28
		if (nick == null)
29
			return;
30
		try {
31
			this.nick = javax.mail.internet.MimeUtility.encodeText(nick);
32
		} catch (UnsupportedEncodingException e) {
33
			this.nick = null;
34
		}
35
	}
36
37
	public String getFrom() {
38
		return from;
39
	}
40
41
	public void setFrom(String from) {
42
		this.from = from;
43
	}
44
45
	private Session getSession() {
46
		if (null == this.session) {
47
			this.session = Session.getInstance(this.sessionProperties);
48
		}
49
		return this.session;
50
	}
51
52
	public int getPort() {
53
		return port;
54
	}
55
56
	public void setPort(int port) {
57
		this.port = port;
58
	}
59
60
	public Properties getSessionProperties() {
61
		return sessionProperties;
62
	}
63
64
	public void setSessionProperties(Map<String, String> map) {
65
		this.sessionProperties.clear();
66
		this.sessionProperties.putAll(map);
67
	}
68
69
	public String getMailHost() {
70
		return mailHost;
71
	}
72
73
	public void setMailHost(String mailHost) {
74
		this.mailHost = mailHost;
75
	}
76
77
	public String getUsername() {
78
		return username;
79
	}
80
81
	public void setUsername(String username) {
82
		this.username = username;
83
	}
84
85
	public String getPassword() {
86
		return password;
87
	}
88
89
	public void setPassword(String password) {
90
		this.password = password;
91
	}
92
93
	public void sendSimpleMail(String to, String template, Map<String, String> values, String subject) throws MessagingException {
94
		Transport ts = this.getSession().getTransport();
95
		ts.connect(this.mailHost, port, username, password);
96
		try {
97
			Message message = this.createSimpleMail(to, subject, template, values);
98
			ts.sendMessage(message, message.getAllRecipients());
99
		} finally {
100
			try {
101
				ts.close();
102
			} catch (Exception e) {
103
			}
104
		}
105
	}
106
107
	private MimeMessage createSimpleMail(String to, String subject, String template, Map<String, String> values) throws AddressException, MessagingException {
108
		MimeMessage message = new MimeMessage(session);
109
		if (null == this.nick) {
110
			message.setFrom(new InternetAddress(this.from));
111
		} else {
112
			message.setFrom(new InternetAddress(this.nick + " <" + this.from + ">"));
113
		}
114
		message.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
115
		message.setSubject(subject);
116
117
		String content = template;
118
		if (null != values && values.size() > 0) {
119
			for (Map.Entry<String, String> entry : values.entrySet()) {
120
				content = content.replaceAll(entry.getKey(), entry.getValue());
121
			}
122
		}
123
		message.setContent(content, "text/html;charset=UTF-8");
124
		return message;
125
	}
126
}

+ 36 - 0
src/main/java/com/ekexiu/project/platform/mobile/MobilePhoneResult.java

@ -0,0 +1,36 @@
1
package com.ekexiu.project.platform.mobile;
2
3
import java.util.List;
4
5
public class MobilePhoneResult {
6
	public static final String SUCCESS="00000";	
7
	
8
	private String respCode;
9
	private String failCount;
10
	private List<MobilePhoneResultEntry> failList;
11
	private String smsId;
12
	public String getRespCode() {
13
		return respCode;
14
	}
15
	public void setRespCode(String respCode) {
16
		this.respCode = respCode;
17
	}
18
	public String getFailCount() {
19
		return failCount;
20
	}
21
	public void setFailCount(String failCount) {
22
		this.failCount = failCount;
23
	}
24
	public List<MobilePhoneResultEntry> getFailList() {
25
		return failList;
26
	}
27
	public void setFailList(List<MobilePhoneResultEntry> failList) {
28
		this.failList = failList;
29
	}
30
	public String getSmsId() {
31
		return smsId;
32
	}
33
	public void setSmsId(String smsId) {
34
		this.smsId = smsId;
35
	}
36
}

+ 20 - 0
src/main/java/com/ekexiu/project/platform/mobile/MobilePhoneResultEntry.java

@ -0,0 +1,20 @@
1
package com.ekexiu.project.platform.mobile;
2
3
public class MobilePhoneResultEntry {
4
	private String phone;
5
	private String respCode;
6
	public String getPhone() {
7
		return phone;
8
	}
9
	public void setPhone(String phone) {
10
		this.phone = phone;
11
	}
12
	public String getRespCode() {
13
		return respCode;
14
	}
15
	public void setRespCode(String respCode) {
16
		this.respCode = respCode;
17
	}
18
	
19
20
}

+ 312 - 0
src/main/java/com/ekexiu/project/platform/mobile/MobilePhoneService.java

@ -0,0 +1,312 @@
1
package com.ekexiu.project.platform.mobile;
2
3
import org.jfw.apt.annotation.Bean;
4
import org.jfw.util.ConstData;
5
import org.jfw.util.DateUtil;
6
import org.jfw.util.StringUtil;
7
import org.jfw.util.exception.JfwBaseException;
8
import org.jfw.util.io.IoUtil;
9
import org.jfw.util.json.JsonService;
10
11
import java.io.ByteArrayInputStream;
12
import java.io.IOException;
13
import java.io.InputStream;
14
import java.io.InputStreamReader;
15
import java.io.OutputStream;
16
import java.net.HttpURLConnection;
17
import java.net.URL;
18
import java.net.URLEncoder;
19
import java.util.HashMap;
20
import java.util.Locale;
21
import java.util.Map;
22
23
@Bean
24
public class MobilePhoneService {
25
	private static final Map<String, String> errorReason = new HashMap<String, String>();
26
27
	private String accountSid = "6f5c2612d691480a9bbbee0c64e10872";
28
	private String authToken = "4fac48f2d37d4ba89cc037e7d012348e";
29
	private String restUrl = "https://api.miaodiyun.com/20150822/industrySMS/sendSMS";
30
	private String marketUrl = "https://api.miaodiyun.com/20150822/affMarkSMS/sendSMS";
31
	private int sendTimeout = 10 * 1000;
32
	private int readTimeout = 10 * 1000;
33
34
	public int getSendTimeout() {
35
		return sendTimeout;
36
	}
37
38
	public void setSendTimeout(int sendTimeout) {
39
		this.sendTimeout = sendTimeout;
40
	}
41
42
	public int getReadTimeout() {
43
		return readTimeout;
44
	}
45
46
	public void setReadTimeout(int readTimeout) {
47
		this.readTimeout = readTimeout;
48
	}
49
50
	public String getRestUrl() {
51
		return restUrl;
52
	}
53
54
	public void setRestUrl(String restUrl) {
55
		this.restUrl = restUrl;
56
	}
57
58
	public String getMarketUrl() {
59
		return marketUrl;
60
	}
61
62
	public void setMarketUrl(String marketUrl) {
63
		this.marketUrl = marketUrl;
64
	}
65
66
	public String getAccountSid() {
67
		return accountSid;
68
	}
69
70
	public void setAccountSid(String accountSid) {
71
		this.accountSid = accountSid;
72
	}
73
74
	public String getAuthToken() {
75
		return authToken;
76
	}
77
78
	public void setAuthToken(String authToken) {
79
		this.authToken = authToken;
80
	}
81
82
	private byte[] send(String content) throws IOException {
83
		URL url = new URL(this.restUrl);
84
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
85
		conn.setRequestMethod("POST");// 提交模式
86
		conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
87
		conn.setConnectTimeout(this.sendTimeout);// 连接超时 单位毫秒
88
		conn.setReadTimeout(this.readTimeout);// 读取超时 单位毫秒
89
		conn.setDoOutput(true);// 是否输入参数
90
		byte[] bypes = content.getBytes(ConstData.UTF8);
91
		OutputStream out = conn.getOutputStream();
92
		try {
93
			out.write(bypes);
94
			out.flush();
95
		} finally {
96
			out.close();
97
		}
98
		InputStream inStream = conn.getInputStream();
99
		return IoUtil.readStream(inStream, true);
100
	}
101
	
102
	private byte[] sendMarket(String content) throws IOException {
103
		URL url = new URL(this.marketUrl);
104
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
105
		conn.setRequestMethod("POST");// 提交模式
106
		conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
107
		conn.setConnectTimeout(this.sendTimeout);// 连接超时 单位毫秒
108
		conn.setReadTimeout(this.readTimeout);// 读取超时 单位毫秒
109
		conn.setDoOutput(true);// 是否输入参数
110
		byte[] bypes = content.getBytes(ConstData.UTF8);
111
		OutputStream out = conn.getOutputStream();
112
		try {
113
			out.write(bypes);
114
			out.flush();
115
		} finally {
116
			out.close();
117
		}
118
		InputStream inStream = conn.getInputStream();
119
		return IoUtil.readStream(inStream, true);
120
	}
121
122
	private MobilePhoneResult parse(byte[] bytes) {
123
		return JsonService.fromJson(new InputStreamReader(new ByteArrayInputStream(bytes), ConstData.UTF8), MobilePhoneResult.class);
124
	}
125
126
	public void sendMessage(String to, String contentTemplate, String replateKey, String value) throws Exception {
127
		String content = contentTemplate.replaceAll(replateKey, value);
128
		String dateStr = DateUtil.formatDateTime(System.currentTimeMillis());
129
		StringBuilder sb = new StringBuilder();
130
		sb.append("accountSid=").append(this.accountSid).append("&smsContent=").append(URLEncoder.encode(content, "UTF-8")).append("&to=").append(to)
131
				.append("&timestamp=").append(dateStr).append("&sig=");
132
		String md5 = StringUtil.md5(this.accountSid + this.authToken + dateStr).toLowerCase(Locale.US);
133
		sb.append(md5);
134
		MobilePhoneResult mpr = this.parse(this.send(sb.toString()));
135
		if (!MobilePhoneResult.SUCCESS.equals(mpr.getRespCode())) {
136
			String reason = errorReason.get(mpr.getRespCode());
137
			if(reason==null) reason="未知错误,请联系技术客服。";
138
			throw new Exception(mpr.getRespCode()+"-"+reason);
139
		}
140
	}
141
	
142
	public void sendMarketMessage(String to, String contentTemplate) throws Exception {
143
		String dateStr = DateUtil.formatDateTime(System.currentTimeMillis());
144
		StringBuilder sb = new StringBuilder();
145
		sb.append("accountSid=").append(this.accountSid).append("&smsContent=").append(URLEncoder.encode(contentTemplate, "UTF-8")).append("&to=").append(to)
146
				.append("&timestamp=").append(dateStr).append("&sig=");
147
		String md5 = StringUtil.md5(this.accountSid + this.authToken + dateStr).toLowerCase(Locale.US);
148
		sb.append(md5);
149
		MobilePhoneResult mpr = this.parse(this.sendMarket(sb.toString()));
150
		if (!MobilePhoneResult.SUCCESS.equals(mpr.getRespCode())) {
151
			String reason = errorReason.get(mpr.getRespCode());
152
			if(reason==null) reason="未知错误,请联系技术客服。";
153
			throw new Exception(mpr.getRespCode()+"-"+reason);
154
		}
155
	}
156
	
157
	
158
	public static void main(String[] args) throws Exception{
159
		MobilePhoneService mps = new MobilePhoneService();
160
		try {
161
			mps.sendMarketMessage("13525007261", "【科袖】您收到了一个新的咨询,快去查看吧。http://a.app.qq.com/o/simple.jsp?pkgname=com.ekexiu.app退订回N");
162
			System.out.println("send success!");
163
		} catch (Exception e) {
164
			throw new JfwBaseException("send error!");
165
		}
166
		//mps.sendMessage("18601149468","【科袖科技】请输入验证码yzm,完成手机绑定。请于1分钟内正确输入验证码。如非本人操作,请忽略本短信。科袖科技","yzm","122234");
167
	}
168
169
	static {
170
		errorReason.put("00001", "未知错误,请联系技术客服。");
171
		errorReason.put("00002", "未知的方法名");
172
		errorReason.put("00003", "请求方式错误");
173
		errorReason.put("00004", "参数非法,如request parameter (key) is missing");
174
		errorReason.put("00005", "timestamp已过期");
175
		errorReason.put("00006", "sign错误");
176
		errorReason.put("00007", "重复提交");
177
		errorReason.put("00008", "操作频繁");
178
		errorReason.put("00011", "请求的xml格式不对");
179
		errorReason.put("00012", "不支持get请求,请使用post");
180
		errorReason.put("00013", "请求url格式不正确");
181
		errorReason.put("00015", "时间戳超出有效时间范围");
182
		errorReason.put("00016", "请求json格式不对");
183
		errorReason.put("00017", "数据库操作失败");
184
		errorReason.put("00018", "参数为空");
185
		errorReason.put("00019", "订单已存在");
186
		errorReason.put("00020", "用户不存在");
187
		errorReason.put("00021", "子账号余额不足");
188
		errorReason.put("00022", "操作频繁");
189
		errorReason.put("00023", "开发者余额不足");
190
		errorReason.put("00025", "手机格式不对");
191
		errorReason.put("00026", "手机号存在");
192
		errorReason.put("00027", "子账号名称已存在");
193
		errorReason.put("00028", "子账号名称过长");
194
		errorReason.put("00029", "回调开发者服务器异常");
195
		errorReason.put("00030", "回调地址为空");
196
		errorReason.put("00031", "appId为空或者没有传值");
197
		errorReason.put("00032", "主叫号码为空或者没有传值");
198
		errorReason.put("00033", "被叫号码为空或者没有传值");
199
		errorReason.put("00034", "子账号为空或者没有传值");
200
		errorReason.put("00035", "主叫号码和被叫号码相同");
201
		errorReason.put("00036", "验证码格式不对(4-8位数字)");
202
		errorReason.put("00037", "limit格式不对");
203
		errorReason.put("00038", "start格式不对");
204
		errorReason.put("00039", "验证码为空或者缺少此参数");
205
		errorReason.put("00040", "用户名或者密码错误");
206
		errorReason.put("00050", "短信或者语音验证码错误");
207
		errorReason.put("00051", "显示号码与被叫号码一样,不允许呼叫");
208
		errorReason.put("00052", "回拨主叫号码格式错误");
209
		errorReason.put("00053", "被叫号码格式错误");
210
		errorReason.put("00054", "显号格式错误");
211
		errorReason.put("00055", "应用不包含此子账号");
212
		errorReason.put("00056", "开发者不包含此应用");
213
		errorReason.put("00060", "请求数据不存在");
214
		errorReason.put("00061", "app不存在");
215
		errorReason.put("00062", "developerId 请求错误");
216
		errorReason.put("00063", "app未上线");
217
		errorReason.put("00064", "请求Content-Type错误");
218
		errorReason.put("00065", "请求Accept错误");
219
		errorReason.put("00066", "开发者余额已被冻结");
220
		errorReason.put("00070", "手机号未绑定");
221
		errorReason.put("00071", "通知类型已停用或者未创建");
222
		errorReason.put("00072", "balance格式不对(必须为大于等于0的double)");
223
		errorReason.put("00073", "charge格式不对(必须为大于等于0的double)");
224
		errorReason.put("00074", "主叫和子账户绑定的手机号不相同");
225
		errorReason.put("00075", "子账户没有绑定手机号");
226
		errorReason.put("00076", "时间格式不对");
227
		errorReason.put("00077", "开始时间小于结束时间");
228
		errorReason.put("00078", "开始时间和結束時間必須是同一天");
229
		errorReason.put("00079", "服务器内部异常");
230
		errorReason.put("00080", "子账号不存在");
231
		errorReason.put("00081", "通知计费系统失败");
232
		errorReason.put("00082", "参数校验失败");
233
		errorReason.put("00083", "充值失败");
234
		errorReason.put("00084", "子账号没有托管 不能进行充值");
235
		errorReason.put("00085", "开发者不包含子帐号");
236
		errorReason.put("00086", "DEMO不能进行充值");
237
		errorReason.put("00087", "IQ类型错误");
238
		errorReason.put("00090", "回调地址为空");
239
		errorReason.put("00091", "没有语音");
240
		errorReason.put("00093", "没有这个语音文件或者审核没通过");
241
		errorReason.put("00094", "每批发送的手机号数量不得超过100个");
242
		errorReason.put("00095", "未开通邮件短信功能");
243
		errorReason.put("00096", "邮件模板未审核通过");
244
		errorReason.put("00097", "邮件模板未启用");
245
		errorReason.put("00098", "同一手机号每天只能发送n条相同的内容");
246
		errorReason.put("00099", "相同的应用每天只能给同一手机号发送n条不同的内容");
247
		errorReason.put("00100", "短信内容不能含有关键字");
248
		errorReason.put("00101", "配置短信端口号失败");
249
		errorReason.put("00102", "一个开发者只能配置一个端口");
250
		errorReason.put("00103", "应用的邮件模板不存在");
251
		errorReason.put("00104", "相同的应用当天给同一手机号发送短信的条数小于等于n");
252
		errorReason.put("00105", "本开发者只能发短信给移动手机");
253
		errorReason.put("00106", "时间戳(timestamp)参数为空");
254
		errorReason.put("00107", "签名(sig)参数为空");
255
		errorReason.put("00108", "时间戳(timestamp)格式错误");
256
		errorReason.put("00109", "子账号已被关闭");
257
		errorReason.put("00110", "解析post数据失败,post数据不符合格式要求");
258
		errorReason.put("00111", "匹配到黑名单");
259
		errorReason.put("00112", "accountSid参数为空");
260
		errorReason.put("00113", "短信内容和模板匹配度过低");
261
		errorReason.put("00114", "clientNumber参数为空");
262
		errorReason.put("00115", "charge参数为空");
263
		errorReason.put("00116", "charge格式不对,不能解析成double");
264
		errorReason.put("00117", "fromTime参数为空");
265
		errorReason.put("00118", "toTime参数为空");
266
		errorReason.put("00119", "fromTime参数格式不正确");
267
		errorReason.put("00120", "toTime参数格式不正确");
268
		errorReason.put("00122", "date参数为空");
269
		errorReason.put("00123", "date的值不在指定范围内");
270
		errorReason.put("00124", "没有查询到话单(所以没有生成下载地址)");
271
		errorReason.put("00125", "emailTemplateId参数为空");
272
		errorReason.put("00126", "to参数为空");
273
		errorReason.put("00127", "param参数为空");
274
		errorReason.put("00128", "templateId参数为空");
275
		errorReason.put("00129", "模板类型错误");
276
		errorReason.put("00130", "serviceType参数为空");
277
		errorReason.put("00131", "content参数为空");
278
		errorReason.put("00132", "本接口的邮件短信业务只能发送移动手机");
279
		errorReason.put("00133", "错误的业务类型");
280
		errorReason.put("00134", "没有和内容匹配的模板");
281
		errorReason.put("00135", "应用没有属于指定类型业务并且已审核通过、已启用的模板");
282
		errorReason.put("00136", "开发者不能调用此接口");
283
		errorReason.put("00137", "没有权限自定义邮件内容");
284
		errorReason.put("00138", "短信没有签名不能发送");
285
		errorReason.put("00139", "短信签名已进入黑名单不能发送");
286
		errorReason.put("00140", "邮件短信发送间隔太小");
287
		errorReason.put("00141", "一小时内发送给单个手机次数超过限制");
288
		errorReason.put("00142", "一天内发送给单个手机次数超过限制");
289
		errorReason.put("00143", "含有非法关键字");
290
		errorReason.put("00144", "mobile参数为空");
291
		errorReason.put("00145", "新手机号和旧手机号相同,不必修改");
292
		errorReason.put("00146", "minutes格式不对(必须为大于等于0的double)");
293
		errorReason.put("00147", "被叫次数超限");
294
		errorReason.put("00148", "主叫次数超限");
295
		errorReason.put("00149", "流量包大小格式错误");
296
		errorReason.put("00150", "找不到匹配的流量包");
297
		errorReason.put("00151", "该签名下的手机号码黑名单");
298
		errorReason.put("00152", "端口号已被关闭");
299
		errorReason.put("00153", "未知的手机号运营商");
300
		errorReason.put("00154", "开发者无权限给此号码发短信");
301
		errorReason.put("00155", "流量充值提交失败");
302
		errorReason.put("00156", "packageId为空或者没有传值");
303
		errorReason.put("00157", "packageId不存在");
304
		errorReason.put("00158", "不允许发验证码");
305
		errorReason.put("00159", "超过每秒发送频率限制");
306
		errorReason.put("00160", "没有发送会员通知推广类短信权限");
307
		errorReason.put("00161", "短信签名没有报备");
308
		errorReason.put("00162", "没有发送营销短信权限");
309
		errorReason.put("00163", "会员营销短信内容必须包含退订");
310
		errorReason.put("00164", "端口号非法");
311
	}
312
}

+ 48 - 0
src/main/java/com/ekexiu/project/platform/professor/po/Professor.java

@ -0,0 +1,48 @@
1
package com.ekexiu.project.platform.professor.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 Professor {
11

12
	private String id;
13
	private long shareId;
14
	private Integer level;
15
	private String assTime;
16
	
17
	@Column(DE.text_de)
18
	public String getId() {
19
		return id;
20
	}
21
	public void setId(String id) {
22
		this.id = id;
23
	}
24
	@Column(DE.long_de)
25
	public long getShareId() {
26
		return shareId;
27
	}
28
	public void setShareId(long shareId) {
29
		this.shareId = shareId;
30
	}
31
	@Column(DE.Int_de)
32
	public Integer getLevel() {
33
		return level;
34
	}
35
	public void setLevel(Integer level) {
36
		this.level = level;
37
	}
38
	@Column(DE.text_de)
39
	public String getAssTime() {
40
		return assTime;
41
	}
42
	public void setAssTime(String assTime) {
43
		this.assTime = assTime;
44
	}
45
	
46
	
47
	
48
}

+ 43 - 0
src/main/java/com/ekexiu/project/platform/system/dao/DictDao.java

@ -0,0 +1,43 @@
1
package com.ekexiu.project.platform.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.IncludeFixSet;
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.SelectList;
15
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
16
import org.jfw.apt.orm.annotation.dao.param.Set;
17

18
import com.ekexiu.project.platform.system.po.DictItem;
19

20
@DAO
21
public interface DictDao {
22

23
	@SelectList
24
	List<DictItem> query(Connection con) throws SQLException;
25

26
	@Insert
27
	int insert(Connection con, DictItem dict) throws SQLException;
28

29
	@UpdateWith
30
	@From(DictItem.class)
31
	@Where("ACTIVE = '1' AND READONLY <> '1'")
32
	@SetSentence("ACTIVE='0'")
33
	@IncludeFixSet
34
	int disable(Connection con, String dictCode, String code) throws SQLException;
35

36
	
37
	@UpdateWith
38
	@From(DictItem.class)
39
	@Where("ACTIVE = '1' AND READONLY <> '1'")
40
	int update(Connection con, @Nullable @Set String bcode, @Set String caption, @Nullable @Set String fullCaption, @Set @Nullable String shortCut,
41
			@Nullable @Set String remark, String code, String dictCode) throws SQLException;
42

43
}

+ 100 - 0
src/main/java/com/ekexiu/project/platform/system/dao/UserDao.java

@ -0,0 +1,100 @@
1
package com.ekexiu.project.platform.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.Batch;
8
import org.jfw.apt.orm.annotation.dao.DAO;
9
import org.jfw.apt.orm.annotation.dao.method.Exclude;
10
import org.jfw.apt.orm.annotation.dao.method.From;
11
import org.jfw.apt.orm.annotation.dao.method.IncludeFixSet;
12
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
13
import org.jfw.apt.orm.annotation.dao.method.Where;
14
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
15
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
16
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
17
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
18
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
19
import org.jfw.apt.orm.annotation.dao.param.Alias;
20
import org.jfw.apt.orm.annotation.dao.param.Set;
21
import org.jfw.apt.orm.annotation.dao.param.UnEquals;
22
23
import com.ekexiu.project.platform.system.po.Manager;
24
import com.ekexiu.project.platform.system.po.SysRight;
25
import com.ekexiu.project.platform.system.po.User;
26
import com.ekexiu.project.platform.system.po.UserLoginLog;
27
28
29
@DAO
30
public interface UserDao {
31
32
	@Nullable
33
	@SelectOne
34
	User query(Connection con, String id) throws SQLException;
35
36
	@Nullable
37
	@SelectOne
38
	User queryByLoginPhone(Connection con,String loginPhone,Boolean active) throws SQLException;
39
	
40
	@Nullable
41
	@SelectOne
42
	User login(Connection con, String account, String passwd) throws SQLException;
43
	
44
	@Insert
45
	int insert(Connection con, User user) throws SQLException;
46
	
47
	@Insert
48
	int insert(Connection con,UserLoginLog uli)throws SQLException;
49
	
50
	@UpdateWith
51
	@From(UserLoginLog.class)
52
	int updateLoginLog(Connection con,String id,@Set String lastLoginTime)throws SQLException;
53
54
	@Update
55
	@Exclude({"passwd","active","loginPhone"})
56
	int update(Connection con, User user) throws SQLException;
57
	
58
	@UpdateWith
59
	@From(User.class)
60
	int changePasswd(Connection con,String id,String passwd,@Set @Alias("passwd") String newPasswd) throws SQLException;
61
	
62
	@UpdateWith
63
	@From(User.class)
64
	int resetPasswd(Connection con,String loginPhone,@Set String passwd) throws SQLException;
65
	
66
	
67
	
68
	@Insert
69
	int insert(Connection con,Manager user)throws SQLException;
70
	
71
	@Insert
72
	@Batch
73
	int[] insert(Connection con,SysRight[] rightcodes)throws SQLException;
74
	
75
	@DeleteWith
76
	@From(SysRight.class)
77
	int delete(Connection con,String uid,@UnEquals String rightCode)throws SQLException;
78
	
79
	
80
	@Update
81
	@Where("ACTIVE ='1'")
82
	@IncludeFixSet
83
	@Exclude(value = { "invalidTime","invalidOperator","passwd","active" })
84
	int update(Connection con,Manager user)throws SQLException;
85
	
86
	@UpdateWith
87
	@From(Manager.class)
88
	@Where("ACTIVE ='1'")
89
	@SetSentence("ACTIVE='0',INVALID_TIME=TO_CHAR(NOW(),'YYYYMMDDHH24MISS')")
90
	int disable(Connection con,String id,@Set String invalidOperator)throws SQLException;
91
	
92
	@UpdateWith
93
	@From(Manager.class)
94
	@Where("ACTIVE ='0'")
95
	@SetSentence("ACTIVE='1'")
96
	int disable(Connection con,String id)throws SQLException;
97
	
98
	
99
	
100
}

+ 88 - 0
src/main/java/com/ekexiu/project/platform/system/po/DictItem.java

@ -0,0 +1,88 @@
1
package com.ekexiu.project.platform.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({"dictCode","code"})
9
@Table(descp="数据字典表",value="SYS_DICT")
10
public class DictItem {
11
	private String code;
12
	private String dictCode;
13
	private String bcode;
14
	private String caption;
15
	private String fullCaption;
16
	private String shortCut;
17
	private String remark;
18
	private boolean readonly;
19
	private boolean active;
20
	
21
	@Column(descp="字典项编码",value= DE.rtext_de)
22
	public String getCode() {
23
		return code;
24
	}
25
	public void setCode(String code) {
26
		this.code = code;
27
	}
28
	
29
	@Column(descp="字典项编码(业务编码)",value= DE.Text_de)
30
	public String getBcode() {
31
		return bcode;
32
	}
33
	public void setBcode(String bcode) {
34
		this.bcode = bcode;
35
	}
36
	@Column(descp="字典编码",value= DE.rtext_de)
37
	public String getDictCode() {
38
		return dictCode;
39
	}
40
	public void setDictCode(String dictCode) {
41
		this.dictCode = dictCode;
42
	}
43
	@Column(descp="字典项显示",value= DE.text_de)
44
	public String getCaption() {
45
		return caption;
46
	}
47
	public void setCaption(String caption) {
48
		this.caption = caption;
49
	}
50
	@Column(descp="字典项显示(全)",value= DE.Text_de)
51
	public String getFullCaption() {
52
		return fullCaption;
53
	}
54
	public void setFullCaption(String fullCaption) {
55
		this.fullCaption = fullCaption;
56
	}
57
	@Column(descp="助记码",value= DE.Text_de)
58
	public String getShortCut() {
59
		return shortCut;
60
	}
61
	public void setShortCut(String shortCut) {
62
		this.shortCut = shortCut;
63
	}
64
	@Column(descp="备注",value= DE.Text_de)
65
	public String getRemark() {
66
		return remark;
67
	}
68
	public void setRemark(String remark) {
69
		this.remark = remark;
70
	}
71
	@Column(descp="是否只读",value= DE.boolean_de)
72
	public boolean isReadonly() {
73
		return readonly;
74
	}
75
	public void setReadonly(boolean readonly) {
76
		this.readonly = readonly;
77
	}
78
	@Column(descp="是否有效",value= DE.boolean_de)
79
	public boolean isActive() {
80
		return active;
81
	}
82
	public void setActive(boolean active) {
83
		this.active = active;
84
	}
85
	
86
	
87
	
88
}

+ 148 - 0
src/main/java/com/ekexiu/project/platform/system/po/Manager.java

@ -0,0 +1,148 @@
1
package com.ekexiu.project.platform.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.project.platform.base.po.ManagedBaseTable;
9

10
@PrimaryKey("id")
11
@Table
12
public class Manager  implements ManagedBaseTable {
13
	private String id;
14
	private String account;
15
	private String passwd;
16
	private String name;
17
	private String phone;
18
	private String email;
19
	private String job;
20
	private String dep;
21
	private String comp;
22
	private boolean active;
23
	private String createTime;
24
	private String creator;
25
	private String modifyTime;
26
	private String modifier;
27
	private String invalidTime;
28
	
29
	private String invalidOperator;
30
	
31
	@Column(DE.id_32)
32
	public String getId() {
33
		return id;
34
	}
35
	public void setId(String id) {
36
		this.id = id;
37
	}
38
	@Column(DE.text_de)
39
	public String getAccount() {
40
		return account;
41
	}
42
	public void setAccount(String account) {
43
		this.account = account;
44
	}
45
	@Column(DE.text_de)
46
	public String getPasswd() {
47
		return passwd;
48
	}
49
	public void setPasswd(String passwd) {
50
		this.passwd = passwd;
51
	}
52
	@Column(DE.Text_de)
53
	public String getName() {
54
		return name;
55
	}
56
	public void setName(String name) {
57
		this.name = name;
58
	}
59
	@Column(DE.Text_de)
60
	public String getPhone() {
61
		return phone;
62
	}
63
	public void setPhone(String phone) {
64
		this.phone = phone;
65
	}
66
	@Column(DE.Text_de)
67
	public String getEmail() {
68
		return email;
69
	}
70
	public void setEmail(String email) {
71
		this.email = email;
72
	}
73
	@Column(DE.Text_de)
74
	public String getJob() {
75
		return job;
76
	}
77
	
78
	public void setJob(String job) {
79
		this.job = job;
80
	}
81
	@Column(DE.Text_de)
82
	public String getDep() {
83
		return dep;
84
	}
85
	public void setDep(String dep) {
86
		this.dep = dep;
87
	}
88
	@Column(DE.Text_de)
89
	public String getComp() {
90
		return comp;
91
	}
92
	public void setComp(String comp) {
93
		this.comp = comp;
94
	}
95
	@Column(DE.boolean_de)
96
	public boolean isActive() {
97
		return active;
98
	}
99
	public void setActive(boolean active) {
100
		this.active = active;
101
	}
102
	
103
	public String getCreateTime() {
104
		return createTime;
105
	}
106
	public void setCreateTime(String createTime) {
107
		this.createTime = createTime;
108
	}
109
	public String getCreator() {
110
		return creator;
111
	}
112
	public void setCreator(String creator) {
113
		this.creator = creator;
114
	}
115
	public String getModifyTime() {
116
		return modifyTime;
117
	}
118
	public void setModifyTime(String modifyTime) {
119
		this.modifyTime = modifyTime;
120
	}
121
	public String getModifier() {
122
		return modifier;
123
	}
124
	public void setModifier(String modifier) {
125
		this.modifier = modifier;
126
	}
127
	@Column(DE.Text_de)
128
	public String getInvalidTime() {
129
		return invalidTime;
130
	}
131
	public void setInvalidTime(String invalidTime) {
132
		this.invalidTime = invalidTime;
133
	}
134
	@Column(DE.Text_de)
135
	public String getInvalidOperator() {
136
		return invalidOperator;
137
	}
138
	public void setInvalidOperator(String invalidOperator) {
139
		this.invalidOperator = invalidOperator;
140
	}
141
	
142
	
143
	
144
	
145
	
146
	
147

148
}

+ 22 - 0
src/main/java/com/ekexiu/project/platform/system/po/SysRight.java

@ -0,0 +1,22 @@
1
package com.ekexiu.project.platform.system.po;
2

3
import org.jfw.apt.orm.annotation.entry.Table;
4

5
@Table
6
public class SysRight {
7
	private String uid;
8
	private String rightCode;
9
	public String getUid() {
10
		return uid;
11
	}
12
	public void setUid(String uid) {
13
		this.uid = uid;
14
	}
15
	public String getRightCode() {
16
		return rightCode;
17
	}
18
	public void setRightCode(String rightCode) {
19
		this.rightCode = rightCode;
20
	}
21
	
22
}

+ 140 - 0
src/main/java/com/ekexiu/project/platform/system/po/User.java

@ -0,0 +1,140 @@
1
package com.ekexiu.project.platform.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.StringHandler;
9
import org.jfw.apt.orm.core.enums.DE;
10

11
import com.ekexiu.project.platform.base.po.BaseTable;
12

13
@PrimaryKey("id")
14
@Uniques({@Unique(clolumns="account",name="UC_LUSER_ACCOUNT")})
15
@Table(descp="用户表",value="LUSER")
16
public class User implements BaseTable {
17
	private String createTime;
18
	private String modifyTime;
19

20
	
21
	private String id;
22
	private String account;
23
	private String name;
24
	private String sex;
25
	private String job;
26
	private String comp;
27
	private String loginPhone;
28
	private String linkPhone;
29
	private String email;
30
	private String passwd;
31
	private boolean active;
32
	private String addr;
33
	private String head;
34
	
35
	
36
	@Column(descp="是否可用",value=DE.boolean_de)
37
	public boolean isActive() {
38
		return active;
39
	}
40
	public void setActive(boolean active) {
41
		this.active = active;
42
	}
43
	@Column(descp="密码(MD5)",queryable=false,handlerClass = StringHandler.class,dbType = "TEXT")
44
	public String getPasswd() {
45
		return passwd;
46
	}
47
	public void setPasswd(String passwd) {
48
		this.passwd = passwd;
49
	}
50
	@Column(descp="用户ID",value =DE.id_32)
51
	public String getId() {
52
		return id;
53
	}
54
	public void setId(String id) {
55
		this.id = id;
56
	}
57
	@Column(descp="用户姓名",value =DE.Text_de)
58
	public String getName() {
59
		return name;
60
	}
61
	public void setName(String name) {
62
		this.name = name;
63
	}
64
	@Column(descp="用户帐号",value=DE.text_de)
65
	public String getAccount() {
66
		return account;
67
	}
68
	public void setAccount(String account) {
69
		this.account = account;
70
	}
71
	@Column(descp="用户所属单位",value=DE.Text_de)
72
	public String getComp() {
73
		return comp;
74
	}
75
	public void setComp(String comp) {
76
		this.comp = comp;
77
	}
78
	@Column(value=DE.Text_de,descp="用户职位")
79
	public String getJob() {
80
		return job;
81
	}
82
	public void setJob(String job) {
83
		this.job = job;
84
	}
85
	@Column(descp="联系电话",value=DE.Text_de)
86
	public String getLinkPhone() {
87
		return linkPhone;
88
	}
89
	public void setLinkPhone(String phone) {
90
		this.linkPhone = phone;
91
	}
92
	@Column(descp="联系邮件",value=DE.Text_de)
93
	public String getEmail() {
94
		return email;
95
	}
96
	public void setEmail(String email) {
97
		this.email = email;
98
	}
99

100
	public String getCreateTime() {
101
		return createTime;
102
	}
103
	public void setCreateTime(String createTime) {
104
		this.createTime = createTime;
105
	}
106
	public String getModifyTime() {
107
		return modifyTime;
108
	}
109
	public void setModifyTime(String modifyTime) {
110
		this.modifyTime = modifyTime;
111
	}
112
	@Column(value=DE.SingleChar,descp="性别")
113
	public String getSex() {
114
		return sex;
115
	}
116
	public void setSex(String sex) {
117
		this.sex = sex;
118
	}
119
	@Column(value=DE.text_de,descp="登录手机号")
120
	public String getLoginPhone() {
121
		return loginPhone;
122
	}
123
	public void setLoginPhone(String loginPhone) {
124
		this.loginPhone = loginPhone;
125
	}
126
	@Column(value=DE.Text_de,descp="所在城市编码")
127
	public String getAddr() {
128
		return addr;
129
	}
130
	public void setAddr(String addr) {
131
		this.addr = addr;
132
	}
133
	@Column(value=DE.Text_de,descp="头像")
134
	public String getHead() {
135
		return head;
136
	}
137
	public void setHead(String head) {
138
		this.head = head;
139
	}
140
}

+ 29 - 0
src/main/java/com/ekexiu/project/platform/system/po/UserLoginLog.java

@ -0,0 +1,29 @@
1
package com.ekexiu.project.platform.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
@Table
9
@PrimaryKey("id")
10
public class UserLoginLog {
11
	private String id;
12
	private String lastLoginTime;
13
	@Column(DE.text_de)
14
	public String getId() {
15
		return id;
16
	}
17
	public void setId(String id) {
18
		this.id = id;
19
	}
20
	@Column(DE.text_de)
21
	public String getLastLoginTime() {
22
		return lastLoginTime;
23
	}
24
	public void setLastLoginTime(String lastLoginTime) {
25
		this.lastLoginTime = lastLoginTime;
26
	}
27
	
28
	
29
}

+ 263 - 0
src/main/java/com/ekexiu/project/platform/system/service/CommonUtilService.java

@ -0,0 +1,263 @@
1
package com.ekexiu.project.platform.system.service;
2

3
import java.awt.Color;
4
import java.awt.image.BufferedImage;
5
import java.io.ByteArrayOutputStream;
6
import java.io.File;
7
import java.io.FileOutputStream;
8
import java.io.IOException;
9
import java.io.InputStream;
10
import java.io.OutputStream;
11
import java.util.concurrent.atomic.AtomicInteger;
12

13
import javax.imageio.ImageIO;
14

15
import org.jfw.apt.web.annotation.Path;
16
import org.jfw.apt.web.annotation.operate.Post;
17
import org.jfw.apt.web.annotation.param.Upload;
18
import org.jfw.util.io.IoUtil;
19
import org.jfw.util.web.fileupload.Item;
20
import org.jfw.util.web.fileupload.UploadItemIterator;
21

22
import com.ekexiu.project.vo.UploadFile;
23

24
@Path("")
25
public class CommonUtilService {
26
	public static final String JPG = "jpg";
27

28
	private static final AtomicInteger HEAD_FN_IDX = new AtomicInteger(1);
29
	private File headPath;
30
	
31
	private static final AtomicInteger LOGO_FN_IDX = new AtomicInteger(1);
32
	private File logoPath;
33
	
34
	
35
	private static final AtomicInteger ARTICLE_FN_IDX = new AtomicInteger(1);
36
	private File articlePath;
37
	
38
	private int headMaxHeight = Integer.MAX_VALUE;
39
	
40
	
41

42
	public File getHeadPath() {
43
		return headPath;
44
	}
45

46
	public void setHeadPath(File headPath) {
47
		this.headPath = headPath;
48
	}
49

50
	public File getArticlePath() {
51
		return articlePath;
52
	}
53

54
	public void setArticlePath(File articlePath) {
55
		this.articlePath = articlePath;
56
	}
57

58
	public File getLogoPath() {
59
		return logoPath;
60
	}
61

62
	public void setLogoPath(File logoPath) {
63
		this.logoPath = logoPath;
64
	}
65

66
	public int getHeadMaxHeight() {
67
		return headMaxHeight;
68
	}
69

70
	public void setHeadMaxHeight(int headMaxHeight) {
71
		this.headMaxHeight = headMaxHeight;
72
	}
73

74
	private String normalizeFileName(String fn) {
75
		int index = fn.indexOf('\\');
76
		if (index >= 0) {
77
			fn = fn.substring(fn.lastIndexOf('\\') + 1);
78
		}
79
		index = fn.indexOf('/');
80
		if (index >= 0) {
81
			fn = fn.substring(fn.lastIndexOf('/') + 1);
82
		}
83
		if (fn.length() == 0)
84
			throw new RuntimeException("invalid filename in Multipart/data request");
85
		return fn;
86
	}
87

88
	private UploadFile buildTargetFile(File parentPath, AtomicInteger FN_IDX, String ext) {
89
		StringBuilder sb = new StringBuilder();
90
		sb.append("/").append(System.currentTimeMillis() / (1000 * 60 * 60 * 24));
91
		File path = new File(parentPath, sb.toString());
92
		if (!path.exists()) {
93
			synchronized (this) {
94
				if (!path.mkdirs())
95
					throw new RuntimeException("mkdir error[" + path + "]");
96
				FN_IDX.set(1);
97
			}
98
		}
99
		File file;
100
		do {
101
			String fn = FN_IDX.toString();
102
			if (ext.isEmpty()) {
103
				file = new File(path, fn);
104
			} else {
105
				file = new File(path, fn + "." + ext);
106
			}
107
			FN_IDX.incrementAndGet();
108
		} while (file.exists());
109
		sb.append("/").append(file.getName());
110
		UploadFile uf = new UploadFile();
111
		uf.setFn(file);
112
		uf.setUri(sb.toString());
113
		return uf;
114
	}
115

116
	private void saveHeadPhoto(InputStream in, UploadFile file) throws IOException {
117
		byte[] buf = new byte[8092];
118
		int w, h, sx1, sx2, sy1, sy2;
119
		int len;
120
		ByteArrayOutputStream of = new ByteArrayOutputStream();
121
		while ((len = in.read(buf)) >= 0) {
122
			if (len > 0) {
123
				of.write(buf, 0, len);
124
			}
125
		}
126
		BufferedImage im = ImageIO.read(in);
127
		if(im == null){
128
			throw new IOException("unsupported image type");
129
		}
130
		sx1 = 0;
131
		sy1 = 0;
132
		sx2 = w = im.getWidth();
133
		sy2 = h = im.getHeight();
134
		if (w > h) {
135
			sx1 = (w - h) / 2;
136
			sx2 = sx1 + h;
137
			w = h;
138
		} else if (w < h) {
139
			sy1 = (h - w) / 2;
140
			sy2 = sy1 + w;
141
			h = w;
142
		}
143
		if (h > this.headMaxHeight) {
144
			w = h = this.headMaxHeight;
145
		}
146
		BufferedImage newBufferedImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
147
		newBufferedImage.createGraphics().drawImage(im, 0, 0, w, h, sx1, sy1, sx2, sy2, Color.WHITE, null);
148
		OutputStream fos = new FileOutputStream(file.getFn());
149
		try {
150
			ImageIO.write(newBufferedImage, JPG, fos);
151
			fos.flush();
152
			file.setSize(file.getFn().length());
153
		} finally {
154
			IoUtil.close(fos);
155
		}
156
	}
157

158
	@Post
159
	@Path("/user/head")
160
	public UploadFile userHeadUpload(@Upload UploadItemIterator it) throws IOException {
161
		UploadFile uf = null;
162
		try {
163
			while (it.hasNext()) {
164
				Item item = it.next();
165
				if (!item.isFormField()) {
166
					String name = normalizeFileName(item.getName());
167
					int index = name.lastIndexOf('.');
168
					String ext = index >= 0 ? name.substring(index + 1) : "";
169
					ext = ext.trim();
170
					uf = buildTargetFile(this.headPath, HEAD_FN_IDX, ext);
171
					uf.setName(name);
172
					InputStream in = item.getInputStream();
173
					try {
174
						saveHeadPhoto(in, uf);
175
						return uf;
176
					} finally {
177
						in.close();
178
					}
179
				}
180
			}
181
		} finally {
182
			if (it != null)
183
				it.clean();
184
		}
185
		return uf;
186
	}
187

188

189
	@Post
190
	@Path("/logo")
191
	public UploadFile logoUpload(@Upload UploadItemIterator it) throws IOException {
192
		UploadFile uf = null;
193
		try {
194
			while (it.hasNext()) {
195
				Item item = it.next();
196
				if (!item.isFormField()) {
197
					String name = normalizeFileName(item.getName());
198
					int index = name.lastIndexOf('.');
199
					String ext = index >= 0 ? name.substring(index + 1) : "";
200
					ext = ext.trim();
201
					uf = buildTargetFile(this.logoPath, LOGO_FN_IDX, ext);
202
					uf.setName(name);
203
					InputStream in = item.getInputStream();
204
					try {
205
						OutputStream fos = new FileOutputStream(uf.getFn());
206
						try{
207
							IoUtil.copy(in, fos, false,false);
208
							fos.flush();
209
						}finally{
210
							fos.close();
211
						}
212
						return uf;
213
					} finally {
214
						in.close();
215
					}
216
				}
217
			}
218
		} finally {
219
			if (it != null)
220
				it.clean();
221
		}
222
		return uf;
223
	}
224
	
225
	@Post
226
	@Path("/article/image")
227
	public UploadFile articleImageUpload(@Upload UploadItemIterator it) throws IOException {
228
		UploadFile uf = null;
229
		try {
230
			while (it.hasNext()) {
231
				Item item = it.next();
232
				if (!item.isFormField()) {
233
					String name = normalizeFileName(item.getName());
234
					int index = name.lastIndexOf('.');
235
					String ext = index >= 0 ? name.substring(index + 1) : "";
236
					ext = ext.trim();
237
					uf = buildTargetFile(this.articlePath, ARTICLE_FN_IDX, ext);
238
					uf.setName(name);
239
					InputStream in = item.getInputStream();
240
					try {
241
						OutputStream fos = new FileOutputStream(uf.getFn());
242
						try{
243
							IoUtil.copy(in, fos, false,false);
244
							fos.flush();
245
						}finally{
246
							fos.close();
247
						}
248
						return uf;
249
					} finally {
250
						in.close();
251
					}
252
				}
253
			}
254
		} finally {
255
			if (it != null)
256
				it.clean();
257
		}
258
		return uf;
259
	}
260

261

262

263
}

+ 164 - 0
src/main/java/com/ekexiu/project/platform/system/service/DictService.java

@ -0,0 +1,164 @@
1
package com.ekexiu.project.platform.system.service;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.Collections;
6
import java.util.HashMap;
7
import java.util.LinkedList;
8
import java.util.List;
9

10
import org.jfw.apt.annotation.Autowrie;
11
import org.jfw.apt.annotation.Nullable;
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.Post;
15
import org.jfw.apt.web.annotation.param.AfterCommit;
16
import org.jfw.apt.web.annotation.param.JdbcConn;
17

18
import com.ekexiu.project.platform.system.dao.DictDao;
19
import com.ekexiu.project.platform.system.po.DictItem;
20

21
@Path("/dict")
22
public class DictService {
23
	private static final HashMap<String, List<DictItem>> dictCache = new HashMap<String, List<DictItem>>();
24
	private static final List<DictItem> Empty_DICT = Collections.emptyList();
25

26
	@Autowrie
27
	private DictDao dictDao;
28

29
	public DictDao getDictDao() {
30
		return dictDao;
31
	}
32

33
	public void setDictDao(DictDao dictDao) {
34
		this.dictDao = dictDao;
35
	}
36

37
	@Path("/load")
38
	@Get
39
	public void load(@JdbcConn Connection con) throws SQLException {
40
		HashMap<String, List<DictItem>> map = new HashMap<String, List<DictItem>>();
41
		List<DictItem> items = this.dictDao.query(con);
42
		for (DictItem item : items) {
43
			List<DictItem> list = map.get(item.getDictCode());
44
			if (list == null) {
45
				list = new LinkedList<DictItem>();
46
				map.put(item.getDictCode(), list);
47
			}
48
			list.add(item);
49
		}
50
		synchronized(dictCache){
51
			dictCache.clear();
52
			dictCache.putAll(map);
53
		}
54
	}
55

56
	@Path("/items")
57
	@Get
58
	public List<DictItem> query(String dict) {
59
		List<DictItem> ret = null;
60
		synchronized (dictCache) {
61
			ret = dictCache.get(dict);
62
		}
63
		return ret == null ? Empty_DICT : ret;
64
	}
65

66
	@Path("/delete")
67
	@Post
68
	public int delete(@JdbcConn(true) Connection con, final String dict, final String code, @AfterCommit List<Runnable> runs) throws SQLException {
69
		int num = this.dictDao.disable(con, dict, code);
70
		if (num > 0) {
71
			runs.add(new Runnable() {
72
				@Override
73
				public void run() {
74
					synchronized (dictCache) {
75
						List<DictItem> list = dictCache.get(dict);
76
						if (list != null) {
77
							List<DictItem> newlist = new LinkedList<DictItem>();
78
							for (DictItem item : list) {
79
								if (!item.getCode().equals(code)) {
80
									newlist.add(item);
81
								}
82
							}
83
							dictCache.put(dict, newlist);
84
						}
85
					}
86
				}
87
			});
88
		}
89
		return num;
90
	}
91

92
	@Post
93
	@Path("/add")
94
	public void insert(@JdbcConn(true) Connection con, String code, String dict, @Nullable String bcode, String caption, @Nullable String fullCaption,
95
			@Nullable String shortCut, @Nullable String remark, boolean readonly, @AfterCommit List<Runnable> runs) throws SQLException {
96
		final DictItem item = new DictItem();
97
		item.setActive(true);
98
		item.setBcode(bcode);
99
		item.setCaption(caption);
100
		item.setCode(code);
101
		item.setDictCode(dict);
102
		item.setFullCaption(fullCaption);
103
		item.setReadonly(readonly);
104
		item.setRemark(remark);
105
		item.setShortCut(shortCut);
106
		this.dictDao.insert(con, item);
107
		runs.add(new Runnable() {
108
			@Override
109
			public void run() {
110
				synchronized (dictCache) {
111
					List<DictItem> newlist = new LinkedList<DictItem>();
112
					List<DictItem> list = dictCache.get(item.getDictCode());
113
					if (list != null) {
114
						newlist.addAll(list);
115
					}
116
					newlist.add(item);
117
					dictCache.put(item.getDictCode(), newlist);
118
				}
119
			}
120
		});
121
	}
122

123
	@Post
124
	@Path("/modify")
125
	public int update(@JdbcConn(true) Connection con, String code, String dict, @Nullable String bcode, String caption, @Nullable String fullCaption,
126
			@Nullable String shortCut, @Nullable String remark, @AfterCommit List<Runnable> runs) throws SQLException {
127
		int num = this.dictDao.update(con, bcode, caption, fullCaption, shortCut, remark, code, dict);
128
		if (num > 0) {
129
			final DictItem item = new DictItem();
130
			item.setActive(true);
131
			item.setBcode(bcode);
132
			item.setCaption(caption);
133
			item.setCode(code);
134
			item.setDictCode(dict);
135
			item.setFullCaption(fullCaption);
136
			item.setReadonly(false);
137
			item.setRemark(remark);
138
			item.setShortCut(shortCut);
139

140
			runs.add(new Runnable() {
141
				@Override
142
				public void run() {
143
					synchronized (dictCache) {
144
						List<DictItem> newlist = new LinkedList<DictItem>();
145
						List<DictItem> list = dictCache.get(item.getDictCode());
146
						if (list != null) {
147
							for (DictItem nitem : list) {
148
								if (!nitem.getCode().equals(item.getCode())) {
149
									newlist.add(nitem);
150
								}
151
							}
152
						}
153
						newlist.add(item);
154
						dictCache.put(item.getDictCode(), newlist);
155
					}
156
				}
157
			});
158

159
		}
160
		return num;
161

162
	}
163

164
}

+ 395 - 0
src/main/java/com/ekexiu/project/platform/system/service/SysService.java

@ -0,0 +1,395 @@
1
package com.ekexiu.project.platform.system.service;
2
3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.Random;
6
7
import org.jfw.apt.annotation.Autowrie;
8
import org.jfw.apt.annotation.Nullable;
9
import org.jfw.apt.web.annotation.LoginUser;
10
import org.jfw.apt.web.annotation.Path;
11
import org.jfw.apt.web.annotation.method.InvalidSession;
12
import org.jfw.apt.web.annotation.method.ResultToNull;
13
import org.jfw.apt.web.annotation.method.SetSession;
14
import org.jfw.apt.web.annotation.operate.Get;
15
import org.jfw.apt.web.annotation.operate.Post;
16
import org.jfw.apt.web.annotation.operate.Put;
17
import org.jfw.apt.web.annotation.param.JdbcConn;
18
import org.jfw.apt.web.annotation.param.PathVar;
19
import org.jfw.apt.web.annotation.param.RequestBody;
20
import org.jfw.apt.web.annotation.param.RequestParam;
21
import org.jfw.apt.web.annotation.param.SessionVal;
22
import org.jfw.util.DateUtil;
23
import org.jfw.util.StringUtil;
24
import org.jfw.util.auth.AuthUser;
25
import org.jfw.util.context.JfwAppContext;
26
import org.jfw.util.exception.JfwBaseException;
27
import org.jfw.util.jdbc.JdbcUtil;
28
29
import com.ekexiu.project.platform.mobile.MobilePhoneService;
30
import com.ekexiu.project.platform.system.dao.UserDao;
31
import com.ekexiu.project.platform.system.po.Manager;
32
import com.ekexiu.project.platform.system.po.SysRight;
33
import com.ekexiu.project.platform.system.po.User;
34
import com.ekexiu.project.platform.system.po.UserLoginLog;
35
import com.ekexiu.project.platform.system.vo.ManagerInfo;
36
import com.ekexiu.project.platform.system.vo.SessionUser;
37
38
@Path("/sys")
39
public class SysService {
40
41
	private String regMobilePhoneReplaceKey = "yzm";
42
	private String regMobilePhoneContentTemplate = "【声脉】您的验证码为yzm,请于3分钟内正确输入,如非本人操作,请忽略此短信。";
43
	private long timeLimitWithRegMobilePhone = 3 * 60 * 1000;
44
	
45
	
46
	private String fixRightCode="aaa";
47
	
48
	
49
	
50
	
51
	private String accountPrefix = "xtpt_";
52
53
	@Autowrie
54
	private UserDao userDao;
55
56
	@Autowrie
57
	private MobilePhoneService mobilePhoneService;
58
59
	public UserDao getUserDao() {
60
		return userDao;
61
	}
62
63
	public void setUserDao(UserDao userDao) {
64
		this.userDao = userDao;
65
	}
66
67
	public MobilePhoneService getMobilePhoneService() {
68
		return mobilePhoneService;
69
	}
70
71
	public void setMobilePhoneService(MobilePhoneService mobilePhoneService) {
72
		this.mobilePhoneService = mobilePhoneService;
73
	}
74
75
	public String getRegMobilePhoneReplaceKey() {
76
		return regMobilePhoneReplaceKey;
77
	}
78
79
	public void setRegMobilePhoneReplaceKey(String regMobilePhoneReplaceKey) {
80
		this.regMobilePhoneReplaceKey = regMobilePhoneReplaceKey;
81
	}
82
83
	public String getRegMobilePhoneContentTemplate() {
84
		return regMobilePhoneContentTemplate;
85
	}
86
87
	public void setRegMobilePhoneContentTemplate(String regMobilePhoneContentTemplate) {
88
		this.regMobilePhoneContentTemplate = regMobilePhoneContentTemplate;
89
	}
90
91
	public long getTimeLimitWithRegMobilePhone() {
92
		return timeLimitWithRegMobilePhone;
93
	}
94
95
	public void setTimeLimitWithRegMobilePhone(long timeLimitWithRegMobilePhone) {
96
		this.timeLimitWithRegMobilePhone = timeLimitWithRegMobilePhone;
97
	}
98
99
	public String getAccountPrefix() {
100
		return accountPrefix;
101
	}
102
103
	public void setAccountPrefix(String accountPrefix) {
104
		this.accountPrefix = accountPrefix;
105
	}
106
107
	@SetSession("JFW_SESSION_LOGIN_USER=result")
108
	@Path("/login")
109
	@Post
110
	public SessionUser login(@JdbcConn Connection con, String phone, String pw) throws SQLException, JfwBaseException {
111
		final User user = userDao.queryByLoginPhone(con, phone, null);
112
		if (user != null) {
113
			if (!user.isActive()) {
114
				throw new JfwBaseException(-60003, "user is disabled");
115
			}
116
			if (StringUtil.md5(pw).equals(user.getPasswd())) {
117
				JfwAppContext.getScheduledExecutorService().submit(new Runnable() {
118
119
					@Override
120
					public void run() {
121
						try {
122
							Connection conn = JfwAppContext.getDataSource().getConnection();
123
							try {
124
								userDao.updateLoginLog(conn, user.getId(), DateUtil.formatDateTime(System.currentTimeMillis()));
125
								conn.commit();
126
							} catch (SQLException ee) {
127
								JdbcUtil.rollback(conn);
128
							} finally {
129
								JdbcUtil.close(conn);
130
							}
131
						} catch (Exception e) {
132
133
						}
134
					}
135
136
				});
137
				return makeSessionUser(user);
138
			}
139
			throw new JfwBaseException(-60002, "invalid passwd");
140
		} else {
141
			throw new JfwBaseException(-60001, "user not exists");
142
		}
143
	}
144
145
	@Get
146
	@Path("/user")
147
	public SessionUser get(@LoginUser(false) SessionUser user) {
148
		return user;
149
	}
150
151
	@Post
152
	@Path("/user")
153
	public void modifyUser(@JdbcConn(true) Connection con,@LoginUser SessionUser loginUser,
154
			@RequestParam(excludeFields={"id","createTime","modifyTime","loginPhone","passwd","active"}) User user)throws SQLException{
155
		user.setId(loginUser.getId());
156
		userDao.update(con, user);
157
	}
158
	
159
	@Post
160
	@Path("/user/changepasswd")
161
	public int changePasswd(@JdbcConn(true) Connection con,@LoginUser SessionUser loginUser,String opw,String npw)throws SQLException{
162
		return userDao.changePasswd(con,loginUser.getId(), StringUtil.md5(opw),StringUtil.md5(npw));
163
	}
164
165
	@Get
166
	@Path("/logout")
167
	@InvalidSession
168
	public void logout() {
169
	}
170
171
	@Get
172
	@Path("/serviceTime")
173
	public long serviceTime() {
174
		return System.currentTimeMillis();
175
	}
176
177
	@Get
178
	@Path("/user/exists")
179
	public boolean existsUser(@JdbcConn Connection con, String phone, @Nullable Boolean active) throws SQLException {
180
		return null != userDao.queryByLoginPhone(con, phone, active);
181
	}
182
183
	@SetSession({ "REG_PHONE=result[0]", "REG_PHONE_VC=result[1]", "REG_PHONE_TIMEOUT=result[1]" })
184
	@ResultToNull
185
	@Get
186
	@Post
187
	@Path("/registe/phone/msg")
188
	public Object[] registePhoneMsg(String phone, String vc, @Nullable @SessionVal(value = "PIC_REG", remove = true) String code,
189
			@Nullable @SessionVal(value = "TIMEOUT_PIC_REG", remove = true) Long timeout) throws Exception {
190
		if (code == null || timeout == null || System.currentTimeMillis() > timeout ) {
191
			throw new JfwBaseException(-60001, "not found sessionVal");
192
		}
193
		if (!vc.equals(code)) {
194
			throw new JfwBaseException(-60003, "vc not right");
195
		}
196
		Random rd = new Random();
197
		int vi = rd.nextInt(10000);
198
		String vcode = String.format("%04d", vi);
199
200
		this.mobilePhoneService.sendMessage(phone, this.regMobilePhoneContentTemplate, this.regMobilePhoneReplaceKey, vcode);
201
		Object[] result = new Object[3];
202
		result[0] = phone;
203
		result[1] = vcode;
204
		result[2] = System.currentTimeMillis() + 5000 + timeLimitWithRegMobilePhone;
205
		return result;
206
	}
207
	
208
	
209
	
210
	@SetSession({ "RSP_PHONE=result[0]", "RSP_PHONE_VC=result[1]", "RSP_PHONE_TIMEOUT=result[1]" })
211
	@ResultToNull
212
	@Get
213
	@Post
214
	@Path("/resetpw/phone/msg")
215
	public Object[] resetpwPhoneMsg(@JdbcConn Connection con, String phone) throws Exception {
216
		if( null == userDao.queryByLoginPhone(con, phone, null)){
217
			throw new JfwBaseException(-60001, "invalid phone num");
218
		}
219
		Random rd = new Random();
220
		int vi = rd.nextInt(10000);
221
		String vcode = String.format("%04d", vi);
222
		this.mobilePhoneService.sendMessage(phone, this.regMobilePhoneContentTemplate, this.regMobilePhoneReplaceKey, vcode);
223
		Object[] result = new Object[3];
224
		result[0] = phone;
225
		result[1] = vcode;
226
		result[2] = System.currentTimeMillis() + 5000 + timeLimitWithRegMobilePhone;
227
		return result;
228
	}
229
	@Get
230
	@Path("/resetpw/phone/msgCheck")
231
	public boolean resetpwPhoneMsgCheck(String phone, String vc, @Nullable @SessionVal(value = "RSP_PHONE") String sPhone,
232
			@Nullable @SessionVal(value = "RSP_PHONE_VC") String sCode, @Nullable @SessionVal(value = "RSP_PHONE_TIMEOUT") Long timeout) throws Exception {
233
		if (sCode == null || timeout == null || System.currentTimeMillis() > timeout) {
234
			throw new JfwBaseException(-60001, "not found sessionVal");
235
		}
236
		return vc.equals(sCode) && phone.equals(sPhone);
237
	}
238
	
239
	
240
	
241
	
242
	
243
	
244
245
	@Get
246
	@Path("/registe/phone/msgCheck")
247
	public boolean registePhoneMsgCheck(String phone, String vc, @Nullable @SessionVal(value = "REG_PHONE") String sPhone,
248
			@Nullable @SessionVal(value = "REG_PHONE_VC") String sCode, @Nullable @SessionVal(value = "REG_PHONE_TIMEOUT") Long timeout) throws Exception {
249
		if (sCode == null || timeout == null || System.currentTimeMillis() > timeout) {
250
			throw new JfwBaseException(-60001, "timeout");
251
		}
252
		return vc.equals(sCode) && phone.equals(sPhone);
253
	}
254
255
	@Post
256
	@Path("/registe")
257
	public void registe(@JdbcConn(true) Connection con, @Nullable String head, String phone, String vc, String pw,
258
			@Nullable @SessionVal(value = "REG_PHONE", remove = true) String sPhone, @Nullable @SessionVal(value = "REG_PHONE_VC", remove = true) String sCode,
259
			@Nullable @SessionVal(value = "REG_PHONE_TIMEOUT", remove = true) Long timeout) throws Exception {
260
		if (sCode == null || timeout == null || System.currentTimeMillis() > timeout) {
261
			throw new JfwBaseException(-60001, "timeout");
262
		}
263
		if (!vc.equals(sCode) || !phone.equals(sPhone)) {
264
			throw new JfwBaseException(-60002, "invalid");
265
		}
266
		User user = userDao.queryByLoginPhone(con, phone, null);
267
		if (user != null) {
268
			throw new JfwBaseException(-60003, "phone num exists");
269
		}
270
		Random rd = new Random();
271
		user = new User();
272
		user.setId(StringUtil.buildUUID());
273
		user.setAccount(this.accountPrefix + String.format("%08d", rd.nextInt(100000000)));
274
		user.setActive(true);
275
		user.setHead(head);
276
		user.setLinkPhone(phone);
277
		user.setPasswd(StringUtil.md5(pw));
278
		userDao.insert(con, user);
279
		UserLoginLog uli = new UserLoginLog();
280
		uli.setId(user.getId());
281
		uli.setLastLoginTime(DateUtil.formatDateTime(System.currentTimeMillis()));
282
	}
283
	
284
	@Post
285
	@Path("/resetpw")
286
	@InvalidSession
287
	public void resetpw(@JdbcConn(true) Connection con, String phone, String vc, String pw,
288
			@Nullable @SessionVal(value = "RSP_PHONE", remove = true) String sPhone, @Nullable @SessionVal(value = "RSP_PHONE_VC", remove = true) String sCode,
289
			@Nullable @SessionVal(value = "RSP_PHONE_TIMEOUT", remove = true) Long timeout) throws Exception {
290
		if (sCode == null || timeout == null || System.currentTimeMillis() > timeout) {
291
			throw new JfwBaseException(-60001, "timeout");
292
		}
293
		if (!vc.equals(sCode) || !phone.equals(sPhone)) {
294
			throw new JfwBaseException(-60002, "invalid valid code");
295
		}
296
		if(0 == userDao.resetPasswd(con, phone, pw)){
297
			throw new JfwBaseException(-60003, "no found data");
298
		}
299
	}
300
	
301
	
302
	
303
	
304
	
305
	
306
	
307
	
308
	
309
	
310
	
311
	
312
	
313
	
314
	
315
	
316
	
317
	
318
	
319
	@Path("/user/new")
320
	@Post
321
	public String addUser(@JdbcConn(true) Connection con , @LoginUser AuthUser au, @RequestParam(excludeFields={"id","acitve","createor"}) Manager user,String[] rightCode)throws SQLException{
322
		String id = StringUtil.buildUUID();
323
		user.setActive(true);
324
		user.setCreator(au.getId());
325
		user.setId(id);
326
		user.setInvalidOperator(null);
327
		user.setInvalidTime(null);
328
		user.setPasswd(StringUtil.md5("123456"));
329
		userDao.insert(con, user);
330
		if(rightCode != null && rightCode.length >0){
331
			SysRight rights[]  = new SysRight[rightCode.length];
332
			for(int i = 0; i < rightCode.length;++i){
333
				rights[i] = new SysRight();
334
				rights[i].setUid(id);
335
				rights[i].setRightCode(rightCode[i]);
336
			}
337
			userDao.insert(con, rights);
338
		}
339
		return id;
340
	}
341
	
342
	@Path("/user/renew")
343
	@Put
344
	public void renewUser(@JdbcConn(true) Connection con , @LoginUser AuthUser au, @RequestBody ManagerInfo user)throws SQLException{
345
		user.setModifier(au.getId());
346
		userDao.update(con, user);
347
		userDao.delete(con,user.getId(),this.fixRightCode);
348
		String[] rightCode = user.getRightCode();
349
		if(rightCode != null && rightCode.length >0){
350
			SysRight rights[]  = new SysRight[rightCode.length];
351
			for(int i = 0; i < rightCode.length;++i){
352
				rights[i] = new SysRight();
353
				rights[i].setUid(user.getId());
354
				rights[i].setRightCode(rightCode[i]);
355
			}
356
			userDao.insert(con, rights);
357
		}
358
	}
359
	
360
	@Path("/user/right/{uid}")
361
	@Put
362
	public void rightUser(@JdbcConn(true) Connection con , @LoginUser AuthUser au,@PathVar String uid, @RequestBody String[] rightCode)throws SQLException{
363
		userDao.delete(con,uid,this.fixRightCode);
364
		if(rightCode != null && rightCode.length >0){
365
			SysRight rights[]  = new SysRight[rightCode.length];
366
			for(int i = 0; i < rightCode.length;++i){
367
				rights[i] = new SysRight();
368
				rights[i].setUid(uid);
369
				rights[i].setRightCode(rightCode[i]);
370
			}
371
			userDao.insert(con, rights);
372
		}
373
	}
374
	
375
	
376
377
	private static SessionUser makeSessionUser(User user) {
378
		SessionUser sessionUser = new SessionUser();
379
		sessionUser.setAccount(user.getAccount());
380
		sessionUser.setComp(user.getComp());
381
		sessionUser.setEmail(user.getEmail());
382
		sessionUser.setId(user.getId());
383
		sessionUser.setJob(user.getJob());
384
		sessionUser.setName(user.getName());
385
		sessionUser.setActive(user.isActive());
386
		sessionUser.setAddr(user.getAccount());
387
		sessionUser.setCreateTime(user.getCreateTime());
388
		sessionUser.setHead(user.getHead());
389
		sessionUser.setLinkPhone(user.getLinkPhone());
390
		sessionUser.setLoginPhone(user.getLoginPhone());
391
		sessionUser.setModifyTime(user.getModifyTime());
392
		sessionUser.setSex(user.getSex());
393
		return sessionUser;
394
	}
395
}

+ 20 - 0
src/main/java/com/ekexiu/project/platform/system/vo/ManagerInfo.java

@ -0,0 +1,20 @@
1
package com.ekexiu.project.platform.system.vo;
2

3
import java.util.List;
4

5
import org.jfw.apt.orm.annotation.entry.ExtendTable;
6

7
import com.ekexiu.project.platform.system.po.Manager;
8

9
@ExtendTable
10
public class ManagerInfo extends Manager {
11
	private String[] rightCode;
12

13
	public String[] getRightCode() {
14
		return rightCode;
15
	}
16

17
	public void setRightCode(String[] rightCode) {
18
		this.rightCode = rightCode;
19
	}
20
}

+ 114 - 0
src/main/java/com/ekexiu/project/platform/system/vo/SessionUser.java

@ -0,0 +1,114 @@
1
package com.ekexiu.project.platform.system.vo;
2
3
import org.jfw.util.auth.AuthUser;
4
5
/**
6
 * Created by TT on 2018/8/7.
7
 */
8
public class SessionUser implements AuthUser {
9
10
    private String id;
11
    private String name;
12
    private String account;
13
    private String comp;
14
    private String job;
15
    private String email;
16
	private String createTime;
17
	private String modifyTime;
18
	private String sex;
19
	private String loginPhone;
20
	private String linkPhone;
21
	private String addr;
22
	private String head;
23
    private boolean active;
24
	public String getId() {
25
		return id;
26
	}
27
	public void setId(String id) {
28
		this.id = id;
29
	}
30
	public String getName() {
31
		return name;
32
	}
33
	public void setName(String name) {
34
		this.name = name;
35
	}
36
	public String getAccount() {
37
		return account;
38
	}
39
	public void setAccount(String account) {
40
		this.account = account;
41
	}
42
	public String getComp() {
43
		return comp;
44
	}
45
	public void setComp(String comp) {
46
		this.comp = comp;
47
	}
48
	public String getJob() {
49
		return job;
50
	}
51
	public void setJob(String job) {
52
		this.job = job;
53
	}
54
	public String getEmail() {
55
		return email;
56
	}
57
	public void setEmail(String email) {
58
		this.email = email;
59
	}
60
	public String getCreateTime() {
61
		return createTime;
62
	}
63
	public void setCreateTime(String createTime) {
64
		this.createTime = createTime;
65
	}
66
	public String getModifyTime() {
67
		return modifyTime;
68
	}
69
	public void setModifyTime(String modifyTime) {
70
		this.modifyTime = modifyTime;
71
	}
72
	public String getSex() {
73
		return sex;
74
	}
75
	public void setSex(String sex) {
76
		this.sex = sex;
77
	}
78
	public String getLoginPhone() {
79
		return loginPhone;
80
	}
81
	public void setLoginPhone(String loginPhone) {
82
		this.loginPhone = loginPhone;
83
	}
84
	public String getLinkPhone() {
85
		return linkPhone;
86
	}
87
	public void setLinkPhone(String linkPhone) {
88
		this.linkPhone = linkPhone;
89
	}
90
	public String getAddr() {
91
		return addr;
92
	}
93
	public void setAddr(String addr) {
94
		this.addr = addr;
95
	}
96
	public String getHead() {
97
		return head;
98
	}
99
	public void setHead(String head) {
100
		this.head = head;
101
	}
102
	public boolean isActive() {
103
		return active;
104
	}
105
	public void setActive(boolean active) {
106
		this.active = active;
107
	}
108
	@Override
109
	public boolean hasAuthority(int auth) {
110
		return true;
111
	};
112
113
   
114
}

+ 42 - 0
src/main/java/com/ekexiu/project/vo/UploadFile.java

@ -0,0 +1,42 @@
1
package com.ekexiu.project.vo;
2

3
import java.io.File;
4

5
public class UploadFile {
6
	   private String name;
7
       private String uri;
8
       private long size;
9
       private transient File fn;
10

11
       public File getFn() {
12
           return fn;
13
       }
14

15
       public void setFn(File fn) {
16
           this.fn = fn;
17
       }
18

19
       public String getName() {
20
           return name;
21
       }
22

23
       public void setName(String name) {
24
           this.name = name;
25
       }
26

27
       public String getUri() {
28
           return uri;
29
       }
30

31
       public void setUri(String uri) {
32
           this.uri = uri;
33
       }
34

35
       public long getSize() {
36
           return size;
37
       }
38

39
       public void setSize(long size) {
40
           this.size = size;
41
       }
42
}

+ 1 - 0
src/main/resources/.gitignore

@ -0,0 +1 @@
1
/dev.properties

+ 64 - 0
src/main/webapp/web.xml

@ -0,0 +1,64 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
4
                      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
5
	version="3.0" metadata-complete="true">
6
	<servlet>
7
		<servlet-name>ajax</servlet-name>
8
		<servlet-class>org.jfw.web.servlet.core.JdbcConfigServlet</servlet-class>
9
		<init-param>
10
			<param-name>prefixLen</param-name>
11
			<param-value>15</param-value>
12
		</init-param>
13
		<init-param>
14
			<param-name>viewType</param-name>
15
			<param-value>1</param-value>
16
		</init-param>
17
		<init-param>
18
			<param-name>configFileName</param-name>
19
			<param-value>beanConfig.properties,dev.properties</param-value>
20
		</init-param>
21
		<init-param>
22
			<param-name>afterBeanFactory</param-name>
23
			<param-value>com.ekexiu.project.job.TaskJob</param-value>
24
		</init-param>
25
		<init-param>
26
			<param-name>overrideFileConfig</param-name>
27
			<param-value>true</param-value>
28
		</init-param>
29
		<init-param>
30
			<param-name>driverClassName</param-name>
31
			<param-value>org.postgresql.Driver</param-value>
32
		</init-param>
33
		<init-param>
34
			<param-name>url</param-name>
35
			<param-value>jdbc:postgresql://192.168.3.233:5432/platform</param-value>
36
		</init-param>
37
		<init-param>
38
			<param-name>username</param-name>
39
			<param-value>postgres</param-value>
40
		</init-param>
41
		<init-param>
42
			<param-name>password</param-name>
43
			<param-value>postgres</param-value>
44
		</init-param>
45
		<init-param>
46
			<param-name>sql</param-name>
47
			<param-value>SELECT CFG_NAME,CFG_VALUE FROM CONSOLE_CONFIG</param-value>
48
		</init-param>
49
		<load-on-startup>1</load-on-startup>
50
	</servlet>
51
	<servlet-mapping>
52
		<servlet-name>ajax</servlet-name>
53
		<url-pattern>/ajax/*</url-pattern>
54
	</servlet-mapping>
55

56
	
57
	<session-config>
58
		<cookie-config>
59
			<name>JSES_PF_M</name>
60
			<http-only>true</http-only>
61
			<path>/</path>
62
		</cookie-config>
63
	</session-config>
64
</web-app>