package com.njzscloud.supervisory.discount.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.discount.pojo.DiscountManageEntity;
import com.njzscloud.supervisory.discount.service.DiscountManageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 优惠管理
 */
@Slf4j
@RestController
@RequestMapping("/discount")
@RequiredArgsConstructor
public class DiscountManageController {

    private final DiscountManageService discountManageService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody DiscountManageEntity discountManageEntity) {
        discountManageService.add(discountManageEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody DiscountManageEntity discountManageEntity) {
        discountManageService.modify(discountManageEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        discountManageService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<DiscountManageEntity> detail(@RequestParam Long id) {
        return R.success(discountManageService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<DiscountManageEntity>> paging(PageParam pageParam, DiscountManageEntity discountManageEntity) {
        return R.success(discountManageService.paging(pageParam, discountManageEntity));
    }

}

