package com.yanzhu.manage.controller;

import com.yanzhu.common.core.utils.poi.ExcelUtil;
import com.yanzhu.common.core.web.controller.BaseController;
import com.yanzhu.common.core.web.domain.AjaxResult;
import com.yanzhu.common.core.web.page.TableDataInfo;
import com.yanzhu.common.log.annotation.Log;
import com.yanzhu.common.log.enums.BusinessType;
import com.yanzhu.common.security.annotation.RequiresPermissions;
import com.yanzhu.manage.domain.AttendanceUbiData;
import com.yanzhu.manage.service.IAttendanceUbiDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 考勤管理Controller
 * 
 * @author yanzhu
 * @date 2024-10-12
 */
@RestController
@RequestMapping("/attendanceUbiData")
public class AttendanceUbiDataController extends BaseController
{
    @Autowired
    private IAttendanceUbiDataService attendanceUbiDataService;

    /**
     * 查询考勤管理列表
     */
    @RequiresPermissions("manage:attendanceUbiData:list")
    @GetMapping("/list")
    public TableDataInfo list(AttendanceUbiData attendanceUbiData)
    {
        startPage();
        List<AttendanceUbiData> list = attendanceUbiDataService.selectAttendanceUbiDataList(attendanceUbiData);
        return getDataTable(list);
    }

    /**
     * 导出考勤管理列表
     */
    @RequiresPermissions("manage:attendanceUbiData:export")
    @Log(title = "考勤管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AttendanceUbiData attendanceUbiData)
    {
        List<AttendanceUbiData> list = attendanceUbiDataService.selectAttendanceUbiDataList(attendanceUbiData);
        ExcelUtil<AttendanceUbiData> util = new ExcelUtil<AttendanceUbiData>(AttendanceUbiData.class);
        util.exportExcel(response, list, "考勤管理数据");
    }

    /**
     * 获取考勤管理详细信息
     */
    @RequiresPermissions("manage:attendanceUbiData:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(attendanceUbiDataService.selectAttendanceUbiDataById(id));
    }

    /**
     * 新增考勤管理
     */
    @RequiresPermissions("manage:attendanceUbiData:add")
    @Log(title = "考勤管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AttendanceUbiData attendanceUbiData)
    {
        return toAjax(attendanceUbiDataService.insertAttendanceUbiData(attendanceUbiData));
    }

    /**
     * 修改考勤管理
     */
    @RequiresPermissions("manage:attendanceUbiData:edit")
    @Log(title = "考勤管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AttendanceUbiData attendanceUbiData)
    {
        return toAjax(attendanceUbiDataService.updateAttendanceUbiData(attendanceUbiData));
    }

    /**
     * 删除考勤管理
     */
    @RequiresPermissions("manage:attendanceUbiData:remove")
    @Log(title = "考勤管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(attendanceUbiDataService.deleteAttendanceUbiDataByIds(ids));
    }
}
