Browse Source

--新的文章和资源相关接口;

zzy.zhiyuan.foxmail 8 years ago
parent
commit
7580670b32

+ 63 - 7
src/main/java/com/ekexiu/portal/dao/ArticleDao.java

104
	@Where("STATUS = '1'")
104
	@Where("STATUS = '1'")
105
	public abstract PageQueryResult<Article> queryPageForPublish(Connection con,@Like@Nullable String articleTitle,int pageSize,int pageNo) throws SQLException;
105
	public abstract PageQueryResult<Article> queryPageForPublish(Connection con,@Like@Nullable String articleTitle,int pageSize,int pageNo) throws SQLException;
106
	
106
	
107
	public PageQueryResult<Article> queryPageForSelf(Connection con,@Nullable String articleTitle,int pageSize,int pageNo) throws SQLException{
107
	public PageQueryResult<Article> queryPageForSelf(Connection con,@Nullable String professorId,@Nullable String orgId,
108
			@Nullable String articleTitle,int pageSize,int pageNo) throws SQLException{
108
        int total = 0;
109
        int total = 0;
109
        PageQueryResult<Article> queryResult = new PageQueryResult<Article>();
110
        PageQueryResult<Article> queryResult = new PageQueryResult<Article>();
110
        int index = 1;
111
        int index = 1;
112
        boolean hasProfessorId = null != professorId;
113
        boolean hasOrgId = null != orgId;
111
        boolean hasArticleTitle = null != articleTitle;
114
        boolean hasArticleTitle = null != articleTitle;
112
        StringBuilder sql = new StringBuilder();
115
        StringBuilder sql = new StringBuilder();
113
        sql.append("SELECT COUNT(1) FROM ARTICLE WHERE STATUS IN('0','1','2')");
116
        sql.append("SELECT COUNT(1) FROM ARTICLE WHERE STATUS IN('0','1','2')");
117
        if(hasProfessorId){
118
        	sql.append(" AND PROFESSOR_ID = ?");
119
        }
120
        if(hasOrgId){
121
        	sql.append(" AND ORG_ID = ?");
122
        }
114
        if(hasArticleTitle){
123
        if(hasArticleTitle){
115
        	sql.append(" AND ARTICLE_TITLE LIKE ?");
124
        	sql.append(" AND ARTICLE_TITLE LIKE ?");
116
        }
125
        }
117
        PreparedStatement ps = con.prepareStatement(sql.toString());
126
        PreparedStatement ps = con.prepareStatement(sql.toString());
118
        try{
127
        try{
128
        	if(hasProfessorId){
129
        		ps.setString(index++, professorId);
130
        	}
131
        	if(hasOrgId){
132
        		ps.setString(index++, orgId);
133
        	}
119
        	if(hasArticleTitle){
134
        	if(hasArticleTitle){
120
        		ps.setString(index++, articleTitle);
135
        		ps.setString(index++, articleTitle);
121
        	}
136
        	}
141
        	queryResult.setPageNo(1);
156
        	queryResult.setPageNo(1);
142
        	sql = new StringBuilder();
157
        	sql = new StringBuilder();
143
        	sql.append("(SELECT ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,ARTICLE_CONTENT,SUBJECT,INDUSTRY,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME FROM ARTICLE WHERE STATUS IN('0','2')");
158
        	sql.append("(SELECT ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,ARTICLE_CONTENT,SUBJECT,INDUSTRY,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME FROM ARTICLE WHERE STATUS IN('0','2')");
159
        	if(hasProfessorId){
160
            	sql.append(" AND PROFESSOR_ID = ?");
161
            }
162
            if(hasOrgId){
163
            	sql.append(" AND ORG_ID = ?");
164
            }
144
        	if(hasArticleTitle){
165
        	if(hasArticleTitle){
145
        		sql.append(" AND ARTICLE_TITLE LIKE ?");
166
        		sql.append(" AND ARTICLE_TITLE LIKE ?");
146
        	}
167
        	}
147
        	sql.append(" ORDER BY MODIFY_TIME DESC) UNION ALL (SELECT ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,ARTICLE_CONTENT,SUBJECT,INDUSTRY,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME FROM ARTICLE WHERE STATUS = '1'");
168
        	sql.append(" ORDER BY MODIFY_TIME DESC) UNION ALL (SELECT ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,ARTICLE_CONTENT,SUBJECT,INDUSTRY,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME FROM ARTICLE WHERE STATUS = '1'");
169
        	if(hasProfessorId){
170
            	sql.append(" AND PROFESSOR_ID = ?");
171
            }
172
            if(hasOrgId){
173
            	sql.append(" AND ORG_ID = ?");
174
            }
148
        	if(hasArticleTitle){
175
        	if(hasArticleTitle){
149
        		sql.append(" AND ARTICLE_TITLE LIKE ?");
176
        		sql.append(" AND ARTICLE_TITLE LIKE ?");
150
        	}
177
        	}
161
            queryResult.setPageNo(pageNo);
188
            queryResult.setPageNo(pageNo);
162
            --pageNo;
189
            --pageNo;
163
            int offset = (pageNo * pageSize);
190
            int offset = (pageNo * pageSize);
191
            sql = new StringBuilder();
164
            sql.append("(SELECT ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,ARTICLE_CONTENT,SUBJECT,INDUSTRY,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME FROM ARTICLE WHERE STATUS IN('0','2')");
192
            sql.append("(SELECT ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,ARTICLE_CONTENT,SUBJECT,INDUSTRY,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME FROM ARTICLE WHERE STATUS IN('0','2')");
193
        	if(hasProfessorId){
194
            	sql.append(" AND PROFESSOR_ID = ?");
195
            }
196
            if(hasOrgId){
197
            	sql.append(" AND ORG_ID = ?");
198
            }
165
        	if(hasArticleTitle){
199
        	if(hasArticleTitle){
166
        		sql.append(" AND ARTICLE_TITLE LIKE ?");
200
        		sql.append(" AND ARTICLE_TITLE LIKE ?");
167
        	}
201
        	}
168
        	sql.append(" ORDER BY MODIFY_TIME DESC) UNION ALL (SELECT ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,ARTICLE_CONTENT,SUBJECT,INDUSTRY,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME FROM ARTICLE WHERE STATUS = '1'");
202
        	sql.append(" ORDER BY MODIFY_TIME DESC) UNION ALL (SELECT ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,ARTICLE_CONTENT,SUBJECT,INDUSTRY,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME FROM ARTICLE WHERE STATUS = '1'");
203
        	if(hasProfessorId){
204
            	sql.append(" AND PROFESSOR_ID = ?");
205
            }
206
            if(hasOrgId){
207
            	sql.append(" AND ORG_ID = ?");
208
            }
169
        	if(hasArticleTitle){
209
        	if(hasArticleTitle){
170
        		sql.append(" AND ARTICLE_TITLE LIKE ?");
210
        		sql.append(" AND ARTICLE_TITLE LIKE ?");
171
        	}
211
        	}
173
            sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
213
            sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
174
        }
214
        }
175
        ps = con.prepareStatement(sql.toString());
215
        ps = con.prepareStatement(sql.toString());
216
        System.out.println(sql.toString());
217
        index = 1;
176
        try{
218
        try{
219
        	if(hasProfessorId){
220
        		ps.setString(index++, professorId);
221
        	}
222
        	if(hasOrgId){
223
        		ps.setString(index++, orgId);
224
        	}
177
        	if(hasArticleTitle){
225
        	if(hasArticleTitle){
178
        		ps.setString(index++, articleTitle);
226
        		ps.setString(index++, articleTitle);
227
        	}
228
        	if(hasProfessorId){
229
        		ps.setString(index++, professorId);
230
        	}
231
        	if(hasOrgId){
232
        		ps.setString(index++, orgId);
233
        	}
234
        	if(hasArticleTitle){
179
        		ps.setString(index++, articleTitle);
235
        		ps.setString(index++, articleTitle);
180
        	}
236
        	}
181
            ResultSet rs = ps.executeQuery();
237
            ResultSet rs = ps.executeQuery();
187
                    ++size;
243
                    ++size;
188
                    Article article =  new Article();
244
                    Article article =  new Article();
189
                    article.setArticleId(rs.getString(1));
245
                    article.setArticleId(rs.getString(1));
190
                    String professorId = rs.getString(2);
246
                    String proId = rs.getString(2);
191
                    if(rs.wasNull()){
247
                    if(rs.wasNull()){
192
                    	professorId = null;
248
                    	proId = null;
193
                    }
249
                    }
194
                    article.setProfessorId(professorId);
250
                    article.setProfessorId(proId);
195
                    article.setArticleTitle(rs.getString(3));
251
                    article.setArticleTitle(rs.getString(3));
196
                    String articleContent = rs.getString(4);
252
                    String articleContent = rs.getString(4);
197
                    if(rs.wasNull()){
253
                    if(rs.wasNull()){
218
                    	articleImg = null;
274
                    	articleImg = null;
219
                    }
275
                    }
220
                    article.setArticleImg(articleImg);
276
                    article.setArticleImg(articleImg);
221
                    String orgId = rs.getString(9);
277
                    String org = rs.getString(9);
222
                    if(rs.wasNull()){
278
                    if(rs.wasNull()){
223
                    	orgId = null;
279
                    	org = null;
224
                    }
280
                    }
225
                    article.setOrgId(orgId);
281
                    article.setOrgId(org);
226
                    String articleType = rs.getString(10);
282
                    String articleType = rs.getString(10);
227
                    if(rs.wasNull()){
283
                    if(rs.wasNull()){
228
                    	articleType = null;
284
                    	articleType = null;

+ 27 - 3
src/main/java/com/ekexiu/portal/dao/ArticleResDao.java

1
package com.ekexiu.portal.dao;
1
package com.ekexiu.portal.dao;
2

2

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

9

7
import org.jfw.apt.annotation.DefaultValue;
10
import org.jfw.apt.annotation.DefaultValue;
11
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
14
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
12
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
15
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
13
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
16
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
14
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
15
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
17
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
16

18

17
import com.ekexiu.portal.po.ArticlePro;
19
import com.ekexiu.portal.po.ArticlePro;
28
	@DefaultValue("0")
30
	@DefaultValue("0")
29
	public abstract int queryByArticleId(Connection con, String articleId) throws SQLException;
31
	public abstract int queryByArticleId(Connection con, String articleId) throws SQLException;
30

32

31
	@SelectList
32
	public abstract List<ArticleRes> query(Connection con, String articleId) throws SQLException;
33
	public List<ArticleRes> query(Connection con,java.lang.String articleId) throws SQLException{
34
        int index = 1;
35
        String sql = "SELECT ARTICLE_ID,A.RESOURCE_ID,A.CREATE_TIME FROM ARTICLE_RES A INNER JOIN RESOURCE R ON A.RESOURCE_ID = R.RESOURCE_ID WHERE R.STATUS = '1' AND ARTICLE_ID = ?";
36
        PreparedStatement ps = con.prepareStatement(sql);
37
        try{
38
            ps.setString(index++,articleId);
39
            ResultSet rs = ps.executeQuery();
40
            try{
41
                List<ArticleRes> result = new ArrayList<ArticleRes>();
42
                while(rs.next()){
43
                    ArticleRes articleRes =  new ArticleRes();
44
                    articleRes.setArticleId(rs.getString(1));
45
                    articleRes.setResourceId(rs.getString(2));
46
                    articleRes.setCreateTime(rs.getString(3));
47
                    result.add(articleRes);
48
                }
49
                return result;
50
            }finally{
51
                try{rs.close();}catch(Exception e1){}
52
            }
53
        }finally{
54
            try{ps.close();}catch(Exception e2){}
55
        }
56
    }
33
	
57
	
34
	@DeleteWith
58
	@DeleteWith
35
	@From(ArticleRes.class)
59
	@From(ArticleRes.class)

+ 8 - 0
src/main/java/com/ekexiu/portal/dao/OrgDao.java

10
import org.jfw.apt.orm.annotation.dao.Column;
10
import org.jfw.apt.orm.annotation.dao.Column;
11
import org.jfw.apt.orm.annotation.dao.DAO;
11
import org.jfw.apt.orm.annotation.dao.DAO;
12
import org.jfw.apt.orm.annotation.dao.method.From;
12
import org.jfw.apt.orm.annotation.dao.method.From;
13
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
14
import org.jfw.apt.orm.annotation.dao.method.Select;
13
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
15
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
14
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
16
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
15
import org.jfw.apt.orm.annotation.dao.method.operator.LimitQuery;
17
import org.jfw.apt.orm.annotation.dao.method.operator.LimitQuery;
143
	@LimitQuery
145
	@LimitQuery
144
	public abstract List<Organization> limitQuery(Connection con, @Like String name,int rows)throws SQLException;
146
	public abstract List<Organization> limitQuery(Connection con, @Like String name,int rows)throws SQLException;
145
	
147
	
148
	@LimitQuery
149
	@From(Organization.class)
150
	@OrderBy("ORDER BY NAME")
151
	@Select(Organization.class)
152
	public abstract List<EditOrganization> queryLimit(Connection con,@Like String name,int rows)throws SQLException;
153
	
146
	@Nullable
154
	@Nullable
147
	@QueryVal
155
	@QueryVal
148
	@Column(handlerClass=StringHandler.class,value="id")
156
	@Column(handlerClass=StringHandler.class,value="id")

+ 69 - 0
src/main/java/com/ekexiu/portal/dao/ProfessorDao.java

341
        }
341
        }
342
	}
342
	}
343
	
343
	
344
	public List<EditProfessor> queryByName(Connection con,String name,int total) throws SQLException{
345
        int index = 1;
346
        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 "
347
        		+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.NAME LIKE ? ORDER BY P.SCORE_PERCENT DESC LIMIT ? ";
348
        PreparedStatement ps = con.prepareStatement(sql);
349
        try{
350
            ps.setString(index++,name);
351
            ps.setInt(index++, total);
352
            ResultSet rs = ps.executeQuery();
353
            try{
354
                List<EditProfessor> editProfessors = new ArrayList<EditProfessor>();
355
                while(rs.next()){
356
                	EditProfessor professor =  new EditProfessor();
357
                	String office = rs.getString(1);
358
                	if(rs.wasNull()){
359
                		office = null;
360
                	}
361
                    professor.setOffice(office);
362
                    String depart = rs.getString(2);
363
                    if(rs.wasNull()){
364
                    	depart = null;
365
                	}
366
                    professor.setDepartment(depart);
367
                    String title = rs.getString(3);
368
                    if(rs.wasNull()){
369
                    	title = null;
370
                	}
371
                    professor.setTitle(title);
372
                    Integer auth = rs.getInt(4);
373
                    if(rs.wasNull()){
374
                    	auth = null;
375
                    }
376
                    professor.setAuthentication(auth);
377
                    professor.setAuthType(rs.getInt(5));
378
                    professor.setAuthStatus(rs.getInt(6));
379
                    professor.setId(rs.getString(7));
380
                    professor.setName(rs.getString(8));
381
                    String address = rs.getString(9);
382
                    if(rs.wasNull()){
383
                    	address = null;
384
                	}
385
                    professor.setAddress(address);
386
                    professor.setOrgAuth(rs.getString(10));
387
                    String orgName = rs.getString(11);
388
                    if(rs.wasNull()){
389
                    	orgName = null;
390
                    }
391
                    professor.setOrgName(orgName);
392
                    String orgId = rs.getString(12);
393
                    if(rs.wasNull()){
394
                    	orgId = null;
395
                    }
396
                    professor.setOrgId(orgId);
397
                    String scorePercent = rs.getString(13);
398
                    if(rs.wasNull()){
399
                    	scorePercent = null;
400
                    }
401
                    professor.setScorePercent(scorePercent);
402
                    editProfessors.add(professor);
403
                }
404
                return editProfessors;
405
            }finally{
406
                try{rs.close();}catch(Exception e1){}
407
            }
408
        }finally{
409
            try{ps.close();}catch(Exception e2){}
410
        }
411
    }
412
	
344
	/**
413
	/**
345
	 * 查询专家基本信息+星级+咨询次数的接口
414
	 * 查询专家基本信息+星级+咨询次数的接口
346
	 * @param con
415
	 * @param con

+ 29 - 1
src/main/java/com/ekexiu/portal/dao/ResourceDao.java

9
import java.util.List;
9
import java.util.List;
10

10

11
import org.jfw.apt.annotation.Autowrie;
11
import org.jfw.apt.annotation.Autowrie;
12
import org.jfw.apt.annotation.Nullable;
12
import org.jfw.apt.orm.annotation.dao.DAO;
13
import org.jfw.apt.orm.annotation.dao.DAO;
14
import org.jfw.apt.orm.annotation.dao.Dynamic;
13
import org.jfw.apt.orm.annotation.dao.method.From;
15
import org.jfw.apt.orm.annotation.dao.method.From;
16
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
17
import org.jfw.apt.orm.annotation.dao.method.Where;
14
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
18
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
15
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
19
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
20
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
21
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
16
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
22
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
17
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
23
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
24
import org.jfw.apt.orm.annotation.dao.param.Like;
18
import org.jfw.apt.orm.annotation.dao.param.Set;
25
import org.jfw.apt.orm.annotation.dao.param.Set;
19
import org.jfw.util.PageQueryResult;
26
import org.jfw.util.PageQueryResult;
20

27

52
	@Update
59
	@Update
53
	public abstract int update(Connection con,Resource resource) throws SQLException;
60
	public abstract int update(Connection con,Resource resource) throws SQLException;
54
	
61
	
62
	@Update
63
	@Dynamic
64
	public abstract int updateRes(Connection con,Resource resource) throws SQLException;
65
	
66
	@UpdateWith
67
	@From(Resource.class)
68
	public abstract int updateStatus(Connection con, String resourceId, @Set String status) throws SQLException;
69
	
70
	@UpdateWith
71
	@From(Resource.class)
72
	public abstract int updatePublishTime(Connection con,String resourceId,@Set String status,@Set String publishTime)throws SQLException;
73
	
55
	@UpdateWith
74
	@UpdateWith
56
	@From(Resource.class)
75
	@From(Resource.class)
57
	public abstract int updateNameAndSupport(Connection con, String resourceId, @Set String resourceName, 
76
	public abstract int updateNameAndSupport(Connection con, String resourceId, @Set String resourceName, 
85
	@From(Resource.class)
104
	@From(Resource.class)
86
	public abstract int delete(Connection con, String resourceId) throws SQLException;
105
	public abstract int delete(Connection con, String resourceId) throws SQLException;
87
	
106
	
107
	@SelectOne
108
	@Nullable
109
	public abstract Resource queryOne(Connection con, String resourceId) throws SQLException;
110
	
88
	/**
111
	/**
89
	 * 查询资源基础信息(ID,名称,学术领域,应用行业,可提供服务,发布者ID,资源图片)
112
	 * 查询资源基础信息(ID,名称,学术领域,应用行业,可提供服务,发布者ID,资源图片)
90
	 * @param con
113
	 * @param con
93
	 * @throws SQLException
116
	 * @throws SQLException
94
	 */
117
	 */
95
	public Resource queryBaseInfo(Connection con,String resourceId) throws SQLException{
118
	public Resource queryBaseInfo(Connection con,String resourceId) throws SQLException{
96
        List<Image> images = this.imageDao.queryRes(con, resourceId);
97
        String sql = "SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,INDUSTRY,SUPPORTED_SERVICES,PROFESSOR_ID"
119
        String sql = "SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,INDUSTRY,SUPPORTED_SERVICES,PROFESSOR_ID"
98
        		+ " FROM RESOURCE WHERE RESOURCE_ID = ?";
120
        		+ " FROM RESOURCE WHERE RESOURCE_ID = ?";
99
        PreparedStatement ps = con.prepareStatement(sql);
121
        PreparedStatement ps = con.prepareStatement(sql);
117
                    resource.setIndustry(industry);
139
                    resource.setIndustry(industry);
118
                    resource.setSupportedServices(rs.getString(5));
140
                    resource.setSupportedServices(rs.getString(5));
119
                    resource.setProfessorId(rs.getString(6));
141
                    resource.setProfessorId(rs.getString(6));
142
                    List<Image> images = this.imageDao.queryRes(con, resourceId);
120
                    resource.setImages(images);
143
                    resource.setImages(images);
121
                    return resource;
144
                    return resource;
122
                }else{
145
                }else{
394
        }
417
        }
395
    }
418
    }
