|
|
@@ -0,0 +1,102 @@
|
|
|
+package com.zhiqiyun.open.mvc.controller;
|
|
|
+
|
|
|
+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.zhiqiyun.open.annotation.Permission;
|
|
|
+import com.zhiqiyun.open.core.models.statistics.PopularFeelings;
|
|
|
+import com.zhiqiyun.open.core.models.user.OauthInfo;
|
|
|
+import com.zhiqiyun.open.core.service.OauthService;
|
|
|
+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.QueryPopularFeelingsParam;
|
|
|
+import com.zhiqiyun.open.mvc.params.statistics.SavePopularFeelingsParam;
|
|
|
+import com.zhiqiyun.open.utils.DateUtil;
|
|
|
+import com.zhiqiyun.open.utils.ServletContext;
|
|
|
+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 org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author jtoms
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/popular/feelings")
|
|
|
+public class PopularFeelingsController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PopularFeelingsService popularFeelingsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OauthService oauthService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SequenceService sequenceService;
|
|
|
+
|
|
|
+
|
|
|
+ @Permission(value = "popular.feelings.find", tags = "查询舆情监控")
|
|
|
+ @PostMapping("/findPage")
|
|
|
+ public Result findPage(@RequestBody QueryPopularFeelingsParam param) {
|
|
|
+
|
|
|
+ QueryWrapper<PopularFeelings> wrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ Page<PopularFeelings> page = param.getPage();
|
|
|
+ page.addOrder(OrderItem.desc("id"));
|
|
|
+
|
|
|
+ Page<PopularFeelings> resultData = this.popularFeelingsService.page(page, wrapper);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "popular.feelings.add", tags = "新建舆情监控")
|
|
|
+ @PostMapping("/save")
|
|
|
+ public Result save(@Valid @RequestBody SavePopularFeelingsParam param) throws Exception {
|
|
|
+
|
|
|
+ PopularFeelings entity = new PopularFeelings();
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+
|
|
|
+ OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
|
|
|
+
|
|
|
+ entity.setCreatedTime(DateUtil.current());
|
|
|
+ entity.setCreatedBy(oauthInfo.getId());
|
|
|
+
|
|
|
+ entity.setUpdatedTime(DateUtil.current());
|
|
|
+ entity.setUpdatedBy(oauthInfo.getId());
|
|
|
+ entity.setId(this.sequenceService.nextId());
|
|
|
+
|
|
|
+ this.popularFeelingsService.save(entity);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "popular.feelings.edit", tags = "更新舆情监控")
|
|
|
+ @PostMapping("/updateById")
|
|
|
+ public Result updateById(Long id, @Valid @RequestBody SavePopularFeelingsParam param) {
|
|
|
+ PopularFeelings entity = new PopularFeelings();
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+
|
|
|
+ OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
|
|
|
+
|
|
|
+ entity.setUpdatedBy(oauthInfo.getId());
|
|
|
+ entity.setUpdatedTime(DateUtil.current());
|
|
|
+ entity.setId(id);
|
|
|
+
|
|
|
+ this.popularFeelingsService.updateById(entity);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "popular.feelings.delete", tags = "删除舆情监控")
|
|
|
+ @PostMapping("/deleteByIds")
|
|
|
+ public Result deleteByIds(@RequestBody List<Long> ids) {
|
|
|
+ this.popularFeelingsService.removeByIds(ids);
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+}
|