瀏覽代碼

Merge remote-tracking branch 'origin/test'

Conflicts:
	src/main/java/com/ekexiu/portal/ware/WareDao.java
	src/main/java/com/ekexiu/portal/ware/WareService.java
jiapeng 7 年之前
父節點
當前提交
7978e6ac89

+ 55 - 15
src/main/java/com/ekexiu/portal/dao/ArticleDao.java

@ -1,18 +1,16 @@
1 1
package com.ekexiu.portal.dao;
2 2

3
import java.sql.Connection;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
6
import java.sql.SQLException;
7
import java.util.ArrayList;
8
import java.util.Collections;
9
import java.util.List;
10

3
import com.ekexiu.portal.po.Article;
4
import com.ekexiu.portal.po.ArticleWare;
5
import com.ekexiu.portal.pojo.FindInfo;
6
import com.ekexiu.portal.pojo.SelfArticle;
7
import org.jfw.apt.annotation.DefaultValue;
11 8
import org.jfw.apt.annotation.Nullable;
12 9
import org.jfw.apt.orm.annotation.dao.DAO;
13 10
import org.jfw.apt.orm.annotation.dao.Dynamic;
14 11
import org.jfw.apt.orm.annotation.dao.method.Exclude;
15 12
import org.jfw.apt.orm.annotation.dao.method.From;
13
import org.jfw.apt.orm.annotation.dao.method.LimitColumn;
16 14
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
17 15
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
18 16
import org.jfw.apt.orm.annotation.dao.method.Where;
@ -21,6 +19,7 @@ import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
21 19
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
22 20
import org.jfw.apt.orm.annotation.dao.method.operator.PageQuery;
23 21
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
22
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
24 23
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
25 24
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
26 25
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
@ -32,13 +31,18 @@ import org.jfw.apt.orm.annotation.dao.param.LessThan;
32 31
import org.jfw.apt.orm.annotation.dao.param.Like;
33 32
import org.jfw.apt.orm.annotation.dao.param.Set;
34 33
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
34
import org.jfw.apt.orm.annotation.dao.Column;
35
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
35 36
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
36 37
import org.jfw.util.PageQueryResult;
37 38

38
import com.ekexiu.portal.po.Article;
39
import com.ekexiu.portal.po.ArticleWare;
40
import com.ekexiu.portal.pojo.FindInfo;
41
import com.ekexiu.portal.pojo.SelfArticle;
39
import java.sql.Connection;
40
import java.sql.PreparedStatement;
41
import java.sql.ResultSet;
42
import java.sql.SQLException;
43
import java.util.ArrayList;
44
import java.util.Collections;
45
import java.util.List;
42 46

43 47
@DAO
44 48
public abstract class ArticleDao {
@ -51,11 +55,11 @@ public abstract class ArticleDao {
51 55

52 56
	@Insert
53 57
	public abstract int insert(Connection con,ArticleWare ware)throws SQLException;
54
	
58

55 59
	@DeleteWith
56 60
	@From(ArticleWare.class)
57 61
	public abstract int deleteWare(Connection con,String id)throws SQLException;
58
	
62

59 63
	@UpdateWith
60 64
	@From(Article.class)
61 65
	@SetSentence("PAGE_VIEWS = PAGE_VIEWS + 1")
@ -117,6 +121,24 @@ public abstract class ArticleDao {
117 121
	@Where("STATUS = '1'")
118 122
	public abstract PageQueryResult<Article> pageQueryProPublish(Connection con, String professorId, int pageSize, int pageNo) throws SQLException;
119 123

124
	//@LimitSelect
125
	//@Exclude("articleContent")
126
	//@OrderBy(cols = {@LimitColumn(value = "publishTime", asc = false), @LimitColumn(value = "shareId",asc = false, handlerClass = LongHandler.class)}, value = "")
127
	//@Where("STATUS = '1'")
128
	//public abstract List<Article> proPublish(Connection con, String professorId, String publishTime, long shareId, int rows)throws SQLException;
129
    //
130
	//@LimitSelect
131
	//@Exclude("articleContent")
132
	//@OrderBy(cols = {@LimitColumn(value = "publishTime", asc = false), @LimitColumn(value = "shareId",asc = false, handlerClass = LongHandler.class)}, value = "")
133
	//@Where("STATUS = '1'")
134
	//public abstract List<Article> orgPublish(Connection con, String orgId, String publishTime, long shareId, int rows)throws SQLException;
135

136
	@LimitSelect
137
	@Exclude("articleContent")
138
	@OrderBy(cols = {@LimitColumn(value = "publishTime", asc = false), @LimitColumn(value = "shareId",asc = false, handlerClass = LongHandler.class)}, value = "")
139
	@Where("STATUS = '1'")
140
	public abstract List<Article> publish(Connection con,String articleType,@GroupSqlColumn(handlerClass = StringHandler.class,value ={"PROFESSOR_ID = ?","ORG_ID = ?"},isAnd = false) String owner, String publishTime, long shareId, int rows)throws SQLException;
141

120 142
	@Exclude("articleContent")
121 143
	@SelectList
122 144
	@OrderBy(" ORDER BY MODIFY_TIME DESC ")
@ -149,6 +171,9 @@ public abstract class ArticleDao {
149 171
	@Nullable
150 172
	public abstract Article queryOne(Connection con, String articleId) throws SQLException;
151 173

174
	@SelectList
175
	public abstract List<ArticleWare> queryWares(Connection con,String id)throws SQLException;
176

152 177
	public List<Article> queryByPageViews(Connection con, String articleId, int rows) throws SQLException {
153 178
		int index = 1;
154 179
		boolean hasArticleId = null != articleId;
@ -366,6 +391,7 @@ public abstract class ArticleDao {
366 391
	}
367 392

368 393
	@SelectList
394
	@Exclude("articleContent")
369 395
	public abstract List<Article> query(Connection con, @In String[] articleId) throws SQLException;
370 396

371 397
	@Exclude("articleContent")
@ -490,6 +516,12 @@ public abstract class ArticleDao {
490 516
					"SUBJECT LIKE ?" }, additional = 1) @Nullable String key,
491 517
			int pageSize, int pageNo) throws SQLException;
492 518

519
	@LimitSelect
520
	@Exclude("articleContent")
521
	@Where("STATUS = '1'")
522
	@OrderBy(cols = {@LimitColumn(value = "sortNum", asc = false, handlerClass = LongHandler.class), @LimitColumn(value = "publishTime", asc = false), @LimitColumn(value = "articleId", asc = false)}, value = "")
523
	public abstract List<Article> indexSearch(Connection con,@Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = {"PROFESSOR_ID IN (SELECT ID FROM PROFESSOR WHERE NAME LIKE ?)", "ORG_ID IN (SELECT ID FROM ORGANIZATION WHERE NAME LIKE ? OR FOR_SHORT LIKE ?)", "ARTICLE_TITLE LIKE ?", "SUBJECT LIKE ?"}, additional = 1, isAnd = false) String key, long sortNum, String publishTime, String articleId, int rows) throws SQLException;
524

493 525
	// public PageQueryResult<Article> firstPageQuery(Connection con, String
494 526
	// key, int pageSize, int pageNo) throws SQLException {
495 527
	// int total = 0;
@ -882,5 +914,13 @@ public abstract class ArticleDao {
882 914

883 915
	@LimitSelect
884 916
	@OrderBy( " ORDER BY PAGE_VIEWS DESC")
885
	public abstract List<Article> queryByWareId(Connection con,@SqlColumn(handlerClass = StringHandler.class, value = { "ARTICLE_ID IN (SELECT ID FROM ARTICLE_WARE WHERE WARE =?))" }) String ware,int rows) throws SQLException;
917
	public abstract List<Article> queryByWareId(Connection con,@SqlColumn(handlerClass = StringHandler.class, value = { "ARTICLE_ID IN (SELECT ID FROM ARTICLE_WARE WHERE WARE =?)" }) String ware,int rows) throws SQLException;
918

919
	@DefaultValue("0")
920
	@QueryVal
921
	@Where("STATUS = '1'")
922
	@Column(value = "COUNT(1)", handlerClass = LongHandler.class)
923
	@From(Article.class)
924
	public abstract long countPublish(Connection con, String articleType,@GroupSqlColumn(handlerClass = StringHandler.class,value = {"PROFESSOR_ID = ?","ORG_ID = ?"},isAnd = false) String owner) throws SQLException;
925

886 926
}

+ 19 - 10
src/main/java/com/ekexiu/portal/dao/OrgDao.java

@ -1,16 +1,13 @@
1 1
package com.ekexiu.portal.dao;
2 2
3
import java.sql.Connection;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
6
import java.sql.SQLException;
7
import java.util.ArrayList;
8
import java.util.List;
9
3
import com.ekexiu.portal.basepo.BaseOrganization;
4
import com.ekexiu.portal.po.Organization;
5
import com.ekexiu.portal.pojo.EditOrganization;
10 6
import org.jfw.apt.annotation.Nullable;
11 7
import org.jfw.apt.orm.annotation.dao.Column;
12 8
import org.jfw.apt.orm.annotation.dao.DAO;
13 9
import org.jfw.apt.orm.annotation.dao.method.From;
10
import org.jfw.apt.orm.annotation.dao.method.LimitColumn;
14 11
import org.jfw.apt.orm.annotation.dao.method.Or;
15 12
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
16 13
import org.jfw.apt.orm.annotation.dao.method.Select;
@ -33,12 +30,16 @@ import org.jfw.apt.orm.annotation.dao.param.In;
33 30
import org.jfw.apt.orm.annotation.dao.param.Like;
34 31
import org.jfw.apt.orm.annotation.dao.param.Set;
35 32
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
33
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
36 34
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
37 35
import org.jfw.util.PageQueryResult;
38 36
39
import com.ekexiu.portal.basepo.BaseOrganization;
40
import com.ekexiu.portal.po.Organization;
41
import com.ekexiu.portal.pojo.EditOrganization;
37
import java.sql.Connection;
38
import java.sql.PreparedStatement;
39
import java.sql.ResultSet;
40
import java.sql.SQLException;
41
import java.util.ArrayList;
42
import java.util.List;
42 43
43 44
@DAO
44 45
public abstract class OrgDao {
@ -219,6 +220,14 @@ public abstract class OrgDao {
219 220
					"(ID IN (SELECT ORG_ID FROM ARTICLE WHERE ARTICLE_TYPE='2' AND ARTICLE_TITLE LIKE ?) AND IS_JOIN ='1')" }) String kw,
220 221
			int pageSize, int pageNo) throws SQLException;
221 222
223
	@LimitQuery
224
	@Select(Organization.class)
225
	@From(Organization.class)
226
	@OrderBy(cols = {@LimitColumn(value = "sortNum", asc = false, handlerClass = LongHandler.class), @LimitColumn(value = "modifyTime", asc = false), @LimitColumn(value = "id", asc = false)}, value = "")
227
	public abstract List<EditOrganization> indexSearch(Connection con, @Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = {"NAME LIKE ? AND IS_JOIN ='1'", "FOR_SHORT LIKE ? AND IS_JOIN ='1'", "DESCP LIKE ?  AND IS_JOIN ='1'", "SUBJECT LIKE ? AND IS_JOIN ='1' ", "industry LIKE ?  AND IS_JOIN ='1'",
228
			"ID IN (SELECT ORG_ID FROM RESOURCE WHERE RESOURCE_TYPE='2' AND RESOURCE_NAME LIKE ?) AND IS_JOIN ='1'",
229
			"ID IN (SELECT ORG_ID FROM ARTICLE WHERE ARTICLE_TYPE='2' AND ARTICLE_TITLE LIKE ?) AND IS_JOIN ='1'"},isAnd = false) String kw, long sortNum, String modifyTime, String id, int rows) throws SQLException;
230
222 231
	@PageQuery
223 232
	@Select(Organization.class)
224 233
	@From(Organization.class)

+ 35 - 11
src/main/java/com/ekexiu/portal/dao/PpaperDao.java

@ -1,34 +1,42 @@
1 1
package com.ekexiu.portal.dao;
2 2

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

3
import com.ekexiu.portal.po.Ppaper;
4
import com.ekexiu.portal.pojo.AssedPaper;
5
import org.jfw.apt.annotation.DefaultValue;
10 6
import org.jfw.apt.annotation.Nullable;
11 7
import org.jfw.apt.orm.annotation.dao.DAO;
12 8
import org.jfw.apt.orm.annotation.dao.method.Exclude;
13 9
import org.jfw.apt.orm.annotation.dao.method.From;
10
import org.jfw.apt.orm.annotation.dao.method.LimitColumn;
14 11
import org.jfw.apt.orm.annotation.dao.method.Or;
15 12
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
16 13
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
14
import org.jfw.apt.orm.annotation.dao.method.operator.LimitQuery;
15
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
17 16
import org.jfw.apt.orm.annotation.dao.method.operator.PageQuery;
18 17
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
18
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
19 19
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
20 20
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
21 21
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
22 22
import org.jfw.apt.orm.annotation.dao.param.Alias;
23
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
23 24
import org.jfw.apt.orm.annotation.dao.param.In;
24 25
import org.jfw.apt.orm.annotation.dao.param.Like;
25 26
import org.jfw.apt.orm.annotation.dao.param.Set;
26 27
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
28
import org.jfw.apt.orm.annotation.dao.Column;
27 29
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
30
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
31
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
28 32
import org.jfw.util.PageQueryResult;
29 33

