package com.yonge.cooleshow.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.microsvc.toolkit.common.response.paging.QueryInfo;
import com.yonge.cooleshow.biz.dal.entity.SysGoodsPrice;
import com.yonge.cooleshow.biz.dal.service.SysGoodsPriceService;
import com.yonge.cooleshow.biz.dal.wrapper.SysGoodsPriceWrapper;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import com.yonge.toolset.base.page.PageInfo;
import com.yonge.toolset.mybatis.support.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品价格设置
 * 2023-07-21 17:32:49
 */

@RestController
@RequestMapping("${app-config.url.admin:}/sysGoodsPrice")
@Api(value = "商品价格", tags = "商品价格")
public class SysGoodsPriceController extends BaseController {

    @Autowired
    SysGoodsPriceService sysGoodsPriceService;

    /**
     * 查询分页
     * @param query
     */
    @PostMapping("/page")
    @ApiOperation(value = "查询分页", notes = "sysGoodsPrice")
    @PreAuthorize("@pcs.hasPermissions('sysGoodsPrice/page')")
    public HttpResponseResult<PageInfo<SysGoodsPrice>> page(@RequestBody SysGoodsPriceWrapper.SysGoodsPriceQuery query) {
        IPage<SysGoodsPrice> pages = sysGoodsPriceService.selectPage(QueryInfo.getPage(query), query);
        return HttpResponseResult.succeed(PageUtil.pageInfo(pages));
    }


    /**
     * 修改
     * @param sysGoodsPrice
     */
    @PostMapping("/update")
    @ApiOperation(value = "修改", notes = "sysGoodsPrice")
    @PreAuthorize("@pcs.hasPermissions('sysGoodsPrice/update')")
    public HttpResponseResult<Boolean> update(@RequestBody SysGoodsPriceWrapper.SysGoodsPrice sysGoodsPrice) {

        return HttpResponseResult.succeed(sysGoodsPriceService.update(sysGoodsPrice));
    }

    /**
     * 新增
     * @param sysGoodsPrice
     */
    @PostMapping("/add")
    @ApiOperation(value = "新增", notes = "sysGoodsPrice")
    @PreAuthorize("@pcs.hasPermissions('sysGoodsPrice/add')")
    public HttpResponseResult<Boolean> add(@RequestBody SysGoodsPriceWrapper.SysGoodsPrice sysGoodsPrice) {
        return HttpResponseResult.succeed(sysGoodsPriceService.add(sysGoodsPrice));
    }


}
