package com.starry.admin.modules.order.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.starry.admin.modules.order.module.entity.PlayOrderEvaluateInfoEntity;
import com.starry.admin.modules.order.module.vo.PlayOrderEvaluateEditStateVo;
import com.starry.admin.modules.order.module.vo.PlayOrderEvaluateQueryVo;
import com.starry.admin.modules.order.module.vo.PlayOrderEvaluateReturnVo;
import com.starry.admin.modules.order.service.IPlayOrderEvaluateInfoService;
import com.starry.common.annotation.Log;
import com.starry.common.enums.BusinessType;
import com.starry.common.result.R;
import com.starry.common.utils.ConvertUtil;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 订单评价信息Controller
 *
 * @author admin
 * @since 2024-05-07
 */
@RestController
@RequestMapping("/order/evaluate")
public class PlayOrderEvaluateInfoController {
    @Resource
    private IPlayOrderEvaluateInfoService playOrderEvaluateInfoService;

    /**
     * 查询订单评价信息列表
     */
    @PostMapping("/listByPage")
    public R list(@Validated @RequestBody PlayOrderEvaluateQueryVo vo) {
        IPage<PlayOrderEvaluateReturnVo> list = playOrderEvaluateInfoService.selectByPage(vo);
        return R.ok(list);
    }



    /**
     * 修改订单评价信息
     */
    //@PreAuthorize("@customSs.hasPermission('order:evaluate:update')")
    @Log(title = "修改订单评价状态", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/updateStatus")
    public R update(@Validated @RequestBody PlayOrderEvaluateEditStateVo vo) {
        PlayOrderEvaluateInfoEntity entity = ConvertUtil.entityToVo(vo, PlayOrderEvaluateInfoEntity.class);
        boolean success = playOrderEvaluateInfoService.update(entity);
        if (success) {
            return R.ok();
        }
        return R.error("修改失败");
    }

    /**
     * 删除订单评价信息
     */
    //@PreAuthorize("@customSs.hasPermission('order:evaluate:delete')")
    @Log(title = "订单评价信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable String[] ids) {
        return R.ok(playOrderEvaluateInfoService.deletePlayOrderEvaluateInfoByIds(ids));
    }
}
