package com.yiqi.admin.controller.activity;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.yiqi.activity.domain.vo.ActivityClothItemVO;
import com.yiqi.common.constant.UrlConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
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.yiqi.common.annotation.Log;
import com.yiqi.common.core.controller.BaseController;
import com.yiqi.common.core.domain.AjaxResult;
import com.yiqi.common.enums.BusinessType;
import com.yiqi.activity.domain.ActivityClothItem;
import com.yiqi.activity.service.IActivityClothItemService;
import com.yiqi.common.utils.poi.ExcelUtil;
import com.yiqi.common.core.page.TableDataInfo;

/**
 * 指定衣服折扣活动明细Controller
 *
 * @author xiaohei
 * @date 2023-09-11
 */
@Api(tags = "管理后台 - 指定衣服折扣活动明细")
@RestController
@RequestMapping(UrlConstants.managerApi + "/activity/clothItem")
public class ActivityClothItemController extends BaseController {
    @Autowired
    private IActivityClothItemService activityClothItemService;

    /**
     * 查询指定衣服折扣活动明细列表
     */
    @PreAuthorize("@ss.hasPermi('activity:clothInfo:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询指定衣服折扣活动明细列表")
    public TableDataInfo list(ActivityClothItem activityClothItem) {
        startPage();
        List<ActivityClothItemVO> list = activityClothItemService.selectActivityClothItemList(activityClothItem);
        return getDataTable(list);
    }

    /**
     * 导出指定衣服折扣活动明细列表
     */
    @PreAuthorize("@ss.hasPermi('activity:clothInfo:export')")
    @Log(title = "指定衣服折扣活动明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出指定衣服折扣活动明细列表")
    public void export(HttpServletResponse response, ActivityClothItem activityClothItem) {
        List<ActivityClothItemVO> list = activityClothItemService.selectActivityClothItemList(activityClothItem);
        ExcelUtil<ActivityClothItemVO> util = new ExcelUtil<ActivityClothItemVO>(ActivityClothItemVO. class);
        util.exportExcel(response, list, "指定衣服折扣活动明细数据");
    }

    /**
     * 获取指定衣服折扣活动明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('activity:clothInfo:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取指定衣服折扣活动明细详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(activityClothItemService.selectActivityClothItemById(id));
    }

    /**
     * 新增指定衣服折扣活动明细
     */
    @PreAuthorize("@ss.hasPermi('activity:clothInfo:add')")
    @Log(title = "指定衣服折扣活动明细", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增指定衣服折扣活动明细")
    public AjaxResult add(@RequestBody ActivityClothItem activityClothItem) {
        activityClothItem.setCreateById(getUserId());
        activityClothItem.setCreateBy(getUsername());
        return toAjax(activityClothItemService.insertActivityClothItem(activityClothItem));
    }

    /**
     * 修改指定衣服折扣活动明细
     */
    @PreAuthorize("@ss.hasPermi('activity:clothInfo:edit')")
    @Log(title = "指定衣服折扣活动明细", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改指定衣服折扣活动明细")
    public AjaxResult edit(@RequestBody ActivityClothItem activityClothItem) {
        activityClothItem.setUpdateById(getUserId());
        activityClothItem.setUpdateBy(getUsername());
        return toAjax(activityClothItemService.updateActivityClothItem(activityClothItem));
    }

    /**
     * 删除指定衣服折扣活动明细
     */
    @PreAuthorize("@ss.hasPermi('activity:clothInfo:remove')")
    @Log(title = "指定衣服折扣活动明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除指定衣服折扣活动明细")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(activityClothItemService.deleteActivityClothItemByIds(ids));
    }

}
