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

/**
 * 门店团购套餐商品图片				Controller
 *
 * @author dail
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/gpGoodsImg")
public class GpGoodsImgController extends BaseController {
    @Autowired
    private IGpGoodsImgService gpGoodsImgService;

    /**
     * 查询门店团购套餐商品图片				列表
     */
    @RequiresPermissions("img:list")
    @PostMapping("/list")
    public Page list(@RequestBody PageParam<GpGoodsImg> page) {

        return gpGoodsImgService.page(page);
    }


    /**
     * 获取门店团购套餐商品图片				详细信息
     */
    @RequiresPermissions("img:query")
    @GetMapping(value = "/{gpGoodsImgId}")
    public APIResult getInfo(@PathVariable("gpGoodsImgId") String gpGoodsImgId) {
        return ResultGenerator.getSuccessResult(gpGoodsImgService.getById(gpGoodsImgId));
    }

    /**
     * 新增门店团购套餐商品图片				
     */
    @RequiresPermissions("img:add")
    @OpLog(title = "门店团购套餐商品图片				", type = BusinessType.INSERT)
    @PostMapping
    public APIResult add(@RequestBody GpGoodsImg gpGoodsImg) {
        return ResultGenerator.getSuccessResult(gpGoodsImgService.save(gpGoodsImg));
    }

    /**
     * 修改门店团购套餐商品图片				
     */
    @RequiresPermissions("img:edit")
    @OpLog(title = "门店团购套餐商品图片				", type = BusinessType.UPDATE)
    @PutMapping
    public APIResult edit(@RequestBody GpGoodsImg gpGoodsImg) {
        return ResultGenerator.getSuccessResult(gpGoodsImgService.updateById(gpGoodsImg));
    }

    /**
     * 删除门店团购套餐商品图片				
     */
    @RequiresPermissions("img:remove")
    @OpLog(title = "门店团购套餐商品图片				", type = BusinessType.DELETE)
    @DeleteMapping("/{gpGoodsImgIds}")
    public APIResult remove(@PathVariable List<String> gpGoodsImgIds) {
        return ResultGenerator.getSuccessResult(gpGoodsImgService.removeByIds(gpGoodsImgIds));
    }
}
