|
@@ -34,6 +34,8 @@ import java.lang.reflect.Field;
|
|
|
import java.sql.SQLException;
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
@@ -91,9 +93,11 @@ public class ContentController{
|
|
|
throw new CmsException("对不起,您没有当前栏目的管理权限!");
|
|
|
}
|
|
|
UserVo userVo = ((UserVo) ControllerUtil.getHttpSession().getAttribute(CmsConst.SITE_USER_SESSION_KEY));
|
|
|
+
|
|
|
if(CmsUtil.isNullOrEmpty(userVo)) {
|
|
|
throw new UnauthenticatedException();
|
|
|
}
|
|
|
+
|
|
|
content.setSiteId(userVo.getSiteId());
|
|
|
content.setUserId(userVo.getUserId());
|
|
|
model.addAttribute("model",contentService.page(pageNumber,pageSize,content));
|
|
@@ -124,8 +128,31 @@ public class ContentController{
|
|
|
}
|
|
|
TCmsModel cmsModel = modelService.findById(category.getModelId());
|
|
|
List<TCmsModelFiled> cmsModelFileds = modelFiledService.findModelFiledListByModelId(cmsModel.getModelId());
|
|
|
- if(contentId!=null) {
|
|
|
- model.addAttribute("content",contentService.findContentByContentIdAndTableName(contentId,cmsModel.getTableName()));
|
|
|
+ java.util.Date inputdate = new Date(); // 从content中获取inputdate的值
|
|
|
+
|
|
|
+ // 检查 inputdate 是否为 null
|
|
|
+ if (inputdate != null) {
|
|
|
+ // 将 Date 转换为 LocalDate
|
|
|
+ LocalDate localDate = inputdate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ // 去除时间部分,只保留日期
|
|
|
+ LocalDate dateWithoutTime = LocalDate.of(localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth());
|
|
|
+ // 将 LocalDate 转换回 Date
|
|
|
+ inputdate = Date.from(dateWithoutTime.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (contentId != null) {
|
|
|
+ // 查询内容并获取 obj
|
|
|
+ Map obj = contentService.findContentByContentIdAndTableName(contentId, cmsModel.getTableName());
|
|
|
+ // 检查 obj 中的 inputdate 是否为 null
|
|
|
+ Object inputDateObj = obj.get("inputdate");
|
|
|
+ if (inputDateObj instanceof Date) {
|
|
|
+ // 格式化 inputdate
|
|
|
+ Date inputDate = (Date) inputDateObj;
|
|
|
+ String formattedDate = new SimpleDateFormat("yyyy-MM-dd").format(inputDate);
|
|
|
+ obj.put("inputdate", formattedDate);
|
|
|
+ }
|
|
|
+ // 将 obj 添加到 model 中
|
|
|
+ model.addAttribute("content", obj);
|
|
|
}
|
|
|
model.addAttribute("modelFiled",cmsModelFileds);
|
|
|
model.addAttribute("category",category);
|
|
@@ -133,6 +160,7 @@ public class ContentController{
|
|
|
return "cms/content_input";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@SysLog("内容复制")
|
|
|
@RequiresPermissions("content:input")
|
|
|
@RequestMapping("/copy")
|