package com.dcsoft.system.controller;

import com.dcsoft.common.core.constant.HttpStatus;
import com.dcsoft.common.core.utils.StringUtils;
import com.dcsoft.common.core.utils.poi.ExcelUtil;
import com.dcsoft.common.core.utils.sql.SqlUtil;
import com.dcsoft.common.core.web.controller.BaseController;
import com.dcsoft.common.core.web.domain.AjaxResult;
import com.dcsoft.common.core.web.page.PageDomain;
import com.dcsoft.common.core.web.page.TableDataInfo;
import com.dcsoft.common.core.web.page.TableDatasInfo;
import com.dcsoft.common.core.web.page.TableSupport;
import com.dcsoft.common.log.annotation.Log;
import com.dcsoft.common.log.enums.BusinessType;
import com.dcsoft.common.security.annotation.RequiresPermissions;
import com.dcsoft.system.domain.HkPeopleRecord;
import com.dcsoft.system.service.IHkPeopleRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * 海康打卡记录Controller
 *
 * @author nichun
 * @date 2023-09-27
 */
@RestController
@RequestMapping("/hkdkRecord")
public class HkPeopleRecordController extends BaseController
{
    @Autowired
    private IHkPeopleRecordService hkPeopleRecordService;

    /**
     * 查询海康打卡记录列表
     */
    @RequiresPermissions("system:hkdkRecord:list")
    @GetMapping("/list")
    public TableDataInfo list(HkPeopleRecord hkPeopleRecord)
    {
        startPage();
        List<HkPeopleRecord> list = hkPeopleRecordService.selectHkPeopleRecordList(hkPeopleRecord);
        return getDataTable(list);
    }

    /**
     * 导出海康打卡记录列表
     */
    @RequiresPermissions("system:hkdkRecord:export")
    @Log(title = "海康打卡记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HkPeopleRecord hkPeopleRecord)
    {
        List<HkPeopleRecord> list = hkPeopleRecordService.selectHkPeopleRecordList(hkPeopleRecord);
        ExcelUtil<HkPeopleRecord> util = new ExcelUtil<HkPeopleRecord>(HkPeopleRecord.class);
        util.exportExcel(response, list, "海康打卡记录数据");
    }

    /**
     * 获取海康打卡记录详细信息
     */
    @RequiresPermissions("system:hkdkRecord:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hkPeopleRecordService.selectHkPeopleRecordById(id));
    }

    /**
     * 新增海康打卡记录
     */
    @RequiresPermissions("system:hkdkRecord:add")
    @Log(title = "海康打卡记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HkPeopleRecord hkPeopleRecord)
    {
        return toAjax(hkPeopleRecordService.insertHkPeopleRecord(hkPeopleRecord));
    }

    /**
     * 修改海康打卡记录
     */
    @RequiresPermissions("system:hkdkRecord:edit")
    @Log(title = "海康打卡记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HkPeopleRecord hkPeopleRecord)
    {
        return toAjax(hkPeopleRecordService.updateHkPeopleRecord(hkPeopleRecord));
    }

    /**
     * 删除海康打卡记录
     */
    @RequiresPermissions("system:hkdkRecord:remove")
    @Log(title = "海康打卡记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hkPeopleRecordService.deleteHkPeopleRecordByIds(ids));
    }



}
