package com.ruoyi.web.controller.care;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.care.domain.CareAssignments;
import com.ruoyi.care.service.ICareAssignmentsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务务指派Controller
 * 
 * @author qy
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/care/assignments")
public class CareAssignmentsController extends BaseController
{
    @Autowired
    private ICareAssignmentsService careAssignmentsService;

    /**
     * 查询业务务指派列表
     */
    @PreAuthorize("@ss.hasPermi('care:assignments:list')")
    @GetMapping("/list")
    public TableDataInfo list(CareAssignments careAssignments)
    {
        startPage();
        List<CareAssignments> list = careAssignmentsService.selectCareAssignmentsList(careAssignments);
        return getDataTable(list);
    }

    /**
     * 导出业务务指派列表
     */
    @PreAuthorize("@ss.hasPermi('care:assignments:export')")
    @Log(title = "业务务指派", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CareAssignments careAssignments)
    {
        List<CareAssignments> list = careAssignmentsService.selectCareAssignmentsList(careAssignments);
        ExcelUtil<CareAssignments> util = new ExcelUtil<CareAssignments>(CareAssignments.class);
        util.exportExcel(response, list, "业务务指派数据");
    }

    /**
     * 获取业务务指派详细信息
     */
    @PreAuthorize("@ss.hasPermi('care:assignments:query')")
    @GetMapping(value = "/{assignId}")
    public AjaxResult getInfo(@PathVariable("assignId") Long assignId)
    {
        return success(careAssignmentsService.selectCareAssignmentsByAssignId(assignId));
    }

    /**
     * 新增业务务指派
     */
    @PreAuthorize("@ss.hasPermi('care:assignments:add')")
    @Log(title = "业务务指派", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CareAssignments careAssignments)
    {
        return toAjax(careAssignmentsService.insertCareAssignments(careAssignments));
    }

    /**
     * 修改业务务指派
     */
    @PreAuthorize("@ss.hasPermi('care:assignments:edit')")
    @Log(title = "业务务指派", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CareAssignments careAssignments)
    {
        return toAjax(careAssignmentsService.updateCareAssignments(careAssignments));
    }

    /**
     * 删除业务务指派
     */
    @PreAuthorize("@ss.hasPermi('care:assignments:remove')")
    @Log(title = "业务务指派", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assignIds}")
    public AjaxResult remove(@PathVariable Long[] assignIds)
    {
        return toAjax(careAssignmentsService.deleteCareAssignmentsByAssignIds(assignIds));
    }
}