396
	
419
	
420
	@LimitSelect
421
	@Where("STATUS = '1'")
422
	@OrderBy("ORDER BY PUBLISH_TIME DESC")
423
	public abstract List<Resource> queryByName(Connection con, @Like String resourceName, int rows) throws SQLException;
424
	
397
	/**
425
	/**
398
	 * 按专家ID查询发布的所有资源
426
	 * 按专家ID查询发布的所有资源
399
	 * @param con
427
	 * @param con

+ 9 - 2
src/main/java/com/ekexiu/portal/po/Image.java

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

8

8
@PrimaryKey("imageId")
9
@PrimaryKey("imageId")
9
@Table
10
@Table
10
public class Image {
11
public class Image {
11
	private String imageId;
12
	private String imageId;
13
	private int sort;
12
	private String imageSrc;
14
	private String imageSrc;
13
	private String resourceId;
15
	private String resourceId;
14
	private Resource resource;
16
	private Resource resource;
26
	public void setImageId(String imageId) {
28
	public void setImageId(String imageId) {
27
		this.imageId = imageId;
29
		this.imageId = imageId;
28
	}
30
	}
29
	
31
	@Column(handlerClass=IntHandler.class, dbType="INTEGER", nullable=true)
32
	public int getSort() {
33
		return sort;
34
	}
35
	public void setSort(int sort) {
36
		this.sort = sort;
37
	}
30
	@Column(DE.string_de)
38
	@Column(DE.string_de)
31
	public String getImageSrc() {
39
	public String getImageSrc() {
32
		return imageSrc;
40
		return imageSrc;
34
	public void setImageSrc(String imageSrc) {
42
	public void setImageSrc(String imageSrc) {
35
		this.imageSrc = imageSrc;
43
		this.imageSrc = imageSrc;
36
	}
44
	}
37
	
38
	@Column(DE.id_32)
45
	@Column(DE.id_32)
39
	public String getResourceId() {
46
	public String getResourceId() {
40
		return resourceId;
47
		return resourceId;

+ 63 - 1
src/main/java/com/ekexiu/portal/po/Resource.java

5
import org.jfw.apt.orm.annotation.entry.Column;
5
import org.jfw.apt.orm.annotation.entry.Column;
6
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
6
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
7
import org.jfw.apt.orm.annotation.entry.Table;
7
import org.jfw.apt.orm.annotation.entry.Table;
8
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
8
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
9
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
9
import org.jfw.apt.orm.core.enums.DE;
10
import org.jfw.apt.orm.core.enums.DE;
10

11

17
public class Resource implements CreateTimeSupported, ModifyTimeSupported{
18
public class Resource implements CreateTimeSupported, ModifyTimeSupported{
18
	private String resourceId;
19
	private String resourceId;
19
	private String resourceName;
20
	private String resourceName;
21
	/**
22
	 * 关键字
23
	 */
