jiapeng 7 年 前
コミット
bbbacd84bd

+ 43 - 0
src/main/java/com/ekexiu/portal/dao/PaperAgreeDao.java

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

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

6
import org.jfw.apt.annotation.DefaultValue;
7
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.orm.annotation.dao.Column;
9
import org.jfw.apt.orm.annotation.dao.DAO;
10
import org.jfw.apt.orm.annotation.dao.method.From;
11
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
12
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
13
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
14
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
15
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
16

17
import com.ekexiu.portal.po.PaperAgree;
18

19
@DAO
20
public interface PaperAgreeDao {
21
	@Insert
22
	int insert(Connection con,PaperAgree pa) throws SQLException;
23
	
24
	@DeleteWith
25
	@From(PaperAgree.class)
26
	int delete(Connection con,String opId,String paperId) throws SQLException;
27
	
28
	@DeleteWith
29
	@From(PaperAgree.class)
30
	int delete(Connection con,String paperId) throws SQLException;
31
	
32
	@Nullable
33
	@SelectOne
34
	PaperAgree query(Connection con,String opId,String paperId) throws SQLException;
35
	
36
	
37
	@QueryVal
38
	@From(PaperAgree.class)
39
	@Column(handlerClass = IntHandler.class, value = "COUNT(1)")
40
	@DefaultValue("0")
41
	int query(Connection con,String paperId) throws SQLException;
42

43
}

+ 42 - 0
src/main/java/com/ekexiu/portal/dao/PatentAgreeDao.java

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

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

6
import org.jfw.apt.annotation.DefaultValue;
7
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.orm.annotation.dao.Column;
9
import org.jfw.apt.orm.annotation.dao.DAO;
10
import org.jfw.apt.orm.annotation.dao.method.From;
11
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
12
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
13
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
14
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
15
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
16

17
import com.ekexiu.portal.po.PatentAgree;
18

19
@DAO
20
public interface PatentAgreeDao {
21
	@Insert
22
	int insert(Connection con,PatentAgree pa) throws SQLException;
23
	
24
	@DeleteWith
25
	@From(PatentAgree.class)
26
	int delete(Connection con,String opId,String patentId) throws SQLException;
27
	
28
	@DeleteWith
29
	@From(PatentAgree.class)
30
	int delete(Connection con,String patentId) throws SQLException;
31
	
32
	@Nullable
33
	@SelectOne
34
	PatentAgree query(Connection con,String opId,String patentId) throws SQLException;
35
	
36
	
37
	@QueryVal
38
	@From(PatentAgree.class)
39
	@Column(handlerClass = IntHandler.class, value = "COUNT(1)")
40
	@DefaultValue("0")
41
	int query(Connection con,String patentId) throws SQLException;
42
}

+ 37 - 0
src/main/java/com/ekexiu/portal/po/PaperAgree.java

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

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

8
import com.ekexiu.portal.basepo.CreateTimeSupported;
9

10
@PrimaryKey({"paperId","opId"})
11
@Table
12
public class PaperAgree implements CreateTimeSupported {
13
	private String opId;
14
	private String paperId;
15
	private String createTime;
16
	@Column(DE.id_32)
17
	public String getOpId() {
18
		return opId;
19
	}
20
	public void setOpId(String opId) {
21
		this.opId = opId;
22
	}
23
	@Column(DE.id_32)
24
	public String getPaperId() {
25
		return paperId;
26
	}
27
	public void setPaperId(String paperId) {
28
		this.paperId = paperId;
29
	}
30
	public String getCreateTime() {
31
		return createTime;
32
	}
33
	public void setCreateTime(String createTime) {
34
		this.createTime = createTime;
35
	}
36
	
37
}

+ 37 - 0
src/main/java/com/ekexiu/portal/po/PatentAgree.java

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

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

8
import com.ekexiu.portal.basepo.CreateTimeSupported;
9

