|
@@ -8,6 +8,7 @@ import com.google.gson.reflect.TypeToken;
|
|
|
import com.happy.Model.*;
|
|
import com.happy.Model.*;
|
|
|
import com.happy.Model.weixin.Users;
|
|
import com.happy.Model.weixin.Users;
|
|
|
import com.happy.Until.*;
|
|
import com.happy.Until.*;
|
|
|
|
|
+import com.happy.Until.Enum.DataType;
|
|
|
import com.happy.common.controller.BaseController;
|
|
import com.happy.common.controller.BaseController;
|
|
|
import com.happy.common.http.HttpsClient;
|
|
import com.happy.common.http.HttpsClient;
|
|
|
import com.happy.constant.ConstDefault;
|
|
import com.happy.constant.ConstDefault;
|
|
@@ -50,27 +51,27 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
public ArticleTweetService articleTweetService;
|
|
public ArticleTweetService articleTweetService;
|
|
|
-
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
public HousePriceService housePriceService;
|
|
public HousePriceService housePriceService;
|
|
|
-
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
public HotelDictService hotelDictService;
|
|
public HotelDictService hotelDictService;
|
|
|
-
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
public WorkflowService workflowService;
|
|
public WorkflowService workflowService;
|
|
|
-
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
public HouseService houseService;
|
|
public HouseService houseService;
|
|
|
-
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
public UserService userService;
|
|
public UserService userService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ public AdminManagerService adminManagerService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ public AdminService adminService;
|
|
|
|
|
|
|
|
public String key;
|
|
public String key;
|
|
|
-
|
|
|
|
|
public String startTime;
|
|
public String startTime;
|
|
|
-
|
|
|
|
|
public String endTime;
|
|
public String endTime;
|
|
|
|
|
+ public String keyWord;
|
|
|
|
|
+ public String userName;
|
|
|
|
|
+ public String adminId;
|
|
|
|
|
|
|
|
public String getKey() {
|
|
public String getKey() {
|
|
|
return key;
|
|
return key;
|
|
@@ -96,6 +97,30 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
this.endTime = endTime;
|
|
this.endTime = endTime;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String getKeyWord() {
|
|
|
|
|
+ return keyWord;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setKeyWord(String keyWord) {
|
|
|
|
|
+ this.keyWord = keyWord;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public String getUserName() {
|
|
|
|
|
+ return userName;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setUserName(String userName) {
|
|
|
|
|
+ this.userName = userName;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public String getAdminId() {
|
|
|
|
|
+ return adminId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setAdminId(String adminId) {
|
|
|
|
|
+ this.adminId = adminId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 推文发布
|
|
* 推文发布
|
|
|
*/
|
|
*/
|
|
@@ -105,7 +130,6 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
|
|
com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
|
|
|
ArticleTweetDto articleTweetDto = gson.fromJson(json.toString(), new TypeToken<ArticleTweetDto>() {
|
|
ArticleTweetDto articleTweetDto = gson.fromJson(json.toString(), new TypeToken<ArticleTweetDto>() {
|
|
|
}.getType());
|
|
}.getType());
|
|
|
-
|
|
|
|
|
//图片和视频判断
|
|
//图片和视频判断
|
|
|
if (articleTweetDto.getImages() == null && articleTweetDto.getVideo() == null) {
|
|
if (articleTweetDto.getImages() == null && articleTweetDto.getVideo() == null) {
|
|
|
jsonObject.put("code", 500);
|
|
jsonObject.put("code", 500);
|
|
@@ -132,10 +156,8 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
//推文发布参数
|
|
//推文发布参数
|
|
|
System.out.println("推文发布参数:" + JSON.toJSON(articleTweetDto));
|
|
System.out.println("推文发布参数:" + JSON.toJSON(articleTweetDto));
|
|
|
-
|
|
|
|
|
//查询当前用户
|
|
//查询当前用户
|
|
|
Users user = userService.queryByUserId(String.valueOf(articleTweetDto.getCreateId()));
|
|
Users user = userService.queryByUserId(String.valueOf(articleTweetDto.getCreateId()));
|
|
|
if (user == null) {
|
|
if (user == null) {
|
|
@@ -145,7 +167,6 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
Date now = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
|
|
Date now = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
|
|
|
try {
|
|
try {
|
|
|
//添加推文
|
|
//添加推文
|
|
@@ -159,6 +180,8 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
data.setCreateDate(now);
|
|
data.setCreateDate(now);
|
|
|
data.setApprove(1);//正在审批
|
|
data.setApprove(1);//正在审批
|
|
|
data.setStatus(1);
|
|
data.setStatus(1);
|
|
|
|
|
+ data.setPublishWay("小程序");
|
|
|
|
|
+ data.setIsTop(0);
|
|
|
data.setUserName(user.getUser_name());
|
|
data.setUserName(user.getUser_name());
|
|
|
data.setUserPhoto(user.getHeadPhoto() == null ? ConstDefault.DefaultHeadPhoto : user.getHeadPhoto());
|
|
data.setUserPhoto(user.getHeadPhoto() == null ? ConstDefault.DefaultHeadPhoto : user.getHeadPhoto());
|
|
|
int aId = articleTweetService.insert(data);
|
|
int aId = articleTweetService.insert(data);
|
|
@@ -170,15 +193,15 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
|
|
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
//添加附件
|
|
//添加附件
|
|
|
List<String> fileStr = new ArrayList<>();
|
|
List<String> fileStr = new ArrayList<>();
|
|
|
if (articleTweetDto.getImages() != null && articleTweetDto.getImages().size() > 0) {
|
|
if (articleTweetDto.getImages() != null && articleTweetDto.getImages().size() > 0) {
|
|
|
fileStr = articleTweetDto.getImages();
|
|
fileStr = articleTweetDto.getImages();
|
|
|
- } else {
|
|
|
|
|
- fileStr.add(articleTweetDto.getVideo());
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ List<String> fileStrVideo = new ArrayList<>();
|
|
|
|
|
+ if (articleTweetDto.getVideo() != null && articleTweetDto.getVideo().length() > 0) {
|
|
|
|
|
+ fileStrVideo.add(articleTweetDto.getVideo());
|
|
|
|
|
+ }
|
|
|
List<ArticleFileInfo> afis = new ArrayList<>();
|
|
List<ArticleFileInfo> afis = new ArrayList<>();
|
|
|
for (String f : fileStr) {
|
|
for (String f : fileStr) {
|
|
|
String[] split = f.split("/");
|
|
String[] split = f.split("/");
|
|
@@ -189,6 +212,19 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
afi.setType(1);
|
|
afi.setType(1);
|
|
|
afi.setUrl(f);
|
|
afi.setUrl(f);
|
|
|
afi.setCreateDate(now);
|
|
afi.setCreateDate(now);
|
|
|
|
|
+ afi.setFileType(1);
|
|
|
|
|
+ afis.add(afi);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (String f : fileStrVideo) {
|
|
|
|
|
+ String[] split = f.split("/");
|
|
|
|
|
+ String fileName = split[split.length - 1];
|
|
|
|
|
+ ArticleFileInfo afi = new ArticleFileInfo();
|
|
|
|
|
+ afi.setLinkId(aId);
|
|
|
|
|
+ afi.setName(fileName);
|
|
|
|
|
+ afi.setType(1);
|
|
|
|
|
+ afi.setUrl(f);
|
|
|
|
|
+ afi.setCreateDate(now);
|
|
|
|
|
+ afi.setFileType(2);
|
|
|
afis.add(afi);
|
|
afis.add(afi);
|
|
|
}
|
|
}
|
|
|
int length = articleTweetService.insertArticleFileBatch(afis);
|
|
int length = articleTweetService.insertArticleFileBatch(afis);
|
|
@@ -199,7 +235,6 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
}}.toString());
|
|
}}.toString());
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
//添加流程
|
|
//添加流程
|
|
|
Workflow workflow = new Workflow();
|
|
Workflow workflow = new Workflow();
|
|
|
String id = String.valueOf(UUID.randomUUID());
|
|
String id = String.valueOf(UUID.randomUUID());
|
|
@@ -227,8 +262,307 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
}}.toString());
|
|
}}.toString());
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
|
|
|
+ put("message", "推文发布成功");
|
|
|
|
|
+ put("code", 200);
|
|
|
|
|
+ }}.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 管理端推文发布
|
|
|
|
|
+ */
|
|
|
|
|
+ public String insertArticleTweetMana() throws ParseException {
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
|
|
|
|
|
+ ArticleTweetDto articleTweetDto = gson.fromJson(json.toString(), new TypeToken<ArticleTweetDto>() {
|
|
|
|
|
+ }.getType());
|
|
|
|
|
+ //图片和视频判断
|
|
|
|
|
+ if (articleTweetDto.getImages() == null && articleTweetDto.getVideo() == null) {
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "请上传图片或视频");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ //图片最多上传九张
|
|
|
|
|
+ if (articleTweetDto.getImages() != null && articleTweetDto.getImages().size() > 9) {
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "最多上传9张图片");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ //标题、内容、地点、关联民宿不能为空
|
|
|
|
|
+ if (Func.checkNull(articleTweetDto.getTitle()) || Func.checkNull(articleTweetDto.getContent())
|
|
|
|
|
+ || Func.checkNull(articleTweetDto.getTownId()) || articleTweetDto.getHotelIds() == null
|
|
|
|
|
+ || articleTweetDto.getCreateId() == null) {
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "参数不能为空");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ //推文发布参数
|
|
|
|
|
+ System.out.println("推文发布参数:" + JSON.toJSON(articleTweetDto));
|
|
|
|
|
+
|
|
|
|
|
+ //查询当前用户
|
|
|
|
|
+ Users user = userService.queryByUserId(String.valueOf(articleTweetDto.getCreateId()));
|
|
|
|
|
+ if (user == null) {
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "用户信息已失效,查看详情失败");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<ArticleTweet> articleTweets = articleTweetService.queryTops();
|
|
|
|
|
+ if (articleTweets!=null && articleTweets.size()>=3 && articleTweetDto.getIsTop()==1){
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "置顶攻略不可超过3个");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ Date now = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
|
|
|
|
|
+ try {
|
|
|
|
|
+ //添加推文
|
|
|
|
|
+ ArticleTweet data = new ArticleTweet();
|
|
|
|
|
+ data.setUserId(articleTweetDto.getCreateId());
|
|
|
|
|
+ data.setTitle(articleTweetDto.getTitle());
|
|
|
|
|
+ data.setContent(articleTweetDto.getContent());
|
|
|
|
|
+ data.setLocationId(articleTweetDto.getTownId());
|
|
|
|
|
+ data.setHotelId(StringUtils.join(articleTweetDto.getHotelIds(), ","));
|
|
|
|
|
+ data.setCreateId(articleTweetDto.getCreateId());
|
|
|
|
|
+ data.setCreateDate(now);
|
|
|
|
|
+ data.setApprove(2);//正在审批
|
|
|
|
|
+ data.setStatus(1);
|
|
|
|
|
+ data.setPublishWay("管理端");
|
|
|
|
|
+ data.setIsTop(articleTweetDto.getIsTop());
|
|
|
|
|
+ data.setUserName(user.getUser_name());
|
|
|
|
|
+ data.setUserPhoto(user.getHeadPhoto() == null ? ConstDefault.DefaultHeadPhoto : user.getHeadPhoto());
|
|
|
|
|
+ int aId = articleTweetService.insert(data);
|
|
|
|
|
+ if (aId <= 0) {
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
|
|
|
+ put("message", "推文发布失败");
|
|
|
|
|
+ put("code", 500);
|
|
|
|
|
+ }}.toString());
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ //添加附件
|
|
|
|
|
+ List<String> fileStr = new ArrayList<>();
|
|
|
|
|
+ if (articleTweetDto.getImages() != null && articleTweetDto.getImages().size() > 0) {
|
|
|
|
|
+ fileStr = articleTweetDto.getImages();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<String> fileStrVideo = new ArrayList<>();
|
|
|
|
|
+ if (articleTweetDto.getVideo() != null && articleTweetDto.getVideo().length() > 0) {
|
|
|
|
|
+ fileStrVideo.add(articleTweetDto.getVideo());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<ArticleFileInfo> afis = new ArrayList<>();
|
|
|
|
|
+ for (String f : fileStr) {
|
|
|
|
|
+ String[] split = f.split("/");
|
|
|
|
|
+ String fileName = split[split.length - 1];
|
|
|
|
|
+ ArticleFileInfo afi = new ArticleFileInfo();
|
|
|
|
|
+ afi.setLinkId(aId);
|
|
|
|
|
+ afi.setName(fileName);
|
|
|
|
|
+ afi.setType(1);
|
|
|
|
|
+ afi.setUrl(f);
|
|
|
|
|
+ afi.setCreateDate(now);
|
|
|
|
|
+ afi.setFileType(1);
|
|
|
|
|
+ afis.add(afi);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (String f : fileStrVideo) {
|
|
|
|
|
+ String[] split = f.split("/");
|
|
|
|
|
+ String fileName = split[split.length - 1];
|
|
|
|
|
+ ArticleFileInfo afi = new ArticleFileInfo();
|
|
|
|
|
+ afi.setLinkId(aId);
|
|
|
|
|
+ afi.setName(fileName);
|
|
|
|
|
+ afi.setType(1);
|
|
|
|
|
+ afi.setUrl(f);
|
|
|
|
|
+ afi.setCreateDate(now);
|
|
|
|
|
+ afi.setFileType(2);
|
|
|
|
|
+ afis.add(afi);
|
|
|
|
|
+ }
|
|
|
|
|
+ int length = articleTweetService.insertArticleFileBatch(afis);
|
|
|
|
|
+ if (length <= 0) {
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
|
|
|
+ put("message", "推文附件新增失败");
|
|
|
|
|
+ put("code", 500);
|
|
|
|
|
+ }}.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ //添加流程
|
|
|
|
|
+ Workflow workflow = new Workflow();
|
|
|
|
|
+ String id = String.valueOf(UUID.randomUUID());
|
|
|
|
|
+ workflow.setLinkId(String.valueOf(aId));//存推文的ID
|
|
|
|
|
+ workflow.setCreateId(String.valueOf(articleTweetDto.getCreateId()));
|
|
|
|
|
+ workflow.setTitle(articleTweetDto.getTitle());
|
|
|
|
|
+ workflow.setRemark(articleTweetDto.getContent());
|
|
|
|
|
+ workflow.setId(id);
|
|
|
|
|
+ workflow.setStatus(2);//1是正在审批
|
|
|
|
|
+ workflow.setType(3);//3是推文
|
|
|
|
|
+ workflow.setCoverImg(articleTweetDto.getImages() != null && articleTweetDto.getImages().size() > 0 ? articleTweetDto.getImages().get(0) : articleTweetDto.getVideo());
|
|
|
|
|
+ int i = workflowService.insert(workflow);
|
|
|
|
|
+ if (i <= 0) {
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
|
|
|
+ put("message", "推文流程发布失败");
|
|
|
|
|
+ put("code", 500);
|
|
|
|
|
+ }}.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ System.out.println("推文发布异常:" + e.getMessage());
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
|
|
|
+ put("message", "推文发布异常");
|
|
|
|
|
+ put("code", 500);
|
|
|
|
|
+ }}.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
|
|
|
+ put("message", "推文发布成功");
|
|
|
|
|
+ put("code", 200);
|
|
|
|
|
+ }}.toString());
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 管理端修改推文
|
|
|
|
|
+ */
|
|
|
|
|
+ public String updateArticleTweetMana() throws ParseException {
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
|
|
|
|
|
+ ArticleTweetDto articleTweetDto = gson.fromJson(json.toString(), new TypeToken<ArticleTweetDto>() {
|
|
|
|
|
+ }.getType());
|
|
|
|
|
+ //图片和视频判断
|
|
|
|
|
+ if (articleTweetDto.getImages() == null && articleTweetDto.getVideo() == null) {
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "请上传图片或视频");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ //图片最多上传九张
|
|
|
|
|
+ if (articleTweetDto.getImages() != null && articleTweetDto.getImages().size() > 9) {
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "最多上传9张图片");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ //标题、内容、地点、关联民宿不能为空
|
|
|
|
|
+ if (Func.checkNull(articleTweetDto.getTitle()) || Func.checkNull(articleTweetDto.getContent())
|
|
|
|
|
+ || Func.checkNull(articleTweetDto.getTownId()) || articleTweetDto.getHotelIds() == null
|
|
|
|
|
+ || articleTweetDto.getCreateId() == null || articleTweetDto.getId()==null) {
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "参数不能为空");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ //推文发布参数
|
|
|
|
|
+ System.out.println("推文发布参数:" + JSON.toJSON(articleTweetDto));
|
|
|
|
|
|
|
|
|
|
+ //查询当前用户
|
|
|
|
|
+ Users user = userService.queryByUserId(String.valueOf(articleTweetDto.getCreateId()));
|
|
|
|
|
+ if (user == null) {
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "用户信息已失效,查看详情失败");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<ArticleTweet> articleTweets = articleTweetService.queryTops();
|
|
|
|
|
+ if (articleTweets!=null && articleTweets.size()>=3 && articleTweetDto.getIsTop()==1){
|
|
|
|
|
+ List<Integer> ids = articleTweets.stream().map(ArticleTweet::getId).collect(Collectors.toList());
|
|
|
|
|
+ if (!ids.contains(articleTweetDto.getId())){
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "置顶攻略不可超过3个");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ Date now = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
|
|
|
|
|
+ try {
|
|
|
|
|
+ //添加推文
|
|
|
|
|
+ ArticleTweet data = new ArticleTweet();
|
|
|
|
|
+ data.setId(articleTweetDto.getId());
|
|
|
|
|
+ data.setUserId(articleTweetDto.getCreateId());
|
|
|
|
|
+ data.setTitle(articleTweetDto.getTitle());
|
|
|
|
|
+ data.setContent(articleTweetDto.getContent());
|
|
|
|
|
+ data.setLocationId(articleTweetDto.getTownId());
|
|
|
|
|
+ data.setHotelId(StringUtils.join(articleTweetDto.getHotelIds(), ","));
|
|
|
|
|
+ data.setCreateId(articleTweetDto.getCreateId());
|
|
|
|
|
+ data.setCreateDate(now);
|
|
|
|
|
+ data.setApprove(2);//1正在审批
|
|
|
|
|
+ data.setStatus(1);
|
|
|
|
|
+ data.setPublishWay("管理端");
|
|
|
|
|
+ data.setIsTop(articleTweetDto.getIsTop());
|
|
|
|
|
+ data.setUserName(user.getUser_name());
|
|
|
|
|
+ data.setUserPhoto(user.getHeadPhoto() == null ? ConstDefault.DefaultHeadPhoto : user.getHeadPhoto());
|
|
|
|
|
+ int aId = articleTweetService.update(data);
|
|
|
|
|
+ if (aId <= 0) {
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
|
|
|
+ put("message", "推文发布失败");
|
|
|
|
|
+ put("code", 500);
|
|
|
|
|
+ }}.toString());
|
|
|
|
|
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ articleTweetService.delArticleFile(articleTweetDto.getId());
|
|
|
|
|
+ //添加附件
|
|
|
|
|
+ List<String> fileStr = new ArrayList<>();
|
|
|
|
|
+ if (articleTweetDto.getImages() != null && articleTweetDto.getImages().size() > 0) {
|
|
|
|
|
+ fileStr = articleTweetDto.getImages();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<String> fileStrVideo = new ArrayList<>();
|
|
|
|
|
+ if (articleTweetDto.getVideo() != null && articleTweetDto.getVideo().length() > 0) {
|
|
|
|
|
+ fileStrVideo.add(articleTweetDto.getVideo());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<ArticleFileInfo> afis = new ArrayList<>();
|
|
|
|
|
+ for (String f : fileStr) {
|
|
|
|
|
+ String[] split = f.split("/");
|
|
|
|
|
+ String fileName = split[split.length - 1];
|
|
|
|
|
+ ArticleFileInfo afi = new ArticleFileInfo();
|
|
|
|
|
+ afi.setLinkId(aId);
|
|
|
|
|
+ afi.setName(fileName);
|
|
|
|
|
+ afi.setType(1);
|
|
|
|
|
+ afi.setUrl(f);
|
|
|
|
|
+ afi.setCreateDate(now);
|
|
|
|
|
+ afi.setFileType(1);
|
|
|
|
|
+ afis.add(afi);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (String f : fileStrVideo) {
|
|
|
|
|
+ String[] split = f.split("/");
|
|
|
|
|
+ String fileName = split[split.length - 1];
|
|
|
|
|
+ ArticleFileInfo afi = new ArticleFileInfo();
|
|
|
|
|
+ afi.setLinkId(aId);
|
|
|
|
|
+ afi.setName(fileName);
|
|
|
|
|
+ afi.setType(1);
|
|
|
|
|
+ afi.setUrl(f);
|
|
|
|
|
+ afi.setCreateDate(now);
|
|
|
|
|
+ afi.setFileType(2);
|
|
|
|
|
+ afis.add(afi);
|
|
|
|
|
+ }
|
|
|
|
|
+ int length = articleTweetService.insertArticleFileBatch(afis);
|
|
|
|
|
+ if (length <= 0) {
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
|
|
|
+ put("message", "推文附件新增失败");
|
|
|
|
|
+ put("code", 500);
|
|
|
|
|
+ }}.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ System.out.println("推文发布异常:" + e.getMessage());
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
|
|
|
+ put("message", "推文发布异常");
|
|
|
|
|
+ put("code", 500);
|
|
|
|
|
+ }}.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
|
put("message", "推文发布成功");
|
|
put("message", "推文发布成功");
|
|
|
put("code", 200);
|
|
put("code", 200);
|
|
@@ -237,6 +571,178 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 操作推文-删除文件
|
|
|
|
|
+ public String delFile(){
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
|
|
|
|
|
+ Integer id = json.getInteger("id");
|
|
|
|
|
+ int m = articleTweetService.delArticleFileBatch(id);
|
|
|
|
|
+ if (m>0){
|
|
|
|
|
+ jsonObject.put("code", 200);
|
|
|
|
|
+ jsonObject.put("message", "删除成功");
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "删除失败");
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 操作推文-增加文件
|
|
|
|
|
+ public String addFile() throws ParseException {
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
|
|
|
|
|
+ Integer id = json.getInteger("id");
|
|
|
|
|
+ String images = json.getString("images");
|
|
|
|
|
+ String video = json.getString("video");
|
|
|
|
|
+ //图片和视频判断
|
|
|
|
|
+ if (images.equals("") && video.equals("")) {
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "请上传图片或视频");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ String fileStr = "";
|
|
|
|
|
+ if (!images.equals("")) {
|
|
|
|
|
+ fileStr=images;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fileStr=video;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Date now = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
|
|
|
|
|
+ String[] split = fileStr.split("/");
|
|
|
|
|
+ String fileName = split[split.length - 1];
|
|
|
|
|
+ ArticleFileInfo afi = new ArticleFileInfo();
|
|
|
|
|
+ afi.setLinkId(id);
|
|
|
|
|
+ afi.setName(fileName);
|
|
|
|
|
+ afi.setType(1);
|
|
|
|
|
+ afi.setUrl(fileStr);
|
|
|
|
|
+ afi.setCreateDate(now);
|
|
|
|
|
+ int length = articleTweetService.insertArticleFile(afi);
|
|
|
|
|
+ if (length <= 0) {
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
|
|
|
+ put("message", "新增失败");
|
|
|
|
|
+ put("code", 500);
|
|
|
|
|
+ put("data", null);
|
|
|
|
|
+ }}.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
|
|
|
|
|
+ put("message", "新增成功");
|
|
|
|
|
+ put("code", 200);
|
|
|
|
|
+ put("data", length);
|
|
|
|
|
+ }}.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 删除推文
|
|
|
|
|
+ public String delArticle(){
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
|
|
|
|
|
+ Integer id = json.getInteger("id");
|
|
|
|
|
+ int m = articleTweetService.delArticle(id);
|
|
|
|
|
+ int n = articleTweetService.delArticleFile(id);
|
|
|
|
|
+ if (m>0 && n>0){
|
|
|
|
|
+ jsonObject.put("code", 200);
|
|
|
|
|
+ jsonObject.put("message", "删除成功");
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "删除失败");
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 置顶推文
|
|
|
|
|
+ public String topArticle() throws ParseException {
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
|
|
|
|
|
+ ArticleTweetDto articleTweetDto = gson.fromJson(json.toString(), new TypeToken<ArticleTweetDto>() {}.getType());
|
|
|
|
|
+ List<ArticleTweet> articleTweets = articleTweetService.queryTops();
|
|
|
|
|
+ if (articleTweets!=null && articleTweets.size()>=3 && articleTweetDto.getIsTop()==1){
|
|
|
|
|
+ List<Integer> ids = articleTweets.stream().map(ArticleTweet::getId).collect(Collectors.toList());
|
|
|
|
|
+ if (!ids.contains(articleTweetDto.getId())){
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "置顶攻略不可超过3个");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ Date now = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
|
|
|
|
|
+ articleTweetDto.setCreateDate(now);
|
|
|
|
|
+ int m = articleTweetService.updateArticleTop(articleTweetDto);
|
|
|
|
|
+ if (m>0){
|
|
|
|
|
+ jsonObject.put("code", 200);
|
|
|
|
|
+ jsonObject.put("message", "修改成功");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "修改失败");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public String queryManageArticlePage() {
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ IPage<ArticleListVo> result = articleTweetService.queryManageArticlesPage(articleTweetDto.getKeyWord(), null, page, rows);
|
|
|
|
|
+ if (result.getPageList().size() > 0) {
|
|
|
|
|
+ String articleIds = StringUtils.join(result.getPageList().stream().map(ArticleListVo::getId).collect(Collectors.toList()), ",");
|
|
|
|
|
+ List<FileInfo> fileInfos = articleTweetService.queryList("and link_id in (" + articleIds + ")");
|
|
|
|
|
+
|
|
|
|
|
+ for (ArticleListVo data : result.getPageList()) {
|
|
|
|
|
+ if (fileInfos != null) {
|
|
|
|
|
+ List<FileInfo> fileInfoList = fileInfos.stream().filter(e -> e.getLinkId().equals(data.getId().toString())).collect(Collectors.toList());
|
|
|
|
|
+ if (fileInfoList.size()>0) {
|
|
|
|
|
+ List<String> fileUrl = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < fileInfoList.size(); i++) {
|
|
|
|
|
+ FileInfo fileInfo = fileInfoList.get(i);
|
|
|
|
|
+ if (fileInfo.getFileType()==1){
|
|
|
|
|
+ fileUrl.add(fileInfo.getUrl());
|
|
|
|
|
+ data.setImage(fileUrl);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ data.setVideo(fileInfo.getUrl());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ jsonObject.put("code", ResultStatusCode.OK.getStatus());
|
|
|
|
|
+ jsonObject.put("message", "请求成功");
|
|
|
|
|
+ jsonObject.put("data", result);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public String bindUser(){
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
|
|
|
|
|
+ Admin admin = new Admin();
|
|
|
|
|
+ admin.setId(json.getInteger("id"));
|
|
|
|
|
+ admin.setUserId(json.getString("userId"));
|
|
|
|
|
+ int m = articleTweetService.updateUser(admin);
|
|
|
|
|
+ if (m>0){
|
|
|
|
|
+ jsonObject.put("code", ResultStatusCode.OK.getStatus());
|
|
|
|
|
+ jsonObject.put("message", "绑定成功");
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "绑定失败");
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据推文数据ID查询推文详情数据
|
|
* 根据推文数据ID查询推文详情数据
|
|
@@ -278,21 +784,18 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
result.setIsCollect(data.getIsCollect());
|
|
result.setIsCollect(data.getIsCollect());
|
|
|
result.setId(data.getId());
|
|
result.setId(data.getId());
|
|
|
List<FileInfo> fileInfoList = articleTweetService.queryList("and link_id = '" + articleTweetDto.getId() + "'");
|
|
List<FileInfo> fileInfoList = articleTweetService.queryList("and link_id = '" + articleTweetDto.getId() + "'");
|
|
|
- if (fileInfoList != null) {
|
|
|
|
|
- if (fileInfoList.size() > 1) {
|
|
|
|
|
- result.setImages(fileInfoList.stream().map(FileInfo::getUrl).collect(Collectors.toList()));
|
|
|
|
|
- } else if (fileInfoList.size() == 1) {
|
|
|
|
|
- String url = fileInfoList.get(0).getUrl();
|
|
|
|
|
- if (!url.endsWith("jpg") && !url.endsWith("png")) {
|
|
|
|
|
- result.setVideo(fileInfoList.get(0).getUrl());
|
|
|
|
|
|
|
+ if (fileInfoList != null && fileInfoList.size()>0) {
|
|
|
|
|
+ List<String> fileUrl = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < fileInfoList.size(); i++) {
|
|
|
|
|
+ FileInfo fileInfo = fileInfoList.get(i);
|
|
|
|
|
+ if (fileInfo.getFileType()==1){
|
|
|
|
|
+ fileUrl.add(fileInfo.getUrl());
|
|
|
|
|
+ result.setImages(fileUrl);
|
|
|
} else {
|
|
} else {
|
|
|
- List<String> images = new ArrayList<>();
|
|
|
|
|
- images.add(url);
|
|
|
|
|
- result.setImages(images);
|
|
|
|
|
|
|
+ result.setVideo(fileInfo.getUrl());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
result.setUserId(data.getUserId());
|
|
result.setUserId(data.getUserId());
|
|
|
result.setUserName(data.getUserName());
|
|
result.setUserName(data.getUserName());
|
|
|
result.setUserPhoto(data.getUserPhoto() == null ? ConstDefault.DefaultHeadPhoto : data.getUserPhoto());
|
|
result.setUserPhoto(data.getUserPhoto() == null ? ConstDefault.DefaultHeadPhoto : data.getUserPhoto());
|
|
@@ -684,7 +1187,6 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
jsonObject.put("message", "请求成功");
|
|
jsonObject.put("message", "请求成功");
|
|
|
jsonObject.put("data", result);
|
|
jsonObject.put("data", result);
|
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
-
|
|
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -716,17 +1218,15 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
|
|
|
|
|
for (OwnerArticleVo data : result.getPageList()) {
|
|
for (OwnerArticleVo data : result.getPageList()) {
|
|
|
List<FileInfo> fileInfoList = fileInfos == null ? null : fileInfos.stream().filter(e -> e.getLinkId().equals(data.getId().toString())).collect(Collectors.toList());
|
|
List<FileInfo> fileInfoList = fileInfos == null ? null : fileInfos.stream().filter(e -> e.getLinkId().equals(data.getId().toString())).collect(Collectors.toList());
|
|
|
- if (fileInfoList != null) {
|
|
|
|
|
- if (fileInfoList.size() > 1) {
|
|
|
|
|
- data.setImages(fileInfoList.stream().map(FileInfo::getUrl).collect(Collectors.toList()));
|
|
|
|
|
- } else if (fileInfoList.size() == 1) {
|
|
|
|
|
- String url = fileInfoList.get(0).getUrl();
|
|
|
|
|
- if (!url.endsWith("jpg") && !url.endsWith("png")) {
|
|
|
|
|
- data.setVideo(fileInfoList.get(0).getUrl());
|
|
|
|
|
- } else {
|
|
|
|
|
- List<String> images = new ArrayList<>();
|
|
|
|
|
- images.add(url);
|
|
|
|
|
- data.setImages(images);
|
|
|
|
|
|
|
+ if (fileInfoList != null && fileInfoList.size()>0) {
|
|
|
|
|
+ for (int i = 0; i < fileInfoList.size(); i++) {
|
|
|
|
|
+ FileInfo fileInfo = fileInfoList.get(i);
|
|
|
|
|
+ List<String> fileUrl = new ArrayList<>();
|
|
|
|
|
+ if (fileInfo.getFileType()==1){
|
|
|
|
|
+ fileUrl.add(fileInfo.getUrl());
|
|
|
|
|
+ data.setImages(fileUrl);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ data.setVideo(fileInfo.getUrl());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -741,6 +1241,67 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String getUserContactList() {
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ if (adminId == null ){
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "请传入管理员ID");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ Admin admin = adminService.getById(Integer.parseInt(adminId));
|
|
|
|
|
+ if (admin==null || admin.getStatus()==0){
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "该管理员已删除");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ StringBuilder querySql = new StringBuilder("");
|
|
|
|
|
+ if (!Func.checkNull(articleTweetDto.getUserName())) {
|
|
|
|
|
+ querySql.append(" and user_name like '%").append(articleTweetDto.getUserName()).append("%' ");
|
|
|
|
|
+ }
|
|
|
|
|
+ querySql.append(" and data_type = '").append(DataType.游客数据.toString()).append("' ");
|
|
|
|
|
+ if (admin.getUserId()!=null && !admin.getUserId().equals("")){
|
|
|
|
|
+ querySql.append(" and id in ( ").append(admin.getUserId()).append(") ");
|
|
|
|
|
+ }
|
|
|
|
|
+ IPage listPage = userService.queryUserPage(querySql.toString(), page, rows); // 查询分页
|
|
|
|
|
+ ResponseUtil.writeJsonIPage(ServletActionContext.getResponse(), listPage);
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public String getAllUserList() {
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ if (adminId == null ){
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "请传入管理员ID");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ Admin admin = adminService.getById(Integer.parseInt(adminId));
|
|
|
|
|
+ if (admin==null || admin.getStatus()==0){
|
|
|
|
|
+ jsonObject.put("code", 500);
|
|
|
|
|
+ jsonObject.put("message", "该管理员已删除");
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ StringBuilder querySql = new StringBuilder("");
|
|
|
|
|
+ if (!Func.checkNull(articleTweetDto.getUserName())) {
|
|
|
|
|
+ querySql.append(" and user_name like '%").append(articleTweetDto.getUserName()).append("%' ");
|
|
|
|
|
+ }
|
|
|
|
|
+ querySql.append(" and data_type = '").append(DataType.游客数据.toString()).append("' ");
|
|
|
|
|
+ if (admin.getUserId()!=null && admin.getUserId().length()>0){
|
|
|
|
|
+ querySql.append(" order by case when id in ( ").append(admin.getUserId()).append(") then 0 else 1 end");
|
|
|
|
|
+ }
|
|
|
|
|
+ IPage listPage = userService.queryUserPage2(querySql.toString(), page, rows,admin.getUserId()); // 查询分页
|
|
|
|
|
+ ResponseUtil.writeJsonIPage(ServletActionContext.getResponse(), listPage);
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 社区首页推文列表
|
|
* 社区首页推文列表
|
|
@@ -772,15 +1333,15 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
for (ArticleListVo data : result.getPageList()) {
|
|
for (ArticleListVo data : result.getPageList()) {
|
|
|
if (fileInfos != null) {
|
|
if (fileInfos != null) {
|
|
|
List<FileInfo> fileInfoList = fileInfos.stream().filter(e -> e.getLinkId().equals(data.getId().toString())).collect(Collectors.toList());
|
|
List<FileInfo> fileInfoList = fileInfos.stream().filter(e -> e.getLinkId().equals(data.getId().toString())).collect(Collectors.toList());
|
|
|
- if (fileInfoList != null) {
|
|
|
|
|
- if (fileInfoList.size() > 1) {
|
|
|
|
|
- data.setImage(fileInfoList.get(0).getUrl());
|
|
|
|
|
- } else if (fileInfoList.size() == 1) {
|
|
|
|
|
- String url = fileInfoList.get(0).getUrl();
|
|
|
|
|
- if (!url.endsWith("jpg") && !url.endsWith("png")) {
|
|
|
|
|
- data.setVideo(fileInfoList.get(0).getUrl());
|
|
|
|
|
|
|
+ if (fileInfoList.size() > 0) {
|
|
|
|
|
+ List<String> fileUrl = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < fileInfoList.size(); i++) {
|
|
|
|
|
+ FileInfo fileInfo = fileInfoList.get(i);
|
|
|
|
|
+ if (fileInfo.getFileType()==1){
|
|
|
|
|
+ fileUrl.add(fileInfo.getUrl());
|
|
|
|
|
+ data.setImage(fileUrl);
|
|
|
} else {
|
|
} else {
|
|
|
- data.setImage(url);
|
|
|
|
|
|
|
+ data.setVideo(fileInfo.getUrl());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -806,14 +1367,12 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
if (result != null) {
|
|
if (result != null) {
|
|
|
List<FileInfo> fileInfos = articleTweetService.queryList("and link_id = " + result.getId() + "");
|
|
List<FileInfo> fileInfos = articleTweetService.queryList("and link_id = " + result.getId() + "");
|
|
|
if (fileInfos != null) {
|
|
if (fileInfos != null) {
|
|
|
- if (fileInfos.size() > 1) {
|
|
|
|
|
- result.setImage(fileInfos.get(0).getUrl());
|
|
|
|
|
- } else if (fileInfos.size() == 1) {
|
|
|
|
|
- String url = fileInfos.get(0).getUrl();
|
|
|
|
|
- if (!url.endsWith("jpg") && !url.endsWith("png")) {
|
|
|
|
|
- result.setVideo(fileInfos.get(0).getUrl());
|
|
|
|
|
|
|
+ for (int i = 0; i < fileInfos.size(); i++) {
|
|
|
|
|
+ FileInfo fileInfo = fileInfos.get(i);
|
|
|
|
|
+ if (fileInfo.getFileType()==1){
|
|
|
|
|
+ result.setImage(fileInfo.getUrl());
|
|
|
} else {
|
|
} else {
|
|
|
- result.setImage(url);
|
|
|
|
|
|
|
+ result.setVideo(fileInfo.getUrl());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -848,15 +1407,15 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
|
|
|
|
|
for (ArticleListVo data : result.getPageList()) {
|
|
for (ArticleListVo data : result.getPageList()) {
|
|
|
List<FileInfo> fileInfoList = fileInfos.stream().filter(e -> e.getLinkId().equals(data.getId().toString())).collect(Collectors.toList());
|
|
List<FileInfo> fileInfoList = fileInfos.stream().filter(e -> e.getLinkId().equals(data.getId().toString())).collect(Collectors.toList());
|
|
|
- if (fileInfoList != null) {
|
|
|
|
|
- if (fileInfoList.size() > 1) {
|
|
|
|
|
- data.setImage(fileInfoList.get(0).getUrl());
|
|
|
|
|
- } else if (fileInfoList.size() == 1) {
|
|
|
|
|
- String url = fileInfoList.get(0).getUrl();
|
|
|
|
|
- if (!url.endsWith("jpg") && !url.endsWith("png")) {
|
|
|
|
|
- data.setVideo(fileInfoList.get(0).getUrl());
|
|
|
|
|
|
|
+ if (fileInfoList.size() > 0) {
|
|
|
|
|
+ List<String> fileUrl = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < fileInfoList.size(); i++) {
|
|
|
|
|
+ FileInfo fileInfo = fileInfoList.get(i);
|
|
|
|
|
+ if (fileInfo.getFileType()==1){
|
|
|
|
|
+ fileUrl.add(fileInfo.getUrl());
|
|
|
|
|
+ data.setImage(fileUrl);
|
|
|
} else {
|
|
} else {
|
|
|
- data.setImage(url);
|
|
|
|
|
|
|
+ data.setVideo(fileInfo.getUrl());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1274,5 +1833,32 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 点赞数前三的推文
|
|
|
|
|
+ */
|
|
|
|
|
+ public String queryTop3ArticleLike() {
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ List<ArticleLikeMaxVo> result = articleTweetService.queryTop3ArticleLike();
|
|
|
|
|
+ if (result != null) {
|
|
|
|
|
+ for (int i = 0; i < result.size(); i++) {
|
|
|
|
|
+ List<FileInfo> fileInfos = articleTweetService.queryList("and link_id = " + result.get(i).getId() + "");
|
|
|
|
|
+ if (fileInfos != null) {
|
|
|
|
|
+ for (int j = 0; j < fileInfos.size(); j++) {
|
|
|
|
|
+ FileInfo fileInfo = fileInfos.get(j);
|
|
|
|
|
+ if (fileInfo.getFileType()==1){
|
|
|
|
|
+ result.get(i).setImage(fileInfo.getUrl());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ result.get(i).setVideo(fileInfo.getUrl());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ jsonObject.put("code", ResultStatusCode.OK.getStatus());
|
|
|
|
|
+ jsonObject.put("message", "请求成功");
|
|
|
|
|
+ jsonObject.put("data", result);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|