20
	private String subject;
24
	private String subject;
21
	private String industry;
25
	private String industry;
22
	/**
26
	/**
23
	 * 资源提供的服务
27
	 * 资源提供的服务、应用用途
24
	 */
28
	 */
25
	private String supportedServices;
29
	private String supportedServices;
30
	private String orgName;
31
	/**
32
	 * 厂商及型号规格
33
	 */
34
	private String spec;
35
	/**
36
	 * 性能参数
37
	 */
38
	private String parameter;
39
	/**
40
	 * 
41
	 */
42
	private String status;
26
	private String descp;
43
	private String descp;
27
	private String professorId;
44
	private String professorId;
28
	private Professor professor;
45
	private Professor professor;
39
	 * 合作备注
56
	 * 合作备注
40
	 */
57
	 */
41
	private String cooperationNotes;
58
	private String cooperationNotes;
59
	/**
60
	 * 发布时间
61
	 */
62
	private String publishTime;
42
	
63
	
43
	public List<Image> getImages() {
64
	public List<Image> getImages() {
44
		return images;
65
		return images;
101
		this.supportedServices = supportedServices;
122
		this.supportedServices = supportedServices;
102
	}
123
	}
103
	
124
	
125
	@Column(DE.String_de)
126
	public String getOrgName() {
127
		return orgName;
128
	}
