All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.fosin.cdp.mvc.controller.IRetrieveController Maven / Gradle / Ivy

package com.github.fosin.cdp.mvc.controller;

import com.github.fosin.cdp.mvc.constant.MvcConstant;
import com.github.fosin.cdp.mvc.service.IRetrieveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import java.io.Serializable;
import java.util.Collection;

/**
 * Description:
 *
 * @author fosin
 * @date 2018.8.30
 */
@Api("查询数据类控制器")
public interface IRetrieveController {
    > S getService();

    @PostMapping(value = MvcConstant.PATH_ID)
    @ApiOperation(value = "根据主键ID查询一条数据")
    @ApiImplicitParam(name = "id",value = "主键ID")
    default ResponseEntity findOne(@PathVariable ID id) {
        Assert.notNull(id, "查询数据时传入的ID不能为空!");
        return ResponseEntity.ok(getService().findOne(id));
    }

    @PostMapping(value = MvcConstant.PATH_LIST)
    @ApiOperation(value = "查询所有数据服务")
    default ResponseEntity> findAll() {
        return ResponseEntity.ok(getService().findAll());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy