| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- 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.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.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.util.List;
- @Slf4j
- @ServiceMethodBean
- public class PopularFeelingsApi {
- @Autowired
- private PopularFeelingsPageService popularFeelingsPageService;
- @Autowired
- private PopularFeelingsService popularFeelingsService;
- @Autowired
- private SequenceService sequenceService;
- @ServiceMethod(method = "popular.feelings.findPage", title = "互联网舆情监控查询")
- public OapResponse findPage(QueryPopularFeelingsRequest request) {
- 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());
- }
- if (StringUtils.isNotBlank(request.getDomain())) {
- wrapper.like("domain", request.getDomain());
- }
- 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());
- 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);
- }
- }
|