129
	public void setOrgName(String orgName) {
130
		this.orgName = orgName;
131
	}
132
	
133
	@Column(DE.String_de)
134
	public String getSpec() {
135
		return spec;
136
	}
137
	public void setSpec(String spec) {
138
		this.spec = spec;
139
	}
140
	
141
	@Column(handlerClass=FixLenStringHandler.class,dbType="TEXT",nullable=true)
142
	public String getParameter() {
143
		return parameter;
144
	}
145
	public void setParameter(String parameter) {
146
		this.parameter = parameter;
147
	}
148
	
149
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(1)",nullable=true,renewable=false)
150
	public String getStatus() {
151
		return status;
152
	}
153
	public void setStatus(String status) {
154
		this.status = status;
155
	}
156
	
104
	@Column(handlerClass=StringHandler.class,dbType="TEXT",insertable=true,nullable=true,renewable=true,queryable=true)
157
	@Column(handlerClass=StringHandler.class,dbType="TEXT",insertable=true,nullable=true,renewable=true,queryable=true)
105
	public String getDescp() {
158
	public String getDescp() {
106
		return descp;
159
		return descp;
154
	public void setCooperationNotes(String cooperationNotes) {
207
	public void setCooperationNotes(String cooperationNotes) {
155
		this.cooperationNotes = cooperationNotes;
208
		this.cooperationNotes = cooperationNotes;
156
	}
209
	}
210
	
211
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(14)",nullable=true,renewable=false)
212
	public String getPublishTime() {
213
		return publishTime;
214
	}
215
	public void setPublishTime(String publishTime) {
216
		this.publishTime = publishTime;
217
	}
218
	
157
}
219
}

+ 94 - 69
src/main/java/com/ekexiu/portal/service/ArticleService.java

288
	
288
	
289
	@Post
289
	@Post
290
	@Path("/save")
290
	@Path("/save")
291
	public String saveArticle(@JdbcConn(true) Connection con,Article article,String[] professors,String[] resources)
