Newer
Older
newfiber-termite / newfiber-termites / newfiber-termites-dataup / src / main / java / com / newfiber / termite / controller / ProjectInfoController.java
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.request.UploadApiRequest;
import com.newfiber.termite.domain.request.project.ProjectInfoQueryRequest;
import com.newfiber.termite.domain.request.project.ProjectInfoSaveRequest;
import com.newfiber.termite.domain.request.project.ProjectInfoUpdateRequest;
import com.newfiber.termite.service.IProjectInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
import javax.validation.Valid;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@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(value = "/detailByCode/{projectCode}")
    @ApiOperation(value = "详细查询项目信息", position = 40)
    public Result<ProjectInfo> detailByCode(@PathVariable("projectCode") String projectCode) {
        return success(projectInfoService.selectDetail(projectCode));
    }

    /**
     * 分页查询项目信息
     */
    @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);
    }

    /**
     * 列表查询人员项目
     */
    @GetMapping("/getUserProjectList/{userId}")
    @ApiOperation(value = "列表查询人员项目", position = 60)
    public Result<Set<ProjectInfo>> list(@PathVariable("userId") Long userId) {
        Set<ProjectInfo> list = projectInfoService.getUserProjectList(userId);
        return success(list);
    }

    /**
     * 通过设备SN获取上传地址
     */
    @Deprecated
    @GetMapping("/getUploadApi")
    @ApiOperation(value = "通过设备SN获取上传地址", position = 60)
    public Result<List<ProjectInfo>> list(UploadApiRequest request) {
        List<ProjectInfo> list = projectInfoService.getUploadApi(request.getSn());
        return success(list);
    }

    @Deprecated
    @GetMapping("/getOemConfigApi")
    @ApiOperation(value = "通过设备SN获取OEM厂商的配置读取接口地址(设备获取其他白蚁防治图片接口地址)", position = 70)
    public Result<List<ProjectInfo>> getOemConfigApi(UploadApiRequest request) {
        List<ProjectInfo> list = projectInfoService.getOemConfigApi(request.getSn());
        return success(list);
    }

}