feat:完善项目信息
This commit is contained in:
72
app/api/admin/model/activity_apply.go
Normal file
72
app/api/admin/model/activity_apply.go
Normal file
@ -0,0 +1,72 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ActivityApply struct {
|
||||
*model.ActivityApply
|
||||
}
|
||||
|
||||
type (
|
||||
// ActivityApplyInfo 详细信息
|
||||
ActivityApplyInfo struct {
|
||||
*model.ActivityApply
|
||||
Username string `json:"username"`
|
||||
model.Area
|
||||
HandleUsername string `json:"handle_name"`
|
||||
HandleRemark string `json:"handle_remark"`
|
||||
HandleCreatedAt time.Time `json:"handle_created_at"`
|
||||
}
|
||||
)
|
||||
|
||||
// Apply 申请信息
|
||||
func (m *ActivityApply) Apply(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ActivityApplyInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.id", "a.tenant_id", "a.image", "a.title", "a.contact", "a.contact_mobile", "a.begin_at",
|
||||
"a.finish_at", "a.amount", "a.max_number", "a.status", "a.created_at",
|
||||
"t.province", "t.city", "l.name AS handle_name", "l.remark AS handle_remark", "l.created_at AS handle_created_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON a.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON i.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT a.apply_id, MAX(a.id) AS id, MAX(a.created_at) AS created_at, MAX(a.remark) AS remark "+
|
||||
"MAX(u.`name`) AS name FROM %s AS a LEFT JOIN %s ON a.uid = u.uuid WHERE a.is_deleted = %d GROUP BY a.apply_id) AS l ON a.id = l.apply_id",
|
||||
model.NewActivityApplyLog().TableName(), model.NewSysUser().TableName(), model.DeleteStatusForNot)).
|
||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ActivityApplyInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("a.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (m *ActivityApply) Detail(id uint64) (*ActivityApplyInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.*", "u.name AS username").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON a.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||
Where("a.id = ?", id)
|
||||
|
||||
out := new(ActivityApplyInfo)
|
||||
|
||||
err := db.Scan(out).Error
|
||||
|
||||
return out, err
|
||||
|
||||
}
|
||||
|
||||
func NewActivityApply() *ActivityApply {
|
||||
return &ActivityApply{model.NewActivityApply()}
|
||||
}
|
11
app/api/admin/model/activity_apply_log.go
Normal file
11
app/api/admin/model/activity_apply_log.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ActivityApplyLog struct {
|
||||
*model.ActivityApplyLog
|
||||
}
|
||||
|
||||
func NewActivityApplyLog() *ActivityApplyLog {
|
||||
return &ActivityApplyLog{model.NewActivityApplyLog()}
|
||||
}
|
@ -19,8 +19,9 @@ type ActivityInstanceInfo struct {
|
||||
// Activity 活动信息
|
||||
func (m *ActivityInstance) Activity(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ActivityInstanceInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.id", "a.tenant_id", "a.mode", "a.image", "a.title", "a.begin_at", "a.finish_at", "a.join_deadline",
|
||||
"a.amount", "a.max_number", "a.status", "a.created_at", "j.count AS join_count", "t.province", "t.city").
|
||||
Select("a.id", "a.tenant_id", "a.image", "a.title", "a.contact", "a.contact_mobile", "a.begin_at",
|
||||
"a.finish_at", "a.join_deadline", "a.amount", "a.max_number", "a.status", "a.created_at", "j.count AS join_count",
|
||||
"t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT activity_id, COUNT(id) AS count FROM %s WHERE is_delete = %d AND status = %d GROUP BY activity_id) AS j ON a.id = j.activity_id",
|
||||
model.NewActivityJoin().TableName(), model.DeleteStatusForNot, model.ActivityJoinStatusForSuccess)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON i.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
|
@ -1,11 +1,45 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ActivityJoin struct {
|
||||
*model.ActivityJoin
|
||||
}
|
||||
|
||||
type ActivityJoinInfo struct {
|
||||
model.Model
|
||||
Name string `json:"name"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (m *ActivityJoin) Join(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ActivityJoinInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS j").
|
||||
Select("j.id", "u.name", "j.created_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON j.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||
Where("j.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("j.status = ?", model.ActivityJoinStatusForSuccess)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ActivityJoinInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("j.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewActivityJoin() *ActivityJoin {
|
||||
return &ActivityJoin{model.NewActivityJoin()}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ func (m *ServiceInnovate) Innovate(page, pageSize int, count *int64, where ...*m
|
||||
Select("i.id", "i.title", "t.name AS tenant_name", "k.title AS kind_title", "i.sort", "i.created_at",
|
||||
"t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON i.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS k ON i.kind = k.id", model.NewServiceInnovateKind().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS k ON i.kind_id = k.id", model.NewServiceInnovateKind().TableName())).
|
||||
Where("i.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
|
@ -14,6 +14,7 @@ type ServiceMessage struct {
|
||||
type ServiceMessageInfo struct {
|
||||
*model.ServiceMessage
|
||||
model.Area
|
||||
Domain string `json:"-"`
|
||||
HandleContent string `json:"handle_content"`
|
||||
HandleCreatedAt time.Time `json:"handle_created_at"`
|
||||
}
|
||||
@ -21,11 +22,12 @@ type ServiceMessageInfo struct {
|
||||
func (m *ServiceMessage) Message(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceMessageInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS m").
|
||||
Select("m.*", "l.content AS handle_content", "l.created_at AS handle_created_at",
|
||||
"t.province", "t.city").
|
||||
"t.province", "t.city", "t.domain").
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT MAX(id) AS id, message_id, MAX(created_at) AS created_at, MAX(content) AS content "+
|
||||
"FROM %s WHERE is_deleted = %d GROUP BY message_id) AS l ON m.id = l.message_id",
|
||||
model.NewServiceMessageLog().TableName(), model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON m.tenant_id = t.id", model.NewSysTenant().TableName()))
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON m.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("m.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
|
@ -29,7 +29,7 @@ func (m *SysAuth) TenantAuth(tenantID uint64) ([]*SysAuthScene, error) {
|
||||
out := make([]*SysAuthScene, 0)
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.id", "a.parent_id", "a.kind", "a.name", "r_a.id AS scene_id").
|
||||
Select("a.id", "a.parent_id", "a.kind", "a.name", "t_a.id AS scene_id").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t_a ON t_a.auth_id = a.id AND t_a.tenant_id = %d AND t_a.is_deleted = %d",
|
||||
model.NewSysTenantAuth().TableName(), tenantID, model.DeleteStatusForNot)).
|
||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
Reference in New Issue
Block a user