292
			throws SQLException, IOException, JfwBaseException{
291
	public String saveArticle(@JdbcConn(true) Connection con,Article article,@Nullable String[] professors,
292
			@Nullable String[] resources) throws SQLException, IOException, JfwBaseException{
293
		if(article.getArticleId() == null){
293
		if(article.getArticleId() == null){
294
			String articleId = StringUtil.buildUUID();
294
			String articleId = StringUtil.buildUUID();
295
			if(article.getArticleImg() != null){
295
			if(article.getArticleImg() != null){
309
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
309
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
310
			}
310
			}
311
			this.articleDao.insert(con, article);
311
			this.articleDao.insert(con, article);
312
			for (String professor : professors) {
313
				ArticlePro articlePro = new ArticlePro();
314
				articlePro.setArticleId(articleId);
315
				articlePro.setProfessorId(professor);
316
				this.articleProDao.insert(con, articlePro);
312
			if(professors != null){
313
				for (String professor : professors) {
314
					ArticlePro articlePro = new ArticlePro();
315
					articlePro.setArticleId(articleId);
316
					articlePro.setProfessorId(professor);
317
					this.articleProDao.insert(con, articlePro);
318
				}
317
			}
319
			}
318
			for (String resource : resources) {
319
				ArticleRes articleRes = new ArticleRes();
320
				articleRes.setArticleId(articleId);
321
				articleRes.setResourceId(resource);
322
				this.articleResDao.insert(con, articleRes);
320
			if(resources != null){
321
				for (String resource : resources) {
322
					ArticleRes articleRes = new ArticleRes();
323
					articleRes.setArticleId(articleId);
324
					articleRes.setResourceId(resource);
325
					this.articleResDao.insert(con, articleRes);
326
				}
323
			}
327
			}
324
			return articleId;
328
			return articleId;
325
		}else if(article.getArticleId().trim().length() == 32){
329
		}else if(article.getArticleId().trim().length() == 32){
331
			this.articleDao.updatePublishTime(con, article.getArticleId(), "1", this.publishTime());
335
			this.articleDao.updatePublishTime(con, article.getArticleId(), "1", this.publishTime());
332
			this.articleProDao.delete(con, article.getArticleId());
336
			this.articleProDao.delete(con, article.getArticleId());
333
			this.articleResDao.delete(con, article.getArticleId());
337
			this.articleResDao.delete(con, article.getArticleId());
334
			for (String professor : professors) {
335
				ArticlePro articlePro = new ArticlePro();
336
				articlePro.setArticleId(article.getArticleId());
337
				articlePro.setProfessorId(professor);
338
				this.articleProDao.insert(con, articlePro);
338
			if(professors != null){
339
				for (String professor : professors) {
340
					ArticlePro articlePro = new ArticlePro();
341
					articlePro.setArticleId(article.getArticleId());
342
					articlePro.setProfessorId(professor);
343
					this.articleProDao.insert(con, articlePro);
344
				}
339
			}
345
			}
340
			for (String resource : resources) {
341
				ArticleRes articleRes = new ArticleRes();
342
				articleRes.setArticleId(article.getArticleId());
343
				articleRes.setResourceId(resource);
344
				this.articleResDao.insert(con, articleRes);
346
			if(resources != null){
347
				for (String resource : resources) {
348
					ArticleRes articleRes = new ArticleRes();
349
					articleRes.setArticleId(article.getArticleId());
350
					articleRes.setResourceId(resource);
351
					this.articleResDao.insert(con, articleRes);
352
				}
345
			}
353
			}
346
			return article.getArticleId();
354
			return article.getArticleId();
347
		}else{
355
		}else{
351
	
359
	
352
	@Post
360
	@Post
353
	@Path("/draft")
361
	@Path("/draft")
354
	public String draft(@JdbcConn(true) Connection con,Article article,String[] professors,String[] resources)
355
			throws SQLException, IOException, JfwBaseException{
362
	public String draft(@JdbcConn(true) Connection con,Article article,@Nullable String[] professors,
363
			@Nullable String[] resources) throws SQLException, IOException, JfwBaseException{
356
		if(article.getArticleId() == null){
364
		if(article.getArticleId() == null){
357
			String articleId = StringUtil.buildUUID();
365
			String articleId = StringUtil.buildUUID();
358
			if(article.getArticleImg() != null){
366
			if(article.getArticleImg() != null){
371
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
379
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
372
			}
380
			}
373
			this.articleDao.insert(con, article);
381
			this.articleDao.insert(con, article);
374
			for (String professor : professors) {
375
				ArticlePro articlePro = new ArticlePro();
376
				articlePro.setArticleId(articleId);
377
				articlePro.setProfessorId(professor);
378
				this.articleProDao.insert(con, articlePro);
382
			if(professors != null){
383
				for (String professor : professors) {
384
					ArticlePro articlePro = new ArticlePro();
385
					articlePro.setArticleId(articleId);
386
					articlePro.setProfessorId(professor);
387
					this.articleProDao.insert(con, articlePro);
388
				}
379
			}
389
			}
380
			for (String resource : resources) {
381
				ArticleRes articleRes = new ArticleRes();
382
				articleRes.setArticleId(articleId);
383
				articleRes.setResourceId(resource);
384
				this.articleResDao.insert(con, articleRes);
390
			if(resources != null){
391
				for (String resource : resources) {
392
					ArticleRes articleRes = new ArticleRes();
393
					articleRes.setArticleId(articleId);
394
					articleRes.setResourceId(resource);
395
					this.articleResDao.insert(con, articleRes);
396
				}
385
			}
397
			}
386
			return articleId;
398
			return articleId;
387
		}else if(article.getArticleId().trim().length() == 32){
399
		}else if(article.getArticleId().trim().length() == 32){
393
			this.articleDao.updateStatus(con, article.getArticleId(), "0");
405
			this.articleDao.updateStatus(con, article.getArticleId(), "0");
394
			this.articleProDao.delete(con, article.getArticleId());
406
			this.articleProDao.delete(con, article.getArticleId());
395
			this.articleResDao.delete(con, article.getArticleId());
407
			this.articleResDao.delete(con, article.getArticleId());
396
			for (String professor : professors) {
397
				ArticlePro articlePro = new ArticlePro();
398
				articlePro.setArticleId(article.getArticleId());
399
				articlePro.setProfessorId(professor);
400
				this.articleProDao.insert(con, articlePro);
408
			if(professors != null){
409
				for (String professor : professors) {
410
					ArticlePro articlePro = new ArticlePro();
411
					articlePro.setArticleId(article.getArticleId());
412
					articlePro.setProfessorId(professor);
413
					this.articleProDao.insert(con, articlePro);
414
				}
401
			}
415
			}
402
			for (String resource : resources) {
403
				ArticleRes articleRes = new ArticleRes();
404
				articleRes.setArticleId(article.getArticleId());
405
				articleRes.setResourceId(resource);
406
				this.articleResDao.insert(con, articleRes);
416
			if(resources != null){
417
				for (String resource : resources) {
418
					ArticleRes articleRes = new ArticleRes();
419
					articleRes.setArticleId(article.getArticleId());
420
					articleRes.setResourceId(resource);
421
					this.articleResDao.insert(con, articleRes);
422
				}
407
			}
423
			}
408
			return article.getArticleId();
424
			return article.getArticleId();
409
		}else{
425
		}else{
413
	
429
	
414
	@Post
430
	@Post
415
	@Path("/timing")
431
	@Path("/timing")
416
	public String timingPublish(@JdbcConn(true) Connection con,Article article,String[] professors,String[] resources)
417
			throws SQLException, IOException, JfwBaseException{
432
	public String timingPublish(@JdbcConn(true) Connection con,Article article,@Nullable String[] professors,
433
			@Nullable String[] resources) throws SQLException, IOException, JfwBaseException{
418
		if(article.getPublishTime() == null){
434
		if(article.getPublishTime() == null){
419
			throw new JfwBaseException(-3, "no parameter found:publishTime");
435
			throw new JfwBaseException(-3, "no parameter found:publishTime");
420
		}
436
		}
436
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
452
				throw new JfwBaseException(-1, "错误参数:文章发布者ID");
437
			}
453
			}
438
			this.articleDao.insert(con, article);
454
			this.articleDao.insert(con, article);
439
			for (String professor : professors) {
440
				ArticlePro articlePro = new ArticlePro();
441
				articlePro.setArticleId(articleId);
442
				articlePro.setProfessorId(professor);
443
				this.articleProDao.insert(con, articlePro);
455
			if(professors != null){
456
				for (String professor : professors) {
457
					ArticlePro articlePro = new ArticlePro();
458
					articlePro.setArticleId(articleId);
459
					articlePro.setProfessorId(professor);
460
					this.articleProDao.insert(con, articlePro);
461
				}
444
			}
462
			}
445
			for (String resource : resources) {
446
				ArticleRes articleRes = new ArticleRes();
447
				articleRes.setArticleId(articleId);
448
				articleRes.setResourceId(resource);
449
				this.articleResDao.insert(con, articleRes);
463
			if(resources != null){
464
				for (String resource : resources) {
465
					ArticleRes articleRes = new ArticleRes();
466
					articleRes.setArticleId(articleId);
467
					articleRes.setResourceId(resource);
468
					this.articleResDao.insert(con, articleRes);
469
				}
450
			}
470
			}
451
			return articleId;
471
			return articleId;
452
		}else if(article.getArticleId().trim().length() == 32){
472
		}else if(article.getArticleId().trim().length() == 32){
456
			}
476
			}
457
			this.articleDao.update(con, article);
477
			this.articleDao.update(con, article);
458
			this.articleDao.updatePublishTime(con, article.getArticleId(), "2", article.getPublishTime());
478
			this.articleDao.updatePublishTime(con, article.getArticleId(), "2", article.getPublishTime());
479
			this.articleResDao.delete(con, article.getArticleId());
459
			this.articleProDao.delete(con, article.getArticleId());
480
			this.articleProDao.delete(con, article.getArticleId());
460
			this.articleResDao.delete(con, article.getArticleId());
481
			this.articleResDao.delete(con, article.getArticleId());
461
			for (String professor : professors) {
462
				ArticlePro articlePro = new ArticlePro();
463
				articlePro.setArticleId(article.getArticleId());
464
				articlePro.setProfessorId(professor);
465
				this.articleProDao.insert(con, articlePro);
482
			if(professors != null){
483
				for (String professor : professors) {
484
					ArticlePro articlePro = new ArticlePro();
485
					articlePro.setArticleId(article.getArticleId());
486
					articlePro.setProfessorId(professor);
487
					this.articleProDao.insert(con, articlePro);
488
				}
466
			}
489
			}
467
			for (String resource : resources) {
468
				ArticleRes articleRes = new ArticleRes();
469
				articleRes.setArticleId(article.getArticleId());
470
				articleRes.setResourceId(resource);
471
				this.articleResDao.insert(con, articleRes);
490
			if(resources != null){
491
				for (String resource : resources) {
492
					ArticleRes articleRes = new ArticleRes();
493
					articleRes.setArticleId(article.getArticleId());
494
					articleRes.setResourceId(resource);
495
					this.articleResDao.insert(con, articleRes);
496
				}
472
			}
497
			}
473
			return article.getArticleId();
498
			return article.getArticleId();
474
		}else{
499
		}else{
581
	
606
	
582
	@Get
607
	@Get
583
	@Path("/pqself")
608
	@Path("/pqself")
584
	public PageQueryResult<Article> queryPageSelf(@JdbcConn Connection con,@Nullable String articleTitle,
585
			@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
609
	public PageQueryResult<Article> queryPageSelf(@JdbcConn Connection con,@Nullable String professorId,@Nullable String orgId,
610
			@Nullable String articleTitle,@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
586
		if(articleTitle != null){
611
		if(articleTitle != null){
587
			articleTitle = "%" + articleTitle + "%";
612
			articleTitle = "%" + articleTitle + "%";
588
		}
613
		}
589
		return this.articleDao.queryPageForSelf(con, articleTitle, pageSize, pageNo);
614
		return this.articleDao.queryPageForSelf(con, professorId, orgId, articleTitle, pageSize, pageNo);
590
	}
615
	}
591
	
616
	
592
	@Get
617
	@Get

+ 47 - 0
src/main/java/com/ekexiu/portal/service/ImagesService.java

10
import java.io.InputStream;
10
import java.io.InputStream;
11
import java.sql.Connection;
11
import java.sql.Connection;
12
import java.sql.SQLException;
12
import java.sql.SQLException;
13
import java.text.SimpleDateFormat;
14
import java.util.Date;
13
import java.util.List;
15
import java.util.List;
14

16

15
import javax.imageio.ImageIO;
17
import javax.imageio.ImageIO;
36
public class ImagesService {
38
public class ImagesService {
37
	private File tmpPath;
39
	private File tmpPath;
38
	private File resourcePath;
40
	private File resourcePath;
41
	private File resourceDataPath;
39
	private int resImageMaxLen = 240;
42
	private int resImageMaxLen = 240;
43
	private String dateFormat = "yyyyMM";
40
	private static final String JPG = "jpg";
44
	private static final String JPG = "jpg";
41
	@Autowrie
45
	@Autowrie
42
	private ImageDao imageDao;
46
	private ImageDao imageDao;
57
		this.resourcePath = resourcePath;
61
		this.resourcePath = resourcePath;
58
	}
62
	}
59

63

64
	public File getResourceDataPath() {
65
		return resourceDataPath;
66
	}
67

68
	public void setResourceDataPath(File resourceDataPath) {
69
		this.resourceDataPath = resourceDataPath;
70
	}
71

60
	public int getResImageMaxLen() {
72
	public int getResImageMaxLen() {
61
		return resImageMaxLen;
73
		return resImageMaxLen;
62
	}
74
	}
65
		this.resImageMaxLen = resImageMaxLen;
77
		this.resImageMaxLen = resImageMaxLen;
66
	}
78
	}
67

79

80
	public String getDateFormat() {
81
		return dateFormat;
82
	}
83

84
	public void setDateFormat(String dateFormat) {
85
		this.dateFormat = dateFormat;
86
	}
87

68
	public ImageDao getImageDao() {
88
	public ImageDao getImageDao() {
69
		return imageDao;
89
		return imageDao;
70
	}
90
	}
95
		}
115
		}
96
	}
116
	}
