| | |
| | | |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.HttpStatus; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.data.DictEntity; |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | | import com.lf.server.entity.show.ExportEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.service.data.DownloadService; |
| | | import com.lf.server.service.show.ExportService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @RequestMapping("/export") |
| | | public class ExportController extends BaseController { |
| | | @Autowired |
| | | TokenService tokenService; |
| | | |
| | | @Autowired |
| | | ExportService exportService; |
| | | |
| | | @Autowired |
| | | TokenService tokenService; |
| | | DownloadService downloadService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询") |
| | |
| | | @PostMapping(value = "/insertMap", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<String> insertMap(@RequestBody ExportEntity entity, HttpServletRequest req) { |
| | | try { |
| | | boolean flag = entity.getXmin() == 0 && entity.getYmin() == 0 && entity.getXmax() == 0 && entity.getYmax() == 0; |
| | | if (entity == null || |
| | | StringHelper.isEmpty(entity.getLayers()) || |
| | | StringHelper.isEmpty(entity.getToken()) || |
| | | (entity.getXmin() == 0 && entity.getYmin() == 0 && entity.getXmax() == 0 && entity.getYmax() == 0)) { |
| | | flag) { |
| | | return fail("参数不完整"); |
| | | } |
| | | |
| | |
| | | return fail(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "下载出图") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "guid", value = "文件GUID", dataType = "String", paramType = "query") |
| | | }) |
| | | @RequestMapping(value = "/downloadFile", method = RequestMethod.GET) |
| | | public void downloadFile(String guid, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.UNAUTHORIZED, "用户未登录")); |
| | | } |
| | | |
| | | DownloadEntity de = downloadService.selectByGuid(guid); |
| | | if (de == null) { |
| | | WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.NOT_FOUND, "文件不存在")); |
| | | } |
| | | |
| | | de.setDcount(de.getDcount() + 1); |
| | | de.setDownloadUser(ue.getId()); |
| | | int rows = downloadService.update(de); |
| | | |
| | | String filePath = exportService.getDownloadFilePath(de); |
| | | WebHelper.download(filePath, de.getName(), res); |
| | | } catch (Exception ex) { |
| | | try { |
| | | WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.UNAUTHORIZED, ex.getMessage())); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | } |
| | | } |