web端职代会管理: 修复congress_materials职代会资料文件的fileType,fileSize字段为空的问题;
This commit is contained in:
+3
-3
@@ -134,7 +134,7 @@ public class CongressMaterialsManageController {
|
||||
.add("sort_no", sortNo == null ? 0 : sortNo)
|
||||
.add("file_name", StrUtil.blankToDefault(fileName, name.trim()))
|
||||
.add("file_url", fileUrl)
|
||||
.add("file_type", StrUtil.blankToDefault(fileType, null))
|
||||
.add("file_type", congressManageService.normalizeFileType(fileType, fileName, fileUrl))
|
||||
.add("file_size", StrUtil.blankToDefault(fileSize, null))
|
||||
.add("update_time", now);
|
||||
if (StrUtil.isBlank(id)) {
|
||||
@@ -143,11 +143,11 @@ public class CongressMaterialsManageController {
|
||||
.add("create_time", now)
|
||||
.add("deleted", 0);
|
||||
dao.insert("congress_materials", chain);
|
||||
return Result.success(newId);
|
||||
return Result.success().addData(newId);
|
||||
}
|
||||
dao.update("congress_materials", chain,
|
||||
Cnd.where("id", "=", id).and("deleted", "=", 0));
|
||||
return Result.success(id);
|
||||
return Result.success().addData(id);
|
||||
}
|
||||
|
||||
@At("/delete")
|
||||
|
||||
+54
@@ -57,6 +57,60 @@ public class CongressVotingIssueController {
|
||||
return Result.success(congressManageService.materialOptions(sessionId, typeId));
|
||||
}
|
||||
|
||||
@At("/uploadMaterial")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission("congress.vote.issue")
|
||||
@SLog(tag = "职代会-投票管理", msg = "快捷上传投票资料")
|
||||
public Result uploadMaterial(@Param("sessionId") String sessionId,
|
||||
@Param("typeId") String typeId,
|
||||
@Param("name") String name,
|
||||
@Param("fileName") String fileName,
|
||||
@Param("fileUrl") String fileUrl,
|
||||
@Param("fileType") String fileType,
|
||||
@Param("fileSize") String fileSize) {
|
||||
if (StrUtil.hasBlank(sessionId, typeId, fileUrl)) {
|
||||
return Result.error("届次、投票类型和文件不能为空");
|
||||
}
|
||||
if (congressManageService.count("""
|
||||
SELECT COUNT(1)
|
||||
FROM teacher_congress_session
|
||||
WHERE id = @sessionId
|
||||
AND delFlag = 0
|
||||
""", NutMap.NEW().addv("sessionId", sessionId)) <= 0) {
|
||||
return Result.error("所选届次不存在");
|
||||
}
|
||||
if (congressManageService.count("""
|
||||
SELECT COUNT(1)
|
||||
FROM congress_materials_type
|
||||
WHERE id = @typeId
|
||||
AND COALESCE(deleted, 0) = 0
|
||||
AND COALESCE(is_vote, 0) = 1
|
||||
""", NutMap.NEW().addv("typeId", typeId)) <= 0) {
|
||||
return Result.error("所选投票类型不存在");
|
||||
}
|
||||
Date now = new Date();
|
||||
String materialName = StrUtil.blankToDefault(name, StrUtil.blankToDefault(fileName, "资料")).trim();
|
||||
String newId = R.UU32();
|
||||
dao.insert("congress_materials", Chain.make("id", newId)
|
||||
.add("name", materialName)
|
||||
.add("session_id", sessionId)
|
||||
.add("time_id", null)
|
||||
.add("type_id", typeId)
|
||||
.add("sort_no", 0)
|
||||
.add("file_name", StrUtil.blankToDefault(fileName, materialName))
|
||||
.add("file_url", fileUrl)
|
||||
.add("file_type", congressManageService.normalizeFileType(fileType, fileName, fileUrl))
|
||||
.add("file_size", StrUtil.blankToDefault(fileSize, null))
|
||||
.add("create_time", now)
|
||||
.add("update_time", now)
|
||||
.add("deleted", 0));
|
||||
return Result.success(NutMap.NEW()
|
||||
.addv("id", newId)
|
||||
.addv("name", materialName)
|
||||
.addv("fileName", StrUtil.blankToDefault(fileName, materialName))
|
||||
.addv("fileUrl", fileUrl));
|
||||
}
|
||||
|
||||
@At("/pageData")
|
||||
@SaCheckPermission("congress.vote.issue")
|
||||
public Result issuePageData(PageForm pageForm,
|
||||
|
||||
+28
@@ -17,6 +17,7 @@ import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* 职代会管理公共服务类。
|
||||
@@ -148,4 +149,31 @@ public class CongressManageService {
|
||||
sql.append(" AND ").append(column).append(" = @").append(paramName);
|
||||
params.addv(paramName, value);
|
||||
}
|
||||
|
||||
public String normalizeFileType(String fileType, String fileName, String fileUrl) {
|
||||
if (StrUtil.isNotBlank(fileType) && !fileType.contains("/")) {
|
||||
return fileType.replace(".", "").trim().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
String suffix = extractFileExtension(fileName);
|
||||
if (StrUtil.isBlank(suffix)) {
|
||||
suffix = extractFileExtension(fileUrl);
|
||||
}
|
||||
return StrUtil.blankToDefault(suffix, null);
|
||||
}
|
||||
|
||||
private String extractFileExtension(String name) {
|
||||
if (StrUtil.isBlank(name)) {
|
||||
return "";
|
||||
}
|
||||
String value = name.split("\\?", 2)[0];
|
||||
int slashIndex = Math.max(value.lastIndexOf('/'), value.lastIndexOf('\\'));
|
||||
if (slashIndex >= 0) {
|
||||
value = value.substring(slashIndex + 1);
|
||||
}
|
||||
int dotIndex = value.lastIndexOf('.');
|
||||
if (dotIndex < 0 || dotIndex == value.length() - 1) {
|
||||
return "";
|
||||
}
|
||||
return value.substring(dotIndex + 1).toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user