jiapeng 7 years ago
parent
commit
bb958ecc53

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

@ -11,7 +11,7 @@ import com.ekexiu.portal.basepo.ModifyTimeSupported;
11 11
@PrimaryKey("id")
12 12
@Uniques({@Unique(clolumns={"qid","uid"},name="UNI_ANSWER_QID_UID")})
13 13
@Table
14
public class Answer  implements ModifyTimeSupported{
14
public class Answer {
15 15
	private String id;
16 16
	private String qid;
17 17
	private String uid;
@ -114,6 +114,7 @@ public class Answer  implements ModifyTimeSupported{
114 114
	public void setCreateTime(String createTime) {
115 115
		this.createTime = createTime;
116 116
	}
117
	@Column(DE.text_de)
117 118
	public String getModifyTime() {
118 119
		return modifyTime;
119 120
	}

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

@ -42,6 +42,13 @@ public interface QuestionDao {
42 42
	@SetSentence("REPLY_COUNT=REPLY_COUNT+1")
43 43
	int incQuestionReply(Connection con,String id)throws SQLException;
44 44
	
45
	@UpdateWith
46
	@From(Question.class)
47
	@SetSentence("REPLY_COUNT=REPLY_COUNT+1")
48
	int onlyIncQuestionReply(Connection con,String id)throws SQLException;
49
	
50
	
51
	
45 52
	@UpdateWith
46 53
	@From(Question.class)
47 54
	@SetSentence("REPLY_COUNT=REPLY_COUNT-1")
@ -78,6 +85,12 @@ public interface QuestionDao {
78 85
	@SetSentence("STATE='0'")
79 86
	@Where("STATE ='1'")
80 87
	int logicDeleteAnswer(Connection con,String id)throws SQLException;
88
	
89
	@UpdateWith
90
	@From(Answer.class)
91
	@SetSentence("STATE='1'")
92
	@Where("STATE <>'1'")
93
	int unDeleteAnswer(Connection con,String id,String qid)throws SQLException;
81 94

82 95
	
83 96
	@SelectOne
@ -141,7 +154,8 @@ public interface QuestionDao {
141 154

142 155
	@UpdateWith
143 156
	@From(Answer.class)
144
	@IncludeFixSet
157
	@Where("STATE='1'")
158
	@SetSentence("MODIFY_TIME=TO_CHAR(NOW(),'YYYYMMDDHH24MISS')")
145 159
	int updateAnswer(Connection con, String id, @Set String cnt) throws SQLException;
146 160
	
147 161
	@Insert

+ 24 - 7
src/main/java/com/ekexiu/portal/question/Service.java

@ -5,6 +5,7 @@ import com.ekexiu.portal.notify.NotifyType;
5 5
import com.ekexiu.portal.util.SqlUtil;
6 6
import org.jfw.apt.annotation.Autowrie;
7 7
import org.jfw.apt.annotation.DefaultValue;
8
import org.jfw.apt.annotation.Nullable;
8 9
import org.jfw.apt.web.annotation.Path;
9 10
import org.jfw.apt.web.annotation.operate.Get;
10 11
import org.jfw.apt.web.annotation.operate.Post;
@ -147,7 +148,7 @@ public class Service {
147 148
		q.setPageViews(0);
148 149
		String time = DateUtil.formatDateTime(System.currentTimeMillis());
149 150
		q.setCreateTime(time);
150
		q.setTimeDesc(time+id);
151
		q.setTimeDesc(time + id);
151 152
		List<String> kws = ListUtil.splitTrimExcludeEmpty(q.getKeys(), ',');
152 153
		if (kws.isEmpty())
153 154
			throw new IllegalArgumentException("param keys invalid");
@ -155,10 +156,10 @@ public class Service {
155 156
		questionDao.insert(con, build(id, kws));
156 157
		return id;
157 158
	}
158
	
159

159 160
	@Path("/pageViews")
160 161
	@Post
161
	public void incQuestionPageView(@JdbcConn(true) Connection con,String qid)throws SQLException{
162
	public void incQuestionPageView(@JdbcConn(true) Connection con, String qid) throws SQLException {
162 163
		questionDao.incQuestionPageViews(con, qid);
163 164
	}
164 165

@ -279,7 +280,8 @@ public class Service {
279 280
		a.setState("1");
280 281
		a.setUid(uid);
281 282
		a.setCreateTime(time);
282
		a.setTimeDesc(time+id);
283
		a.setTimeDesc(time + id);
284
		a.setModifyTime(time);
283 285
		try {
284 286
			questionDao.insert(con, a);
285 287
		} catch (SQLException e) {
@ -295,8 +297,13 @@ public class Service {
295 297

296 298
	@Get
297 299
	@Path("/answer")
298
	public Answer answer(@JdbcConn Connection con, String id) throws SQLException {
299
		return questionDao.queryAnswer(con, id);
300
	public Answer answer(@JdbcConn Connection con,@Nullable String id,@Nullable String uid, @Nullable String qid) throws SQLException {
301
		if(id!=null){
302
			return questionDao.queryAnswer(con, id);
303
		}else if(qid!=null && uid !=null){
304
			return questionDao.answer(con, uid, qid);
305
		}
306
		return null;
300 307
	}
301 308

302 309
	@Get
@ -578,13 +585,23 @@ public class Service {
578 585
	@Get
579 586
	@Path("/answer/delete")
580 587
	public int logicDelete(@JdbcConn(true) Connection con, String id) throws SQLException {
581
		if(questionDao.logicDeleteAnswer(con, id)>0){
588
		if (questionDao.logicDeleteAnswer(con, id) > 0) {
582 589
			questionDao.deccQuestionReply(con, id);
583 590
			return 1;
584 591
		}
585 592
		return 0;
586 593
	}
587 594

595
	@Get
596
	@Path("/answer/unDel")
597
	public int unDelete(@JdbcConn(true) Connection con, String id, String qid) throws SQLException {
598
		if (questionDao.unDeleteAnswer(con, id, qid) > 0) {
599
			questionDao.onlyIncQuestionReply(con, qid);
600
			return 1;
601
		}
602
		return 0;
603
	}
604

588 605
	@Post
589 606
	@Path("/answer/unAgree")
590 607
	public void unAgree(@JdbcConn(true) Connection con, String id, String uid, String uname, @AfterCommit List<Runnable> runs)