| | |
| | | <artifactId>fast-md5</artifactId> |
| | | <version>2.7.1</version> |
| | | </dependency> |
| | | <!--fastjson2--> |
| | | <dependency> |
| | | <groupId>com.alibaba.fastjson2</groupId> |
| | | <artifactId>fastjson2</artifactId> |
| | | <version>2.0.52</version> |
| | | </dependency> |
| | | <!--gdal--> |
| | | <dependency> |
| | | <groupId>org.gdal</groupId> |
| | |
| | | |
| | | private boolean validate(String serviceName, HttpServletResponse res) { |
| | | if (StringHelper.isEmpty(serviceName)) { |
| | | return WebHelper.writeStr2Page(res, HttpStatus.BAD_REQUEST, "服务名不能为空"); |
| | | return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "服务名不能为空"); |
| | | } |
| | | |
| | | return true; |
| | |
| | | |
| | | private boolean validate(String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) { |
| | | if (StringHelper.isEmpty(serviceName)) { |
| | | return WebHelper.writeStr2Page(res, HttpStatus.BAD_REQUEST, "服务名不能为空"); |
| | | return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "服务名不能为空"); |
| | | } |
| | | if (null == width || width < MIN_SIZE || width > MAX_SIZE) { |
| | | return WebHelper.writeStr2Page(res, HttpStatus.BAD_REQUEST, "图像宽度不能为空且取值范围为" + MIN_SIZE + "~" + MAX_SIZE + "之间"); |
| | | return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "图像宽度不能为空且取值范围为" + MIN_SIZE + "~" + MAX_SIZE + "之间"); |
| | | } |
| | | if (null == height || height < MIN_SIZE || height > MAX_SIZE) { |
| | | return WebHelper.writeStr2Page(res, HttpStatus.BAD_REQUEST, "图像高度不能为空且取值范围为" + MIN_SIZE + "~" + MAX_SIZE + "之间"); |
| | | return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "图像高度不能为空且取值范围为" + MIN_SIZE + "~" + MAX_SIZE + "之间"); |
| | | } |
| | | if (null == timestamp || timestamp < Y2000) { |
| | | return WebHelper.writeStr2Page(res, HttpStatus.BAD_REQUEST, "时间不能为空且大于2000年"); |
| | | return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "时间不能为空且大于2000年"); |
| | | } |
| | | |
| | | return true; |
| | |
| | | package com.se.simu.helper; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 输出JSON至页面 |
| | | */ |
| | | public static boolean writeJson2Page(HttpServletResponse res, HttpStatus status, String str) { |
| | | res.setStatus(status.value()); |
| | | |
| | | Map<String, Object> map = new HashMap(2); |
| | | map.put("code", status.value() >= 400 ? -1 : 0); |
| | | map.put("msg", str); |
| | | |
| | | return writeStr2Page(res, JSON.toJSONString(map)); |
| | | } |
| | | |
| | | /** |
| | | * 输出str至页面 |
| | | */ |
| | | public static boolean writeStr2Page(HttpServletResponse res, HttpStatus status, String str) { |