package com.younike.member.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.OrderGpDetail;
import com.younike.service.service.IOrderGpDetailService;
import com.younike.common.core.page.TableResult;

/**
 * 门店订单团购套餐内容商品信息Controller
 *
 * @author dail
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/orderGpDetail")
public class OrderGpDetailController extends BaseController {
    @Autowired
    private IOrderGpDetailService orderGpDetailService;

    /**
     * 查询门店订单团购套餐内容商品信息列表
     */
    @RequiresPermissions("detail:list")
    @PostMapping("/list")
    public Page list(@RequestBody PageParam<OrderGpDetail> page) {

        return orderGpDetailService.page(page);
    }


    /**
     * 获取门店订单团购套餐内容商品信息详细信息
     */
    @RequiresPermissions("detail:query")
    @GetMapping(value = "/{orderGpDetailId}")
    public APIResult getInfo(@PathVariable("orderGpDetailId") String orderGpDetailId) {
        return ResultGenerator.getSuccessResult(orderGpDetailService.getById(orderGpDetailId));
    }

    /**
     * 新增门店订单团购套餐内容商品信息
     */
    @RequiresPermissions("detail:add")
    @OpLog(title = "门店订单团购套餐内容商品信息", type = BusinessType.INSERT)
    @PostMapping
    public APIResult add(@RequestBody OrderGpDetail orderGpDetail) {
        return ResultGenerator.getSuccessResult(orderGpDetailService.save(orderGpDetail));
    }

    /**
     * 修改门店订单团购套餐内容商品信息
     */
    @RequiresPermissions("detail:edit")
    @OpLog(title = "门店订单团购套餐内容商品信息", type = BusinessType.UPDATE)
    @PutMapping
    public APIResult edit(@RequestBody OrderGpDetail orderGpDetail) {
        return ResultGenerator.getSuccessResult(orderGpDetailService.updateById(orderGpDetail));
    }

    /**
     * 删除门店订单团购套餐内容商品信息
     */
    @RequiresPermissions("detail:remove")
    @OpLog(title = "门店订单团购套餐内容商品信息", type = BusinessType.DELETE)
    @DeleteMapping("/{orderGpDetailIds}")
    public APIResult remove(@PathVariable List<String> orderGpDetailIds) {
        return ResultGenerator.getSuccessResult(orderGpDetailService.removeByIds(orderGpDetailIds));
    }
}