97
	
117
	
118
	private String createDate(){
119
		SimpleDateFormat df = new SimpleDateFormat(this.dateFormat);
120
		String date = df.format(new Date());
121
		return date;
122
	}
123
	
98
	@Post
124
	@Post
99
	@Path("/resourceImg")
125
	@Path("/resourceImg")
100
	public String insert(@JdbcConn(true) Connection con, String resourceId, String fn) 
126
	public String insert(@JdbcConn(true) Connection con, String resourceId, String fn) 
119
		}
145
		}
120
	}
146
	}
121
	
147
	
148
	@Post
149
	@Path("/saveImg")
150
	public void saveImg(@JdbcConn(true) Connection con, String resourceId, String[] fns) 
151
			throws SQLException, IOException, JfwBaseException {
152
		for (int i = 0; i < fns.length; i++) {
153
			byte[] src = this.readTmpFile(fns[i]);
154
			src = JpgUtil.read(src);
155
			byte[] shareResImage = this.resImage(src, this.resImageMaxLen);
156
			IoUtil.saveStream(new FileOutputStream(new File(this.resourceDataPath + "/" + this.createDate(), resourceId + "_" + i+1 + "." + JPG)), src, true);
157
			IoUtil.saveStream(new FileOutputStream(new File(this.resourceDataPath + "/" + this.createDate(), resourceId + "_" + i+1 + "_s." + JPG)), shareResImage, true);
158
			Image image = new Image();
159
			String imageId = StringUtil.buildUUID();
160
			image.setImageId(imageId);
161
			image.setSort(i+1);
162
			String imageSrc = this.createDate() + "/" + resourceId + "_" + i+1 + "." + JPG;
163
			image.setImageSrc(imageSrc);
164
			image.setResourceId(resourceId);
165
			this.imageDao.insert(con, image);
166
		}
167
	}
168
	
122
	@Post
169
	@Post
123
	@Path("/saveResImg")
170
	@Path("/saveResImg")
