fix(cms): 修复网站状态显示逻辑
- 增加空值检查,避免 NullPointerException - 添加默认状态处理:当 running为 null 时,设置为"状态未知" - 优化代码结构,减少重复代码
This commit is contained in:
@@ -294,28 +294,37 @@ public class CmsWebsiteController extends BaseController {
|
||||
}
|
||||
|
||||
private void setWebsiteStatus(CmsWebsite website) {
|
||||
if (!website.getRunning().equals(1)) {
|
||||
// 空值检查,避免NullPointerException
|
||||
Integer running = website.getRunning();
|
||||
if (running == null) {
|
||||
// 默认状态:未开通
|
||||
website.setStatusIcon("error");
|
||||
website.setStatusText("状态未知");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!running.equals(1)) {
|
||||
// 未开通
|
||||
if (website.getRunning().equals(0)) {
|
||||
if (running.equals(0)) {
|
||||
website.setStatusIcon("error");
|
||||
website.setStatusText("该站点未开通");
|
||||
}
|
||||
// 维护中
|
||||
if (website.getRunning().equals(2)) {
|
||||
if (running.equals(2)) {
|
||||
website.setStatusIcon("warning");
|
||||
}
|
||||
// 已关闭
|
||||
if (website.getRunning().equals(3)) {
|
||||
if (running.equals(3)) {
|
||||
website.setStatusIcon("error");
|
||||
website.setStatusText("已关闭");
|
||||
}
|
||||
// 已欠费停机
|
||||
if (website.getRunning().equals(4)) {
|
||||
if (running.equals(4)) {
|
||||
website.setStatusIcon("error");
|
||||
website.setStatusText("已欠费停机");
|
||||
}
|
||||
// 违规关停
|
||||
if (website.getRunning().equals(5)) {
|
||||
if (running.equals(5)) {
|
||||
website.setStatusIcon("error");
|
||||
website.setStatusText("违规关停");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user