| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.system.ApplicationHome; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | @RestController |
| | | @RequestMapping("station3D") |
| | | @Api(tags = "3D机房配置") |
| | | public class Station3DController { |
| | | public class Station3DController extends BaseController{ |
| | | |
| | | @Autowired |
| | | private Station3DService service; |
| | |
| | | return new Response().setII(1,"新增成功"); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @PostMapping("delete") |
| | | @ApiOperation(value = "删除") |
| | | public Response delete(@RequestParam int stationId){ |
| | | service.delete(stationId); |
| | | return new Response().setII(1,"删除成功"); |
| | | } |
| | | |
| | | @PutMapping |
| | | @PostMapping("update") |
| | | @ApiOperation(value = "更新") |
| | | public Response update(@RequestBody Station3D station3D){ |
| | | service.update(station3D); |
| | | return new Response().setII(1,"更新成功"); |
| | | } |
| | | |
| | | @PostMapping("updateBatch") |
| | | @ApiOperation(value = "更新批量") |
| | | public Response updateBatch(@RequestBody List<Station3D> station3DList){ |
| | | service.updateBatch(station3DList); |
| | | return new Response().setII(1,"更新成功"); |
| | | } |
| | | |
| | |
| | | String fileData = (String)map.get("fileData"); |
| | | String pictureName = (String)map.get("pictureName"); |
| | | String stationName = (String)map.get("stationName"); |
| | | //过滤特殊字符,避免路径遍历攻击 |
| | | pictureName = ActionUtil.filterFileName(pictureName); |
| | | service.uploadPicture(stationName,fileData,pictureName,request); |
| | | return new Response().setII(1,"上传成功"); |
| | | |
| | |
| | | @ApiOperation(value = "读取图片") |
| | | public Response pictureLoad(HttpServletRequest request){ |
| | | /*=========图片保存===========*/ |
| | | //获取到tomcat webapp绝对路径 |
| | | String realPath = request.getServletContext().getRealPath("/"); |
| | | //String realPath = ActionUtil.getApplication().getRealPath("/"); |
| | | String[] split = realPath.split("\\\\"); |
| | | String projectName = split[split.length - 1]; |
| | | |
| | | String webAppPath = realPath.substring(0, realPath.lastIndexOf(projectName)); |
| | | |
| | | ApplicationHome applicationHome = new ApplicationHome(getClass()); |
| | | File jarFile = applicationHome.getDir(); |
| | | //存储3D站点图片的文件夹 |
| | | String fileDirName = webAppPath + projectName + "_photo_3DStation"; |
| | | |
| | | //开发 |
| | | String fileDirName = jarFile.getParentFile().toString()+File.separator+"fg_photo_3DStation"; |
| | | //打包 |
| | | //String fileDirName = jarFile.toString()+File.separator+"fg_photo_3DStation"; |
| | | |
| | | //图片的Url |
| | | File file = new File(fileDirName); |
| | | if(file.exists()){ |