图片上传后台

import request from '@/utils/request'

export function createExpert(data) {
return request({
url: '/expert',
method: 'post',
data
})
}

import java.io.IOException;

import javax.validation.Valid;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.RequestMethod;
import org.springframework.web.multipart.MultipartFile;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import mobi.peihu.domain.Expert;
import mobi.peihu.service.QiniuService;

@Api(value = "expert", description = "the expert API")
@RequestMapping(value = "/api/v1/expert")
public interface ExpertApi {

@ApiOperation(value = "Add a new expert", notes = "", response = Expert.class, tags = {})
@ApiResponses(value = { @ApiResponse(code = 200, message = "Expert created successful", response = Expert.class),
@ApiResponse(code = 405, message = "Invalid input", response = Void.class) })

@RequestMapping(value = "", produces = { "application/json" }, consumes = { "application/json",
"application/x-www-form-urlencoded", "multipart/form-data" }, method = RequestMethod.POST)
Expert addExpert(
@ApiParam(value = "Expert object that needs to be added", required = true) @Valid @RequestBody Expert expert);

}


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;

import java.io.*;
import java.util.UUID;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;

import io.swagger.annotations.ApiParam;
import mobi.peihu.domain.Expert;
import mobi.peihu.repository.ExpertRepository;
import mobi.peihu.service.ExpertService;
import mobi.peihu.service.QiniuService;

@CrossOrigin
@RestController
public class ExpertApiController implements ExpertApi {

@Override
public Expert addExpert(@RequestBody Expert expert) {
// TODO Auto-generated method stub
return expertRepository.save(expert);
}

}

猜你喜欢

转载自www.cnblogs.com/reprint/p/9779354.html