Newer
Older
newfiber-termite / newfiber-termites / newfiber-termites-dataup / src / main / java / com / newfiber / termite / controller / DeviceInfoController.java
@xiongkai xiongkai on 4 Jun 3 KB 设备状态同步接口
package com.newfiber.termite.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.validation.Valid;
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.newfiber.common.log.annotation.Log;
import com.newfiber.common.log.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.service.IDeviceInfoService;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;

/**
 * 设备信息Controller
 * 
 * @author X.K
 * @date 2024-05-27
 */
@RestController
@RequestMapping("/deviceInfo")
@Api(value = "设备信息", tags = "设备信息")
public class DeviceInfoController extends BaseController {

    @Resource
    private IDeviceInfoService deviceInfoService;

    /**
     * 新增设备信息
     */
    @PostMapping("add")
    @ApiOperation(value = "新增设备信息", position = 10)
    @Log(title = "设备信息", businessType = BusinessType.INSERT)
    public Result<Long> add(@Valid @RequestBody DeviceInfoSaveRequest request) {
        return success(deviceInfoService.insert(request));
    }

    /**
     * 修改设备信息
     */
    @PutMapping("edit")
    @ApiOperation(value = "修改设备信息", position = 20)
    @Log(title = "设备信息", businessType = BusinessType.UPDATE)
    public Result<Object> edit(@Valid @RequestBody DeviceInfoUpdateRequest request) {
        return success(deviceInfoService.update(request));
    }

    /**
     * 删除设备信息
     */
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除设备信息", notes = "传入ids(,隔开)", position = 30)
    @Log(title = "设备信息", businessType = BusinessType.DELETE)
    public Result<Object> remove(@PathVariable String ids) {
        return success(deviceInfoService.delete(ids));
    }

    /**
     * 详细查询设备信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "详细查询设备信息", position = 40)
    public Result<DeviceInfo> detail(@PathVariable("id") Long id) {
        return success(deviceInfoService.selectDetail(id));
    }

    /**
     * 分页查询设备信息
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询设备信息", position = 50)
    public PageResult<List<DeviceInfo>> page(DeviceInfoQueryRequest request) {
        startPage();
        List<DeviceInfo> list = deviceInfoService.selectPage(request);
        return pageResult(list);
    }

    /**
     * 列表查询设备信息
     */
    @GetMapping("/list")
    @ApiOperation(value = "列表查询设备信息", position = 60)
    public Result<List<DeviceInfo>> list(DeviceInfoQueryRequest request) {
        List<DeviceInfo> list = deviceInfoService.selectList(request);
        return success(list);
    }

}