30
import com.ekexiu.portal.po.Ppaper;
31
import com.ekexiu.portal.pojo.AssedPaper;
34
import java.sql.Connection;
35
import java.sql.PreparedStatement;
36
import java.sql.ResultSet;
37
import java.sql.SQLException;
38
import java.util.ArrayList;
39
import java.util.List;
32 40

33 41
@DAO
34 42
public abstract class PpaperDao {
@ -52,6 +60,11 @@ public abstract class PpaperDao {
52 60
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "A.PROFESSOR_ID=?" })  String professorId,
53 61
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "P.NAME LIKE ?" }) String name, int pageSize, int pageNo) throws SQLException;
54 62

63
	@Exclude("summary")
64
	@LimitQuery
65
	@OrderBy(cols = {@LimitColumn(value = "assTime", asc = false), @LimitColumn(value = "id", asc = false)}, value = "")
66
	public abstract List<AssedPaper> queryProfessor(Connection con,@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "A.PROFESSOR_ID = ?" }) String professorId,@Nullable @SqlColumn(handlerClass = StringHandler.class,value = {"P.NAME LIKE ?"}) String name, String assTime, String id, int rows) throws SQLException;
67

55 68
	@Exclude("summary")
56 69
	@PageQuery
57 70
	@OrderBy(" ORDER BY ASS_TIME DESC,ID ASC")
@ -76,8 +89,12 @@ public abstract class PpaperDao {
76 89
	@OrderBy(" ORDER BY SORT_NUM DESC,CREATE_TIME DESC,ID DESC")
77 90
	@Or
78 91
	public abstract PageQueryResult<Ppaper> query(Connection con,@Alias({"name","authors","keywords","cn4periodical","en4periodical"}) @Like String cnt,int pageSize,int pageNo) throws SQLException;
79
	
80
	
92

93
	@LimitSelect
94
	@Exclude("summary")
95
	@OrderBy(cols = {@LimitColumn(value = "sortNum", asc = false, handlerClass = LongHandler.class), @LimitColumn(value = "createTime", asc = false), @LimitColumn(value = "id", asc = false)}, value = "")
96
	public abstract List<Ppaper> indexSearch(Connection con,@Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = {"EN4PERIODICAL LIKE ?", "CN4PERIODICAL LIKE ?", "KEYWORDS LIKE ?", "AUTHORS LIKE ?", "NAME LIKE ?"}, isAnd = false) String key, long sortNum, String createTime, String id, int rows) throws SQLException;
97

81 98
	@SelectOne
82 99
	@Nullable
83 100
	public abstract Ppaper query(Connection con,long shareId)throws SQLException;
@ -139,4 +156,11 @@ public abstract class PpaperDao {
139 156
		}
140 157
		return ret.isEmpty() ? null : ret.toArray(new String[ret.size()]);
141 158
	}
159

160
	@DefaultValue("0")
161
	@QueryVal
162
	@Column(value = "count(1)", handlerClass = LongHandler.class)
163
	@From(AssedPaper.class)
164
	public abstract long countPublish(Connection con,@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "A.PROFESSOR_ID=?" })String professorId) throws SQLException;
165

142 166
}

+ 33 - 9
src/main/java/com/ekexiu/portal/dao/PpatentDao.java

@ -1,34 +1,42 @@
1 1
package com.ekexiu.portal.dao;
2 2

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

3
import com.ekexiu.portal.po.Ppatent;
4
import com.ekexiu.portal.pojo.AssedPatent;
5
import org.jfw.apt.annotation.DefaultValue;
10 6
import org.jfw.apt.annotation.Nullable;
7
import org.jfw.apt.orm.annotation.dao.Column;
11 8
import org.jfw.apt.orm.annotation.dao.DAO;
12 9
import org.jfw.apt.orm.annotation.dao.method.Exclude;
13 10
import org.jfw.apt.orm.annotation.dao.method.From;
11
import org.jfw.apt.orm.annotation.dao.method.LimitColumn;
14 12
import org.jfw.apt.orm.annotation.dao.method.Or;
15 13
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
16 14
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
15
import org.jfw.apt.orm.annotation.dao.method.operator.LimitQuery;
16
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
17 17
import org.jfw.apt.orm.annotation.dao.method.operator.PageQuery;
18 18
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
19
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
19 20
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
20 21
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
21 22
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
22 23
import org.jfw.apt.orm.annotation.dao.param.Alias;
24
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
23 25
import org.jfw.apt.orm.annotation.dao.param.In;
24 26
import org.jfw.apt.orm.annotation.dao.param.Like;
25 27
import org.jfw.apt.orm.annotation.dao.param.Set;
26 28
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
27 29
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
30
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
31
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
28 32
import org.jfw.util.PageQueryResult;
29 33

30
import com.ekexiu.portal.po.Ppatent;
31
import com.ekexiu.portal.pojo.AssedPatent;
34
import java.sql.Connection;
35
import java.sql.PreparedStatement;
36
import java.sql.ResultSet;
37
import java.sql.SQLException;
38
import java.util.ArrayList;
39
import java.util.List;
32 40

33 41
@DAO
34 42
public abstract class PpatentDao {
@ -53,6 +61,11 @@ public abstract class PpatentDao {
53 61
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "A.PROFESSOR_ID=?" }) String professId,
54 62
			@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "P.NAME LIKE ?" }) String name, int pageSize, int pageNo) throws SQLException;
55 63

64
	@Exclude("summary")
65
	@LimitQuery
66
	@OrderBy(cols = {@LimitColumn(value = "assTime", asc = false), @LimitColumn(value = "id", asc = false)}, value = "")
67
	public abstract List<AssedPatent> queryProfessor(Connection con,@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "A.PROFESSOR_ID=?" }) String professorId, @Nullable @SqlColumn(handlerClass = StringHandler.class,value = {"P.NAME LIKE ?"}) String name, String assTime, String id, int rows) throws SQLException;
68

56 69
	@Exclude("summary")
57 70
	@PageQuery
58 71
	@OrderBy(" ORDER BY ASS_TIME DESC,ID ASC")
@ -79,6 +92,11 @@ public abstract class PpatentDao {
79 92
	public abstract PageQueryResult<Ppatent> query(Connection con, @Alias({ "code", "authors", "name", "keywords","reqPerson" }) @Like String cnt, int pageSize, int pageNo)
80 93
			throws SQLException;
81 94

95
	@Exclude("summary")
96
	@LimitSelect
97
	@OrderBy(cols = {@LimitColumn(value = "sortNum", handlerClass = LongHandler.class, asc = false), @LimitColumn(value = "createTime", asc = false), @LimitColumn(value = "id", asc = false)}, value = "")
98
	public abstract List<Ppatent> indexSearch(Connection con, @Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = {"REQ_PERSON LIKE ?", "KEYWORDS LIKE ?", "NAME LIKE ?", "AUTHORS LIKE ?", "CODE LIKE ?"},isAnd = false) String key, long sortNum, String createTime, String id, int rows) throws SQLException;
99

82 100
	@SelectOne
83 101
	@Nullable
84 102
	public abstract Ppatent query(Connection con, long shareId) throws SQLException;
@ -147,4 +165,10 @@ public abstract class PpatentDao {
147 165
		return ret.isEmpty() ? null : ret.toArray(new String[ret.size()]);
148 166
	}
149 167

168
	@DefaultValue("0")
169
	@QueryVal
170
	@Column(value = "count(1)", handlerClass = LongHandler.class)
171
	@From(AssedPatent.class)
172
	public abstract long countPublish(Connection con,@SqlColumn(handlerClass = FixLenStringHandler.class, value = { "A.PROFESSOR_ID=?" }) String professorId) throws SQLException;
173

150 174
}

+ 35 - 16
src/main/java/com/ekexiu/portal/dao/ProfessorDao.java

@ -1,14 +1,12 @@
1 1
package com.ekexiu.portal.dao;
2 2

3
import java.math.BigDecimal;
4
import java.sql.Connection;
5
import java.sql.PreparedStatement;
6
import java.sql.ResultSet;
7
import java.sql.SQLException;
8
import java.util.ArrayList;
9
import java.util.Collections;
10
import java.util.List;
11

3
import com.ekexiu.portal.po.Organization;
4
import com.ekexiu.portal.po.Professor;
5
import com.ekexiu.portal.pojo.EditProfessor;
6
import com.ekexiu.portal.pojo.ProfessorInfo;
7
import com.ekexiu.portal.pojo.SortedPro;
8
import com.ekexiu.portal.pojo.UserInfo;
9
import com.ekexiu.portal.ware.Ware;
12 10
import org.jfw.apt.annotation.DefaultValue;
13 11
import org.jfw.apt.annotation.Nullable;
14 12
import org.jfw.apt.orm.annotation.dao.Column;
@ -20,15 +18,19 @@ import org.jfw.apt.orm.annotation.dao.method.Select;
20 18
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
21 19
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
22 20
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
21
import org.jfw.apt.orm.annotation.dao.method.operator.LimitQuery;
23 22
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
23
import org.jfw.apt.orm.annotation.dao.method.operator.QueryList;
24 24
import org.jfw.apt.orm.annotation.dao.method.operator.QueryOne;
25 25
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
26 26
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
27 27
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
28 28
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
29 29
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
30
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
30 31
import org.jfw.apt.orm.annotation.dao.param.In;
31 32
import org.jfw.apt.orm.annotation.dao.param.LessThan;
33
import org.jfw.apt.orm.annotation.dao.param.Like;
32 34
import org.jfw.apt.orm.annotation.dao.param.Set;
33 35
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
34 36
import org.jfw.apt.orm.core.defaultImpl.BigDecimalHandler;
@ -37,11 +39,14 @@ import org.jfw.apt.orm.core.defaultImpl.StringHandler;
37 39
import org.jfw.util.PageQueryResult;
38 40
import org.jfw.util.exception.JfwBaseException;
39 41

40
import com.ekexiu.portal.po.Organization;
41
import com.ekexiu.portal.po.Professor;
42
import com.ekexiu.portal.pojo.EditProfessor;
43
import com.ekexiu.portal.pojo.ProfessorInfo;
44
import com.ekexiu.portal.pojo.UserInfo;
42
import java.math.BigDecimal;
43
import java.sql.Connection;
44
import java.sql.PreparedStatement;
45
import java.sql.ResultSet;
46
import java.sql.SQLException;
47
import java.util.ArrayList;
48
import java.util.Collections;
49
import java.util.List;
45 50

