feat[景区管理]:后台管理界面新增景区管理模块,以及部分代码优化等逻辑
This commit is contained in:
+2
-12
@@ -16,6 +16,7 @@ import com.central.order.service.IOrderFileService;
|
||||
import com.central.order.service.IOrderService;
|
||||
import com.central.order.service.IQrCodeService;
|
||||
import com.central.order.service.ITourismService;
|
||||
import com.central.order.util.ContentTypeUtil;
|
||||
import com.wechat.pay.java.core.exception.ServiceException;
|
||||
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.*;
|
||||
@@ -141,18 +142,7 @@ public class OrderController {
|
||||
Map<String,String> imgMap = new HashMap<>();
|
||||
String url = fileCenterService.getViewUrlByName(orderFile.getFilePath());
|
||||
imgMap.put("url", url.replace(cdnOssUrl,cdnUrl));
|
||||
//@TODO 待优化file_type获取方式
|
||||
if (url != null && !"".equals(url) ){
|
||||
if (url.contains(".jpeg")){
|
||||
imgMap.put("contentType", "image/jpeg");
|
||||
}else if (url.contains(".png")){
|
||||
imgMap.put("contentType", "image/png");
|
||||
}else if (url.contains(".gif")){
|
||||
imgMap.put("contentType", "image/gif");
|
||||
}else if (url.contains(".mp4")){
|
||||
imgMap.put("contentType", "video/mp4");
|
||||
}
|
||||
}
|
||||
imgMap.put("contentType", ContentTypeUtil.getContentTypeFromUrl(url));
|
||||
resultList.add(imgMap);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-10
@@ -45,16 +45,9 @@ public class TourismController {
|
||||
return tourismService.findList(params);
|
||||
}
|
||||
|
||||
@Operation(summary = "创建Tourism")
|
||||
@PostMapping
|
||||
public Result<Tourism> createTourism(@RequestBody Tourism tourism) {
|
||||
|
||||
boolean result = tourismService.createTourism(tourism);
|
||||
if (result) {
|
||||
return Result.succeed(tourism,"jq创建成功");
|
||||
} else {
|
||||
return Result.failed("jq创建失败");
|
||||
}
|
||||
@PostMapping()
|
||||
public Result saveOrUpdate(@RequestBody Tourism tourism) {
|
||||
return tourismService.saveOrUpdateTourism(tourism);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询Tourism")
|
||||
@@ -67,4 +60,10 @@ public class TourismController {
|
||||
return Result.succeed(tourism,"获取成功");
|
||||
}
|
||||
|
||||
@DeleteMapping()
|
||||
// @AuditLog(operation = "'新增或更新用户:' + #sysUser.username")
|
||||
public Result delete(@RequestBody Tourism tourism) {
|
||||
boolean result = tourismService.removeById(tourism);
|
||||
return result ? Result.succeed(tourism, "操作成功") : Result.failed("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.central.order.enums;
|
||||
|
||||
public enum FileType {
|
||||
JPEG("image/jpeg", ".jpeg", ".jpg"),
|
||||
PNG("image/png", ".png"),
|
||||
GIF("image/gif", ".gif"),
|
||||
MP4("video/mp4", ".mp4");
|
||||
|
||||
private final String contentType;
|
||||
private final String[] extensions;
|
||||
|
||||
FileType(String contentType, String... extensions) {
|
||||
this.contentType = contentType;
|
||||
this.extensions = extensions;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public String[] getExtensions() {
|
||||
return extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件扩展名获取对应的 FileType
|
||||
*
|
||||
* @param extension 文件扩展名
|
||||
* @return 对应的 FileType,如果不支持则返回 null
|
||||
*/
|
||||
public static FileType fromExtension(String extension) {
|
||||
for (FileType type : values()) {
|
||||
for (String ext : type.getExtensions()) {
|
||||
if (ext.equalsIgnoreCase(extension)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package com.central.order.service;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.common.service.ISuperService;
|
||||
import com.central.order.model.Tourism;
|
||||
|
||||
@@ -26,7 +27,7 @@ public interface ITourismService extends ISuperService<Tourism> {
|
||||
* @param tourism
|
||||
* @return
|
||||
*/
|
||||
boolean createTourism(Tourism tourism) ;
|
||||
Result saveOrUpdateTourism(Tourism tourism) ;
|
||||
|
||||
/**
|
||||
* id查询
|
||||
|
||||
+4
-6
@@ -2,6 +2,7 @@ package com.central.order.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.common.service.impl.SuperServiceImpl;
|
||||
import com.central.order.mapper.TourismMapper;
|
||||
import com.central.order.model.Tourism;
|
||||
@@ -36,12 +37,9 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createTourism(Tourism tourism) {
|
||||
int result = baseMapper.insert(tourism);
|
||||
if(result > 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
public Result saveOrUpdateTourism(Tourism tourism) {
|
||||
boolean result = saveOrUpdate(tourism);
|
||||
return result ? Result.succeed(tourism, "操作成功") : Result.failed("操作失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.central.order.util;
|
||||
|
||||
import com.central.order.enums.FileType;
|
||||
|
||||
public class ContentTypeUtil {
|
||||
|
||||
/**
|
||||
* 根据 URL 的文件扩展名获取对应的 contentType
|
||||
*
|
||||
* @param url 文件的 URL
|
||||
* @return 包含 contentType 的 Map,如果 URL 为空或不包含支持的扩展名,返回空的 Map
|
||||
*/
|
||||
public static String getContentTypeFromUrl(String url) {
|
||||
|
||||
if (url != null && !url.isEmpty()) {
|
||||
// 获取文件扩展名
|
||||
int lastDotIndex = url.lastIndexOf('.');
|
||||
if (lastDotIndex != -1) {
|
||||
String extension = url.substring(lastDotIndex);
|
||||
FileType fileType = FileType.fromExtension(extension);
|
||||
if (fileType != null) {
|
||||
return fileType.getContentType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FileType.JPEG.getContentType();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user