XMTT vor 7 Jahren
Ursprung
Commit
6235896d93

+ 11 - 1
src/main/java/com/ekexiu/console/system/dao/QuestionDao.java

@ -53,18 +53,28 @@ public interface QuestionDao {
53 53
54 54
    @DeleteWith
55 55
    @From(Answer.class)
56
    int deleteAnswer(Connection con, String id)throws SQLException;
56
    int deleteAnswer(Connection con, String id,String qid)throws SQLException;
57
58
59
    @UpdateWith
60
    @From(Question.class)
61
    @SetSentence("REPLY_COUNT=REPLY_COUNT-1")
62
    @Where("REPLY_COUNT >0")
63
    int decQuestionReply(Connection con,String id)throws SQLException;
57 64
58 65
    @PageQuery
59 66
    @OrderBy("order by create_time DESC")
67
    @Where("STATE='1'")
60 68
    PageQueryResult<QuestionInfo> questionByTime(Connection con, @Nullable @Like String title, @Nullable @Like String requester, int pageSize, int pageNo)throws SQLException;
61 69
62 70
    @PageQuery
63 71
    @OrderBy("order by page_views DESC")
72
    @Where("STATE='1'")
64 73
    PageQueryResult<QuestionInfo> questionByPV(Connection con, @Nullable @Like String title, @Nullable @Like String requester, int pageSize, int pageNo)throws SQLException;
65 74
66 75
    @PageQuery
67 76
    @OrderBy("order by reply_count DESC")
77
    @Where("STATE='1'")
68 78
    PageQueryResult<QuestionInfo> questionByReply(Connection con, @Nullable @Like String title, @Nullable @Like String requester, int pageSize, int pageNo)throws SQLException;
69 79
70 80
    @QueryOne

+ 7 - 4
src/main/java/com/ekexiu/console/system/service/QuestionService.java

@ -9,7 +9,6 @@ import org.jfw.apt.annotation.Autowrie;
9 9
import org.jfw.apt.annotation.DefaultValue;
10 10
import org.jfw.apt.annotation.Nullable;
11 11
import org.jfw.apt.web.annotation.Path;
12
import org.jfw.apt.web.annotation.operate.Delete;
13 12
import org.jfw.apt.web.annotation.operate.Get;
14 13
import org.jfw.apt.web.annotation.operate.Post;
15 14
import org.jfw.apt.web.annotation.param.JdbcConn;
@ -89,9 +88,13 @@ public class QuestionService {
89 88
    }
90 89
91 90
    @Path("/deleteAnswer")
92
    @Delete
93
    public void deleteAnswer(@JdbcConn(true) Connection con, String id) throws SQLException {
94
        this.questionDao.deleteAnswer(con, id);
91
    @Get
92
    public int deleteAnswer(@JdbcConn(true) Connection con, String id,String qid) throws SQLException {
93
        if (questionDao.deleteAnswer(con, id, qid) > 0) {
94
            questionDao.decQuestionReply(con, qid);
95
            return 1;
96
        }
97
        return 0;
95 98
    }
96 99
97 100
    @Path("/pqQuestion")