|
@@ -7,10 +7,9 @@ import (
|
|
|
"lims-extend/response"
|
|
|
)
|
|
|
|
|
|
-func GetStatisticsInfoForAdmin(c *gin.Context) {
|
|
|
- userId := c.Params.ByName("userId")
|
|
|
- db := common.GetDB()
|
|
|
+func GetStatisticsData(userId string) (int64, int64, int64) {
|
|
|
|
|
|
+ db := common.GetDB()
|
|
|
|
|
|
var totalSendCount int64
|
|
|
db.Model(&model.Task{}).Joins("left join plan on task.plan_id = plan.id").
|
|
@@ -24,7 +23,29 @@ func GetStatisticsInfoForAdmin(c *gin.Context) {
|
|
|
var totalFinishedCount int64
|
|
|
db.Model(&model.Task{}).Joins("left join plan on task.plan_id = plan.id").
|
|
|
Where("plan.creator_id = ? and task.state = 2", userId).Count(&totalFinishedCount)
|
|
|
+ return totalSendCount, totalRecvCount, totalFinishedCount
|
|
|
+}
|
|
|
+
|
|
|
+func GetStatisticsInfoForAdmin(c *gin.Context) {
|
|
|
+ userId := c.Params.ByName("userId")
|
|
|
+ totalSendCount, totalRecvCount, totalFinishedCount := GetStatisticsData(userId)
|
|
|
+ response.Success(c, gin.H{
|
|
|
+ "totalSendCount": totalSendCount,
|
|
|
+ "totalRecvCount": totalRecvCount,
|
|
|
+ "totalFinishedCount": totalFinishedCount,
|
|
|
+ }, "success")
|
|
|
+}
|
|
|
+
|
|
|
+func GetStatisticsInfoForSuperAdmin(c *gin.Context) {
|
|
|
+ db := common.GetDB()
|
|
|
|
|
|
+ var totalSendCount, totalRecvCount, totalFinishedCount int64
|
|
|
+ db.Model(&model.Task{}).Joins("left join plan on task.plan_id = plan.id").
|
|
|
+ Where("1 = 1 ").Count(&totalSendCount)
|
|
|
+ db.Model(&model.Task{}).Joins("left join plan on task.plan_id = plan.id").
|
|
|
+ Where("task.state <> 3").Count(&totalRecvCount)
|
|
|
+ db.Model(&model.Task{}).Joins("left join plan on task.plan_id = plan.id").
|
|
|
+ Where("task.state = 2").Count(&totalFinishedCount)
|
|
|
response.Success(c, gin.H{
|
|
|
"totalSendCount": totalSendCount,
|
|
|
"totalRecvCount": totalRecvCount,
|
|
@@ -98,3 +119,23 @@ func GetCompanyOfUser(c *gin.Context) {
|
|
|
}
|
|
|
response.Success(c, gin.H{"company": company}, "查询成功")
|
|
|
}
|
|
|
+
|
|
|
+func GetUsers(c *gin.Context) {
|
|
|
+ db := common.GetDB()
|
|
|
+ type result struct {
|
|
|
+ ID string `json:"id"`
|
|
|
+ Username string `json:"username"`
|
|
|
+ Identify int `json:"identify"`
|
|
|
+ Tel string `json:"tel"`
|
|
|
+ IsLogin string `json:"isLogin" gorm:"column:is_login"`
|
|
|
+ Name string `json:"company_name"`
|
|
|
+ }
|
|
|
+ var res []result
|
|
|
+ db.Raw("SELECT user.id,username,identify,tel,company.name,is_login " +
|
|
|
+ "FROM `user` LEFT JOIN `company_users` ON `user`.id = `company_users`.user_id " +
|
|
|
+ "LEFT JOIN company ON `company_users`.company_id = `company`.id " +
|
|
|
+ "ORDER BY user.create_time").Find(&res)
|
|
|
+
|
|
|
+ response.Success(c, gin.H{"users": res}, "查询成功")
|
|
|
+
|
|
|
+}
|