package com.gree.mall.manager.controller.order;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gree.mall.manager.bean.order.OrderDetailBean;
import com.gree.mall.manager.helper.ResponseHelper;
import com.gree.mall.manager.logic.order.CommentTagLogic;
import com.gree.mall.manager.plus.entity.CommentTag;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@Api(value = "评价标签管理API", tags = {"评价标签管理API"})
@RequestMapping(value = "/comment/tag", produces = "application/json; charset=utf-8")
public class CommentTagController {

    @Autowired
    CommentTagLogic commentTagLogic;

    @GetMapping("/list")
    @ApiOperation("标签列表")
    public ResponseHelper<IPage<CommentTag>> list(
            @ApiParam(value = "页号", required = true) @RequestParam(required = true) Integer pageNo,
            @ApiParam(value = "页大小", required = true) @RequestParam(required = true) Integer pageSize,
            HttpServletRequest request
    ) {
        IPage<CommentTag> list = commentTagLogic.list(request,pageNo, pageSize);
        return ResponseHelper.success(list);
    }

    @PostMapping("/add")
    @ApiOperation("新增标签")
    public ResponseHelper remark(
            @ApiParam(value = "标签名称", required = true) @RequestParam(required = true) String tag,
            HttpServletRequest request
    ) {
        commentTagLogic.add(tag,request);
        return ResponseHelper.success();
    }

    @PostMapping("/update")
    @ApiOperation("修改标签")
    public ResponseHelper update(
            @ApiParam(value = "标签id", required = true) @RequestParam(required = true) String commentTagId,
            @ApiParam(value = "标签名称", required = true) @RequestParam(required = true) String tag
    ) {
        commentTagLogic.update(commentTagId,tag);
        return ResponseHelper.success();
    }

    @PostMapping("/delete")
    @ApiOperation("删除标签")
    public ResponseHelper delete(
            @ApiParam(value = "标签id", required = true) @RequestParam(required = true) String commentTagId
    ) {
        commentTagLogic.delete(commentTagId);
        return ResponseHelper.success();
    }

}
