|
@@ -5,6 +5,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.ruoyi.system.domain.*;
|
|
import com.ruoyi.system.domain.*;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
@@ -41,8 +42,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
*/
|
|
*/
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/system/review")
|
|
@RequestMapping("/system/review")
|
|
|
-public class PosReviewController extends BaseController
|
|
|
|
|
-{
|
|
|
|
|
|
|
+public class PosReviewController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IPosReviewService posReviewService;
|
|
private IPosReviewService posReviewService;
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -55,10 +55,11 @@ public class PosReviewController extends BaseController
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IUserWalletService userWalletService;
|
|
private IUserWalletService userWalletService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private IPointsTransactionService pointsTransactionService;
|
|
|
|
|
|
|
+ private IPointsTransactionService pointsTransactionService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询用户的评论列表
|
|
* 查询用户的评论列表
|
|
|
|
|
+ *
|
|
|
* @param token
|
|
* @param token
|
|
|
* @param page
|
|
* @param page
|
|
|
* @param size
|
|
* @param size
|
|
@@ -69,28 +70,30 @@ public class PosReviewController extends BaseController
|
|
|
@GetMapping("/getUserRevew")
|
|
@GetMapping("/getUserRevew")
|
|
|
public AjaxResult getUserRevew(
|
|
public AjaxResult getUserRevew(
|
|
|
@RequestHeader String token,
|
|
@RequestHeader String token,
|
|
|
|
|
+ @RequestParam String ddId,
|
|
|
@RequestParam Integer page,
|
|
@RequestParam Integer page,
|
|
|
- @RequestParam Integer size
|
|
|
|
|
- ){
|
|
|
|
|
|
|
+ @RequestParam Integer size
|
|
|
|
|
+ ) {
|
|
|
JwtUtil jwtUtil = new JwtUtil();
|
|
JwtUtil jwtUtil = new JwtUtil();
|
|
|
String id = jwtUtil.getusid(token);
|
|
String id = jwtUtil.getusid(token);
|
|
|
- Long userId=Long.valueOf(id);
|
|
|
|
|
- IPage<PosReview> palist = new Page<>(page,size);
|
|
|
|
|
- QueryWrapper<PosReview> Wrapper= new QueryWrapper<>();
|
|
|
|
|
- Wrapper.eq("user_id",userId);
|
|
|
|
|
- IPage<PosReview> list = posReviewService.page(palist,Wrapper);
|
|
|
|
|
|
|
+ Long userId = Long.valueOf(id);
|
|
|
|
|
+ IPage<PosReview> palist = new Page<>(page, size);
|
|
|
|
|
+ QueryWrapper<PosReview> Wrapper = new QueryWrapper<>();
|
|
|
|
|
+ Wrapper.eq("user_id", userId);
|
|
|
|
|
+ Wrapper.eq(!StrUtil.isEmpty(ddId),"dd_id",ddId);
|
|
|
|
|
+ IPage<PosReview> list = posReviewService.page(palist, Wrapper);
|
|
|
List<PosReview> orlist = list.getRecords();
|
|
List<PosReview> orlist = list.getRecords();
|
|
|
JSONArray arr = new JSONArray();
|
|
JSONArray arr = new JSONArray();
|
|
|
- for(int i=0;i<orlist.size();i++){
|
|
|
|
|
|
|
+ for (int i = 0; i < orlist.size(); i++) {
|
|
|
JSONObject org = new JSONObject();
|
|
JSONObject org = new JSONObject();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- org.put("id",orlist.get(i).getId());
|
|
|
|
|
- org.put("ddId",orlist.get(i).getDdId());
|
|
|
|
|
- org.put("score",orlist.get(i).getScore());
|
|
|
|
|
- org.put("cretim",sdf.format(orlist.get(i).getCretim()));
|
|
|
|
|
- org.put("content",orlist.get(i).getContent());
|
|
|
|
|
- org.put("images",orlist.get(i).getImages());
|
|
|
|
|
- org.put("user",orlist.get(i).getAnonymous()==0?infoUserService.getById(orlist.get(i).getUserId()):"匿名");
|
|
|
|
|
|
|
+ org.put("id", orlist.get(i).getId());
|
|
|
|
|
+ org.put("ddId", orlist.get(i).getDdId());
|
|
|
|
|
+ org.put("score", orlist.get(i).getScore());
|
|
|
|
|
+ org.put("cretim", sdf.format(orlist.get(i).getCretim()));
|
|
|
|
|
+ org.put("content", orlist.get(i).getContent());
|
|
|
|
|
+ org.put("images", orlist.get(i).getImages());
|
|
|
|
|
+ org.put("user", orlist.get(i).getAnonymous() == 0 ? infoUserService.getById(orlist.get(i).getUserId()) : "匿名");
|
|
|
arr.add(org);
|
|
arr.add(org);
|
|
|
}
|
|
}
|
|
|
return success(arr);
|
|
return success(arr);
|
|
@@ -100,23 +103,23 @@ public class PosReviewController extends BaseController
|
|
|
@GetMapping("/getmdrevew")
|
|
@GetMapping("/getmdrevew")
|
|
|
public AjaxResult getmdrevew(@RequestParam Integer page,
|
|
public AjaxResult getmdrevew(@RequestParam Integer page,
|
|
|
@RequestParam Integer size,
|
|
@RequestParam Integer size,
|
|
|
- @RequestParam Long mdid){
|
|
|
|
|
- IPage<PosReview> palist = new Page<>(page,size);
|
|
|
|
|
- QueryWrapper<PosReview> Wrapper= new QueryWrapper<>();
|
|
|
|
|
- Wrapper.eq("md_id",mdid);
|
|
|
|
|
- IPage<PosReview> list = posReviewService.page(palist,Wrapper);
|
|
|
|
|
|
|
+ @RequestParam Long mdid) {
|
|
|
|
|
+ IPage<PosReview> palist = new Page<>(page, size);
|
|
|
|
|
+ QueryWrapper<PosReview> Wrapper = new QueryWrapper<>();
|
|
|
|
|
+ Wrapper.eq("md_id", mdid);
|
|
|
|
|
+ IPage<PosReview> list = posReviewService.page(palist, Wrapper);
|
|
|
List<PosReview> orlist = list.getRecords();
|
|
List<PosReview> orlist = list.getRecords();
|
|
|
JSONArray arr = new JSONArray();
|
|
JSONArray arr = new JSONArray();
|
|
|
- for(int i=0;i<orlist.size();i++){
|
|
|
|
|
|
|
+ for (int i = 0; i < orlist.size(); i++) {
|
|
|
JSONObject org = new JSONObject();
|
|
JSONObject org = new JSONObject();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- org.put("id",orlist.get(i).getId());
|
|
|
|
|
- org.put("ddId",orlist.get(i).getDdId());
|
|
|
|
|
- org.put("score",orlist.get(i).getScore());
|
|
|
|
|
- org.put("cretim",sdf.format(orlist.get(i).getCretim()));
|
|
|
|
|
- org.put("content",orlist.get(i).getContent());
|
|
|
|
|
- org.put("images",orlist.get(i).getImages());
|
|
|
|
|
- org.put("user",orlist.get(i).getAnonymous()==0?infoUserService.getById(orlist.get(i).getUserId()):"匿名");
|
|
|
|
|
|
|
+ org.put("id", orlist.get(i).getId());
|
|
|
|
|
+ org.put("ddId", orlist.get(i).getDdId());
|
|
|
|
|
+ org.put("score", orlist.get(i).getScore());
|
|
|
|
|
+ org.put("cretim", sdf.format(orlist.get(i).getCretim()));
|
|
|
|
|
+ org.put("content", orlist.get(i).getContent());
|
|
|
|
|
+ org.put("images", orlist.get(i).getImages());
|
|
|
|
|
+ org.put("user", orlist.get(i).getAnonymous() == 0 ? infoUserService.getById(orlist.get(i).getUserId()) : "匿名");
|
|
|
arr.add(org);
|
|
arr.add(org);
|
|
|
}
|
|
}
|
|
|
return success(arr);
|
|
return success(arr);
|
|
@@ -126,59 +129,60 @@ public class PosReviewController extends BaseController
|
|
|
@Anonymous
|
|
@Anonymous
|
|
|
@Auth
|
|
@Auth
|
|
|
@PostMapping("/addrevew")
|
|
@PostMapping("/addrevew")
|
|
|
- public AjaxResult addrevew(@RequestHeader String token,@RequestBody PosReview posReview)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public AjaxResult addrevew(@RequestHeader String token, @RequestBody PosReview posReview) {
|
|
|
JwtUtil jwtUtil = new JwtUtil();
|
|
JwtUtil jwtUtil = new JwtUtil();
|
|
|
String id = jwtUtil.getusid(token);
|
|
String id = jwtUtil.getusid(token);
|
|
|
PosReview review = posReviewMapper.getrewiew(posReview.getDdId());
|
|
PosReview review = posReviewMapper.getrewiew(posReview.getDdId());
|
|
|
- if(review==null){
|
|
|
|
|
|
|
+ if (review == null) {
|
|
|
posReview.setUserId(Long.valueOf(id));
|
|
posReview.setUserId(Long.valueOf(id));
|
|
|
//判断是否为新增
|
|
//判断是否为新增
|
|
|
- if(ObjectUtil.isEmpty(posReview.getId())){
|
|
|
|
|
- addPoint(Long.valueOf(id),posReview.getDdId());
|
|
|
|
|
|
|
+ if (ObjectUtil.isEmpty(posReview.getId())) {
|
|
|
|
|
+ addPoint(Long.valueOf(id), posReview.getDdId());
|
|
|
}
|
|
}
|
|
|
boolean org = posReviewService.saveOrUpdate(posReview);
|
|
boolean org = posReviewService.saveOrUpdate(posReview);
|
|
|
- if(org){
|
|
|
|
|
|
|
+ if (org) {
|
|
|
return success(MessageUtils.message("no.comment.success"));
|
|
return success(MessageUtils.message("no.comment.success"));
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
throw new ServiceException(MessageUtils.message("no.comment.fail"));
|
|
throw new ServiceException(MessageUtils.message("no.comment.fail"));
|
|
|
}
|
|
}
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
return error(MessageUtils.message("no.comment.repeat"));
|
|
return error(MessageUtils.message("no.comment.repeat"));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 添加积分
|
|
* 添加积分
|
|
|
*/
|
|
*/
|
|
|
- private void addPoint(Long userid, String ddId){
|
|
|
|
|
|
|
+ private void addPoint(Long userid, String ddId) {
|
|
|
SysPointControl control = pointControlService.getById(1);
|
|
SysPointControl control = pointControlService.getById(1);
|
|
|
//开启评论获得积分
|
|
//开启评论获得积分
|
|
|
- if(control.getReviewEnable().equals(1L)){
|
|
|
|
|
- LambdaQueryWrapper<UserWallet> walletQuery=new LambdaQueryWrapper<>();
|
|
|
|
|
- walletQuery.eq(UserWallet::getUserId,userid);
|
|
|
|
|
|
|
+ if (control.getReviewEnable().equals(1L)) {
|
|
|
|
|
+ LambdaQueryWrapper<UserWallet> walletQuery = new LambdaQueryWrapper<>();
|
|
|
|
|
+ walletQuery.eq(UserWallet::getUserId, userid);
|
|
|
UserWallet userWallet = userWalletService.getOne(walletQuery);
|
|
UserWallet userWallet = userWalletService.getOne(walletQuery);
|
|
|
|
|
|
|
|
- if(userWallet==null){
|
|
|
|
|
|
|
+ if (userWallet == null) {
|
|
|
|
|
|
|
|
userWalletService.createUserWallet(userid);
|
|
userWalletService.createUserWallet(userid);
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
Long userPoint = userWallet.getPointsWallet();
|
|
Long userPoint = userWallet.getPointsWallet();
|
|
|
Long point = control.getReviewPoints();
|
|
Long point = control.getReviewPoints();
|
|
|
- long newPoint = userPoint+point;
|
|
|
|
|
|
|
+ long newPoint = userPoint + point;
|
|
|
userWallet.setPointsWallet(newPoint);
|
|
userWallet.setPointsWallet(newPoint);
|
|
|
int oldVersion = userWallet.getVersion();
|
|
int oldVersion = userWallet.getVersion();
|
|
|
- userWallet.setVersion(userWallet.getVersion()+1);
|
|
|
|
|
- walletQuery.eq(UserWallet::getVersion,oldVersion);
|
|
|
|
|
- boolean update= userWalletService.update(userWallet,walletQuery);
|
|
|
|
|
- if(!update){
|
|
|
|
|
- throw new ServiceException(MessageUtils.message("no.points.update.fail"));
|
|
|
|
|
- }
|
|
|
|
|
- createPointTransaction(userid,control.getReviewPoints(), userWallet.getPointsWallet(), ddId,"1");
|
|
|
|
|
|
|
+ userWallet.setVersion(userWallet.getVersion() + 1);
|
|
|
|
|
+ walletQuery.eq(UserWallet::getVersion, oldVersion);
|
|
|
|
|
+ boolean update = userWalletService.update(userWallet, walletQuery);
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ throw new ServiceException(MessageUtils.message("no.points.update.fail"));
|
|
|
|
|
+ }
|
|
|
|
|
+ createPointTransaction(userid, control.getReviewPoints(), userWallet.getPointsWallet(), ddId, "1");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 创建积分流水
|
|
* 创建积分流水
|
|
|
*/
|
|
*/
|
|
@@ -192,8 +196,7 @@ public class PosReviewController extends BaseController
|
|
|
// pointsTransaction.setCreateTime(new Date());
|
|
// pointsTransaction.setCreateTime(new Date());
|
|
|
// pointsTransactionService.save(pointsTransaction);
|
|
// pointsTransactionService.save(pointsTransaction);
|
|
|
// }
|
|
// }
|
|
|
-
|
|
|
|
|
- private void createPointTransaction(Long userid, Long pointsChange, Long currentPoints, String ddId,String type) {
|
|
|
|
|
|
|
+ private void createPointTransaction(Long userid, Long pointsChange, Long currentPoints, String ddId, String type) {
|
|
|
PointsTransaction pointsTransaction = new PointsTransaction();
|
|
PointsTransaction pointsTransaction = new PointsTransaction();
|
|
|
pointsTransaction.setUserId(userid);
|
|
pointsTransaction.setUserId(userid);
|
|
|
if (type.equals("1")) {
|
|
if (type.equals("1")) {
|
|
@@ -211,15 +214,12 @@ public class PosReviewController extends BaseController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询review列表
|
|
* 查询review列表
|
|
|
*/
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('system:review:list')")
|
|
@PreAuthorize("@ss.hasPermi('system:review:list')")
|
|
|
@GetMapping("/list")
|
|
@GetMapping("/list")
|
|
|
- public TableDataInfo list(PosReview posReview)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public TableDataInfo list(PosReview posReview) {
|
|
|
startPage();
|
|
startPage();
|
|
|
List<PosReview> list = posReviewService.selectPosReviewList(posReview);
|
|
List<PosReview> list = posReviewService.selectPosReviewList(posReview);
|
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
@@ -231,8 +231,7 @@ public class PosReviewController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('system:review:export')")
|
|
@PreAuthorize("@ss.hasPermi('system:review:export')")
|
|
|
@Log(title = "review", businessType = BusinessType.EXPORT)
|
|
@Log(title = "review", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
@PostMapping("/export")
|
|
|
- public void export(HttpServletResponse response, PosReview posReview)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public void export(HttpServletResponse response, PosReview posReview) {
|
|
|
List<PosReview> list = posReviewService.selectPosReviewList(posReview);
|
|
List<PosReview> list = posReviewService.selectPosReviewList(posReview);
|
|
|
ExcelUtil<PosReview> util = new ExcelUtil<PosReview>(PosReview.class);
|
|
ExcelUtil<PosReview> util = new ExcelUtil<PosReview>(PosReview.class);
|
|
|
util.exportExcel(response, list, MessageUtils.message("no.export.excel.review"));
|
|
util.exportExcel(response, list, MessageUtils.message("no.export.excel.review"));
|
|
@@ -243,8 +242,7 @@ public class PosReviewController extends BaseController
|
|
|
*/
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('system:review:query')")
|
|
@PreAuthorize("@ss.hasPermi('system:review:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
@GetMapping(value = "/{id}")
|
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
return success(posReviewService.selectPosReviewById(id));
|
|
return success(posReviewService.selectPosReviewById(id));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -254,8 +252,7 @@ public class PosReviewController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('system:review:add')")
|
|
@PreAuthorize("@ss.hasPermi('system:review:add')")
|
|
|
@Log(title = "review", businessType = BusinessType.INSERT)
|
|
@Log(title = "review", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody PosReview posReview)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public AjaxResult add(@RequestBody PosReview posReview) {
|
|
|
return toAjax(posReviewService.insertPosReview(posReview));
|
|
return toAjax(posReviewService.insertPosReview(posReview));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -265,8 +262,7 @@ public class PosReviewController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('system:review:edit')")
|
|
@PreAuthorize("@ss.hasPermi('system:review:edit')")
|
|
|
@Log(title = "review", businessType = BusinessType.UPDATE)
|
|
@Log(title = "review", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@RequestBody PosReview posReview)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public AjaxResult edit(@RequestBody PosReview posReview) {
|
|
|
return toAjax(posReviewService.updatePosReview(posReview));
|
|
return toAjax(posReviewService.updatePosReview(posReview));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -275,9 +271,8 @@ public class PosReviewController extends BaseController
|
|
|
*/
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('system:review:remove')")
|
|
@PreAuthorize("@ss.hasPermi('system:review:remove')")
|
|
|
@Log(title = "review", businessType = BusinessType.DELETE)
|
|
@Log(title = "review", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{ids}")
|
|
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(posReviewService.deletePosReviewByIds(ids));
|
|
return toAjax(posReviewService.deletePosReviewByIds(ids));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|