package com.bonus.sgzb.system.controller;

import java.util.List;

import com.bonus.sgzb.system.api.domain.SysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.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.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import com.bonus.sgzb.common.security.annotation.RequiresPermissions;
import com.bonus.sgzb.system.domain.PurchaseNoticePerson;
import com.bonus.sgzb.system.service.IPurchaseNoticePersonService;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;

/**
 * 新购短信通知人员
 * 
 * @author bonus
 * @date 2023-12-16
 */
@RestController
@Api(value = "新购短信通知人员")
@RequestMapping("/person")
public class PurchaseNoticePersonController extends BaseController
{
    @Autowired
    private IPurchaseNoticePersonService purchaseNoticePersonService;

    /**
     * 查询新购短信通知人员列表
     */
    @ApiOperation("查询新购短信通知人员")
    @GetMapping("/list")
    public AjaxResult list(PurchaseNoticePerson purchaseNoticePerson)
    {
        List<PurchaseNoticePerson> list = purchaseNoticePersonService.selectPurchaseNoticePersonList(purchaseNoticePerson);
        return AjaxResult.success(list);
    }


    /**
     * 新增新购短信通知人员purchase_notice_person
     */
    @ApiOperation(value ="新增新购短信通知人员")
    @Log(title = "新购短信通知人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<PurchaseNoticePerson> purchaseNoticePersonList)
    {
        return toAjax(purchaseNoticePersonService.insertPurchaseNoticePersonList(purchaseNoticePersonList));
    }

    /**
     * 删除新购短信通知人员
     */
    @RequiresPermissions("删除新购短信通知人员")
    @Log(title = "删除新购短信通知人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userId}")
    public AjaxResult remove(@PathVariable Long userId)
    {
        return toAjax(purchaseNoticePersonService.deletePurchaseNoticePersonById(userId));
    }


    /**
     * 通知人员添加查询接口
     * @param sysUser
     * @return
     */
    @GetMapping("/notification")
    public AjaxResult notification(SysUser sysUser) {
        return success(purchaseNoticePersonService.getUserByRoleList(sysUser));
    }
}
