package com.tongran.system.controller;

import com.tongran.common.core.utils.poi.ExcelUtil;
import com.tongran.common.core.web.controller.BaseController;
import com.tongran.common.core.web.domain.AjaxResult;
import com.tongran.common.core.web.page.TableDataInfo;
import com.tongran.common.log.annotation.Log;
import com.tongran.common.log.enums.BusinessType;
import com.tongran.common.security.annotation.RequiresPermissions;
import com.tongran.system.domain.RmRegistrationMachine;
import com.tongran.system.service.IRmRegistrationMachineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 绑定金山machinecodeController
 * 
 * @author tongran
 * @date 2025-10-10
 */
@RestController
@RequestMapping("/machine")
@RequiresPermissions("system:registration")
public class RmRegistrationMachineController extends BaseController
{
    @Autowired
    private IRmRegistrationMachineService rmRegistrationMachineService;

    /**
     * 查询绑定金山machinecode列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RmRegistrationMachine rmRegistrationMachine)
    {
        startPage();
        List<RmRegistrationMachine> list = rmRegistrationMachineService.selectRmRegistrationMachineList(rmRegistrationMachine);
        return getDataTable(list);
    }

    /**
     * 导出绑定金山machinecode列表
     */
    @Log(title = "绑定金山machinecode", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RmRegistrationMachine rmRegistrationMachine)
    {
        List<RmRegistrationMachine> list = rmRegistrationMachineService.selectRmRegistrationMachineList(rmRegistrationMachine);
        ExcelUtil<RmRegistrationMachine> util = new ExcelUtil<RmRegistrationMachine>(RmRegistrationMachine.class);
        util.exportExcel(response, list, "绑定金山machinecode数据");
    }

    /**
     * 获取绑定金山machinecode详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rmRegistrationMachineService.selectRmRegistrationMachineById(id));
    }

    /**
     * 新增绑定金山machinecode
     */
    @Log(title = "绑定金山machinecode", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RmRegistrationMachine rmRegistrationMachine)
    {
        return toAjax(rmRegistrationMachineService.insertRmRegistrationMachine(rmRegistrationMachine));
    }

    /**
     * 修改绑定金山machinecode
     */
    @Log(title = "绑定金山machinecode", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RmRegistrationMachine rmRegistrationMachine)
    {
        return toAjax(rmRegistrationMachineService.updateRmRegistrationMachine(rmRegistrationMachine));
    }

    /**
     * 删除绑定金山machinecode
     */
    @Log(title = "绑定金山machinecode", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rmRegistrationMachineService.deleteRmRegistrationMachineByIds(ids));
    }
}
