1
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
package com.ruoyi.web.controller.jarvis;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.jarvis.domain.Comment;
|
||||
import com.ruoyi.jarvis.domain.dto.CommentApiStatistics;
|
||||
import com.ruoyi.jarvis.domain.dto.CommentStatistics;
|
||||
import com.ruoyi.jarvis.service.ICommentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 评论管理 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/jarvis/comment")
|
||||
public class CommentController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ICommentService commentService;
|
||||
|
||||
/**
|
||||
* 查询京东评论列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:list')")
|
||||
@GetMapping("/jd/list")
|
||||
public TableDataInfo list(Comment comment) {
|
||||
startPage();
|
||||
List<Comment> list = commentService.selectCommentList(comment);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出京东评论列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:export')")
|
||||
@Log(title = "京东评论", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/jd/export")
|
||||
public void export(HttpServletResponse response, Comment comment) {
|
||||
List<Comment> list = commentService.selectCommentList(comment);
|
||||
ExcelUtil<Comment> util = new ExcelUtil<Comment>(Comment.class);
|
||||
util.exportExcel(response, list, "京东评论数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取京东评论详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:query')")
|
||||
@GetMapping("/jd/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(commentService.selectCommentById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改评论使用状态
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:edit')")
|
||||
@Log(title = "评论管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/jd")
|
||||
public AjaxResult edit(@RequestBody Comment comment) {
|
||||
return toAjax(commentService.updateCommentIsUse(comment));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评论
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:remove')")
|
||||
@Log(title = "评论管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/jd/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(commentService.deleteCommentByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置评论使用状态(按商品ID)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:edit')")
|
||||
@Log(title = "评论管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/jd/reset/{productId}")
|
||||
public AjaxResult resetByProductId(@PathVariable String productId) {
|
||||
return toAjax(commentService.resetCommentIsUseByProductId(productId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取评论统计信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:list')")
|
||||
@GetMapping("/statistics")
|
||||
public AjaxResult getStatistics(@RequestParam(required = false) String source) {
|
||||
List<CommentStatistics> statistics = commentService.getCommentStatistics(source);
|
||||
return success(statistics);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取接口调用统计
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:list')")
|
||||
@GetMapping("/api/statistics")
|
||||
public AjaxResult getApiStatistics(
|
||||
@RequestParam(required = false) String apiType,
|
||||
@RequestParam(required = false) String productType,
|
||||
@RequestParam(required = false) String startDate,
|
||||
@RequestParam(required = false) String endDate) {
|
||||
List<CommentApiStatistics> statistics = commentService.getApiStatistics(apiType, productType, startDate, endDate);
|
||||
return success(statistics);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Redis产品类型映射(京东)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:list')")
|
||||
@GetMapping("/redis/jd/map")
|
||||
public AjaxResult getJdProductTypeMap() {
|
||||
Map<String, String> map = commentService.getJdProductTypeMap();
|
||||
return success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Redis产品类型映射(淘宝)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:list')")
|
||||
@GetMapping("/redis/tb/map")
|
||||
public AjaxResult getTbProductTypeMap() {
|
||||
Map<String, String> map = commentService.getTbProductTypeMap();
|
||||
return success(map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.ruoyi.web.controller.jarvis;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.jarvis.domain.TaobaoComment;
|
||||
import com.ruoyi.jarvis.service.ITaobaoCommentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 淘宝评论管理 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/jarvis/taobaoComment")
|
||||
public class TaobaoCommentController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ITaobaoCommentService taobaoCommentService;
|
||||
|
||||
/**
|
||||
* 查询淘宝评论列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(TaobaoComment taobaoComment) {
|
||||
startPage();
|
||||
List<TaobaoComment> list = taobaoCommentService.selectTaobaoCommentList(taobaoComment);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出淘宝评论列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:export')")
|
||||
@Log(title = "淘宝评论", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, TaobaoComment taobaoComment) {
|
||||
List<TaobaoComment> list = taobaoCommentService.selectTaobaoCommentList(taobaoComment);
|
||||
ExcelUtil<TaobaoComment> util = new ExcelUtil<TaobaoComment>(TaobaoComment.class);
|
||||
util.exportExcel(response, list, "淘宝评论数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取淘宝评论详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:query')")
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Integer id) {
|
||||
return success(taobaoCommentService.selectTaobaoCommentById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改评论使用状态
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:edit')")
|
||||
@Log(title = "评论管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody TaobaoComment taobaoComment) {
|
||||
return toAjax(taobaoCommentService.updateTaobaoCommentIsUse(taobaoComment));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评论
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:remove')")
|
||||
@Log(title = "评论管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Integer[] ids) {
|
||||
return toAjax(taobaoCommentService.deleteTaobaoCommentByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置评论使用状态(按商品ID)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:comment:edit')")
|
||||
@Log(title = "评论管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/reset/{productId}")
|
||||
public AjaxResult resetByProductId(@PathVariable String productId) {
|
||||
return toAjax(taobaoCommentService.resetTaobaoCommentIsUseByProductId(productId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.jarvis.service.ICommentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
@@ -22,18 +24,28 @@ public class CommentPublicController extends BaseController {
|
||||
private static final String JD_BASE = "http://192.168.8.88:6666/jd";
|
||||
private static final String SKEY = "2192057370ef8140c201079969c956a3";
|
||||
|
||||
@Autowired(required = false)
|
||||
private ICommentService commentService;
|
||||
|
||||
/**
|
||||
* 获取可选型号/类型(示例)
|
||||
*/
|
||||
@GetMapping("/types")
|
||||
public AjaxResult types() {
|
||||
boolean success = false;
|
||||
try {
|
||||
String url = JD_BASE + "/comment/types?skey=" + SKEY;
|
||||
String result = HttpUtils.sendGet(url);
|
||||
Object parsed = JSON.parse(result);
|
||||
success = true;
|
||||
return AjaxResult.success(parsed);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("types failed: " + e.getMessage());
|
||||
} finally {
|
||||
// 记录接口调用统计
|
||||
if (commentService != null) {
|
||||
commentService.recordApiCall("jd", "types", success);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,18 +55,27 @@ public class CommentPublicController extends BaseController {
|
||||
*/
|
||||
@PostMapping("/generate")
|
||||
public AjaxResult generate(@RequestBody Map<String, String> body) {
|
||||
boolean success = false;
|
||||
String productType = null;
|
||||
try {
|
||||
String url = JD_BASE + "/comment/generate";
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("skey", SKEY);
|
||||
if (body != null && body.get("productType") != null) {
|
||||
param.put("productType", body.get("productType"));
|
||||
productType = body.get("productType");
|
||||
param.put("productType", productType);
|
||||
}
|
||||
String result = HttpUtils.sendJsonPost(url, param.toJSONString());
|
||||
Object parsed = JSON.parse(result);
|
||||
success = true;
|
||||
return AjaxResult.success(parsed);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("generate failed: " + e.getMessage());
|
||||
} finally {
|
||||
// 记录接口调用统计
|
||||
if (commentService != null && productType != null) {
|
||||
commentService.recordApiCall("jd", productType, success);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.ruoyi.jarvis.domain;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 京东评论对象 comments
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Comment extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@Excel(name = "ID")
|
||||
private Long id;
|
||||
|
||||
/** 商品ID */
|
||||
@Excel(name = "商品ID")
|
||||
private String productId;
|
||||
|
||||
/** 用户名 */
|
||||
@Excel(name = "用户名")
|
||||
private String userName;
|
||||
|
||||
/** 评论内容 */
|
||||
@Excel(name = "评论内容")
|
||||
private String commentText;
|
||||
|
||||
/** 评论ID */
|
||||
@Excel(name = "评论ID")
|
||||
private String commentId;
|
||||
|
||||
/** 图片URLs */
|
||||
@Excel(name = "图片URLs")
|
||||
private String pictureUrls;
|
||||
|
||||
/** 创建时间 */
|
||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createdAt;
|
||||
|
||||
/** 评论日期 */
|
||||
@Excel(name = "评论日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date commentDate;
|
||||
|
||||
/** 是否已使用 0-未使用 1-已使用 */
|
||||
@Excel(name = "使用状态", readConverterExp = "0=未使用,1=已使用")
|
||||
private Integer isUse;
|
||||
|
||||
/** 产品类型(从Redis映射获取) */
|
||||
private String productType;
|
||||
|
||||
/** Redis映射的产品ID */
|
||||
private String mappedProductId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.ruoyi.jarvis.domain;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 淘宝评论对象 taobao_comments
|
||||
*/
|
||||
@Data
|
||||
public class TaobaoComment extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@Excel(name = "ID")
|
||||
private Integer id;
|
||||
|
||||
/** 商品ID */
|
||||
@Excel(name = "商品ID")
|
||||
private String productId;
|
||||
|
||||
/** 用户名 */
|
||||
@Excel(name = "用户名")
|
||||
private String userName;
|
||||
|
||||
/** 评论内容 */
|
||||
@Excel(name = "评论内容")
|
||||
private String commentText;
|
||||
|
||||
/** 评论ID */
|
||||
@Excel(name = "评论ID")
|
||||
private String commentId;
|
||||
|
||||
/** 图片URLs */
|
||||
@Excel(name = "图片URLs")
|
||||
private String pictureUrls;
|
||||
|
||||
/** 创建时间 */
|
||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createdAt;
|
||||
|
||||
/** 评论日期 */
|
||||
@Excel(name = "评论日期")
|
||||
private String commentDate;
|
||||
|
||||
/** 是否已使用 0-未使用 1-已使用 */
|
||||
@Excel(name = "使用状态", readConverterExp = "0=未使用,1=已使用")
|
||||
private Integer isUse;
|
||||
|
||||
/** 产品类型(从Redis映射获取) */
|
||||
private String productType;
|
||||
|
||||
/** Redis映射的产品ID */
|
||||
private String mappedProductId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.jarvis.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 评论接口调用统计
|
||||
*/
|
||||
@Data
|
||||
public class CommentApiStatistics {
|
||||
/** 统计日期 */
|
||||
private Date statDate;
|
||||
|
||||
/** 接口类型:jd-京东,tb-淘宝 */
|
||||
private String apiType;
|
||||
|
||||
/** 产品类型 */
|
||||
private String productType;
|
||||
|
||||
/** 调用次数 */
|
||||
private Long callCount;
|
||||
|
||||
/** 成功次数 */
|
||||
private Long successCount;
|
||||
|
||||
/** 失败次数 */
|
||||
private Long failCount;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.ruoyi.jarvis.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 评论统计信息
|
||||
*/
|
||||
@Data
|
||||
public class CommentStatistics {
|
||||
/** 评论来源:jd-京东,tb-淘宝 */
|
||||
private String source;
|
||||
|
||||
/** 产品类型 */
|
||||
private String productType;
|
||||
|
||||
/** 产品ID */
|
||||
private String productId;
|
||||
|
||||
/** 总评论数 */
|
||||
private Long totalCount;
|
||||
|
||||
/** 可用评论数(未使用) */
|
||||
private Long availableCount;
|
||||
|
||||
/** 已使用评论数 */
|
||||
private Long usedCount;
|
||||
|
||||
/** 接口调用次数 */
|
||||
private Long apiCallCount;
|
||||
|
||||
/** 今日调用次数 */
|
||||
private Long todayCallCount;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.ruoyi.jarvis.mapper;
|
||||
|
||||
import com.ruoyi.jarvis.domain.Comment;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 京东评论 Mapper 接口
|
||||
*/
|
||||
public interface CommentMapper {
|
||||
|
||||
/**
|
||||
* 查询京东评论列表
|
||||
*/
|
||||
List<Comment> selectCommentList(Comment comment);
|
||||
|
||||
/**
|
||||
* 根据ID查询京东评论
|
||||
*/
|
||||
Comment selectCommentById(Long id);
|
||||
|
||||
/**
|
||||
* 根据商品ID查询评论统计
|
||||
*/
|
||||
Map<String, Object> selectCommentStatisticsByProductId(String productId);
|
||||
|
||||
/**
|
||||
* 更新评论使用状态
|
||||
*/
|
||||
int updateCommentIsUse(Comment comment);
|
||||
|
||||
/**
|
||||
* 批量删除评论
|
||||
*/
|
||||
int deleteCommentByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 重置评论使用状态(批量)
|
||||
*/
|
||||
int resetCommentIsUseByProductId(String productId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.ruoyi.jarvis.mapper;
|
||||
|
||||
import com.ruoyi.jarvis.domain.TaobaoComment;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 淘宝评论 Mapper 接口
|
||||
*/
|
||||
public interface TaobaoCommentMapper {
|
||||
|
||||
/**
|
||||
* 查询淘宝评论列表
|
||||
*/
|
||||
List<TaobaoComment> selectTaobaoCommentList(TaobaoComment taobaoComment);
|
||||
|
||||
/**
|
||||
* 根据ID查询淘宝评论
|
||||
*/
|
||||
TaobaoComment selectTaobaoCommentById(Integer id);
|
||||
|
||||
/**
|
||||
* 根据商品ID查询评论统计
|
||||
*/
|
||||
Map<String, Object> selectTaobaoCommentStatisticsByProductId(String productId);
|
||||
|
||||
/**
|
||||
* 更新评论使用状态
|
||||
*/
|
||||
int updateTaobaoCommentIsUse(TaobaoComment taobaoComment);
|
||||
|
||||
/**
|
||||
* 批量删除评论
|
||||
*/
|
||||
int deleteTaobaoCommentByIds(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 重置评论使用状态(批量)
|
||||
*/
|
||||
int resetTaobaoCommentIsUseByProductId(String productId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.ruoyi.jarvis.service;
|
||||
|
||||
import com.ruoyi.jarvis.domain.Comment;
|
||||
import com.ruoyi.jarvis.domain.dto.CommentStatistics;
|
||||
import com.ruoyi.jarvis.domain.dto.CommentApiStatistics;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 评论管理 Service 接口
|
||||
*/
|
||||
public interface ICommentService {
|
||||
|
||||
/**
|
||||
* 查询京东评论列表
|
||||
*/
|
||||
List<Comment> selectCommentList(Comment comment);
|
||||
|
||||
/**
|
||||
* 根据ID查询京东评论
|
||||
*/
|
||||
Comment selectCommentById(Long id);
|
||||
|
||||
/**
|
||||
* 更新评论使用状态
|
||||
*/
|
||||
int updateCommentIsUse(Comment comment);
|
||||
|
||||
/**
|
||||
* 批量删除评论
|
||||
*/
|
||||
int deleteCommentByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 重置评论使用状态(批量)
|
||||
*/
|
||||
int resetCommentIsUseByProductId(String productId);
|
||||
|
||||
/**
|
||||
* 获取评论统计信息(包含Redis映射)
|
||||
*/
|
||||
List<CommentStatistics> getCommentStatistics(String source);
|
||||
|
||||
/**
|
||||
* 记录接口调用统计
|
||||
*/
|
||||
void recordApiCall(String apiType, String productType, boolean success);
|
||||
|
||||
/**
|
||||
* 获取接口调用统计
|
||||
*/
|
||||
List<CommentApiStatistics> getApiStatistics(String apiType, String productType, String startDate, String endDate);
|
||||
|
||||
/**
|
||||
* 获取Redis产品类型映射(京东)
|
||||
*/
|
||||
Map<String, String> getJdProductTypeMap();
|
||||
|
||||
/**
|
||||
* 获取Redis产品类型映射(淘宝)
|
||||
*/
|
||||
Map<String, String> getTbProductTypeMap();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.ruoyi.jarvis.service;
|
||||
|
||||
import com.ruoyi.jarvis.domain.TaobaoComment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 淘宝评论管理 Service 接口
|
||||
*/
|
||||
public interface ITaobaoCommentService {
|
||||
|
||||
/**
|
||||
* 查询淘宝评论列表
|
||||
*/
|
||||
List<TaobaoComment> selectTaobaoCommentList(TaobaoComment taobaoComment);
|
||||
|
||||
/**
|
||||
* 根据ID查询淘宝评论
|
||||
*/
|
||||
TaobaoComment selectTaobaoCommentById(Integer id);
|
||||
|
||||
/**
|
||||
* 更新评论使用状态
|
||||
*/
|
||||
int updateTaobaoCommentIsUse(TaobaoComment taobaoComment);
|
||||
|
||||
/**
|
||||
* 批量删除评论
|
||||
*/
|
||||
int deleteTaobaoCommentByIds(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 重置评论使用状态(批量)
|
||||
*/
|
||||
int resetTaobaoCommentIsUseByProductId(String productId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
package com.ruoyi.jarvis.service.impl;
|
||||
|
||||
import com.ruoyi.jarvis.domain.Comment;
|
||||
import com.ruoyi.jarvis.domain.dto.CommentApiStatistics;
|
||||
import com.ruoyi.jarvis.domain.dto.CommentStatistics;
|
||||
import com.ruoyi.jarvis.mapper.CommentMapper;
|
||||
import com.ruoyi.jarvis.service.ICommentService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 评论管理 Service 实现
|
||||
*/
|
||||
@Service
|
||||
public class CommentServiceImpl implements ICommentService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CommentServiceImpl.class);
|
||||
|
||||
private static final String PRODUCT_TYPE_MAP_PREFIX = "product_type_map";
|
||||
private static final String PRODUCT_TYPE_MAP_PREFIX_TB = "product_type_map_tb";
|
||||
private static final String API_CALL_STAT_PREFIX = "comment:api:stat:";
|
||||
private static final String API_CALL_TODAY_PREFIX = "comment:api:today:";
|
||||
|
||||
@Autowired
|
||||
private CommentMapper commentMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
private com.ruoyi.jarvis.mapper.TaobaoCommentMapper taobaoCommentMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Override
|
||||
public List<Comment> selectCommentList(Comment comment) {
|
||||
List<Comment> list = commentMapper.selectCommentList(comment);
|
||||
// 填充Redis映射的产品类型信息
|
||||
if (stringRedisTemplate != null) {
|
||||
Map<String, String> jdMap = getJdProductTypeMap();
|
||||
for (Comment c : list) {
|
||||
// 查找对应的产品类型
|
||||
String productId = c.getProductId();
|
||||
if (jdMap != null) {
|
||||
for (Map.Entry<String, String> entry : jdMap.entrySet()) {
|
||||
if (entry.getValue().equals(productId)) {
|
||||
c.setProductType(entry.getKey());
|
||||
c.setMappedProductId(productId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comment selectCommentById(Long id) {
|
||||
Comment comment = commentMapper.selectCommentById(id);
|
||||
if (comment != null && stringRedisTemplate != null) {
|
||||
Map<String, String> jdMap = getJdProductTypeMap();
|
||||
if (jdMap != null) {
|
||||
String productId = comment.getProductId();
|
||||
for (Map.Entry<String, String> entry : jdMap.entrySet()) {
|
||||
if (entry.getValue().equals(productId)) {
|
||||
comment.setProductType(entry.getKey());
|
||||
comment.setMappedProductId(productId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateCommentIsUse(Comment comment) {
|
||||
return commentMapper.updateCommentIsUse(comment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteCommentByIds(Long[] ids) {
|
||||
return commentMapper.deleteCommentByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int resetCommentIsUseByProductId(String productId) {
|
||||
return commentMapper.resetCommentIsUseByProductId(productId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommentStatistics> getCommentStatistics(String source) {
|
||||
List<CommentStatistics> statisticsList = new ArrayList<>();
|
||||
|
||||
Map<String, String> productTypeMap = null;
|
||||
if ("jd".equals(source) || source == null) {
|
||||
productTypeMap = getJdProductTypeMap();
|
||||
} else if ("tb".equals(source)) {
|
||||
productTypeMap = getTbProductTypeMap();
|
||||
}
|
||||
|
||||
if (productTypeMap == null || productTypeMap.isEmpty()) {
|
||||
return statisticsList;
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> entry : productTypeMap.entrySet()) {
|
||||
String productType = entry.getKey();
|
||||
String productId = entry.getValue();
|
||||
|
||||
CommentStatistics stats = new CommentStatistics();
|
||||
stats.setSource("jd".equals(source) ? "京东评论" : "淘宝评论");
|
||||
stats.setProductType(productType);
|
||||
stats.setProductId(productId);
|
||||
|
||||
// 查询评论统计
|
||||
Map<String, Object> statMap = null;
|
||||
if ("jd".equals(source) || source == null) {
|
||||
statMap = commentMapper.selectCommentStatisticsByProductId(productId);
|
||||
} else if ("tb".equals(source) && taobaoCommentMapper != null) {
|
||||
statMap = taobaoCommentMapper.selectTaobaoCommentStatisticsByProductId(productId);
|
||||
}
|
||||
|
||||
if (statMap != null) {
|
||||
stats.setTotalCount(((Number) statMap.get("totalCount")).longValue());
|
||||
stats.setAvailableCount(((Number) statMap.get("availableCount")).longValue());
|
||||
stats.setUsedCount(((Number) statMap.get("usedCount")).longValue());
|
||||
}
|
||||
|
||||
// 获取接口调用统计
|
||||
if (stringRedisTemplate != null) {
|
||||
String todayKey = API_CALL_TODAY_PREFIX + source + ":" + productType + ":" + getTodayDate();
|
||||
String todayCount = stringRedisTemplate.opsForValue().get(todayKey);
|
||||
stats.setTodayCallCount(todayCount != null ? Long.parseLong(todayCount) : 0L);
|
||||
|
||||
// 获取总调用次数(从Redis中统计)
|
||||
String statKey = API_CALL_STAT_PREFIX + source + ":" + productType;
|
||||
String totalCount = stringRedisTemplate.opsForValue().get(statKey);
|
||||
stats.setApiCallCount(totalCount != null ? Long.parseLong(totalCount) : 0L);
|
||||
}
|
||||
|
||||
statisticsList.add(stats);
|
||||
}
|
||||
|
||||
return statisticsList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordApiCall(String apiType, String productType, boolean success) {
|
||||
if (stringRedisTemplate == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
String today = getTodayDate();
|
||||
String todayKey = API_CALL_TODAY_PREFIX + apiType + ":" + productType + ":" + today;
|
||||
stringRedisTemplate.opsForValue().increment(todayKey);
|
||||
stringRedisTemplate.expire(todayKey, 7, TimeUnit.DAYS); // 保留7天
|
||||
|
||||
String statKey = API_CALL_STAT_PREFIX + apiType + ":" + productType;
|
||||
stringRedisTemplate.opsForValue().increment(statKey);
|
||||
|
||||
// 记录成功/失败统计
|
||||
String successKey = API_CALL_STAT_PREFIX + apiType + ":" + productType + ":success";
|
||||
String failKey = API_CALL_STAT_PREFIX + apiType + ":" + productType + ":fail";
|
||||
if (success) {
|
||||
stringRedisTemplate.opsForValue().increment(successKey);
|
||||
} else {
|
||||
stringRedisTemplate.opsForValue().increment(failKey);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("记录接口调用统计失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommentApiStatistics> getApiStatistics(String apiType, String productType, String startDate, String endDate) {
|
||||
List<CommentApiStatistics> statisticsList = new ArrayList<>();
|
||||
|
||||
if (stringRedisTemplate == null) {
|
||||
return statisticsList;
|
||||
}
|
||||
|
||||
try {
|
||||
// 如果指定了产品类型,只查询该类型的统计
|
||||
if (productType != null && !productType.isEmpty()) {
|
||||
CommentApiStatistics stats = new CommentApiStatistics();
|
||||
stats.setApiType(apiType);
|
||||
stats.setProductType(productType);
|
||||
|
||||
String statKey = API_CALL_STAT_PREFIX + apiType + ":" + productType;
|
||||
String totalCount = stringRedisTemplate.opsForValue().get(statKey);
|
||||
stats.setCallCount(totalCount != null ? Long.parseLong(totalCount) : 0L);
|
||||
|
||||
String successKey = statKey + ":success";
|
||||
String successCount = stringRedisTemplate.opsForValue().get(successKey);
|
||||
stats.setSuccessCount(successCount != null ? Long.parseLong(successCount) : 0L);
|
||||
|
||||
String failKey = statKey + ":fail";
|
||||
String failCount = stringRedisTemplate.opsForValue().get(failKey);
|
||||
stats.setFailCount(failCount != null ? Long.parseLong(failCount) : 0L);
|
||||
|
||||
statisticsList.add(stats);
|
||||
} else {
|
||||
// 查询所有产品类型的统计
|
||||
Map<String, String> productTypeMap = "jd".equals(apiType) ? getJdProductTypeMap() : getTbProductTypeMap();
|
||||
if (productTypeMap != null) {
|
||||
for (String pt : productTypeMap.keySet()) {
|
||||
CommentApiStatistics stats = new CommentApiStatistics();
|
||||
stats.setApiType(apiType);
|
||||
stats.setProductType(pt);
|
||||
|
||||
String statKey = API_CALL_STAT_PREFIX + apiType + ":" + pt;
|
||||
String totalCount = stringRedisTemplate.opsForValue().get(statKey);
|
||||
stats.setCallCount(totalCount != null ? Long.parseLong(totalCount) : 0L);
|
||||
|
||||
String successKey = statKey + ":success";
|
||||
String successCount = stringRedisTemplate.opsForValue().get(successKey);
|
||||
stats.setSuccessCount(successCount != null ? Long.parseLong(successCount) : 0L);
|
||||
|
||||
String failKey = statKey + ":fail";
|
||||
String failCount = stringRedisTemplate.opsForValue().get(failKey);
|
||||
stats.setFailCount(failCount != null ? Long.parseLong(failCount) : 0L);
|
||||
|
||||
statisticsList.add(stats);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取接口调用统计失败", e);
|
||||
}
|
||||
|
||||
return statisticsList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getJdProductTypeMap() {
|
||||
if (stringRedisTemplate == null) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
try {
|
||||
Map<Object, Object> rawMap = stringRedisTemplate.opsForHash().entries(PRODUCT_TYPE_MAP_PREFIX);
|
||||
Map<String, String> result = new LinkedHashMap<>();
|
||||
for (Map.Entry<Object, Object> entry : rawMap.entrySet()) {
|
||||
result.put(entry.getKey().toString(), entry.getValue().toString());
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("获取京东产品类型映射失败", e);
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getTbProductTypeMap() {
|
||||
if (stringRedisTemplate == null) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
try {
|
||||
Map<Object, Object> rawMap = stringRedisTemplate.opsForHash().entries(PRODUCT_TYPE_MAP_PREFIX_TB);
|
||||
Map<String, String> result = new LinkedHashMap<>();
|
||||
for (Map.Entry<Object, Object> entry : rawMap.entrySet()) {
|
||||
result.put(entry.getKey().toString(), entry.getValue().toString());
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("获取淘宝产品类型映射失败", e);
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
private String getTodayDate() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
return sdf.format(new Date());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.ruoyi.jarvis.service.impl;
|
||||
|
||||
import com.ruoyi.jarvis.domain.TaobaoComment;
|
||||
import com.ruoyi.jarvis.mapper.TaobaoCommentMapper;
|
||||
import com.ruoyi.jarvis.service.ITaobaoCommentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 淘宝评论管理 Service 实现
|
||||
*/
|
||||
@Service
|
||||
public class TaobaoCommentServiceImpl implements ITaobaoCommentService {
|
||||
|
||||
private static final String PRODUCT_TYPE_MAP_PREFIX_TB = "product_type_map_tb";
|
||||
|
||||
@Autowired
|
||||
private TaobaoCommentMapper taobaoCommentMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Override
|
||||
public List<TaobaoComment> selectTaobaoCommentList(TaobaoComment taobaoComment) {
|
||||
List<TaobaoComment> list = taobaoCommentMapper.selectTaobaoCommentList(taobaoComment);
|
||||
// 填充Redis映射的产品类型信息
|
||||
if (stringRedisTemplate != null) {
|
||||
Map<String, String> tbMap = getTbProductTypeMap();
|
||||
for (TaobaoComment c : list) {
|
||||
// 查找对应的产品类型
|
||||
String productId = c.getProductId();
|
||||
if (tbMap != null) {
|
||||
for (Map.Entry<String, String> entry : tbMap.entrySet()) {
|
||||
if (entry.getValue().equals(productId)) {
|
||||
c.setProductType(entry.getKey());
|
||||
c.setMappedProductId(productId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaobaoComment selectTaobaoCommentById(Integer id) {
|
||||
TaobaoComment comment = taobaoCommentMapper.selectTaobaoCommentById(id);
|
||||
if (comment != null && stringRedisTemplate != null) {
|
||||
Map<String, String> tbMap = getTbProductTypeMap();
|
||||
if (tbMap != null) {
|
||||
String productId = comment.getProductId();
|
||||
for (Map.Entry<String, String> entry : tbMap.entrySet()) {
|
||||
if (entry.getValue().equals(productId)) {
|
||||
comment.setProductType(entry.getKey());
|
||||
comment.setMappedProductId(productId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateTaobaoCommentIsUse(TaobaoComment taobaoComment) {
|
||||
return taobaoCommentMapper.updateTaobaoCommentIsUse(taobaoComment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteTaobaoCommentByIds(Integer[] ids) {
|
||||
return taobaoCommentMapper.deleteTaobaoCommentByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int resetTaobaoCommentIsUseByProductId(String productId) {
|
||||
return taobaoCommentMapper.resetTaobaoCommentIsUseByProductId(productId);
|
||||
}
|
||||
|
||||
private Map<String, String> getTbProductTypeMap() {
|
||||
if (stringRedisTemplate == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Map<Object, Object> rawMap = stringRedisTemplate.opsForHash().entries(PRODUCT_TYPE_MAP_PREFIX_TB);
|
||||
Map<String, String> result = new java.util.LinkedHashMap<>();
|
||||
for (Map.Entry<Object, Object> entry : rawMap.entrySet()) {
|
||||
result.put(entry.getKey().toString(), entry.getValue().toString());
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.jarvis.mapper.CommentMapper">
|
||||
|
||||
<resultMap id="CommentResult" type="Comment">
|
||||
<result property="id" column="id"/>
|
||||
<result property="productId" column="product_id"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="commentText" column="comment_text"/>
|
||||
<result property="commentId" column="comment_id"/>
|
||||
<result property="pictureUrls" column="picture_urls"/>
|
||||
<result property="createdAt" column="created_at"/>
|
||||
<result property="commentDate" column="comment_date"/>
|
||||
<result property="isUse" column="is_use"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCommentBase">
|
||||
select id, product_id, user_name, comment_text, comment_id, picture_urls,
|
||||
created_at, comment_date, is_use
|
||||
from comments
|
||||
</sql>
|
||||
|
||||
<select id="selectCommentList" parameterType="Comment" resultMap="CommentResult">
|
||||
<include refid="selectCommentBase"/>
|
||||
<where>
|
||||
<if test="productId != null and productId != ''"> and product_id = #{productId}</if>
|
||||
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
|
||||
<if test="commentText != null and commentText != ''"> and comment_text like concat('%', #{commentText}, '%')</if>
|
||||
<if test="isUse != null"> and is_use = #{isUse}</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''">
|
||||
and created_at >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''">
|
||||
and created_at <= #{params.endTime}
|
||||
</if>
|
||||
</where>
|
||||
order by created_at desc
|
||||
</select>
|
||||
|
||||
<select id="selectCommentById" parameterType="Long" resultMap="CommentResult">
|
||||
<include refid="selectCommentBase"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectCommentStatisticsByProductId" parameterType="String" resultType="java.util.Map">
|
||||
select
|
||||
count(*) as totalCount,
|
||||
sum(case when is_use = 0 then 1 else 0 end) as availableCount,
|
||||
sum(case when is_use = 1 then 1 else 0 end) as usedCount
|
||||
from comments
|
||||
where product_id = #{productId}
|
||||
</select>
|
||||
|
||||
<update id="updateCommentIsUse" parameterType="Comment">
|
||||
update comments
|
||||
<set>
|
||||
<if test="isUse != null">is_use = #{isUse},</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="resetCommentIsUseByProductId" parameterType="String">
|
||||
update comments
|
||||
set is_use = 0
|
||||
where product_id = #{productId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteCommentByIds" parameterType="String">
|
||||
delete from comments where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.jarvis.mapper.TaobaoCommentMapper">
|
||||
|
||||
<resultMap id="TaobaoCommentResult" type="TaobaoComment">
|
||||
<result property="id" column="id"/>
|
||||
<result property="productId" column="product_id"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="commentText" column="comment_text"/>
|
||||
<result property="commentId" column="comment_id"/>
|
||||
<result property="pictureUrls" column="picture_urls"/>
|
||||
<result property="createdAt" column="created_at"/>
|
||||
<result property="commentDate" column="comment_date"/>
|
||||
<result property="isUse" column="is_use"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectTaobaoCommentBase">
|
||||
select id, product_id, user_name, comment_text, comment_id, picture_urls,
|
||||
created_at, comment_date, is_use
|
||||
from taobao_comments
|
||||
</sql>
|
||||
|
||||
<select id="selectTaobaoCommentList" parameterType="TaobaoComment" resultMap="TaobaoCommentResult">
|
||||
<include refid="selectTaobaoCommentBase"/>
|
||||
<where>
|
||||
<if test="productId != null and productId != ''"> and product_id = #{productId}</if>
|
||||
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
|
||||
<if test="commentText != null and commentText != ''"> and comment_text like concat('%', #{commentText}, '%')</if>
|
||||
<if test="isUse != null"> and is_use = #{isUse}</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''">
|
||||
and created_at >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''">
|
||||
and created_at <= #{params.endTime}
|
||||
</if>
|
||||
</where>
|
||||
order by created_at desc
|
||||
</select>
|
||||
|
||||
<select id="selectTaobaoCommentById" parameterType="Integer" resultMap="TaobaoCommentResult">
|
||||
<include refid="selectTaobaoCommentBase"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectTaobaoCommentStatisticsByProductId" parameterType="String" resultType="java.util.Map">
|
||||
select
|
||||
count(*) as totalCount,
|
||||
sum(case when is_use = 0 then 1 else 0 end) as availableCount,
|
||||
sum(case when is_use = 1 then 1 else 0 end) as usedCount
|
||||
from taobao_comments
|
||||
where product_id = #{productId}
|
||||
</select>
|
||||
|
||||
<update id="updateTaobaoCommentIsUse" parameterType="TaobaoComment">
|
||||
update taobao_comments
|
||||
<set>
|
||||
<if test="isUse != null">is_use = #{isUse},</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="resetTaobaoCommentIsUseByProductId" parameterType="String">
|
||||
update taobao_comments
|
||||
set is_use = 0
|
||||
where product_id = #{productId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteTaobaoCommentByIds" parameterType="String">
|
||||
delete from taobao_comments where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user