| | |
| | | package com.linghu.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.linghu.config.FinalStatus; |
| | | import com.linghu.listener.KeywordExcelListener; |
| | | import com.linghu.model.common.ResponseResult; |
| | | import com.linghu.model.dto.ExportFeedDTO; |
| | |
| | | import com.linghu.model.dto.ExportStaticsDTO; |
| | | import com.linghu.model.entity.*; |
| | | import com.linghu.model.excel.*; |
| | | import com.linghu.model.validator.UpdateGroup; |
| | | import com.linghu.model.vo.*; |
| | | import com.linghu.model.vo.KeywordStaticsListVO; |
| | | import com.linghu.model.vo.PlatformProportionVO; |
| | | import com.linghu.model.vo.ResultListVO; |
| | | import com.linghu.service.KeywordService; |
| | | |
| | | import com.linghu.service.OrderService; |
| | | import com.linghu.service.ReferenceService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ReferenceService referenceService; |
| | | |
| | | @Autowired |
| | | private OrderService orderService; |
| | | |
| | | /** |
| | | * 关键词统计 EChart图 |
| | |
| | | |
| | | @PostMapping(value = "/exportStatics") |
| | | @ApiOperation(value = "EChart图导出") |
| | | public ResponseEntity<byte[]> exportStatics(@RequestBody ExportStaticsDTO exportStaticsDTO) { |
| | | public ResponseEntity<byte[]> exportStatics(@Valid @RequestBody ExportStaticsDTO exportStaticsDTO) { |
| | | |
| | | return keywordService.exportEChart(exportStaticsDTO); |
| | | } |
| | |
| | | */ |
| | | @PostMapping(value = "/exportGetResultByTypeId") |
| | | @ApiOperation(value = "导出:根据类别查看") |
| | | public ResponseEntity<byte[]> exportGetResultByTypeId(@RequestBody ExportGetResultDTO dto) { |
| | | public ResponseEntity<byte[]> exportGetResultByTypeId(@Valid @RequestBody ExportGetResultDTO dto) { |
| | | return keywordService.exportResult(dto); |
| | | } |
| | | |
| | |
| | | */ |
| | | @PostMapping("/updateKeyword") |
| | | @ApiOperation(value = "修改关键词") |
| | | public ResponseResult<String> updateKeyword(@RequestBody Keyword keyword) { |
| | | if("submitted".equals(keyword.getStatus())){ |
| | | public ResponseResult<String> updateKeyword(@Validated(UpdateGroup.class) @RequestBody Keyword keyword) { |
| | | if(FinalStatus.SUBMITTED.getValue().equals(keyword.getStatus())){ |
| | | return ResponseResult.error("关键词已开始采集不允许修改!"); |
| | | } |
| | | keywordService.updateById(keyword); |
| | |
| | | @ApiOperation(value = "删除关键词") |
| | | public ResponseResult<String> deleteKeyword(@RequestParam("keywordId") Integer keywordId) { |
| | | Keyword keyword = keywordService.getById(keywordId); |
| | | if("submitted".equals(keyword.getStatus())){ |
| | | if(FinalStatus.SUBMITTED.getValue().equals(keyword.getStatus())){ |
| | | return ResponseResult.error("关键词已开始采集或不允许删除!"); |
| | | } |
| | | |
| | | keywordService.removeById(keywordId); |
| | | //找到订单 |
| | | Orders order = orderService.getById(keyword.getOrder_id()); |
| | | //更新关键词数量 |
| | | LambdaQueryWrapper<Keyword> queryKeywordsQueryWrapper = new LambdaQueryWrapper<>(); |
| | | queryKeywordsQueryWrapper.eq(Keyword::getOrder_id, keyword.getOrder_id()); |
| | | int count1 = (int) keywordService.count(queryKeywordsQueryWrapper); |
| | | order.setKeyword_num(count1); |
| | | orderService.updateById(order); |
| | | |
| | | return ResponseResult.success("删除成功"); |
| | | } |
| | | |