124
	public String insertResourceImg(@JdbcConn(true) Connection con, String resourceId, String base64, Integer angle) throws SQLException, IOException {
171
	public String insertResourceImg(@JdbcConn(true) Connection con, String resourceId, String base64, Integer angle) throws SQLException, IOException {

+ 17 - 2
src/main/java/com/ekexiu/portal/service/OrgService.java

107
	}
107
	}
108
	@Get
108
	@Get
109
	@Path("/lq")
109
	@Path("/lq")
110
	public List<Organization> query(@JdbcConn Connection con ,@Nullable String name,@DefaultValue("5") int rows) throws SQLException
111
	{
110
	public List<Organization> query(@JdbcConn Connection con,@Nullable String name,@DefaultValue("5") int rows) throws SQLException{
112
		if(name==null) name = "%";
111
		if(name==null) name = "%";
113
		else name="%"+name+"%";
112
		else name="%"+name+"%";
114
		return this.orgDao.limitQuery(con, name, rows);
113
		return this.orgDao.limitQuery(con, name, rows);
115
	}
114
	}
115
	
116
	@Get
117
	@Path("/querylimit")
118
	public List<EditOrganization> queryLimit(@JdbcConn Connection con,@Nullable String name,@DefaultValue("3") int rows)throws SQLException{
119
		if(name != null){
120
			name = "%" + name + "%";
121
		}
122
		List<EditOrganization> organizations = this.orgDao.queryLimit(con, name, rows);
123
		if(!organizations.isEmpty()){
124
			for (EditOrganization organization : organizations) {
125
				organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
126
			}
127
		}
128
		return organizations;
129
	}
130
	
116
	public String createOrganization(Connection con, String orgName) throws SQLException, IOException {
131
	public String createOrganization(Connection con, String orgName) throws SQLException, IOException {
117
		String id = StringUtil.buildUUID();
132
		String id = StringUtil.buildUUID();
118
		Organization org = new Organization();
133
		Organization org = new Organization();

+ 13 - 0
src/main/java/com/ekexiu/portal/service/ProfessorService.java

342
		return professor;
342
		return professor;
343
	}
343
	}
344
	
344
	
345
	@Get
346
	@Path("/qaByName")
347
	public List<EditProfessor> queryByName(@JdbcConn Connection con,@Nullable String name,@DefaultValue("3") int total)throws SQLException {
348
		if(name != null){
349
			name = "%" + name + "%";
350
		}
351
		List<EditProfessor> professors = this.professorDao.queryByName(con, name, total);
352
		for (EditProfessor professor : professors) {
353
			professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
354
		}
355
		return professors;
356
	}
357
	
345
	@Get
358
	@Get
346
	@Path("/editBaseInfo/{id}")
359
	@Path("/editBaseInfo/{id}")
347
	public EditProfessor queryEditBaseInfo(@JdbcConn Connection con, @PathVar String id) throws SQLException {
360
	public EditProfessor queryEditBaseInfo(@JdbcConn Connection con, @PathVar String id) throws SQLException {

+ 136 - 1
src/main/java/com/ekexiu/portal/service/ResourceService.java

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

9

8
import org.jfw.apt.annotation.Autowrie;
10
import org.jfw.apt.annotation.Autowrie;
29

31

30
@Path("/resource")
32
@Path("/resource")
31
public class ResourceService {
33
public class ResourceService {
34
	private String timeFormat = "yyyyMMddHHmmss";
32
	@Autowrie
35
	@Autowrie
33
	private ProfessorDao professorDao;
36
	private ProfessorDao professorDao;
34
	@Autowrie
37
	@Autowrie
46
	@Autowrie
49
	@Autowrie
47
	private GrowthLogService growthLogService;
50
	private GrowthLogService growthLogService;
48

51

52
	public String getTimeFormat() {
53
		return timeFormat;
54
	}
55

56
	public void setTimeFormat(String timeFormat) {
57
		this.timeFormat = timeFormat;
58
	}
59

49
	public ProfessorDao getProfessorDao() {
60
	public ProfessorDao getProfessorDao() {
50
		return professorDao;
61
		return professorDao;
51
	}
62
	}
109
	public void setGrowthLogService(GrowthLogService growthLogService) {
120
	public void setGrowthLogService(GrowthLogService growthLogService) {
110
		this.growthLogService = growthLogService;
121
		this.growthLogService = growthLogService;
111
	}
122
	}
123
	
124
	private String publishTime(){
125
		SimpleDateFormat df = new SimpleDateFormat(this.timeFormat);
126
		String publishTime = df.format(new Date());
127
		return publishTime;
128
	}
112

129

113
	@Post
130
	@Post
114
	@Path
131
	@Path
124
		return resourceId;
141
		return resourceId;
125
	}
142
	}
126
	
143
	
144
	@Post
145
	@Path("/save")
146
	public String save(@JdbcConn(true) Connection con, Resource resource, @Nullable String[] fns) 
147
			throws JfwBaseException, SQLException, IOException {
148
		if(resource.getResourceId() == null){
149
			String resourceId = StringUtil.buildUUID();
150
			if(fns != null){
151
				this.imagesService.saveImg(con, resourceId, fns);
152
			}
153
			resource.setResourceId(resourceId);
154
			resource.setStatus("1");
155
			resource.setPublishTime(this.publishTime());
156
			this.resourceDao.insert(con, resource);
157
			//this.growthLogService.addResource(con, resource.getProfessorId());
158
			return resourceId;
159
		}else if(resource.getResourceId().trim().length() == 32){
160
			if(fns != null){
161
				this.imageDao.deleteRes(con, resource.getResourceId());
162
				this.imagesService.saveImg(con, resource.getResourceId(), fns);
163
			}
164
			this.resourceDao.update(con, resource);
165
			this.resourceDao.updatePublishTime(con, resource.getResourceId(), "1", this.publishTime());
166
			return resource.getResourceId();
167
		}else{
168
			throw new JfwBaseException(-1, "bad parameter:resourceId");
169
		}
170
	}
171
	
172
	@Post
173
	@Path("/draft")
174
	public String draft(@JdbcConn(true) Connection con, Resource resource, @Nullable String[] fns) 
175
			throws SQLException, IOException, JfwBaseException{
176
		if(resource.getResourceId() == null){
177
			String resourceId = StringUtil.buildUUID();
178
			if(fns != null){
179
				this.imagesService.saveImg(con, resourceId, fns);
180
			}
181
			resource.setResourceId(resourceId);
182
			resource.setStatus("0");
183
			this.resourceDao.insert(con, resource);
184
			return resourceId;
185
		}else if(resource.getResourceId().trim().length() == 32){
186
			if(fns != null){
187
				this.imageDao.deleteRes(con, resource.getResourceId());
188
				this.imagesService.saveImg(con, resource.getResourceId(), fns);
189
			}
190
			this.resourceDao.update(con, resource);
191
			this.resourceDao.updateStatus(con, resource.getResourceId(), "0");
192
			return resource.getResourceId();
193
		}else{
194
			throw new JfwBaseException(-1, "bad parameter:resourceId");
195
		}
196
	}
197
	
198
	@Post
199
	@Path("/timing")
200
	public String timing(@JdbcConn(true) Connection con, Resource resource, @Nullable String[] fns) 
201
			throws SQLException, IOException, JfwBaseException{
202
		if(resource.getResourceId() == null){
203
			String resourceId = StringUtil.buildUUID();
204
			if(fns != null){
205
				this.imagesService.saveImg(con, resourceId, fns);
206
			}
207
			resource.setResourceId(resourceId);
208
			resource.setStatus("2");
209
			this.resourceDao.insert(con, resource);
210
			return resourceId;
211
		}else if(resource.getResourceId().trim().length() == 32){
212
			if(fns != null){
213
				this.imageDao.deleteRes(con, resource.getResourceId());
214
				this.imagesService.saveImg(con, resource.getResourceId(), fns);
215
			}
216
			this.resourceDao.update(con, resource);
217
			this.resourceDao.updatePublishTime(con, resource.getResourceId(), "2", resource.getPublishTime());
218
			return resource.getResourceId();
219
		}else{
220
			throw new JfwBaseException(-1, "bad parameter:resourceId");
221
		}
222
	}
223
	
224
	@Post
225
	@Path("/delete")
226
	public void deleteRes(@JdbcConn(true) Connection con, String resourceId) throws SQLException{
227
		//修改资源状态为删除
228
		this.resourceDao.updateStatus(con, resourceId, "3");
229
	}
230
	
127
	@Post
231
	@Post
128
	@Path("/saveRes")
232
	@Path("/saveRes")
129
	public String insertRes(@JdbcConn(true) Connection con, Resource resource, @Nullable String base64, Integer angle) 
233
	public String insertRes(@JdbcConn(true) Connection con, Resource resource, @Nullable String base64, Integer angle) 
147
		}
251
		}
