You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
4.0 KiB
96 lines
4.0 KiB
package com.community.pocket.data.main.forum;
|
|
|
|
|
|
import androidx.lifecycle.MutableLiveData;
|
|
|
|
import com.community.pocket.data.model.ForumType;
|
|
import com.community.pocket.data.model.LocalToken;
|
|
import com.community.pocket.ui.main.ui.forum.post.ForumPostResponse;
|
|
import com.community.pocket.ui.main.ui.forum.post.QueryUserResponse;
|
|
import com.community.pocket.util.HttpRequest;
|
|
import com.community.pocket.util.HttpUtil;
|
|
import com.community.pocket.util.SimpleHttpParse;
|
|
|
|
import okhttp3.FormBody;
|
|
|
|
/**
|
|
* 发表帖子请求接口
|
|
*/
|
|
public class ForumPostRequest {
|
|
private static volatile ForumPostRequest instance;
|
|
|
|
private ForumPostRequest() {
|
|
}
|
|
|
|
public static ForumPostRequest getInstance() {
|
|
if (instance == null) {
|
|
instance = new ForumPostRequest();
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
//发送活动贴
|
|
@HttpRequest("/forum/sendActive")
|
|
public void sendActive(MutableLiveData<ForumPostResponse> liveData, String title, String content, String activeStartTime, String activeEndTime, String activeScore, String registrationDeadline) {
|
|
HttpUtil.getRequest(HttpUtil.Method.POST,
|
|
new SimpleHttpParse<ForumPostResponse>(liveData).getInterface(ForumPostResponse.class),
|
|
LocalToken.create()
|
|
.add("title", title)
|
|
.add("content", content)
|
|
.add("registrationDeadline", registrationDeadline)
|
|
.add("activeStartTime", activeStartTime)
|
|
.add("activeEndTime", activeEndTime)
|
|
.add("activeScore", activeScore)
|
|
.add("forumType", ForumType.active.name())
|
|
.build());
|
|
}
|
|
|
|
//发送投诉贴
|
|
@HttpRequest("/forum/sendComplain")
|
|
public void sendComplain(MutableLiveData<ForumPostResponse> liveData, String title, String content, String complain) {
|
|
HttpUtil.getRequest(HttpUtil.Method.POST,
|
|
new SimpleHttpParse<ForumPostResponse>(liveData).getInterface(ForumPostResponse.class),
|
|
LocalToken.create()
|
|
.add("title", title)
|
|
.add("content", content)
|
|
.add("complain", complain)
|
|
.add("forumType", ForumType.complan.name())
|
|
.build());
|
|
}
|
|
|
|
//发送动态贴
|
|
@HttpRequest("/forum/sendTopic")
|
|
public void sendTopic(MutableLiveData<ForumPostResponse> liveData, String title, String content) {
|
|
HttpUtil.getRequest(HttpUtil.Method.POST,
|
|
new SimpleHttpParse<ForumPostResponse>(liveData).getInterface(ForumPostResponse.class),
|
|
LocalToken.create()
|
|
.add("title", title)
|
|
.add("content", content)
|
|
.add("forumType", ForumType.topic.name())
|
|
.build());
|
|
}
|
|
|
|
//检索投诉人
|
|
@HttpRequest("/query/user")
|
|
public void searchPeople(MutableLiveData<QueryUserResponse> liveData, String name) {
|
|
HttpUtil.getRequest(HttpUtil.Method.GET,
|
|
new SimpleHttpParse<QueryUserResponse>(liveData).getInterface(QueryUserResponse.class),
|
|
new FormBody.Builder()
|
|
.add("name", name)
|
|
.add("username", LocalToken.getUsername())
|
|
.build());
|
|
}
|
|
|
|
//发送结算贴
|
|
@HttpRequest("/forum/sendScore")
|
|
public void sendScore(MutableLiveData<ForumPostResponse> liveData, String title, String content, String activeScore) {
|
|
HttpUtil.getRequest(HttpUtil.Method.POST,
|
|
new SimpleHttpParse<ForumPostResponse>(liveData).getInterface(ForumPostResponse.class),
|
|
LocalToken.create()
|
|
.add("title", title)
|
|
.add("content", content)
|
|
.add("activeScore", activeScore)
|
|
.add("forumType", ForumType.score.name())
|
|
.build());
|
|
}
|
|
}
|
|
|