package com.younike.store.controller;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import com.younike.common.bean.APIResult;
import com.younike.common.bean.ResultGenerator;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import com.younike.common.core.page.PageParam;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.younike.common.annotation.OpLog;
import com.younike.common.core.controller.BaseController;
import com.younike.common.core.dto.AjaxResult;
import com.younike.common.constant.BusinessType;
import com.younike.service.pojo.GpContentProduct;
import com.younike.service.service.IGpContentProductService;
import com.younike.common.core.page.TableResult;

/**
 * 门店套餐内容产品				Controller
 *
 * @author dail
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/gpContentProduct")
public class GpContentProductController extends BaseController {
    @Autowired
    private IGpContentProductService gpContentProductService;

    /**
     * 查询门店套餐内容产品				列表
     */
    @RequiresPermissions("product:list")
    @PostMapping("/list")
    public Page list(@RequestBody PageParam<GpContentProduct> page) {

        return gpContentProductService.page(page);
    }


    /**
     * 获取门店套餐内容产品				详细信息
     */
    @RequiresPermissions("product:query")
    @GetMapping(value = "/{contentProductId}")
    public APIResult getInfo(@PathVariable("contentProductId") String contentProductId) {
        return ResultGenerator.getSuccessResult(gpContentProductService.getById(contentProductId));
    }

    /**
     * 新增门店套餐内容产品				
     */
    @RequiresPermissions("product:add")
    @OpLog(title = "门店套餐内容产品				", type = BusinessType.INSERT)
    @PostMapping
    public APIResult add(@RequestBody GpContentProduct gpContentProduct) {
        return ResultGenerator.getSuccessResult(gpContentProductService.save(gpContentProduct));
    }

    /**
     * 修改门店套餐内容产品				
     */
    @RequiresPermissions("product:edit")
    @OpLog(title = "门店套餐内容产品				", type = BusinessType.UPDATE)
    @PutMapping
    public APIResult edit(@RequestBody GpContentProduct gpContentProduct) {
        return ResultGenerator.getSuccessResult(gpContentProductService.updateById(gpContentProduct));
    }

    /**
     * 删除门店套餐内容产品				
     */
    @RequiresPermissions("product:remove")
    @OpLog(title = "门店套餐内容产品				", type = BusinessType.DELETE)
    @DeleteMapping("/{contentProductIds}")
    public APIResult remove(@PathVariable List<String> contentProductIds) {
        return ResultGenerator.getSuccessResult(gpContentProductService.removeByIds(contentProductIds));
    }
}
