package com.hw.ems.base.controller;

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

import com.hw.ems.base.domain.BasePublicUserRecord;
import com.hw.ems.base.service.IBasePublicUserRecordService;
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.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.utils.poi.ExcelUtil;
import com.hw.common.core.web.page.TableDataInfo;

/**
 * 公摊用户数据记录Controller
 *
 * @author YinQ
 * @date 2023-06-25
 */
@RestController
@RequestMapping("/publicUserRecord")
public class BasePublicUserRecordController extends BaseController
{
    @Autowired
    private IBasePublicUserRecordService basePublicUserRecordService;

    /**
     * 查询公摊用户数据记录列表
     */
    @RequiresPermissions("energy:publicUserRecord:list")
    @GetMapping("/list")
    public TableDataInfo list(BasePublicUserRecord basePublicUserRecord)
    {
        startPage();
        List<BasePublicUserRecord> list = basePublicUserRecordService.selectBasePublicUserRecordList(basePublicUserRecord);
        return getDataTable(list);
    }

    /**
     * 导出公摊用户数据记录列表
     */
    @RequiresPermissions("energy:publicUserRecord:export")
    @Log(title = "公摊用户数据记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasePublicUserRecord basePublicUserRecord)
    {
        List<BasePublicUserRecord> list = basePublicUserRecordService.selectBasePublicUserRecordList(basePublicUserRecord);
        ExcelUtil<BasePublicUserRecord> util = new ExcelUtil<BasePublicUserRecord>(BasePublicUserRecord.class);
        util.exportExcel(response, list, "公摊用户数据记录数据");
    }

    /**
     * 获取公摊用户数据记录详细信息
     */
    @RequiresPermissions("energy:publicUserRecord:query")
    @GetMapping(value = "/{objid}")
    public AjaxResult getInfo(@PathVariable("objid") Long objid)
    {
        return success(basePublicUserRecordService.selectBasePublicUserRecordByObjid(objid));
    }

    /**
     * 新增公摊用户数据记录
     */
    @RequiresPermissions("energy:publicUserRecord:add")
    @Log(title = "公摊用户数据记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasePublicUserRecord basePublicUserRecord)
    {
        return toAjax(basePublicUserRecordService.insertBasePublicUserRecord(basePublicUserRecord));
    }

    /**
     * 修改公摊用户数据记录
     */
    @RequiresPermissions("energy:publicUserRecord:edit")
    @Log(title = "公摊用户数据记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasePublicUserRecord basePublicUserRecord)
    {
        return toAjax(basePublicUserRecordService.updateBasePublicUserRecord(basePublicUserRecord));
    }

    /**
     * 删除公摊用户数据记录
     */
    @RequiresPermissions("energy:publicUserRecord:remove")
    @Log(title = "公摊用户数据记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{objids}")
    public AjaxResult remove(@PathVariable Long[] objids)
    {
        return toAjax(basePublicUserRecordService.deleteBasePublicUserRecordByObjids(objids));
    }
}