10
@PrimaryKey({"patentId","opId"})
11
@Table
12
public class PatentAgree implements CreateTimeSupported {
13
	private String opId;
14
	private String patentId;
15
	private String createTime;
16
	@Column(DE.id_32)
17
	public String getOpId() {
18
		return opId;
19
	}
20
	public void setOpId(String opId) {
21
		this.opId = opId;
22
	}
23
	@Column(DE.id_32)
24
	public String getPatentId() {
25
		return patentId;
26
	}
27
	public void setPatentId(String patentId) {
28
		this.patentId = patentId;
29
	}
30
	public String getCreateTime() {
31
		return createTime;
32
	}
33
	public void setCreateTime(String createTime) {
34
		this.createTime = createTime;
35
	}
36
	
37
}

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

@ -828,7 +828,7 @@ public class ArticleService {
828 828
	@Get
829 829
	@Path("/ralateArticles")
830 830
	public List<Article> ralateArticles(@JdbcConn Connection con,@Nullable String[] keys,@Nullable String professorId,
831
			@Nullable String orgId,String articleId,@DefaultValue("10") int rows)throws SQLException{
831
			@Nullable String orgId,String articleId,@DefaultValue("5") int rows)throws SQLException{
832 832
		String[] ids = this.articleDao.queryArticleIdWithSameKeyWord(con, articleId, rows);
833 833
		if(ids!=null){
834 834
			return this.articleDao.query(con,ids);

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

@ -266,7 +266,7 @@ public class OrgService {
266 266
	
267 267
	@Get
268 268
	@Path("/ralateOrgs")
269
	public List<EditOrganization> ralateArticles(@JdbcConn Connection con,String orgId,@DefaultValue("10") int rows)throws SQLException{
269
	public List<EditOrganization> ralateArticles(@JdbcConn Connection con,String orgId,@DefaultValue("5") int rows)throws SQLException{
270 270
		String[] ids = this.orgDao.queryOrgIdWithSameKeyWord(con, orgId, rows);
271 271
		if(ids!=null){
272 272
			List<EditOrganization> ret = this.orgDao.query(con,ids);

+ 42 - 2
src/main/java/com/ekexiu/portal/service/PpaperService.java

@ -14,11 +14,12 @@ import org.jfw.apt.web.annotation.operate.Post;
14 14
import org.jfw.apt.web.annotation.param.JdbcConn;
15 15
import org.jfw.util.PageQueryResult;
16 16

17
import com.ekexiu.portal.dao.PaperAgreeDao;
17 18
import com.ekexiu.portal.dao.PaperAuthorDao;
18 19
import com.ekexiu.portal.dao.PpaperDao;
20
import com.ekexiu.portal.po.PaperAgree;
19 21
import com.ekexiu.portal.po.PaperAuthor;
20 22
import com.ekexiu.portal.po.Ppaper;
21
import com.ekexiu.portal.po.Resource;
22 23
import com.ekexiu.portal.pojo.AssedPaper;
23 24

24 25
@Path("/ppaper")
@ -32,8 +33,20 @@ public class PpaperService {
32 33
	@Autowrie
33 34
	private KeyWordService keyWordService;
34 35
	
36
	@Autowrie
37
	private PaperAgreeDao paperAgreeDao;
38
	
39
	
35 40
	
36 41

42
	public PaperAgreeDao getPaperAgreeDao() {
43
		return paperAgreeDao;
44
	}
45

46
	public void setPaperAgreeDao(PaperAgreeDao paperAgreeDao) {
47
		this.paperAgreeDao = paperAgreeDao;
48
	}
49

37 50
	public KeyWordService getKeyWordService() {
38 51
		return keyWordService;
39 52
	}
@ -161,11 +174,38 @@ public class PpaperService {
161 174
	}
162 175
	@Get
163 176
	@Path("/ralatePapers")
164
	public List<Ppaper> ralatePapers(@JdbcConn Connection con,String paperId,@DefaultValue("10") int rows)throws SQLException{
177
	public List<Ppaper> ralatePapers(@JdbcConn Connection con,String paperId,@DefaultValue("5") int rows)throws SQLException{
165 178
		String[] ids = this.ppaperDao.queryPaperIdWithSameKeyWord(con, paperId, rows);
166 179
		if(ids!=null){
167 180
			return this.ppaperDao.query(con,ids);
168 181
		}
169 182
		return Collections.<Ppaper>emptyList();
170 183
	}
184
	
185
	
186
	@Post
187
	@Path("/agree")
188
	public void agree(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
189
		PaperAgree pa = new PaperAgree();
190
		pa.setOpId(uid);
191
		pa.setPaperId(id);
192
		this.paperAgreeDao.insert(con, pa);		
193
	}
194
	
195
	@Post
196
	@Path("/unAgree")
197
	public void unAgree(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
198
		this.paperAgreeDao.delete(con,uid, id);
199
	}
200
	
201
	@Get
202
	@Path("/agree")
203
	public boolean hasAgree(@JdbcConn(false) Connection con,String id,String uid)throws SQLException{
204
		return null!= this.paperAgreeDao.query(con,uid, id);
205
	}
206
	@Get
207
	@Path("/agreeCount")
208
	public int agreeCount(@JdbcConn(false) Connection con,String id)throws SQLException{
209
		return this.paperAgreeDao.query(con,id);
210
	}
171 211
}

+ 41 - 3
src/main/java/com/ekexiu/portal/service/PpatentServcie.java

@ -14,10 +14,11 @@ import org.jfw.apt.web.annotation.operate.Post;
14 14
import org.jfw.apt.web.annotation.param.JdbcConn;
15 15
import org.jfw.util.PageQueryResult;
16 16

17
import com.ekexiu.portal.dao.PatentAgreeDao;
17 18
import com.ekexiu.portal.dao.PatentAuthorDao;
18 19
import com.ekexiu.portal.dao.PpatentDao;
20
import com.ekexiu.portal.po.PatentAgree;
19 21
import com.ekexiu.portal.po.PatentAuthor;
20
import com.ekexiu.portal.po.Ppaper;
21 22
import com.ekexiu.portal.po.Ppatent;
22 23
import com.ekexiu.portal.pojo.AssedPatent;
23 24

@ -32,8 +33,19 @@ public class PpatentServcie {
32 33
	@Autowrie
33 34
	private KeyWordService keyWordService;
34 35
	
36
	@Autowrie
37
	private PatentAgreeDao patentAgreeDao;
38
	
35 39
	
36 40

41
	public PatentAgreeDao getPatentAgreeDao() {
42
		return patentAgreeDao;
43
	}
44

45
	public void setPatentAgreeDao(PatentAgreeDao patentAgreeDao) {
46
		this.patentAgreeDao = patentAgreeDao;
47
	}
48

37 49
	public KeyWordService getKeyWordService() {
38 50
		return keyWordService;
39 51
	}
@ -155,12 +167,38 @@ public class PpatentServcie {
155 167
		return this.ppatentDao.query(con,id);
156 168
	}
157 169
	@Get
158
	@Path("/ralatePatent")
159
	public List<Ppatent> ralatePatents(@JdbcConn Connection con,String patentId,@DefaultValue("10") int rows)throws SQLException{
170
	@Path("/ralatePatents")
171
	public List<Ppatent> ralatePatents(@JdbcConn Connection con,String patentId,@DefaultValue("5") int rows)throws SQLException{
160 172
		String[] ids = this.ppatentDao.queryPatentIdWithSameKeyWord(con, patentId, rows);
161 173
		if(ids!=null){
162 174
			return this.ppatentDao.query(con,ids);
163 175
		}
164 176
		return Collections.<Ppatent>emptyList();
165 177
	}
178
	
179
	@Post
180
	@Path("/agree")
181
	public void agree(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
182
		PatentAgree pa = new PatentAgree();
183
		pa.setOpId(uid);
184
		pa.setPatentId(id);
185
		this.patentAgreeDao.insert(con, pa);		
186
	}
187
	
188
	@Post
189
	@Path("/unAgree")
190
	public void unAgree(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
191
		this.patentAgreeDao.delete(con,uid, id);
192
	}
193
	
194
	@Get
195
	@Path("/agree")
196
	public boolean hasAgree(@JdbcConn(false) Connection con,String id,String uid)throws SQLException{
197
		return null!= this.patentAgreeDao.query(con,uid, id);
198
	}
199
	@Get
200
	@Path("/agreeCount")
201
	public int agreeCount(@JdbcConn(false) Connection con,String id)throws SQLException{
202
		return this.patentAgreeDao.query(con,id);
203
	}
166 204
}

+ 7 - 3
src/main/java/com/ekexiu/portal/service/ProfessorService.java

@ -741,14 +741,18 @@ public class ProfessorService {
741 741
	
742 742
	@Get
743 743
	@Path("/ralateProfessors")
744
	public List<Professor> ralateArticles(@JdbcConn Connection con,String professorId,@DefaultValue("10") int rows)throws SQLException{
744
	public List<Professor> ralateArticles(@JdbcConn Connection con,String professorId,@DefaultValue("5") int rows)throws SQLException{
745 745
		String[] ids = this.professorDao.queryProfessorIdWithSameKeyWord(con, professorId, rows);
746 746
		if(ids!=null){
747
			return this.professorDao.query(con,ids);
747
			 List<Professor> ret = this.professorDao.query(con,ids);
748
			 return ret;
748 749
		}
749 750
		return Collections.<Professor>emptyList();
750 751
	}
751
	
752
//	
753
//	
754
//	@Get
755
//	@Path("/articleRef")
752 756

753 757
	public static void main(String[] args) throws Exception {
754 758
		// Connection con =

+ 5 - 2
src/main/java/com/ekexiu/portal/service/ResourceService.java

@ -4,7 +4,6 @@ import java.io.IOException;
4 4
import java.sql.Connection;
5 5
import java.sql.SQLException;
6 6
import java.text.SimpleDateFormat;
7
import java.util.ArrayList;
8 7
import java.util.Collections;
9 8
import java.util.Date;
10 9
import java.util.List;
@ -998,7 +997,11 @@ public class ResourceService {
998 997
	public List<Resource> ralateResources(@JdbcConn Connection con,String resourceId,@DefaultValue("5") int rows)throws SQLException{
999 998
		String[] ids = this.resourceDao.queryResourceIdWithSameKeyWord(con, resourceId, rows);
1000 999
		if(ids!=null){
1001
			return this.resourceDao.query(con,ids);
1000
			List<Resource> ret = this.resourceDao.query(con,ids);
1001
			for(Resource res:ret){
1002
				res.setImages(this.imageDao.queryRes(con, res.getResourceId()));
1003
			}
1004
			return ret;
1002 1005
		}
1003 1006
		return Collections.<Resource>emptyList();
1004 1007
	}

+ 22 - 0
src/main/resources/database.sql

@ -1558,6 +1558,28 @@ comment on column leave_word.category is '留言分类  1: 文章  2:论文
1558 1558
ALTER TABLE leave_word RENAME article_id TO obj_id;
1559 1559
comment on column leave_word.obj_id is '留言对象ID';
1560 1560

1561
CREATE TABLE paper_agree (
1562
	op_id char(32) NOT NULL,
1563
	paper_id char(32) NOT NULL,
1564
	create_time char(14) NOT NULL
1565
);
1566
COMMENT ON TABLE paper_agree IS '论文点赞表';
1567
COMMENT ON COLUMN paper_agree.op_id IS '点赞人的ID';
1568
COMMENT ON COLUMN paper_agree.paper_id IS '被点赞的论文ID';
1569
COMMENT ON COLUMN paper_agree.create_time IS '点赞时间';
1570

1571
CREATE TABLE patent_agree (
1572
	op_id char(32) NOT NULL,
1573
	patent_id char(32) NOT NULL,
1574
	create_time char(14) NOT NULL
1575
);
1576
COMMENT ON TABLE patent_agree IS '专利点赞表';
1577
COMMENT ON COLUMN patent_agree.op_id IS '点赞人的ID';
1578
COMMENT ON COLUMN patent_agree.patent_id IS '被点赞的专利ID';
1579
COMMENT ON COLUMN patent_agree.create_time IS '点赞时间';
1580

1581
ALTER TABLE patent_agree ADD PRIMARY KEY (op_id,patent_id);
1582
ALTER TABLE paper_agree ADD PRIMARY KEY (op_id,paper_id);
1561 1583

1562 1584

1563 1585