146 lines
3.9 KiB
Java
146 lines
3.9 KiB
Java
package com.peanut.modules.book.controller;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.peanut.common.utils.PageUtils;
|
|
import com.peanut.common.utils.R;
|
|
import com.peanut.modules.book.entity.BookClockinCommentEntity;
|
|
import com.peanut.modules.book.entity.BookClockinEntity;
|
|
import com.peanut.modules.book.entity.BookClockinPunchEntity;
|
|
import com.peanut.modules.book.service.BookClockinCommentService;
|
|
import com.peanut.modules.book.service.BookClockinPunchService;
|
|
import com.peanut.modules.book.service.BookClockinService;
|
|
import com.peanut.modules.book.service.BookTaskService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.Arrays;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 签到信息用户评论
|
|
*
|
|
*/
|
|
|
|
@RestController
|
|
@RequestMapping("clockin/comment")
|
|
public class BookClockinCommentController {
|
|
|
|
@Autowired
|
|
private BookClockinCommentService bookClockinCommentService;
|
|
@Autowired
|
|
private BookClockinPunchService bookClockinPunchService;
|
|
@Autowired
|
|
private BookClockinService bookClockinService;
|
|
|
|
/**
|
|
* 列表 倒叙
|
|
*/
|
|
@RequestMapping("/applist")
|
|
public R applist(@RequestParam Map<String, Object> params){
|
|
PageUtils page = bookClockinCommentService.queryPage(params);
|
|
return R.ok().put("page", page);
|
|
}
|
|
|
|
|
|
/**
|
|
* 信息
|
|
*/
|
|
@RequestMapping("/info/{id}")
|
|
public R info(@PathVariable("id") Integer id){
|
|
BookClockinCommentEntity commentEntity = bookClockinCommentService.getById(id);
|
|
|
|
return R.ok().put("commentEntity", commentEntity);
|
|
}
|
|
|
|
/**
|
|
* 保存
|
|
*/
|
|
@RequestMapping("/save")
|
|
public R save(@RequestBody BookClockinCommentEntity clockinComment){
|
|
Integer bookid1 = clockinComment.getBookId();
|
|
Integer userId = clockinComment.getUserId();
|
|
Integer taskId = clockinComment.getTaskId();
|
|
|
|
|
|
BookClockinCommentEntity bookClockinCommentEntity = bookClockinCommentService.getBaseMapper().selectOne(new QueryWrapper<BookClockinCommentEntity>()
|
|
.eq("book_id", bookid1)
|
|
.eq("user_id", userId)
|
|
.eq("task_id", taskId)
|
|
|
|
);
|
|
BookClockinPunchEntity ClockinCommen = bookClockinPunchService.getBaseMapper().selectOne(new QueryWrapper<BookClockinPunchEntity>()
|
|
.eq("book_id", bookid1)
|
|
.eq("user_id", userId)
|
|
.eq("t_id", taskId)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (bookClockinCommentEntity !=null) {
|
|
return R.error("该信息允许发布一条内容,请勿重复发布");
|
|
}
|
|
|
|
if (ClockinCommen!=null) {
|
|
clockinComment.setPid(1);
|
|
}
|
|
|
|
bookClockinCommentService.save(clockinComment);
|
|
return R.ok();
|
|
}
|
|
|
|
|
|
/**
|
|
* 保存
|
|
*/
|
|
@RequestMapping("/replysave")
|
|
public R replysave(@RequestBody BookClockinCommentEntity clockinComment) {
|
|
Integer bookid = clockinComment.getBookId();
|
|
Integer userId = clockinComment.getUserId();
|
|
Integer pid = clockinComment.getPid();
|
|
BookClockinEntity bookClockinEntity = bookClockinService.getBaseMapper().selectOne(new QueryWrapper<BookClockinEntity>()
|
|
.eq("id",pid)
|
|
);
|
|
clockinComment.setDelFlag(0);
|
|
bookClockinCommentService.save(clockinComment);
|
|
|
|
return R.ok();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* 修改
|
|
*/
|
|
@RequestMapping("/update")
|
|
public R update(@RequestBody BookClockinCommentEntity clockinComment){
|
|
|
|
bookClockinCommentService.updateById(clockinComment);
|
|
return R.ok();
|
|
}
|
|
|
|
|
|
/**
|
|
* 删除
|
|
*/
|
|
@RequestMapping("/delete")
|
|
public R delete(@RequestBody Integer[] ids){
|
|
bookClockinCommentService.removeByIds(Arrays.asList(ids));
|
|
|
|
return R.ok();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|