148
		this.resourceDao.update(con, resource);
252
		this.resourceDao.update(con, resource);
149
	}
253
	}
150

254
	
151
	@Get
255
	@Get
152
	@Path("/{resourceId}")
256
	@Path("/{resourceId}")
153
	public Resource query(@JdbcConn Connection con, @PathVar String resourceId) throws SQLException {
257
	public Resource query(@JdbcConn Connection con, @PathVar String resourceId) throws SQLException {
158
		return resource;
262
		return resource;
159
	}
263
	}
160
	
264
	
265
	@Get
266
	@Path("/queryOne")
267
	public Resource queryOne(@JdbcConn Connection con, String resourceId) throws SQLException {
268
		Resource resource = this.resourceDao.queryOne(con, resourceId);
269
		if(resource != null){
270
			resource.setImages(this.imageDao.queryRes(con, resourceId));
271
			EditProfessor professor = this.professorDao.queryBaseInfo(con, resource.getProfessorId());
272
			if(professor != null){
273
				professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
274
			}
275
			resource.setEditProfessor(professor);
276
		}
277
		return resource;
278
	}
279
	
161
	@Get
280
	@Get
162
	@Path("/resourceInfo")
281
	@Path("/resourceInfo")
163
	public Resource queryInfo(@JdbcConn Connection con, String resourceId) throws SQLException {
282
	public Resource queryInfo(@JdbcConn Connection con, String resourceId) throws SQLException {
185
		return queryResult;
304
		return queryResult;
186
	}
305
	}
187
	
306
	
307
	@Get
308
	@Path("/qaByName")
309
	public List<Resource> queryByName(@JdbcConn Connection con, @Nullable String resourceName, @DefaultValue("3") int rows) throws SQLException {
310
		if(resourceName != null){
311
			resourceName = "%" + resourceName + "%";
312
		}
313
		List<Resource> resources = this.resourceDao.queryByName(con, resourceName, rows);
314
		if(!resources.isEmpty()){
315
			for (Resource resource : resources) {
316
				resource.setImages(this.imageDao.queryRes(con, resource.getResourceId()));
317
				resource.setProfessor(this.professorDao.queryOne(con, resource.getProfessorId()));
318
			}
319
		}
320
		return resources;
321
	}
322
	
188
	@Get
323
	@Get
189
	@Path("/qapro")
324
	@Path("/qapro")
190
	public List<Resource> queryPro(@JdbcConn Connection con, String professorId) throws SQLException {
325
	public List<Resource> queryPro(@JdbcConn Connection con, String professorId) throws SQLException {

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

142
com_ekexiu_portal_service_ImagesService.tmpPath::java.io.File=/kexiu/www/html1/images/tmp
142
com_ekexiu_portal_service_ImagesService.tmpPath::java.io.File=/kexiu/www/html1/images/tmp
143
#资源图片保存目录
143
#资源图片保存目录
144
com_ekexiu_portal_service_ImagesService.resourcePath::java.io.File=/kexiu/www/html1/images/resource
144
com_ekexiu_portal_service_ImagesService.resourcePath::java.io.File=/kexiu/www/html1/images/resource
145
com_ekexiu_portal_service_ImagesService.resourceDataPath::java.io.File=/kexiu/webdata1/data/resource
145
#科研文章图片上传临时目录
146
#科研文章图片上传临时目录
146
com_ekexiu_portal_service_ArticleService.tmpPath::java.io.File=/kexiu/www/html1/images/tmp
147
com_ekexiu_portal_service_ArticleService.tmpPath::java.io.File=/kexiu/www/html1/images/tmp
147
#科研文章图片保存目录
148
#科研文章图片保存目录

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

142
com_ekexiu_portal_service_ImagesService.tmpPath::java.io.File=/kexiu/www/html/images/tmp
142
com_ekexiu_portal_service_ImagesService.tmpPath::java.io.File=/kexiu/www/html/images/tmp
143
#资源图片保存目录
143
#资源图片保存目录
144
com_ekexiu_portal_service_ImagesService.resourcePath::java.io.File=/kexiu/www/html/images/resource
144
com_ekexiu_portal_service_ImagesService.resourcePath::java.io.File=/kexiu/www/html/images/resource
145
com_ekexiu_portal_service_ImagesService.resourceDataPath::java.io.File=/kexiu/webdata/data/resource
145
#科研文章图片上传临时目录
146
#科研文章图片上传临时目录
146
com_ekexiu_portal_service_ArticleService.tmpPath::java.io.File=/kexiu/www/html/images/tmp
147
com_ekexiu_portal_service_ArticleService.tmpPath::java.io.File=/kexiu/www/html/images/tmp
147
#科研文章图片保存目录
148
#科研文章图片保存目录

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

142
com_ekexiu_portal_service_ImagesService.tmpPath::java.io.File=/kexiu/www/html/images/tmp
142
com_ekexiu_portal_service_ImagesService.tmpPath::java.io.File=/kexiu/www/html/images/tmp
143
#资源图片保存目录
143
#资源图片保存目录
144
com_ekexiu_portal_service_ImagesService.resourcePath::java.io.File=/kexiu/www/html/images/resource
144
com_ekexiu_portal_service_ImagesService.resourcePath::java.io.File=/kexiu/www/html/images/resource
145
com_ekexiu_portal_service_ImagesService.resourceDataPath::java.io.File=/kexiu/webdata/data/resource
145
#科研文章图片上传临时目录
146
#科研文章图片上传临时目录
146
com_ekexiu_portal_service_ArticleService.tmpPath::java.io.File=/kexiu/www/html/images/tmp
147
com_ekexiu_portal_service_ArticleService.tmpPath::java.io.File=/kexiu/www/html/images/tmp
147
#科研文章图片保存目录
148
#科研文章图片保存目录