Newer
Older
newfiber-termite / newfiber-termites / newfiber-termites-dataup / src / main / java / com / newfiber / termite / controller / ProjectInfoController.java
@yanghui yanghui on 20 May 3 KB 白蚁代码提交
package com.newfiber.termite.controller;


import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.log.annotation.Log;
import com.newfiber.common.log.enums.BusinessType;
import com.newfiber.termite.domain.ProjectInfo;
import com.newfiber.termite.domain.dto.DeviceInfoDto;
import com.newfiber.termite.domain.request.ProjectInfoQueryRequest;
import com.newfiber.termite.domain.request.ProjectInfoSaveRequest;
import com.newfiber.termite.domain.request.ProjectInfoUpdateRequest;
import com.newfiber.termite.service.IProjectInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/termiteProject")
@Api(value = "项目管理", tags = "项目管理页面接口")
public class ProjectInfoController extends BaseController {

    @Resource
    private IProjectInfoService projectInfoService;


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

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

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

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

    /**
     * 分页查询项目信息
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询项目信息", position = 50)
    public PageResult<List<ProjectInfo>> page(ProjectInfoQueryRequest request) {
        startPage();
        List<ProjectInfo> list = projectInfoService.selectPage(request);
        return pageResult(list);
    }

    /**
     * 列表查询项目信息
     */
    @GetMapping("/list")
    @ApiOperation(value = "列表查询项目信息", position = 60)
    public Result<List<ProjectInfo>> list(ProjectInfoQueryRequest request) {
        List<ProjectInfo> list = projectInfoService.selectList(request);
        return success(list);
    }



    /**
     * 通过设备SN获取上传地址
     */
    @GetMapping("/getUploadApi")
    @ApiOperation(value = "通过设备SN获取上传地址", position = 60)
    public Result<List<ProjectInfo>> list(DeviceInfoDto request) {
        if(request.getSn()==null || "".equals(request.getSn())){
            return error("设备编号:sn 不能为空!");
        }
        List<ProjectInfo> list = projectInfoService.getUploadApi(request.getSn());
        return success(list);
    }

}