package com.sqx.modules.bl.pingjiaTag.content;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sqx.common.utils.Result;
import com.sqx.modules.artificerselfgoods.entity.BlArtificerSelfGoods;
import com.sqx.modules.bl.collect.entity.CollectMassage;
import com.sqx.modules.bl.massage.entity.MassagePackage;
import com.sqx.modules.bl.order.entity.UserPackage;
import com.sqx.modules.bl.order.service.UserPackageService;
import com.sqx.modules.bl.pingjiaTag.entity.BlPingjiaTag;
import com.sqx.modules.bl.pingjiaTag.service.BlPingjiaTagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;


@RestController
@RequestMapping("/bl/pingjiaTag")
@Api(value = "评价标签", tags = {"评价标签"})
public class BlPingjiaTagController {

    @Autowired
    private BlPingjiaTagService service;


    @GetMapping("/list")
    @ApiOperation("获取数据列表")
    public Result list(BlPingjiaTag entity, Integer page, Integer limit){
        QueryWrapper<BlPingjiaTag> qw = new QueryWrapper<>();
        qw.orderByDesc("create_time");
        IPage<BlPingjiaTag> pageList = service.page(new Page<>(page,limit),qw);
        return Result.success().put("data",pageList);
    }

    @PostMapping("/add")
    @ApiOperation("添加")
    public Result add(BlPingjiaTag blPingjiaTag){
        blPingjiaTag.setCreateTime(new Date());
        service.save(blPingjiaTag);
        return Result.success();
    }

    @PostMapping("/modify")
    @ApiOperation("修改")
    public Result modify(BlPingjiaTag blPingjiaTag){
        blPingjiaTag.setCreateTime(new Date());
        service.updateById(blPingjiaTag);
        return Result.success();
    }

    @PostMapping("/delete")
    @ApiOperation("删除")
    public Result delete(BlPingjiaTag blPingjiaTag){
        service.removeById(blPingjiaTag.getId());
        return Result.success();
    }

}
