|
|
@@ -1,42 +1,134 @@
|
|
|
package com.zhiqiyun.open.router.apis;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.dliyun.oap.framework.annotation.ServiceMethod;
|
|
|
import com.dliyun.oap.framework.annotation.ServiceMethodBean;
|
|
|
import com.dliyun.oap.framework.response.OapResponse;
|
|
|
-import com.zhiqiyun.open.core.models.UploadResult;
|
|
|
-import com.zhiqiyun.open.core.service.UploadFileInfoService;
|
|
|
-import com.zhiqiyun.open.router.request.UploaderBase64Request;
|
|
|
+import com.zhiqiyun.open.annotation.Permission;
|
|
|
+import com.zhiqiyun.open.core.models.statistics.PopularFeelings;
|
|
|
+import com.zhiqiyun.open.core.models.statistics.PopularFeelingsPage;
|
|
|
+import com.zhiqiyun.open.core.service.PopularFeelingsPageService;
|
|
|
+import com.zhiqiyun.open.core.service.PopularFeelingsService;
|
|
|
+import com.zhiqiyun.open.core.service.SequenceService;
|
|
|
+import com.zhiqiyun.open.mvc.Result;
|
|
|
+import com.zhiqiyun.open.mvc.params.statistics.QueryPopularFeelingsPageParam;
|
|
|
+import com.zhiqiyun.open.router.request.statistics.*;
|
|
|
+import com.zhiqiyun.open.utils.DateUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.codec.binary.Base64;
|
|
|
-import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Slf4j
|
|
|
@ServiceMethodBean
|
|
|
public class PopularFeelingsApi {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PopularFeelingsPageService popularFeelingsPageService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PopularFeelingsService popularFeelingsService;
|
|
|
+
|
|
|
@Autowired
|
|
|
- private UploadFileInfoService uploadFileInfoService;
|
|
|
+ private SequenceService sequenceService;
|
|
|
|
|
|
- @ServiceMethod(method = "uploader.handle.base64File", title = "文件上传")
|
|
|
- public OapResponse handleBase64File(@RequestBody UploaderBase64Request request) throws IOException {
|
|
|
+ @ServiceMethod(method = "popular.feelings.findPage", title = "互联网舆情监控查询")
|
|
|
+ public OapResponse findPage(QueryPopularFeelingsRequest request) {
|
|
|
|
|
|
- byte[] fileBuff = Base64.decodeBase64(request.getBase64File());
|
|
|
+ QueryWrapper<PopularFeelings> wrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(request.getTitle())) {
|
|
|
+ wrapper.like("title", request.getTitle());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(request.getKeywords())) {
|
|
|
+ wrapper.like("keywords", request.getKeywords());
|
|
|
+ }
|
|
|
|
|
|
- String originalFilename = request.getFilename();
|
|
|
- if (StringUtils.isBlank(originalFilename)) {
|
|
|
- originalFilename = String.format("%s.%s", DigestUtils.md5Hex(fileBuff), "png");
|
|
|
+ if (StringUtils.isNotBlank(request.getDomain())) {
|
|
|
+ wrapper.like("domain", request.getDomain());
|
|
|
}
|
|
|
|
|
|
- UploadResult uploadResult = this.uploadFileInfoService.handle(originalFilename, fileBuff);
|
|
|
+ Page<PopularFeelings> page = new Page<>(request.getCurrent(), request.getPageSize());
|
|
|
+ page.addOrder(OrderItem.desc("id"));
|
|
|
+
|
|
|
+ Page<PopularFeelings> resultData = this.popularFeelingsService.page(page, wrapper);
|
|
|
+
|
|
|
+ return OapResponse.success().setBody(resultData);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ServiceMethod(method = "popular.feelings.add", title = "新建舆情监控")
|
|
|
+ public OapResponse save(SavePopularFeelingsRequest request) {
|
|
|
+ PopularFeelings entity = new PopularFeelings();
|
|
|
+ BeanUtils.copyProperties(request, entity);
|
|
|
+
|
|
|
+ entity.setCreatedTime(DateUtil.current());
|
|
|
+ entity.setCreatedBy(1000L);
|
|
|
+
|
|
|
+ entity.setUpdatedTime(DateUtil.current());
|
|
|
+ entity.setUpdatedBy(1000L);
|
|
|
+ entity.setId(this.sequenceService.nextId());
|
|
|
+
|
|
|
+ this.popularFeelingsService.save(entity);
|
|
|
+
|
|
|
+ return OapResponse.success().setBody(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ServiceMethod(method = "popular.feelings.updateById", title = "更新舆情监控")
|
|
|
+ public OapResponse updateById(UpdatePopularFeelingsRequest request) {
|
|
|
+ PopularFeelings entity = new PopularFeelings();
|
|
|
+ BeanUtils.copyProperties(request, entity);
|
|
|
+
|
|
|
+ entity.setUpdatedBy(1000L);
|
|
|
+ entity.setUpdatedTime(DateUtil.current());
|
|
|
|
|
|
- if (uploadResult.isSuccess()) {
|
|
|
- return OapResponse.success().setBody(uploadResult);
|
|
|
- } else {
|
|
|
- return OapResponse.fail("UPLOAD_FAIL", uploadResult.getMessage());
|
|
|
+ this.popularFeelingsService.updateById(entity);
|
|
|
+
|
|
|
+ return OapResponse.success().setBody(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ServiceMethod(method = "popular.feelings.deleteByIds", title = "删除舆情监控")
|
|
|
+ public OapResponse deleteByIds(PopularFeelingsIdsRequest request) {
|
|
|
+ this.popularFeelingsService.removeByIds(request.getIds());
|
|
|
+ return OapResponse.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ServiceMethod(method = "popular.feelings.start", title = "启动舆情监控")
|
|
|
+ public OapResponse startSpider(PopularFeelingsIdsRequest request) {
|
|
|
+ List<PopularFeelings> listData = this.popularFeelingsService.listByIds(request.getIds());
|
|
|
+ for (PopularFeelings popularFeelings : listData) {
|
|
|
+ this.popularFeelingsService.start(popularFeelings);
|
|
|
}
|
|
|
+ return OapResponse.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ServiceMethod(method = "popular.feelings.stop", title = "停止舆情监控")
|
|
|
+ public OapResponse stopSpider(PopularFeelingsIdsRequest request) {
|
|
|
+ List<PopularFeelings> listData = this.popularFeelingsService.listByIds(request.getIds());
|
|
|
+ for (PopularFeelings popularFeelings : listData) {
|
|
|
+ this.popularFeelingsService.stop(popularFeelings);
|
|
|
+ }
|
|
|
+ return OapResponse.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ServiceMethod(method = "popular.feelings.findDetailPage", title = "分页查询舆情监控详情")
|
|
|
+ public OapResponse findDetailPage(QueryPopularFeelingsDetailPageRequest request) {
|
|
|
+
|
|
|
+ QueryWrapper<PopularFeelingsPage> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.select("id", "popular_feelings_id", "url", "title", "spider_time");
|
|
|
+ wrapper.eq("popular_feelings_id", request.getPopularFeelingsId());
|
|
|
+
|
|
|
+ Page<PopularFeelingsPage> page = new Page<>(request.getCurrent(), request.getPageSize());
|
|
|
+ page.addOrder(OrderItem.desc("id"));
|
|
|
+
|
|
|
+ Page<PopularFeelingsPage> resultData = this.popularFeelingsPageService.page(page, wrapper);
|
|
|
+
|
|
|
+ return OapResponse.success().setBody(resultData);
|
|
|
}
|
|
|
}
|