【新增】完善后台首页面板
This commit is contained in:
@@ -1,11 +1,26 @@
|
||||
package com.corewing.app.modules.admin.sys;
|
||||
|
||||
import com.corewing.app.common.Result;
|
||||
import com.corewing.app.service.FirmwareService;
|
||||
import com.corewing.app.service.SysUserService;
|
||||
import com.corewing.app.service.UserService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
public class SysMainController {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@Resource
|
||||
private FirmwareService firmwareService;
|
||||
|
||||
/**
|
||||
* 加载页
|
||||
* @return
|
||||
@@ -42,4 +57,17 @@ public class SysMainController {
|
||||
return "admin/dashboard";
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/main/statistics")
|
||||
@ResponseBody
|
||||
public Result<Map<String, Object>> statistics() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("userCount", userService.count ());
|
||||
result.put("firmwareCount", firmwareService.count());
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="stat-card primary">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
<h3>1,234</h3>
|
||||
<h3>{{statistics.userCount}}</h3>
|
||||
<p>用户数</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -39,7 +39,7 @@
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="stat-card warning">
|
||||
<i class="bi bi-graph-up"></i>
|
||||
<h3>89%</h3>
|
||||
<h3>{{statistics.firmwareCount}}</h3>
|
||||
<p>固件数</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -66,6 +66,10 @@
|
||||
username: '',
|
||||
realName: '',
|
||||
userId: ''
|
||||
},
|
||||
statistics: {
|
||||
userCount: 0,
|
||||
firmwareCount: 0,
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -90,10 +94,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
async loadStatistics() {
|
||||
try {
|
||||
const response = await request.get('/main/statistics');
|
||||
if (response.code === 200) {
|
||||
this.statistics = response.data;
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 加载用户信息
|
||||
this.loadUserInfo();
|
||||
// 加载统计信息
|
||||
this.loadStatistics();
|
||||
}
|
||||
}).mount('#app');
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user