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.GpGoodsDetail;
import com.younike.service.service.IGpGoodsDetailService;
import com.younike.common.core.page.TableResult;

/**
 * 门店团购（到店套餐）套餐明细				Controller
 *
 * @author dail
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/gpGoodsDetail")
public class GpGoodsDetailController extends BaseController {
    @Autowired
    private IGpGoodsDetailService gpGoodsDetailService;

    /**
     * 查询门店团购（到店套餐）套餐明细				列表
     */
    @RequiresPermissions("detail:list")
    @PostMapping("/list")
    public Page list(@RequestBody PageParam<GpGoodsDetail> page) {

        return gpGoodsDetailService.page(page);
    }


    /**
     * 获取门店团购（到店套餐）套餐明细				详细信息
     */
    @RequiresPermissions("detail:query")
    @GetMapping(value = "/{gpGoodsDetailId}")
    public APIResult getInfo(@PathVariable("gpGoodsDetailId") String gpGoodsDetailId) {
        return ResultGenerator.getSuccessResult(gpGoodsDetailService.getById(gpGoodsDetailId));
    }

    /**
     * 新增门店团购（到店套餐）套餐明细				
     */
    @RequiresPermissions("detail:add")
    @OpLog(title = "门店团购（到店套餐）套餐明细				", type = BusinessType.INSERT)
    @PostMapping
    public APIResult add(@RequestBody GpGoodsDetail gpGoodsDetail) {
        return ResultGenerator.getSuccessResult(gpGoodsDetailService.save(gpGoodsDetail));
    }

    /**
     * 修改门店团购（到店套餐）套餐明细				
     */
    @RequiresPermissions("detail:edit")
    @OpLog(title = "门店团购（到店套餐）套餐明细				", type = BusinessType.UPDATE)
    @PutMapping
    public APIResult edit(@RequestBody GpGoodsDetail gpGoodsDetail) {
        return ResultGenerator.getSuccessResult(gpGoodsDetailService.updateById(gpGoodsDetail));
    }

    /**
     * 删除门店团购（到店套餐）套餐明细				
     */
    @RequiresPermissions("detail:remove")
    @OpLog(title = "门店团购（到店套餐）套餐明细				", type = BusinessType.DELETE)
    @DeleteMapping("/{gpGoodsDetailIds}")
    public APIResult remove(@PathVariable List<String> gpGoodsDetailIds) {
        return ResultGenerator.getSuccessResult(gpGoodsDetailService.removeByIds(gpGoodsDetailIds));
    }
}
