package com.sqx.modules.taking.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sqx.common.utils.DateUtils;
import com.sqx.common.utils.Result;
import com.sqx.modules.bl.order.entity.UserPackageOrder;
import com.sqx.modules.taking.entity.TakingCommnt;
import com.sqx.modules.taking.service.OrderTakingCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/takingComment")
@Api(value = "评论", tags = {"评论"})
public class OrderTakingCommentController {

    @Autowired
    private OrderTakingCommentService orderTakingCommentService;

    /**
     * 查看我的评论
     */
     @GetMapping("/queryMyComment")
     public Result queryMyComment(Integer page,Integer limit,Long userId){
         return orderTakingCommentService.selectOrderTakingCommentByUserId(page,limit,userId);
     }

    @GetMapping("/selectOrderTakingComment")
    @ApiOperation("查看评论")
    public Result selectOrderTakingComment(Integer page, Integer limit, Long id,Long massageTypeId) {
        return orderTakingCommentService.selectOrderTakingComment(page, limit, id,massageTypeId);
    }

    @PostMapping("/deleteOrderTakingComment/{id}")
    @ApiOperation("删除评论")
    public Result deleteOrderTakingComment(@PathVariable Long id){
         orderTakingCommentService.removeById(id);
         return Result.success();
    }

    @GetMapping("/selectOrderTakingCommentByOrdersId")
    @ApiOperation("根据订单查看评论")
    public Result selectOrderTakingCommentByOrdersId(Long ordersId){
        return Result.success().put("data",orderTakingCommentService.getOne(new QueryWrapper<TakingCommnt>().eq("order_id",ordersId)));
    }


    @PostMapping("/insertTaking")
    public Result refund(TakingCommnt takingCommnt){
        takingCommnt.setCreateTime(DateUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
        orderTakingCommentService.save(takingCommnt);
        return Result.success();
    }


}