46 51
@DAO
47 52
public abstract class ProfessorDao {
@ -386,7 +391,7 @@ public abstract class ProfessorDao {
386 391
	public List<EditProfessor> queryByName(Connection con, String name, int total) throws SQLException {
387 392
		int index = 1;
388 393
		String sql = "SELECT P.OFFICE,P.DEPARTMENT,P.TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,P.ADDRESS,P.ORG_AUTH,ORGANIZATION.NAME,P.ORG_ID,P.SCORE_PERCENT,P.SHARE_ID "
389
				+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.NAME LIKE ? ORDER BY P.SCORE_PERCENT DESC LIMIT " + total;
394
				+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.NAME LIKE ? ORDER BY P.NAME ASC LIMIT " + total;
390 395
		PreparedStatement ps = con.prepareStatement(sql);
391 396
		try {
392 397
			ps.setString(index++, name);
@ -470,7 +475,7 @@ public abstract class ProfessorDao {
470 475
	public EditProfessor queryEditBaseInfo(Connection con, String id) throws SQLException {
471 476
		int index = 1;
472 477
		String sql = "SELECT P.OFFICE,P.DEPARTMENT,P.TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,"
473
				+ " P.ID,P.NAME,P.ADDRESS,P.STAR_LEVEL,P.CONSULT_COUNT,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID,P.PHONE,P.EMAIL,P.PROVINCE "
478
				+ " P.ID,P.NAME,P.ADDRESS,P.STAR_LEVEL,P.CONSULT_COUNT,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID,P.PHONE,P.EMAIL,P.PROVINCE,P.SEX,P.BIRTHDAY "
474 479
				+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.ID = ?";
475 480
		PreparedStatement ps = con.prepareStatement(sql);
476 481
		try {
@ -520,6 +525,8 @@ public abstract class ProfessorDao {
520 525
					professor.setPhone(rs.getString(15));
521 526
					professor.setEmail(rs.getString(16));
522 527
					professor.setProvince(rs.getString(17));
528
					professor.setSex(rs.getString(18));
529
					professor.setBirthday(rs.getString(19));
523 530
					return professor;
524 531
				} else {
525 532
					return null;
@ -1386,6 +1393,13 @@ public abstract class ProfessorDao {
1386 1393
		}
1387 1394
	}
1388 1395

1396
	@LimitQuery
1397
	@OrderBy("ORDER BY sort_desc DESC ")
1398
	public abstract List<SortedPro> indexSearch(Connection con,
1399
											  @SqlColumn(handlerClass = StringHandler.class, value = {"(case when sort_first=0 then '00000' else TO_CHAR(sort_first,'00009') end || TO_CHAR(CEIL(star_level * 100),'0009') || p.id )< ? "}) String sortDesc, @Nullable @GroupSqlColumn(value = {
1400
			"P.NAME LIKE ?", "O.NAME LIKE ?", "P.DEPARTMENT LIKE ?", "P.DESCP LIKE ?", "P.SUBJECT LIKE ?", "P.INDUSTRY LIKE ?", "P.ID IN (SELECT DISTINCT PROFESSOR_ID FROM RESEARCH_AREA WHERE CAPTION LIKE ?)", "P.ID IN (SELECT DISTINCT PROFESSOR_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?)", "P.ID IN (SELECT DISTINCT PROFESSOR_ID FROM ARTICLE WHERE ARTICLE_TITLE LIKE ?)", "P.ID IN (SELECT DISTINCT PROFESSOR_ID FROM PAPER_AUTHOR WHERE PAPER_ID IN (SELECT ID FROM PPAPER WHERE NAME LIKE ?))", "P.ID IN (SELECT DISTINCT PROFESSOR_ID FROM PATENT_AUTHOR WHERE PATENT_ID IN (SELECT ID FROM PPATENT WHERE NAME LIKE ?))"
1401
	}, handlerClass = StringHandler.class, isAnd = false) String key, @Nullable @Like String subject, @Nullable @Like String industry, @Nullable @Like String address, @Nullable Integer authType, int rows) throws SQLException;
1402

1389 1403
	/**
1390 1404
	 * 分页查询专家基础信息,多条件查询专家列表。
1391 1405
	 * 
@ -2090,4 +2104,9 @@ public abstract class ProfessorDao {
2090 2104

2091 2105
	@SelectList
2092 2106
	public abstract List<Professor> query(Connection con, @In String[] id) throws SQLException;
2107

2108
	@QueryList
2109
	@Select(Professor.class)
2110
	@From(Professor.class)
2111
	public abstract List<EditProfessor> queryPro(Connection con, @In String[] id) throws SQLException;
2093 2112
}

+ 57 - 15
src/main/java/com/ekexiu/portal/dao/ResourceDao.java

@ -1,18 +1,17 @@
1 1
package com.ekexiu.portal.dao;
2 2

3
import java.sql.Connection;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
6
import java.sql.SQLException;
7
import java.util.ArrayList;
8
import java.util.Collections;
9
import java.util.List;
10

3
import com.ekexiu.portal.po.Image;
4
import com.ekexiu.portal.po.Professor;
5
import com.ekexiu.portal.po.Resource;
6
import com.ekexiu.portal.pojo.EditProfessor;
11 7
import org.jfw.apt.annotation.Autowrie;
8
import org.jfw.apt.annotation.DefaultValue;
12 9
import org.jfw.apt.annotation.Nullable;
10
import org.jfw.apt.orm.annotation.dao.Column;
13 11
import org.jfw.apt.orm.annotation.dao.DAO;
14 12
import org.jfw.apt.orm.annotation.dao.Dynamic;
15 13
import org.jfw.apt.orm.annotation.dao.method.From;
14
import org.jfw.apt.orm.annotation.dao.method.LimitColumn;
16 15
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
17 16
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
18 17
import org.jfw.apt.orm.annotation.dao.method.Where;
@ -20,19 +19,26 @@ import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
20 19
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
21 20
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
22 21
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
22
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
23 23
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
24 24
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
25 25
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
26 26
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
27
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
27 28
import org.jfw.apt.orm.annotation.dao.param.In;
28 29
import org.jfw.apt.orm.annotation.dao.param.Like;
29 30
import org.jfw.apt.orm.annotation.dao.param.Set;
31
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
32
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
30 33
import org.jfw.util.PageQueryResult;
31 34

32
import com.ekexiu.portal.po.Image;
33
import com.ekexiu.portal.po.Professor;
34
import com.ekexiu.portal.po.Resource;
35
import com.ekexiu.portal.pojo.EditProfessor;
35
import java.sql.Connection;
36
import java.sql.PreparedStatement;
37
import java.sql.ResultSet;
38
import java.sql.SQLException;
39
import java.util.ArrayList;
40
import java.util.Collections;
41
import java.util.List;
36 42

37 43
@DAO
38 44
public abstract class ResourceDao {
@ -117,6 +123,15 @@ public abstract class ResourceDao {
117 123
	@Nullable
118 124
	public abstract Resource queryOne(Connection con, String resourceId) throws SQLException;
119 125
	
126
	@LimitSelect
127
	@OrderBy("ORDER BY RESOURCE_NAME ASC")
128
	@Where("STATUS ='1'")
129
	public abstract List<Resource> publishByProfessor(Connection con,String professorId,@Like String resourceName, int rows)throws SQLException;
130
	@LimitSelect
131
	@OrderBy("ORDER BY RESOURCE_NAME ASC")
132
	@Where("STATUS ='1'")
133
	public abstract List<Resource> publishByOrg(Connection con,String orgId,@Like String resourceName, int rows)throws SQLException;
134
	
120 135
	public PageQueryResult<Resource> queryForSelf(Connection con,String professorId,@Nullable String key,int pageSize,int pageNo) throws SQLException{
121 136
        int total = 0;
122 137
        PageQueryResult<Resource> queryResult = new PageQueryResult<Resource>();
@ -1086,7 +1101,22 @@ public abstract class ResourceDao {
1086 1101
	@OrderBy("ORDER BY PUBLISH_TIME DESC")
1087 1102
	@Where("STATUS = '1'")
1088 1103
	public abstract PageQueryResult<Resource> pageQueryProPublish(Connection con,String professorId,int pageSize,int pageNo) throws SQLException;
1089
	
1104

1105
    //@LimitSelect
1106
    //@OrderBy(cols = {@LimitColumn(value = "publishTime", asc = false), @LimitColumn(value = "shareId",asc = false,handlerClass = LongHandler.class)}, value = "")
1107
    //@Where("STATUS='1'")
1108
    //public abstract List<Resource> proPublish(Connection con, String professorId, String publishTime, long shareId, int rows) throws SQLException;
1109
    //
1110
    //@LimitSelect
1111
    //@OrderBy(cols = {@LimitColumn(value = "publishTime", asc = false), @LimitColumn(value = "shareId",asc = false, handlerClass = LongHandler.class)}, value = "")
1112
    //@Where("STATUS='1'")
1113
    //public abstract List<Resource> orgPublish(Connection con, String orgId, String publishTime, long shareId, int rows) throws SQLException;
1114

1115
    @LimitSelect
1116
    @OrderBy(cols = {@LimitColumn(value = "publishTime", asc = false), @LimitColumn(value = "shareId",asc = false, handlerClass = LongHandler.class)}, value = "")
1117
    @Where("STATUS='1'")
1118
    public abstract List<Resource> publish(Connection con,String resourceType,@GroupSqlColumn(handlerClass = StringHandler.class,value ={"PROFESSOR_ID = ?","ORG_ID = ?"},isAnd = false) String owner, String publishTime, long shareId, int rows) throws SQLException;
1119

1090 1120
	@SelectList
1091 1121
	@OrderBy("ORDER BY PUBLISH_TIME DESC")
1092 1122
	@Where("STATUS IN ('0','1')")
@ -1324,8 +1354,13 @@ public abstract class ResourceDao {
1324 1354
            try{ps.close();}catch(Exception e4){}
1325 1355
        }
1326 1356
    }
1327
	
1328
	/**
1357

1358
    @LimitSelect
1359
    @Where("STATUS='1'")
1360
    @OrderBy(cols = {@LimitColumn(value = "sortNum", asc = false, handlerClass = LongHandler.class), @LimitColumn(value = "publishTime", asc = false, handlerClass = StringHandler.class), @LimitColumn(value = "resourceId", asc = false, handlerClass = StringHandler.class)}, value = "")
1361
    public abstract List<Resource> indexSearch(Connection con, @Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = {"PROFESSOR_ID IN (SELECT ID FROM PROFESSOR WHERE NAME LIKE ?)", "ORG_ID IN (SELECT ID FROM ORGANIZATION WHERE NAME LIKE ? OR FOR_SHORT LIKE ?)", "RESOURCE_NAME LIKE ?", "SUBJECT LIKE ?", "SUPPORTED_SERVICES LIKE ?", "ORG_NAME LIKE ?", "SPEC LIKE ?"}, additional = 1, isAnd = false, force = true) String key, long sortNum, String publishTime, String resourceId, int rows) throws SQLException;
1362

1363
    /**
1329 1364
	 * 资源搜索页面接口,添加资源拥有者基本信息
1330 1365
	 * @param key 搜索条件
1331 1366
	 * @param subject 学术领域
@ -1804,4 +1839,11 @@ public abstract class ResourceDao {
1804 1839
		}
1805 1840
		return ret.isEmpty()?null:ret.toArray(new String[ret.size()]);		
1806 1841
	}
1842

1843
    @DefaultValue("0")
1844
    @QueryVal
1845
    @Where("STATUS = '1'")
1846
    @Column(value = "COUNT(1)", handlerClass = LongHandler.class)
1847
    @From(Resource.class)
1848
    public abstract long countPublish(Connection con, String resourceType, @GroupSqlColumn(handlerClass = StringHandler.class, value = {"PROFESSOR_ID = ?", "ORG_ID = ?"}, isAnd = false) String owner) throws SQLException;
1807 1849
}

+ 15 - 5
src/main/java/com/ekexiu/portal/dao/WatchDao.java

@ -1,17 +1,16 @@
1 1
package com.ekexiu.portal.dao;
2 2

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

3
import com.ekexiu.portal.po.Watch;
7 4
import org.jfw.apt.annotation.DefaultValue;
8 5
import org.jfw.apt.annotation.Nullable;
9 6
import org.jfw.apt.orm.annotation.dao.Column;
10 7
import org.jfw.apt.orm.annotation.dao.DAO;
11 8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.LimitColumn;
12 10
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
13 11
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
14 12
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
13
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
15 14
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
16 15
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
17 16
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
@ -19,7 +18,9 @@ import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
19 18
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
20 19
import org.jfw.util.PageQueryResult;
21 20

22
import com.ekexiu.portal.po.Watch;
21
import java.sql.Connection;
22
import java.sql.SQLException;
23
import java.util.List;
23 24

24 25
@DAO
25 26
public abstract class WatchDao {
@ -46,10 +47,19 @@ public abstract class WatchDao {
46 47
	@OrderBy(" ORDER BY CREATE_TIME DESC ")
47 48
	public abstract PageQueryResult<Watch> queryPro(Connection con, String professorId, short watchType, int pageSize, int pageNo) throws SQLException;
48 49

50
	@LimitSelect
51
	@OrderBy(cols = {@LimitColumn(value = "createTime", asc = false), @LimitColumn(value = "watchObject", asc = false)}, value = "")
52
	public abstract List<Watch> proList(Connection con, String professorId, short watchType, String createTime, String watchObject, int rows) throws SQLException;
53

49 54
	@SelectList
50 55
	@OrderBy(" ORDER BY CREATE_TIME DESC ")
51 56
	public abstract List<Watch> queryWatch(Connection con, String watchObject) throws SQLException;
52 57

58
	@LimitSelect
59
	@OrderBy(cols = {@LimitColumn(value = "createTime", asc = false), @LimitColumn(value = "professorId", asc = false)}, value = "")
60
	public abstract List<Watch> watchList(Connection con, String createTime, String professorId, String watchObject,int rows) throws SQLException;
61

62

53 63
	@QueryVal
54 64
	@From(Watch.class)
55 65
	@Column(value = "COUNT(1)", handlerClass = IntHandler.class)

+ 12 - 0
src/main/java/com/ekexiu/portal/po/Article.java

@ -5,6 +5,7 @@ import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5 5
import org.jfw.apt.orm.annotation.entry.Table;
6 6
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
7 7
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
8
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
8 9
import org.jfw.apt.orm.core.enums.DE;
9 10

10 11
import com.ekexiu.portal.basepo.CreateTimeSupported;
@ -35,6 +36,10 @@ public class Article implements CreateTimeSupported, ModifyTimeSupported {
35 36
	private Organization organization;
36 37
	private EditOrganization editOrganization;
37 38
	private int colNum;
39
	/**
40
	 * 排序字段
41
	 */
42
	private long sortNum;
38 43
	
39 44
	public EditProfessor getProfessor() {
40 45
		return professor;
@ -171,4 +176,11 @@ public class Article implements CreateTimeSupported, ModifyTimeSupported {
171 176
	public void setColNum(int colNum) {
172 177
		this.colNum = colNum;
173 178
	}
179
	@Column(handlerClass=LongHandler.class,dbType="BIGINT",fixSqlValueWithInsert="0",insertable=true,renewable=false,nullable=false,queryable=true)
180
	public long getSortNum() {
181
		return sortNum;
182
	}
183
	public void setSortNum(long sortNum) {
184
		this.sortNum = sortNum;
185
	}
174 186
}

+ 18 - 6
src/main/java/com/ekexiu/portal/po/Resource.java

@ -1,19 +1,19 @@
1 1
package com.ekexiu.portal.po;
2 2

3
import java.util.List;
4

3
import com.ekexiu.portal.basepo.CreateTimeSupported;
4
import com.ekexiu.portal.basepo.ModifyTimeSupported;
5
import com.ekexiu.portal.pojo.EditOrganization;
6
import com.ekexiu.portal.pojo.EditProfessor;
5 7
import org.jfw.apt.orm.annotation.entry.Column;
6 8
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
7 9
import org.jfw.apt.orm.annotation.entry.Table;
8 10
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
9 11
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
12
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
10 13
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
11 14
import org.jfw.apt.orm.core.enums.DE;
12 15

13
import com.ekexiu.portal.basepo.CreateTimeSupported;
14
import com.ekexiu.portal.basepo.ModifyTimeSupported;
15
import com.ekexiu.portal.pojo.EditOrganization;
16
import com.ekexiu.portal.pojo.EditProfessor;
16
import java.util.List;
17 17

18 18
@PrimaryKey("resourceId")
19 19
@Table
@ -78,6 +78,10 @@ public class Resource implements CreateTimeSupported, ModifyTimeSupported{
78 78
	private String orgId;
79 79
	
80 80
	private long shareId;
81
	/**
82
	 * 排序字段
83
	 */
84
	private long sortNum;
81 85
	
82 86
	public List<Image> getImages() {
83 87
		return images;
@ -278,6 +282,14 @@ public class Resource implements CreateTimeSupported, ModifyTimeSupported{
278 282
	public void setShareId(long shareId) {
279 283
		this.shareId = shareId;
280 284
	}
285

286
	@Column(handlerClass=LongHandler.class,dbType="BIGINT",fixSqlValueWithInsert="0",insertable=true,renewable=false,nullable=false,queryable=true)
287
	public long getSortNum() {
288
		return sortNum;
289
	}
290
	public void setSortNum(long sortNum) {
291
		this.sortNum = sortNum;
292
	}
281 293
	
282 294
	
283 295
}

+ 55 - 0
src/main/java/com/ekexiu/portal/pojo/SortedPro.java

@ -0,0 +1,55 @@
1
package com.ekexiu.portal.pojo;
2
3
import com.ekexiu.portal.po.Professor;
4
import com.ekexiu.portal.po.ResearchArea;
5
import org.jfw.apt.orm.annotation.entry.CalcColumn;
6
import org.jfw.apt.orm.annotation.entry.ExtendView;
7
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
8
9
import java.util.List;
10
11
/**
12
 * Created by TT on 2018/3/8.
13
 */
14
@ExtendView(fromSentence = "Professor p left join organization o on p.org_id = o.id",tableAlias = "p")
15
public class SortedPro extends Professor {
16
    private String sortDesc;
17
    private String orgName;
18
    private Integer hasHeadImage;
19
    private List<ResearchArea> researchAreas;
20
21
    @CalcColumn(nullable = false,handlerClass = StringHandler.class,column = "case when sort_first = 0 then '00000' else TO_CHAR(sort_first,'00009') end || TO_CHAR(CEIL(star_level * 100),'0009') || p.id sort_desc ")
22
    public String getSortDesc() {
23
        return sortDesc;
24
    }
25
26
    public void setSortDesc(String sortDesc) {
27
        this.sortDesc = sortDesc;
28
    }
29
30
    @CalcColumn(handlerClass = StringHandler.class, column = "o.name")
31
    public String getOrgName() {
32
        return orgName;
33
    }
34
35
    public void setOrgName(String orgName) {
36
        this.orgName = orgName;
37
    }
38
39
40
    public Integer getHasHeadImage() {
41
        return hasHeadImage;
42
    }
43
44
    public void setHasHeadImage(Integer hasHeadImage) {
45
        this.hasHeadImage = hasHeadImage;
46
    }
47
48
    public List<ResearchArea> getResearchAreas() {
49
        return researchAreas;
50
    }
51
52
    public void setResearchAreas(List<ResearchArea> researchAreas) {
53
        this.researchAreas = researchAreas;
54
    }
55
}

+ 12 - 5
src/main/java/com/ekexiu/portal/question/QuestionDao.java

@ -1,9 +1,5 @@
1 1
package com.ekexiu.portal.question;
2 2

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

7 3
import org.jfw.apt.annotation.DefaultValue;
8 4
import org.jfw.apt.annotation.Nullable;
9 5
import org.jfw.apt.orm.annotation.dao.Batch;
@ -29,6 +25,10 @@ import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
29 25
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
30 26
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
31 27

28
import java.sql.Connection;
29
import java.sql.SQLException;
30
import java.util.List;
31

32 32

33 33
@DAO
34 34
public interface QuestionDao {
@ -134,7 +134,7 @@ public interface QuestionDao {
134 134
	@LimitQuery
135 135
	@OrderBy("ORDER BY SCORE_DESC DESC")
136 136
	@Where("STATE='1'")
137
	List<SortedAnswwer> byQesScore(Connection con, String qid, @SqlColumn(handlerClass = StringHandler.class, value = { "(case when ballot=0 then '00000'  else  TO_CHAR(10000 *AGREE / BALLOT,'00009') end  || ID) < ?  " })  String score, int rows) throws SQLException;
137
	List<SortedAnswwer> byQesScore(Connection con, String qid, @SqlColumn(handlerClass = StringHandler.class, value = { "(case when ballot=0 then '00000'  else  TO_CHAR(10000 *AGREE / BALLOT,'00009') end || TO_CHAR(AGREE,'00000000000000000009') || ID) < ?  " })  String score, int rows) throws SQLException;
138 138

139 139
	@Insert
140 140
	int insert(Connection con,AnswerAgreeRec aar)throws SQLException;
@ -182,4 +182,11 @@ public interface QuestionDao {
182 182
	@Column(value="COUNT(1)",handlerClass=LongHandler.class)
183 183
	@From(Answer.class)
184 184
	long answerCount(Connection con,@Nullable String uid,@Nullable String qid, @Nullable String state)throws SQLException;
185

186
	@DefaultValue("0")
187
	@QueryVal
188
	@Column(value = "COUNT(1)", handlerClass = LongHandler.class)
189
	@From(Answer.class)
190
	@Where("QID IN(SELECT ID FROM QUESTION WHERE STATE='1') AND STATE='1'")
191
	long answerSelfCount(Connection con, String uid)throws SQLException;
185 192
}

+ 28 - 22
src/main/java/com/ekexiu/portal/question/Service.java

@ -1,21 +1,9 @@
1 1
package com.ekexiu.portal.question;
2 2

3
import java.io.ByteArrayInputStream;
4
import java.io.File;
5
import java.io.FileInputStream;
6
import java.io.FileOutputStream;
7
import java.io.IOException;
8
import java.io.InputStream;
9
import java.io.OutputStream;
10
import java.sql.Connection;
11
import java.sql.PreparedStatement;
12
import java.sql.SQLException;
13
import java.util.ArrayList;
14
import java.util.LinkedList;
15
import java.util.List;
16
import java.util.Map;
17
import java.util.concurrent.atomic.AtomicInteger;
18

3
import com.ekexiu.portal.notify.NotifyService;
4
import com.ekexiu.portal.notify.NotifyType;
5
import com.ekexiu.portal.service.GrowthLogService;
6
import com.ekexiu.portal.util.SqlUtil;
19 7
import org.jfw.apt.annotation.Autowrie;
20 8
import org.jfw.apt.annotation.DefaultValue;
21 9
import org.jfw.apt.annotation.Nullable;
@ -38,10 +26,21 @@ import org.jfw.util.jdbc.PreparedStatementConfig;
38 26
import org.jfw.util.web.fileupload.Item;
39 27
import org.jfw.util.web.fileupload.UploadItemIterator;
40 28

41
import com.ekexiu.portal.notify.NotifyService;
42
import com.ekexiu.portal.notify.NotifyType;
43
import com.ekexiu.portal.service.GrowthLogService;
44
import com.ekexiu.portal.util.SqlUtil;
29
import java.io.ByteArrayInputStream;
30
import java.io.File;
31
import java.io.FileInputStream;
32
import java.io.FileOutputStream;
33
import java.io.IOException;
34
import java.io.InputStream;
35
import java.io.OutputStream;
36
import java.sql.Connection;
37
import java.sql.PreparedStatement;
38
import java.sql.SQLException;
39
import java.util.ArrayList;
40
import java.util.LinkedList;
41
import java.util.List;
42
import java.util.Map;
43
import java.util.concurrent.atomic.AtomicInteger;
45 44

46 45
@Path("/question")
47 46
public class Service {
@ -585,10 +584,11 @@ public class Service {
585 584
	 */
586 585
	@Get
587 586
	@Path("/answer/qes/byScore")
588
	public List<SortedAnswwer> byQes(@JdbcConn Connection con, String qid, @DefaultValue("99999") int score, @DefaultValue("\"Z\"") String id,
587
	public List<SortedAnswwer> byQes(@JdbcConn Connection con, String qid, @DefaultValue("99999") int score, @DefaultValue("\"Z\"") String id,@DefaultValue("0") long agree,
589 588
			@DefaultValue("10000000") int rows) throws SQLException {
590 589
		String p = "000000" + score;
591
		p = p.substring(p.length() - 5) + id;
590
		String a = "00000000000000000000"+agree;
591
		p = p.substring(p.length() - 5) + a.substring(a.length()-20) + id;
592 592
		return questionDao.byQesScore(con, qid, p, rows);
593 593
	}
594 594

@ -738,6 +738,12 @@ public class Service {
738 738
		}
739 739
	}
740 740

741
	@Get
742
	@Path("/answer/bySelf/count")
743
	public long answerSelfCount(@JdbcConn Connection con,String uid)throws SQLException {
744
		return this.questionDao.answerSelfCount(con, uid);
745
	}
746

741 747
	public QetKeyWord[] build(String id, List<String> ss) {
742 748
		List<QetKeyWord> qKws = new ArrayList<>(ss.size());
743 749
		for (String s : ss) {

+ 1 - 1
src/main/java/com/ekexiu/portal/question/SortedAnswwer.java

@ -11,7 +11,7 @@ public class SortedAnswwer extends Answer {
11 11
	private transient String scoreDesc;
12 12
	
13 13
	
14
	@CalcColumn(nullable=false,handlerClass=StringHandler.class,column=" case when ballot=0 then '00000' else  TO_CHAR(10000 *AGREE / BALLOT,'00009') end  || ID SCORE_DESC")
14
	@CalcColumn(nullable=false,handlerClass=StringHandler.class,column=" case when ballot=0 then '00000' else  TO_CHAR(10000 *AGREE / BALLOT,'00009') end ||  TO_CHAR(AGREE,'00000000000000000009') || ID SCORE_DESC")
15 15
	public String getScoreDesc() {
16 16
		return scoreDesc;
17 17
	}

+ 50 - 0
src/main/java/com/ekexiu/portal/service/ArticleService.java

@ -885,6 +885,12 @@ public class ArticleService {
885 885
		return this.articleDao.pageQueryProPublish(con, professorId, pageSize, pageNo);
886 886
	}
887 887

888
	@Get
889
	@Path("/publish")
890
	public List<Article> proPublish(@JdbcConn Connection con, String category, String owner, @DefaultValue("\"9\"") String publishTime,@DefaultValue("Long.MAX_VALUE")long shareId, int rows)throws SQLException {
891
			return this.articleDao.publish(con,category, owner, publishTime,shareId, rows);
892
	}
893

888 894
	@Get
889 895
	@Path("/qaForDesk")
890 896
	public List<Article> queryForDesk(@JdbcConn Connection con, String professorId) throws SQLException {
@ -962,6 +968,33 @@ public class ArticleService {
962 968
		return queryResult;
963 969
	}
964 970

971
	@Get
972
	@Path("/index/search")
973
	public List<Article> indexSearch(@JdbcConn Connection con, @Nullable String key, @DefaultValue("Long.MAX_VALUE") long sortNum, @DefaultValue("\"9\"") String publishTime, @DefaultValue("\"G\"") String id, @DefaultValue("10000000") int rows) throws SQLException {
974
		if (key != null) {
975
			key = "%" + key + "%";
976
		}
977
		List<Article> articles = this.articleDao.indexSearch(con, key, sortNum, publishTime, id, rows);
978
		if (!articles.isEmpty()) {
979
			for (Article article : articles) {
980
				if ("1".equals(article.getArticleType())) {
981
					EditProfessor professor = this.professorDao.queryBaseInfo(con, article.getProfessorId());
982
					if (professor != null) {
983
						professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
984
					}
985
					article.setProfessor(professor);
986
				} else if ("2".equals(article.getArticleType())) {
987
					EditOrganization organization = this.orgDao.queryEditOrg(con, article.getOrgId());
988
					if (organization != null) {
989
						organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
990
					}
991
					article.setEditOrganization(organization);
992
				}
993
			}
994
		}
995
		return articles;
996
	}
997

965 998
	@Get
966 999
	@Path("/pqself")
967 1000
	public PageQueryResult<SelfArticle> queryPageSelf(@JdbcConn Connection con, @Nullable String professorId, @Nullable String orgId,
@ -1118,6 +1151,23 @@ public class ArticleService {
1118 1151
	public List<Article> byWare(@JdbcConn Connection con,String ware,int rows) throws SQLException{
1119 1152
		return articleDao.queryByWareId(con, ware, rows);
1120 1153
	}
1154
	@Get
1155
	@Path("/ware")
1156
	public List<ArticleWare> queryWares(@JdbcConn Connection con,String id)throws SQLException{
1157
		return articleDao.queryWares(con, id);
1158
	}
1159

1160
	@Get
1161
	@Path("/count/publish")
1162
	public long countPublish(@JdbcConn Connection con,String category,String owner)throws SQLException {
1163
		return articleDao.countPublish(con, category, owner);
1164
	}
1165

1166
	@Get
1167
	@Path("/qm")
1168
	public List<Article> query(@JdbcConn Connection con,String[] id)throws SQLException {
1169
		return this.articleDao.query(con, id);
1170
	}
1121 1171

1122 1172
	public static void main(String[] args) {
1123 1173
		System.out.println(DateUtil.formatDate(System.currentTimeMillis() - 7 * 24 * 60 * 60 * 1000));

+ 23 - 11
src/main/java/com/ekexiu/portal/service/OrgService.java

@ -1,11 +1,10 @@
1 1
package com.ekexiu.portal.service;
2 2
3
import java.io.IOException;
4
import java.sql.Connection;
5
import java.sql.SQLException;
6
import java.util.Collections;
7
import java.util.List;
8
3
import com.ekexiu.portal.dao.OrgDao;
4
import com.ekexiu.portal.dao.OrgRegInfoDao;
5
import com.ekexiu.portal.po.OrgRegInfo;
6
import com.ekexiu.portal.po.Organization;
7
import com.ekexiu.portal.pojo.EditOrganization;
9 8
import org.jfw.apt.annotation.Autowrie;
10 9
import org.jfw.apt.annotation.DefaultValue;
11 10
import org.jfw.apt.annotation.Nullable;
@ -17,11 +16,11 @@ import org.jfw.apt.web.annotation.param.PathVar;
17 16
import org.jfw.util.PageQueryResult;
18 17
import org.jfw.util.StringUtil;
19 18
20
import com.ekexiu.portal.dao.OrgDao;
21
import com.ekexiu.portal.dao.OrgRegInfoDao;
22
import com.ekexiu.portal.po.OrgRegInfo;
23
import com.ekexiu.portal.po.Organization;
24
import com.ekexiu.portal.pojo.EditOrganization;
19
import java.io.IOException;
20
import java.sql.Connection;
21
import java.sql.SQLException;
22
import java.util.Collections;
23
import java.util.List;
25 24
26 25
@Path("/org")
27 26
public class OrgService {
@ -245,6 +244,19 @@ public class OrgService {
245 244
		}
246 245
		return pqr;
247 246
	}
247
248
	@Get
249
	@Path("/index/search")
250
	public List<EditOrganization> indexSearch(@JdbcConn Connection con, @Nullable String key, @DefaultValue("Long.MAX_VALUE") long sortNum, @DefaultValue("\"9\"") String modifyTime,@DefaultValue("\"Z\"")String id, @DefaultValue("10000000") int rows)throws SQLException {
251
		if (key != null) {
252
			key = "%" + key + "%";
253
		}
254
		List<EditOrganization> orgs = this.orgDao.indexSearch(con,key,sortNum,modifyTime,id,rows);
255
		for (EditOrganization organization : orgs) {
256
			organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
257
		}
258
		return orgs;
259
	}
248 260
	@Get
249 261
	@Path("/qm")
250 262
	public List<EditOrganization> query(@JdbcConn Connection con,String[] id)throws SQLException{

+ 26 - 0
src/main/java/com/ekexiu/portal/service/PpaperService.java

@ -118,6 +118,17 @@ public class PpaperService {
118 118
		return this.ppaperDao.pageQueryWithProfessor(con, id, name, pageSize, pageNo);
119 119
	}
120 120

121
	@Get
122
	@Path("/professor")
123
	public List<AssedPaper> queryProfessor(@JdbcConn Connection con,String owner,@Nullable String name,@DefaultValue("\"9\"")String assTime,@DefaultValue("\"Z\"")String id,int rows)throws SQLException {
124
		if (name == null) {
125
			name = "%";
126
		} else {
127
			name = "%" + name + "%";
128
		}
129
		return this.ppaperDao.queryProfessor(con, owner, name, assTime, id,rows);
130
	}
131

121 132
	@Get
122 133
	@Path("/byAuthor")
123 134
	public PageQueryResult<AssedPaper> queryByAuthor(@JdbcConn Connection con, String author, String id, @Nullable String name,
@ -143,6 +154,15 @@ public class PpaperService {
143 154
		return null == qw ? this.ppaperDao.query(con, pageSize, pageNo) : this.ppaperDao.query(con, "%" + qw + "%", pageSize, pageNo);
144 155
	}
145 156

157
	@Get
158
	@Path("/index/search")
159
	public List<Ppaper> indexSearch(@JdbcConn Connection con, @Nullable String key, @DefaultValue("Long.MAX_VALUE") long sortNum, @DefaultValue("\"9\"") String createTime,@DefaultValue("\"G\"")String id, @DefaultValue("10000000") int rows)throws SQLException {
160
		if (key != null) {
161
			key = "%" + key + "%";
162
		}
163
		return this.ppaperDao.indexSearch(con, key, sortNum, createTime, id, rows);
164

165
	}
146 166
	/**
147 167
	 * 
148 168
	 * @param con
@ -257,4 +277,10 @@ public class PpaperService {
257 277
			return Collections.<Ppaper> emptyList();
258 278
		return this.ppaperDao.query(con, ids);
259 279
	}
280

281
	@Get
282
	@Path("/count/publish")
283
	public long countPublish(@JdbcConn Connection con,String owner)throws SQLException {
284
		return this.ppaperDao.countPublish(con, owner);
285
	}
260 286
}

+ 27 - 0
src/main/java/com/ekexiu/portal/service/PpatentServcie.java

@ -123,6 +123,18 @@ public class PpatentServcie {
123 123
		}
124 124
		return this.ppatentDao.pageQueryWithProfessor(con, id, name, pageSize, pageNo);
125 125
	}
126

127
	@Get
128
	@Path("/professor")
129
	public List<AssedPatent> queryProfessor(@JdbcConn Connection con, String owner, @Nullable String name, @DefaultValue("\"9\"")String assTime, @DefaultValue("\"Z\"")String id, int rows)throws SQLException {
130
		if (name == null) {
131
			name = "%";
132
		} else {
133
			name = "%" + name + "%";
134
		}
135
		return this.ppatentDao.queryProfessor(con, owner, name, assTime, id,rows);
136
	}
137

126 138
	@Get
127 139
	@Path("/byAuthor")
128 140
	public PageQueryResult<AssedPatent> queryByAuthor(@JdbcConn Connection con,String author,String id,@Nullable String name,@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
@ -145,6 +157,15 @@ public class PpatentServcie {
145 157
			throws SQLException {
146 158
		return null == qw ? this.ppatentDao.query(con, pageSize, pageNo) : this.ppatentDao.query(con, "%" + qw + "%", pageSize, pageNo);
147 159
	}
160

161
	@Get
162
	@Path("/index/search")
163
	public List<Ppatent> indexSearch(@JdbcConn Connection con, @Nullable String key, @DefaultValue("Long.MAX_VALUE") long sortNum, @DefaultValue("\"9\"") String createTime,@DefaultValue("\"G\"")String id, @DefaultValue("10000000") int rows)throws SQLException {
164
		if (key != null) {
165
			key = "%" + key + "%";
166
		}
167
		return this.ppatentDao.indexSearch(con, key, sortNum, createTime,id, rows);
168
	}
148 169
	/**
149 170
	 * 
150 171
	 * @param con
@ -254,5 +275,11 @@ public class PpatentServcie {
254 275
		if(ids==null || ids.length==0) return Collections.<Ppatent>emptyList();
255 276
		return this.ppatentDao.query(con, ids);		
256 277
	}
278

279
	@Get
280
	@Path("/count/publish")
281
	public long countPublish(@JdbcConn Connection con,String owner)throws SQLException {
282
		return this.ppatentDao.countPublish(con, owner);
283
	}
257 284
	
258 285
}

+ 87 - 31
src/main/java/com/ekexiu/portal/service/ProfessorService.java

@ -1,35 +1,5 @@
1 1
package com.ekexiu.portal.service;
2 2

3
import java.io.IOException;
4
import java.math.BigDecimal;
5
import java.net.URLEncoder;
6
import java.sql.Connection;
7
import java.sql.PreparedStatement;
8
import java.sql.ResultSet;
9
import java.sql.SQLException;
10
import java.text.DecimalFormat;
11
import java.util.ArrayList;
12
import java.util.Collections;
13
import java.util.HashMap;
14
import java.util.List;
15
import java.util.Map;
16

17
import org.jfw.apt.annotation.Autowrie;
18
import org.jfw.apt.annotation.DefaultValue;
19
import org.jfw.apt.annotation.Nullable;
20
import org.jfw.apt.web.annotation.Path;
21
import org.jfw.apt.web.annotation.operate.Delete;
22
import org.jfw.apt.web.annotation.operate.Get;
23
import org.jfw.apt.web.annotation.operate.Post;
24
import org.jfw.apt.web.annotation.operate.Put;
25
import org.jfw.apt.web.annotation.param.JdbcConn;
26
import org.jfw.apt.web.annotation.param.PathVar;
27
import org.jfw.apt.web.annotation.param.RequestBody;
28
import org.jfw.util.PageQueryResult;
29
import org.jfw.util.StringUtil;
30
import org.jfw.util.jdbc.JdbcUtil;
31
import org.jfw.util.jdbc.PreparedStatementConfig;
32

33 3
import com.ekexiu.portal.dao.ArticleDao;
34 4
import com.ekexiu.portal.dao.DemandDao;
35 5
import com.ekexiu.portal.dao.HonorDao;
@ -49,14 +19,45 @@ import com.ekexiu.portal.dao.ResearchAreaLogDao;
49 19
import com.ekexiu.portal.dao.ResourceDao;
50 20
import com.ekexiu.portal.dao.UserDao;
51 21
import com.ekexiu.portal.dao.WatchDao;
22
import com.ekexiu.portal.po.Organization;
52 23
import com.ekexiu.portal.po.Professor;
53 24
import com.ekexiu.portal.po.Resource;
54 25
import com.ekexiu.portal.po.User;
55 26
import com.ekexiu.portal.pojo.EditProfessor;
56 27
import com.ekexiu.portal.pojo.EditResearchAreaLog;
57 28
import com.ekexiu.portal.pojo.ProfessorInfo;
29
import com.ekexiu.portal.pojo.SortedPro;
58 30
import com.ekexiu.portal.pojo.UserInfo;
59 31
import com.ekexiu.portal.util.Calculate;
32
import org.jfw.apt.annotation.Autowrie;
33
import org.jfw.apt.annotation.DefaultValue;
34
import org.jfw.apt.annotation.Nullable;
35
import org.jfw.apt.web.annotation.Path;
36
import org.jfw.apt.web.annotation.operate.Delete;
37
import org.jfw.apt.web.annotation.operate.Get;
38
import org.jfw.apt.web.annotation.operate.Post;
39
import org.jfw.apt.web.annotation.operate.Put;
40
import org.jfw.apt.web.annotation.param.JdbcConn;
41
import org.jfw.apt.web.annotation.param.PathVar;
42
import org.jfw.apt.web.annotation.param.RequestBody;
43
import org.jfw.util.PageQueryResult;
44
import org.jfw.util.StringUtil;
45
import org.jfw.util.jdbc.JdbcUtil;
46
import org.jfw.util.jdbc.PreparedStatementConfig;
47

48
import java.io.IOException;
49
import java.math.BigDecimal;
50
import java.net.URLEncoder;
51
import java.sql.Connection;
52
import java.sql.PreparedStatement;
53
import java.sql.ResultSet;
54
import java.sql.SQLException;
55
import java.text.DecimalFormat;
56
import java.util.ArrayList;
57
import java.util.Collections;
58
import java.util.HashMap;
59
import java.util.List;
60
import java.util.Map;
60 61

61 62
@Path("/professor")
62 63
public class ProfessorService {
@ -380,7 +381,7 @@ public class ProfessorService {
380 381

381 382
	@Put
382 383
	@Path
383
	public void update(@JdbcConn(true) Connection con, @RequestBody EditProfessor professor) throws SQLException, IOException {
384
	public void update(@JdbcConn(true) Connection con,final @RequestBody EditProfessor professor) throws SQLException, IOException {
384 385
		if (professor.getOrgName() != null)
385 386
			if (null != this.orgDao.queryByName(con, professor.getOrgName())) {
386 387
				professor.setOrgId(this.orgDao.queryByName(con, professor.getOrgName()));
@ -401,6 +402,12 @@ public class ProfessorService {
401 402
				this.professorDao.updateOrgAuth(con, op.getId(), "0");
402 403
				this.demandDao.closeByCreator(con, op.getId(), op.getId());
403 404
				this.orgResStaffDao.deletePro(con, op.getId());
405
				JdbcUtil.execute(con,"DELETE FROM WARE_PRO WHERE PROFESSOR=?",new PreparedStatementConfig() {
406
					@Override
407
					public void config(PreparedStatement ps) throws SQLException {
408
						ps.setString(1, professor.getId());
409
					}
410
				});
404 411
			}
405 412
		}
406 413
		;
@ -761,6 +768,37 @@ public class ProfessorService {
761 768
		return queryResult;
762 769
	}
763 770

771
	@Get
772
	@Path("/index/search")
773
	public List<SortedPro> searchPro(@JdbcConn(false) Connection con, @Nullable String key, @Nullable String subject,
774
									 @Nullable String industry, @Nullable String address, @Nullable Integer authType, @DefaultValue("99999") int sortFirst, @DefaultValue("\"Z\"")String id, @DefaultValue("0")double starLevel, @DefaultValue("10000000") int rows)
775
			throws SQLException {
776
		if (key != null) {
777
			key = "%" + key + "%";
778
		}
779
		if (subject != null) {
780
			subject = "%" + subject + "%";
781
		}
782
		if (null != industry) {
783
			industry = "%" + industry + "%";
784
		}
785
		if (null != address) {
786
			address = "%" + address + "%";
787
		}
788
		String sortDesc = "000000"+ sortFirst;
789
		String a =  "0000" + (int)(starLevel*100);
790
		sortDesc = sortDesc.substring(sortDesc.length()-5)+a.substring(a.length()-4)+id;
791
		List<SortedPro> queryResult = this.professorDao.indexSearch(con,sortDesc, key, subject, industry, address, authType,rows );
792
		if (!queryResult.isEmpty()) {
793
			for (SortedPro editProfessor : queryResult) {
794
				editProfessor.setHasHeadImage(this.imageService.hasProfessorImage(editProfessor.getId()));
795
				editProfessor.setResearchAreas(this.researchAreaDao.query(con, editProfessor.getId()));
796
			}
797
			hiddenPrivacyInfo(queryResult);
798
		}
799
		return queryResult;
800
	}
801

764 802
	@Get
765 803
	@Path("/pqUserInfo")
766 804
	public PageQueryResult<UserInfo> queryUserInfo(@JdbcConn(false) Connection con, @Nullable String key, @Nullable String address, @Nullable String orgName,
@ -922,6 +960,24 @@ public class ProfessorService {
922 960
		}
923 961
	}
924 962

963
	@Get
964
	@Path("/qm")
965
	public List<EditProfessor> query(@JdbcConn Connection con,String[] id)throws SQLException {
966
		List<EditProfessor> editProfessors= this.professorDao.queryPro(con, id);
967
		if (!editProfessors.isEmpty()) {
968
			for (EditProfessor editProfessor : editProfessors) {
969
				editProfessor.setHasHeadImage(this.imageService.hasProfessorImage(editProfessor.getId()));
970
				if(editProfessor.getOrgId() != null) {
971
					Organization organization = this.orgDao.query(con, editProfessor.getOrgId());
972
					if(organization != null) {
973
						editProfessor.setOrgName(organization.getName());
974
					}
975
				}
976
			}
977
		}
978
		return hiddenPrivacyInfo(editProfessors);
979
	}
980

925 981
	public static <T extends Professor> T hiddenPrivacyInfo(T p) {
926 982
		if (null != p) {
927 983
			p.setPhone(null);

+ 86 - 22
src/main/java/com/ekexiu/portal/service/ResourceService.java

@ -1,26 +1,5 @@
1 1
package com.ekexiu.portal.service;
2 2

3
import java.io.IOException;
4
import java.sql.Connection;
5
import java.sql.SQLException;
6
import java.text.SimpleDateFormat;
7
import java.util.Collections;
8
import java.util.Date;
9
import java.util.List;
10

11
import org.jfw.apt.annotation.Autowrie;
12
import org.jfw.apt.annotation.DefaultValue;
13
import org.jfw.apt.annotation.Nullable;
14
import org.jfw.apt.web.annotation.Path;
15
import org.jfw.apt.web.annotation.operate.Delete;
16
import org.jfw.apt.web.annotation.operate.Get;
17
import org.jfw.apt.web.annotation.operate.Post;
18
import org.jfw.apt.web.annotation.param.JdbcConn;
19
import org.jfw.apt.web.annotation.param.PathVar;
20
import org.jfw.util.PageQueryResult;
21
import org.jfw.util.StringUtil;
22
import org.jfw.util.exception.JfwBaseException;
23

24 3
import com.ekexiu.portal.dao.ArticleDao;
25 4
import com.ekexiu.portal.dao.ArticleResDao;
26 5
import com.ekexiu.portal.dao.ImageDao;
@ -39,6 +18,26 @@ import com.ekexiu.portal.po.Resource;
39 18
import com.ekexiu.portal.po.ResourceTmpLog;
40 19
import com.ekexiu.portal.pojo.EditOrganization;
41 20
import com.ekexiu.portal.pojo.EditProfessor;
21
import org.jfw.apt.annotation.Autowrie;
22
import org.jfw.apt.annotation.DefaultValue;
23
import org.jfw.apt.annotation.Nullable;
24
import org.jfw.apt.web.annotation.Path;
25
import org.jfw.apt.web.annotation.operate.Delete;
26
import org.jfw.apt.web.annotation.operate.Get;
27
import org.jfw.apt.web.annotation.operate.Post;
28
import org.jfw.apt.web.annotation.param.JdbcConn;
29
import org.jfw.apt.web.annotation.param.PathVar;
30
import org.jfw.util.PageQueryResult;
31
import org.jfw.util.StringUtil;
32
import org.jfw.util.exception.JfwBaseException;
33

34
import java.io.IOException;
35
import java.sql.Connection;
36
import java.sql.SQLException;
37
import java.text.SimpleDateFormat;
38
import java.util.Collections;
39
import java.util.Date;
40
import java.util.List;
42 41

43 42
@Path("/resource")
44 43
public class ResourceService {
@ -647,6 +646,12 @@ public class ResourceService {
647 646
		return queryResult;
648 647
	}
649 648
	
649
	@Get
650
	@Path("/lq/publish/org")
651
	public List<Resource> publishByOrg(@JdbcConn Connection con,String resourceName,String orgid,int rows)throws SQLException{
652
		return this.resourceDao.publishByOrg(con, orgid,"%"+resourceName+"%", rows);
653
	}
654

650 655
//	@Get
651 656
//	@Path("/ralateRes")
652 657
//	public List<Resource> queryLimit(@JdbcConn Connection con,@Nullable String[] keys,String resourceId,
@ -827,7 +832,21 @@ public class ResourceService {
827 832
		}
828 833
		return resources;
829 834
	}
830
	
835

836
	@Get
837
	@Path("/publish")
838
	List<Resource> queryPublish(@JdbcConn Connection con, String category, String owner, @DefaultValue("\"9\"") String publishTime,@DefaultValue("Long.MAX_VALUE")long shareId, int rows) throws SQLException {
839
		List<Resource> resources = this.resourceDao.publish(con, category, owner, publishTime, shareId, rows);
840
		if (resources != null && resources.size() > 0) {
841
			for (Resource resource : resources) {
842
				resource.setImages(this.imageDao.queryRes(con, resource.getResourceId()));
843
			}
844
			return resources;
845
		} else {
846
			return Collections.emptyList();
847
		}
848
	}
849

831 850
	@Get
832 851
	@Path("/qaForDesk")
833 852
	public List<Resource> queryForDesk(@JdbcConn Connection con, String professorId) throws SQLException {
@ -946,6 +965,34 @@ public class ResourceService {
946 965
		}
947 966
		return queryResult;
948 967
	}
968

969
	@Get
970
	@Path("/index/search")
971
	public List<Resource> indexSearch(@JdbcConn Connection con, @Nullable String key, @DefaultValue("Long.MAX_VALUE") long sortNum, @DefaultValue("\"9\"") String publishTime,@DefaultValue("\"G\"")String id, @DefaultValue("10000000") int rows)throws SQLException {
972
		if (key != null) {
973
			key = "%" + key + "%";
974
		}
975
		List<Resource> resources =  this.resourceDao.indexSearch(con, key, sortNum, publishTime,id, rows);
976
		if(!resources.isEmpty()){
977
			for (Resource resource : resources) {
978
				resource.setImages(this.imagesService.queryRes(con, resource.getResourceId()));
979
				if(resource.getProfessorId() != null){
980
					EditProfessor professor = this.professorDao.queryBaseInfo(con, resource.getProfessorId());
981
					if(professor != null){
982
						professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
983
					}
984
					resource.setEditProfessor(professor);
985
				}else if(resource.getOrgId() != null){
986
					EditOrganization organization = this.orgDao.queryEditOrg(con, resource.getOrgId());
987
					if(organization != null){
988
						organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
989
					}
990
					resource.setOrganization(organization);
991
				}
992
			}
993
		}
994
		return resources;
995
	}
949 996
	
950 997
	@Get
951 998
	@Path("/pqRes")
@ -1005,4 +1052,21 @@ public class ResourceService {
1005 1052
		}
1006 1053
		return Collections.<Resource>emptyList();
1007 1054
	}
1055

1056
	@Get
1057
	@Path("/count/publish")
1058
	public long countPublish(@JdbcConn Connection con, String category, String owner) throws SQLException {
1059
		return this.resourceDao.countPublish(con, category, owner);
1060
	}
1061

1062
	@Get
1063
	@Path("/qm")
1064
	public List<Resource> query(@JdbcConn Connection con,String[] id)throws SQLException {
1065
		List<Resource> ret = this.resourceDao.query(con,id);
1066
		for(Resource res:ret){
1067
			res.setImages(this.imageDao.queryRes(con, res.getResourceId()));
1068
		}
1069
		return ret;
1070
	}
1071

1008 1072
}

+ 12 - 0
src/main/java/com/ekexiu/portal/service/WatchService.java

@ -193,6 +193,12 @@ public class WatchService {
193 193
		return queryResult;
194 194
	}
195 195

196
	@Get
197
	@Path("/proList")
198
	public List<Watch> proList(@JdbcConn Connection con,String professorId,short watchType,@DefaultValue("\"9\"")String createTime,@DefaultValue("\"Z\"")String watchObject,int rows)throws SQLException {
199
		return this.watchDao.proList(con, professorId, watchType, createTime, watchObject, rows);
200
	}
201

196 202
	@Get
197 203
	@Path("/qaWatch")
198 204
	public List<Watch> queryWatch(@JdbcConn Connection con, String watchObject) throws SQLException {
@ -209,6 +215,12 @@ public class WatchService {
209 215
		return watchs;
210 216
	}
211 217

218
	@Get
219
	@Path("/watchList")
220
	public List<Watch> watchList(@JdbcConn Connection con,String watchObject,@DefaultValue("\"9\"")String createTime,@DefaultValue("\"Z\"")String professorId,int rows) throws SQLException {
221
		return this.watchDao.watchList(con, createTime, professorId, watchObject, rows);
222
	}
223

212 224
	@Get
213 225
	@Path("/countObject")
214 226
	public int countObject(@JdbcConn Connection con, String id, short type) throws SQLException {

+ 29 - 98
src/main/java/com/ekexiu/portal/ware/WareDao.java

@ -1,17 +1,16 @@
1 1
package com.ekexiu.portal.ware;
2 2

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

9 7
import org.jfw.apt.annotation.DefaultValue;
10 8
import org.jfw.apt.annotation.Nullable;
11 9
import org.jfw.apt.orm.annotation.dao.Column;
12 10
import org.jfw.apt.orm.annotation.dao.DAO;
11
import org.jfw.apt.orm.annotation.dao.method.Exclude;
13 12
import org.jfw.apt.orm.annotation.dao.method.From;
14
import org.jfw.apt.orm.annotation.dao.method.IncludeFixSet;
13
import org.jfw.apt.orm.annotation.dao.method.LimitColumn;
15 14
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
16 15
import org.jfw.apt.orm.annotation.dao.method.Select;
17 16
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
@ -33,11 +32,8 @@ import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
33 32
import org.jfw.apt.orm.annotation.dao.param.UnEquals;
34 33
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
35 34
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
36
import org.jfw.apt.web.annotation.method.SetCookie;
37 35
import org.jfw.util.PageQueryResult;
38 36

39
import com.ekexiu.portal.question.Answer;
40

41 37
@DAO
42 38
public abstract class WareDao {
43 39

@ -122,7 +118,7 @@ public abstract class WareDao {
122 118
	public abstract List<Ware> queryPublish(Connection con, String category, String owner, @LessThan String modifyTime, int rows) throws SQLException;
123 119

124 120
	@PageSelect
125
	@OrderBy("OrderBy STATE DESC,MODIFY_TIMDE DESC")
121
	@OrderBy("ORDER By STATE DESC,MODIFY_TIME DESC")
126 122
	@Where("(STATE='1' OR STATE ='2') AND CATEGORY='1'")
127 123
	public abstract PageQueryResult<Ware> pageQuery(Connection con,
128 124
			@Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = { "NAME LIKE ?", "CNT LIKE ?", "KEYWORDS LIKE ?" }, isAnd = false) String key,
@ -135,105 +131,40 @@ public abstract class WareDao {
135 131
	public abstract List<CountWare> queryByOwner(Connection con,
136 132
			@Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = { "NAME LIKE ?", "CNT LIKE ?", "KEYWORDS LIKE ?" }, isAnd = false) String key,
137 133
			String owner) throws SQLException;
138
	
134

139 135
	@LimitSelect
140 136
	@OrderBy(" ORDER BY PAGE_VIEWS DESC")
141 137
	@Where("STATE='1'")
142
	public abstract List<Ware> queryByOwnerWithPageViews(Connection con,String category,String owner,@Nullable @UnEquals String id, int rows)throws SQLException;
143
	
138
	public abstract List<Ware> queryByOwnerWithPageViews(Connection con, String category, String owner, @Nullable @UnEquals String id, int rows)
139
			throws SQLException;
140

144 141
	@LimitSelect
145 142
	@OrderBy("ORDER BY MODIFY_TIME DESC")
146 143
	@Where("STATE='1'")
147
	public abstract List<Ware> queryByResource(Connection con,@SqlColumn(handlerClass=StringHandler.class, value = { "ID IN (SELECT ID FROM WARE_RES WHERE RESOURCE=?)" }) String id,int rows)throws SQLException;
144

145
	public abstract List<Ware> queryByResource(Connection con,
146
			@SqlColumn(handlerClass = StringHandler.class, value = { "ID IN (SELECT ID FROM WARE_RES WHERE RESOURCE=?)" }) String id, int rows)
147
			throws SQLException;
148

148 149
	@LimitSelect
149 150
	@OrderBy("ORDER BY MODIFY_TIME DESC")
150 151
	@Where("STATE='1'")
151
	public abstract List<Ware> queryByArticle(Connection con,@SqlColumn(handlerClass=StringHandler.class, value = { "ID IN (SELECT WARE FROM ARTICLE_WARE WHERE ID=?)" }) String id,int rows) throws SQLException;
152
	
153
	
154
	public List<Ware> indexSeach(Connection con, String key, long sortFirst, String modifyTime, String id, int rows) throws SQLException {
155
		List<Ware> result = new ArrayList<Ware>(rows);
156
		StringBuilder sb = new StringBuilder();
157
		sb.append("SELECT PAGE_VIEWS,ID,NAME,KEYWORDS,CNT,COOPERATION,DESCP,CATEGORY,OWNER,IMAGES,STATE,SHARE_ID,SORT_FIRST,CREATE_TIME,MODIFY_TIME FROM WARE")
158
				.append(" WHERE STATE='1' AND ((SORT_FIRST<?) OR (SORT_FIRST=? AND MODIFY_TIME < ?) OR ( SORT_FIRST=? AND MODIFY_TIME = ? AND ID < ?)");
159
		if (key != null) {
160
			sb.append(" AND (NAME LIKE ? OR CNT LIKE ? OR KEYWORDS LIKE ?  OR(CATEGORY='1' AND OWNER IN(SELECT ID FROM PROFESSOR WHERE NAME LIKE ?))")
161
					.append(" OR (CATEGORY ='2' AND OWNER IN(SELECT ID FROM ORGANIZATION WHERE NAME LIKE ? OR FOR_SHORT LIKE ?))");
162
		}
163
		sb.append(" ORDER BY SORT_FIRST DESC,MODIFY_TIME DESC,ID DESC LIMIT ?");
164
		PreparedStatement ps = con.prepareStatement(sb.toString());
165
		try {
166
			int idx = 1;
167
			ps.setLong(idx++, sortFirst);
168
			ps.setLong(idx++, sortFirst);
169
			ps.setString(idx++, modifyTime);
170
			ps.setLong(idx++, sortFirst);
171
			ps.setString(idx++, modifyTime);
172
			ps.setString(idx++, id);
173
			if (key != null) {
174
				ps.setString(idx++, key);
175
				ps.setString(idx++, key);
176
				ps.setString(idx++, key);
177
				ps.setString(idx++, key);
178
				ps.setString(idx++, key);
179
				ps.setString(idx++, key);
180
			}
181
			ps.setInt(idx++, rows);
182
			java.sql.ResultSet rs = ps.executeQuery();
183
			try {
184
				while (rs.next()) {
185
					Ware _obj = new Ware();
186
					_obj.setPageViews(rs.getLong(1));
187
					_obj.setId(rs.getString(2));
188
					_obj.setName(rs.getString(3));
189
					java.lang.String _m_3 = rs.getString(4);
190
					if (rs.wasNull()) {
191
						_m_3 = null;
192
					}
193
					_obj.setKeywords(_m_3);
194
					java.lang.String _m_4 = rs.getString(5);
195
					if (rs.wasNull()) {
196
						_m_4 = null;
197
					}
198
					_obj.setCnt(_m_4);
199
					java.lang.String _m_5 = rs.getString(6);
200
					if (rs.wasNull()) {
201
						_m_5 = null;
202
					}
203
					_obj.setCooperation(_m_5);
204
					java.lang.String _m_6 = rs.getString(7);
205
					if (rs.wasNull()) {
206
						_m_6 = null;
207
					}
208
					_obj.setDescp(_m_6);
209
					_obj.setCategory(rs.getString(8));
210
					_obj.setOwner(rs.getString(9));
211
					java.lang.String _m_7 = rs.getString(10);
212
					if (rs.wasNull()) {
213
						_m_7 = null;
214
					}
215
					_obj.setImages(_m_7);
216
					_obj.setState(rs.getString(11));
217
					_obj.setShareId(rs.getLong(12));
218
					_obj.setSortFirst(rs.getLong(13));
219
					_obj.setCreateTime(rs.getString(14));
220
					_obj.setModifyTime(rs.getString(15));
221
					result.add(_obj);
222
				}
223
				return result;
224
			} finally {
225
				try {
226
					rs.close();
227
				} catch (Exception _m_8) {
228
				}
229
			}
230
		} finally {
231
			try {
232
				ps.close();
233
			} catch (Exception _m_9) {
234
			}
235
		}
236

237
	}
152
	public abstract List<Ware> queryByArticle(Connection con,
153
			@SqlColumn(handlerClass = StringHandler.class, value = { "ID IN (SELECT WARE FROM ARTICLE_WARE WHERE ID=?)" }) String id, int rows)
154
			throws SQLException;
155

156
	@LimitSelect
157
	@Where("STATE='1'")
158
	@OrderBy(cols = { @LimitColumn(value = "sortFirst", asc = false, handlerClass = LongHandler.class), @LimitColumn(value = "modifyTime", asc = false),
159
			@LimitColumn(value = "id", asc = false) }, value = "")
160
	public abstract List<Ware> indexSearch(Connection con,
161
			@Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = { "NAME LIKE ?", "CNT LIKE ?", "KEYWORDS LIKE ?",
162
					"CATEGORY='1' AND OWNER IN(SELECT ID FROM PROFESSOR WHERE NAME LIKE ?)",
163
					"CATEGORY ='2' AND OWNER IN(SELECT ID FROM ORGANIZATION WHERE NAME LIKE ? OR FOR_SHORT LIKE ?)" }, additional = 1, isAnd = false, force = true) String key,
164
			long sortFirst, String modifyTime, String id, int rows) throws SQLException;
165

166
	@Update
167
	@Exclude("modifyTime")
168
	public abstract int conUpdate(Connection con, Ware ware) throws SQLException;
238 169

239 170
}

+ 112 - 50
src/main/java/com/ekexiu/portal/ware/WareService.java

@ -1,24 +1,7 @@
1 1
package com.ekexiu.portal.ware;
2 2

3
import java.io.ByteArrayInputStream;
4
import java.io.File;
5
import java.io.FileInputStream;
6
import java.io.FileOutputStream;
7
import java.io.IOException;
8
import java.io.InputStream;
9
import java.io.OutputStream;
10
import java.sql.Connection;
11
import java.sql.PreparedStatement;
12
import java.sql.ResultSet;
13
import java.sql.SQLException;
14
import java.util.Collections;
15
import java.util.Comparator;
16
import java.util.HashMap;
17
import java.util.LinkedList;
18
import java.util.List;
19
import java.util.Map;
20
import java.util.concurrent.atomic.AtomicInteger;
21

3
import com.ekexiu.portal.service.GrowthLogService;
4
import com.ekexiu.portal.service.KeyWordService;
22 5
import org.jfw.apt.annotation.Autowrie;
23 6
import org.jfw.apt.annotation.DefaultValue;
24 7
import org.jfw.apt.annotation.Nullable;
@ -39,8 +22,24 @@ import org.jfw.util.jdbc.ResultSetExtractor;
39 22
import org.jfw.util.web.fileupload.Item;
40 23
import org.jfw.util.web.fileupload.UploadItemIterator;
41 24

42
import com.ekexiu.portal.service.GrowthLogService;
43
import com.ekexiu.portal.service.KeyWordService;
25
import java.io.ByteArrayInputStream;
26
import java.io.File;
27
import java.io.FileInputStream;
28
import java.io.FileOutputStream;
29
import java.io.IOException;
30
import java.io.InputStream;
31
import java.io.OutputStream;
32
import java.sql.Connection;
33
import java.sql.PreparedStatement;
34
import java.sql.ResultSet;
35
import java.sql.SQLException;
36
import java.util.Collections;
37
import java.util.Comparator;
38
import java.util.HashMap;
39
import java.util.LinkedList;
40
import java.util.List;
41
import java.util.Map;
42
import java.util.concurrent.atomic.AtomicInteger;
44 43

45 44
@Path("/ware")
46 45
public class WareService {
@ -231,8 +230,9 @@ public class WareService {
231 230
	 */
232 231
	@Post
233 232
	@Path("/draft")
234
	public String draft(@JdbcConn(true) Connection con, @RequestParam(excludeFields = { "category", "id", "state", "createTime", "modifyTime", 
235
			"shareId", "pageViews", "sortFirst" }) Ware ware, @Nullable String[] resource) throws SQLException, IOException {
233
	public String draft(@JdbcConn(true) Connection con,
234
			@RequestParam(excludeFields = { "category", "id", "state", "createTime", "modifyTime", "shareId", "pageViews", "sortFirst" }) Ware ware,
235
			@Nullable String[] resource) throws SQLException, IOException {
236 236
		ware.setState("2");
237 237
		ware.setCategory("1");
238 238
		return insert(con, ware, null, resource);
@ -251,8 +251,10 @@ public class WareService {
251 251
	 */
252 252
	@Post
253 253
	@Path("/draft/org")
254
	public String draft(@JdbcConn(true) Connection con, @RequestParam(excludeFields = { "category", "id", "state", "createTime", "modifyTime", 
255
			"shareId", "pageViews", "sortFirst" }) Ware ware, String[] resource, String[] professor) throws SQLException, IOException {
254

255
	public String draft(@JdbcConn(true) Connection con,
256
			@RequestParam(excludeFields = { "category", "id", "state", "createTime", "modifyTime", "shareId", "pageViews", "sortFirst" }) Ware ware,
257
			@Nullable String[] resource, @Nullable String[] professor) throws SQLException, IOException {
256 258
		ware.setState("2");
257 259
		ware.setCategory("2");
258 260
		return insert(con, ware, professor, resource);
@ -270,8 +272,9 @@ public class WareService {
270 272
	 */
271 273
	@Post
272 274
	@Path("/publish")
273
	public String publish(@JdbcConn(true) Connection con, @RequestParam(excludeFields = { "category", "id", "state", "createTime", "modifyTime", 
274
			"shareId", "pageViews", "sortFirst" }) Ware ware, String[] resource) throws SQLException, IOException {
275
	public String publish(@JdbcConn(true) Connection con,
276
			@RequestParam(excludeFields = { "category", "id", "state", "createTime", "modifyTime", "shareId", "pageViews", "sortFirst" }) Ware ware,
277
			@Nullable String[] resource) throws SQLException, IOException {
275 278
		ware.setState("1");
276 279
		ware.setCategory("1");
277 280
		return insert(con, ware, null, resource);
@ -290,8 +293,9 @@ public class WareService {
290 293
	 */
291 294
	@Post
292 295
	@Path("/publish/org")
293
	public String publish(@JdbcConn(true) Connection con, @RequestParam(excludeFields = { "category", "id", "state", "createTime", "modifyTime", 
294
			"shareId", "pageViews", "sortFirst" }) Ware ware, String[] resource, String[] professor) throws SQLException, IOException {
296
	public String publish(@JdbcConn(true) Connection con,
297
			@RequestParam(excludeFields = { "category", "id", "state", "createTime", "modifyTime", "shareId", "pageViews", "sortFirst" }) Ware ware,
298
			@Nullable String[] resource, @Nullable String[] professor) throws SQLException, IOException {
295 299
		ware.setState("1");
296 300
		ware.setCategory("2");
297 301
		return insert(con, ware, professor, resource);
@ -309,8 +313,9 @@ public class WareService {
309 313
	 */
310 314
	@Post
311 315
	@Path("/draft/update")
312
	public boolean updateDraft(@JdbcConn(true) Connection con, @RequestParam(excludeFields = { "category", "state", "createTime", "modifyTime",
313
			"shareId", "pageViews", "sortFirst" }) Ware ware, @Nullable String[] resource) throws SQLException, IOException {
316
	public boolean updateDraft(@JdbcConn(true) Connection con,
317
			@RequestParam(excludeFields = { "category", "state", "createTime", "modifyTime", "shareId", "pageViews", "sortFirst" }) Ware ware,
318
			@Nullable String[] resource) throws SQLException, IOException {
314 319
		ware.setState("2");
315 320
		ware.setCategory("1");
316 321
		return update(con, ware, null, resource);
@ -329,8 +334,9 @@ public class WareService {
329 334
	 */
330 335
	@Post
331 336
	@Path("/draft/org/update")
332
	public boolean updateDraft(@JdbcConn(true) Connection con, @RequestParam(excludeFields = { "category", "state", "createTime", "modifyTime",
333
			"shareId", "pageViews", "sortFirst" }) Ware ware, String[] resource, String[] professor) throws SQLException, IOException {
337
	public boolean updateDraft(@JdbcConn(true) Connection con,
338
			@RequestParam(excludeFields = { "category", "state", "createTime", "modifyTime", "shareId", "pageViews", "sortFirst" }) Ware ware,
339
			@Nullable String[] resource, @Nullable String[] professor) throws SQLException, IOException {
334 340
		ware.setState("2");
335 341
		ware.setCategory("2");
336 342
		return update(con, ware, professor, resource);
@ -348,11 +354,13 @@ public class WareService {
348 354
	 */
349 355
	@Post
350 356
	@Path("/publish/update")
351
	public String updatePublish(@JdbcConn(true) Connection con, @RequestParam(excludeFields = { "category", "state", "createTime", "modifyTime",
352
		 "shareId", "pageViews", "sortFirst" }) Ware ware, String[] resource) throws SQLException, IOException {
357

358
	public boolean updatePublish(@JdbcConn(true) Connection con,
359
			@RequestParam(excludeFields = { "category", "state", "createTime", "modifyTime", "shareId", "pageViews", "sortFirst" }) Ware ware,
360
			@Nullable String[] resource) throws SQLException, IOException {
353 361
		ware.setState("1");
354 362
		ware.setCategory("1");
355
		return insert(con, ware, null, resource);
363
		return update(con, ware, null, resource);
356 364
	}
357 365

358 366
	/**
@ -368,11 +376,12 @@ public class WareService {
368 376
	 */
369 377
	@Post
370 378
	@Path("/publish/org/update")
371
	public String updatePublish(@JdbcConn(true) Connection con, @RequestParam(excludeFields = { "category", "state", "createTime", "modifyTime",
372
		"shareId", "pageViews", "sortFirst" }) Ware ware, String[] resource, String[] professor) throws SQLException, IOException {
379
	public boolean updatePublish(@JdbcConn(true) Connection con,
380
			@RequestParam(excludeFields = { "category", "state", "createTime", "modifyTime", "shareId", "pageViews", "sortFirst" }) Ware ware,
381
			@Nullable String[] resource, @Nullable String[] professor) throws SQLException, IOException {
373 382
		ware.setState("1");
374 383
		ware.setCategory("2");
375
		return insert(con, ware, professor, resource);
384
		return update(con, ware, professor, resource);
376 385
	}
377 386

378 387
	/**
@ -454,7 +463,7 @@ public class WareService {
454 463
	 * @throws SQLException
455 464
	 */
456 465
	@Get
457
	@Path("/pq/org/seach")
466
	@Path("/pq/org/search")
458 467
	public PageQueryResult<CountWare> pageQueryOrg(@JdbcConn Connection con, @Nullable String key, String oid, int pageSize, int pageNo) throws SQLException {
459 468
		if (key != null) {
460 469
			key = "%" + key + "%";
@ -539,7 +548,7 @@ public class WareService {
539 548
	 * @throws SQLException
540 549
	 */
541 550
	@Get
542
	@Path("/pg/seach")
551
	@Path("/pq/search")
543 552
	public PageQueryResult<Ware> pageQuery(@JdbcConn Connection con, @Nullable String key, String pid, int pageSize, int pageNo) throws SQLException {
544 553
		if (key != null) {
545 554
			key = "%" + key + "%";
@ -557,7 +566,7 @@ public class WareService {
557 566
	 */
558 567
	@Post
559 568
	@Path("/delete")
560
	public int delete(@JdbcConn Connection con, String id) throws SQLException {
569
	public int delete(@JdbcConn(true) Connection con, String id) throws SQLException {
561 570
		return wareDao.logicDelete(con, id);
562 571
	}
563 572

@ -596,7 +605,7 @@ public class WareService {
596 605

597 606
	@Post
598 607
	@Path("/incPageViews")
599
	public int incPageViews(@JdbcConn Connection con, String id) throws SQLException {
608
	public int incPageViews(@JdbcConn(true) Connection con, String id) throws SQLException {
600 609
		return wareDao.incPageViews(con, id);
601 610
	}
602 611

@ -607,19 +616,20 @@ public class WareService {
607 616
		if (key != null) {
608 617
			key = "%" + key + "%";
609 618
		}
610
		return wareDao.indexSeach(con, key, sortFirst, time, id, rows);
619
		return wareDao.indexSearch(con, key, sortFirst, time, id, rows);
611 620
	}
612 621

613 622
	@Get
614 623
	@Path("/ralateWare")
615 624
	public List<Map<String, Object>> queryRalateWare(@JdbcConn Connection con, final String id, final int rows) throws SQLException {
616 625
		return JdbcUtil.queryList(con,
617
				"SELECT ID,NUM FROM (SELECT ID,COUNT(1) NUM FROM WRE_KEY_WORD WEHRE ID <> ? AND KW IN (SELECT KW FROM WRE_KEY_WORD WHERE ID=?)) T ORDER BY NUM DESC LIMIT ?",
626
				"SELECT ID,NUM FROM (SELECT ID,COUNT(1) NUM FROM WRE_KEY_WORD WHERE ID <> ? AND KW IN (SELECT KW FROM WRE_KEY_WORD WHERE ID = ?) AND ID IN (SELECT ID FROM WARE WHERE STATE = '1') GROUP BY ID ) T ORDER BY NUM DESC LIMIT ?",
618 627
				new ResultSetExtractor<Map<String, Object>>() {
619 628
					@Override
620 629
					public Map<String, Object> extractData(ResultSet rs) throws SQLException {
621 630
						Map<String, Object> map = new HashMap<String, Object>();
622
						map.put(rs.getString(1), rs.getLong(2));
631
						map.put("id", rs.getString(1));
632
						map.put("num", rs.getLong(2));
623 633
						return map;
624 634
					}
625 635
				}, new PreparedStatementConfig() {
@ -632,22 +642,25 @@ public class WareService {
632 642
					}
633 643
				});
634 644
	}
645

635 646
	@Get
636 647
	@Path("/byOwnerWithPageViews")
637
	public List<Ware> queryBySameKwWithPageViews(@JdbcConn Connection con,String category,String owner,@Nullable String id,int rows) throws SQLException{
648
	public List<Ware> queryBySameKwWithPageViews(@JdbcConn Connection con, String category, String owner, @Nullable String id, int rows) throws SQLException {
638 649
		return wareDao.queryByOwnerWithPageViews(con, category, owner, id, rows);
639 650
	}
651

640 652
	@Get
641 653
	@Path("/byResourceWithModifyTime")
642
	public List<Ware> queryByResourceWithModifyTime(@JdbcConn Connection con,String id,int rows) throws SQLException{
654
	public List<Ware> queryByResourceWithModifyTime(@JdbcConn Connection con, String id, int rows) throws SQLException {
643 655
		return wareDao.queryByResource(con, id, rows);
644 656
	}
657

645 658
	@Get
646 659
	@Path("/byArticle")
647
	public List<Ware> queryByArticle(@JdbcConn Connection con,String id,@DefaultValue("Integer.MAX_VALUE" ) int rows) throws SQLException{
660
	public List<Ware> queryByArticle(@JdbcConn Connection con, String id, @DefaultValue("Integer.MAX_VALUE") int rows) throws SQLException {
648 661
		return wareDao.queryByArticle(con, id, rows);
649 662
	}
650
	
663

651 664
	//
652 665
	// @Post
653 666
	// @Path("/update")
@ -774,4 +787,53 @@ public class WareService {
774 787
			this.size = size;
775 788
		}
776 789
	}
790

791
	/**
792
	 * 后台管理系统中使用
793
	 */
794
	public boolean conUpdate(Connection con, Ware ware, String[] professor, String[] resource) throws SQLException, IOException {
795
		String id = ware.getId();
796
		if (wareDao.conUpdate(con, ware) > 0) {
797
			this.saveSmallImg(ware.getImages());
798
			String[] kws = null;
799
			if (ware.getKeywords() != null) {
800
				kws = ListUtil.splitTrimExcludeEmpty(ware.getKeywords(), ',').toArray(new String[0]);
801
			}
802
			if (ware.getState().equals("1")) {
803
				keyWordService.refreshWrae(con, id, kws);
804
			} else {
805
				keyWordService.deleteWare(con, id);
806
			}
807
			wareDao.deleteWareRes(con, id);
808
			if (resource != null && resource.length > 0) {
809
				for (String rid : resource) {
810
					WareRes wr = new WareRes();
811
					wr.setId(id);
812
					wr.setResource(rid);
813
					wareDao.insert(con, wr);
814
				}
815
			}
816
			wareDao.deleteWarePro(con, id);
817
			if (professor != null && professor.length > 0) {
818
				for (String pid : professor) {
819
					WarePro wp = new WarePro();
820
					wp.setId(id);
821
					wp.setProfessor(pid);
822
					wareDao.insert(con, wp);
823
				}
824
			}
825
			return true;
826
		}
827
		return false;
828
	}
829

830
	@Post
831
	@Path("/publish/conUpdate")
832
	public boolean conUpdatePublish(@JdbcConn(true) Connection con,
833
			@RequestParam(excludeFields = { "category", "state", "createTime", "modifyTime", "shareId", "pageViews", "sortFirst" }) Ware ware,
834
			@Nullable String[] resource, @Nullable String[] professor) throws SQLException, IOException {
835
		ware.setState("1");
836
		// ware.setCategory("1");
837
		return conUpdate(con, ware, professor, resource);
838
	}
777 839
}