|  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.doumee.api.BaseController; | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.config.annotation.LoginRequired; | 
|---|
|  |  |  | import com.doumee.core.annotation.trace.Trace; | 
|---|
|  |  |  | import com.doumee.core.model.ApiResponse; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.FtpUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.aliyun.ALiYunUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.tyyun.TyyZosUtil; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Users; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemDictData; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParams; | 
|---|
|  |  |  | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @LoginRequired | 
|---|
|  |  |  | @ApiOperation(value = "字典值查询") | 
|---|
|  |  |  | @GetMapping("/getDictData") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(paramType = "query", dataType = "String", name = "code", value = "大类编码", required = true), | 
|---|
|  |  |  | @ApiImplicitParam(paramType = "query", dataType = "String", name = "label", value = "子类编码", required = true) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ApiResponse<SystemDictData> getDictData (@RequestParam String code,@RequestParam String label) { | 
|---|
|  |  |  | SystemDictData systemDictData = systemDictDataBiz.queryByCode(code,label); | 
|---|
|  |  |  | return ApiResponse.success(systemDictData); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static FtpUtil ftp  = null; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "上传", notes = "上传", httpMethod = "POST", position = 6) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "folder", value = "文件夹", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class), | 
|---|
|  |  |  | @ApiImplicitParam(name = "folder", value = "文件夹", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @PostMapping(value = "/upload", headers = "content-type=multipart/form-data") | 
|---|
|  |  |  | public void uploadMobile(String folder, HttpServletRequest request, HttpServletResponse response) throws Exception { | 
|---|
|  |  |  | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; | 
|---|
|  |  |  | upload(multipartRequest, response, folder + "/", | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.BUCKETNAME).getCode(), | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.ACCESS_ID).getCode(), | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.ACCESS_KEY).getCode(), | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.RESOURCE_PATH).getCode(), | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.ENDPOINT).getCode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "上传图片", notes = "上传图片", httpMethod = "POST", position = 6) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "folder", value = "文件夹", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @PostMapping(value = "/uploadPicture", headers = "content-type=multipart/form-data") | 
|---|
|  |  |  | public void uploadPicture(String folder, HttpServletRequest request, HttpServletResponse response) throws Exception { | 
|---|
|  |  |  | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; | 
|---|
|  |  |  | Iterator<String> fileNames = multipartRequest.getFileNames(); | 
|---|
|  |  |  | Map<String, Object> context = new HashMap<>(); | 
|---|
|  |  |  | while (fileNames.hasNext()){ | 
|---|
|  |  |  | MultipartFile file = multipartRequest.getFile(fileNames.next()); | 
|---|
|  |  |  | String fileName = file.getOriginalFilename(); | 
|---|
|  |  |  | String suffix = fileName.substring(fileName.lastIndexOf(".")); | 
|---|
|  |  |  | if ( !StringUtils.equalsIgnoreCase(suffix, ".jpg") || !StringUtils.equalsIgnoreCase(suffix, ".png")) { | 
|---|
|  |  |  | context.put("code", 0); | 
|---|
|  |  |  | context.put("message", "对不起,文件格式上传有误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | upload(multipartRequest, response, folder + "/", | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.BUCKETNAME).getCode(), | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.ACCESS_ID).getCode(), | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static  FtpUtil ftp  = null; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "上传文件到FTP") | 
|---|
|  |  |  | @RequestMapping(method= RequestMethod.POST,value="api/uploadFtp.do",headers = "content-type=multipart/form-data") | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void upload(HttpServletRequest request, HttpServletResponse response, String folder, String bucketName, | 
|---|
|  |  |  | String access_id, String access_key, String resourcePath, String endpoint) throws Exception { | 
|---|
|  |  |  | String access_id, String access_key, String resourcePath, String endpoint) throws Exception { | 
|---|
|  |  |  | response.setCharacterEncoding("UTF-8"); | 
|---|
|  |  |  | response.setContentType("text/html;charset=UTF-8"); | 
|---|
|  |  |  | Map<String, Object> context = new HashMap<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (StringUtils.equalsIgnoreCase(nfix, ".dll")) { | 
|---|
|  |  |  | context.put("code", 4000); | 
|---|
|  |  |  | context.put("message", "对不起,文件格式\".dll\"上传有误!"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (StringUtils.equalsIgnoreCase(nfix, ".so")) { | 
|---|
|  |  |  | context.put("code", 4000); | 
|---|
|  |  |  | context.put("message", "对不起,文件格式\".so\"上传有误!"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String nowDate = DateUtil.getNowShortDate();// 当前时间(年月日) | 
|---|
|  |  |  | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|