feat:完善项目信息
This commit is contained in:
56
app/api/admin/api/sys.go
Normal file
56
app/api/admin/api/sys.go
Normal file
@ -0,0 +1,56 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/controller/sys"
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/app/session"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Sys struct{}
|
||||
|
||||
func (*Sys) Navigation(c *gin.Context) {
|
||||
form := new(api.TenantIDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := sys.NewNavigation()(api.GetSession()(c).(*session.Admin)).Instance(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Sys) NavigationForm(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
api.TenantIDStringForm
|
||||
ParentID string `json:"parent_id" form:"parent_id"`
|
||||
Title string `json:"title" form:"title"`
|
||||
Link string `json:"link" form:"link"`
|
||||
IsTarget int `json:"is_target" form:"is_target"`
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
Status int `json:"status" form:"status"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := sys.NewNavigation()(api.GetSession()(c).(*session.Admin)).Form(&sys.NavigationParams{
|
||||
ID: form.IDStringForm.Convert(),
|
||||
TenantID: form.TenantIDStringForm.Convert(),
|
||||
PatentID: (&api.IDStringForm{ID: form.ParentID}).Convert(),
|
||||
Title: form.Title, Link: form.Link, IsTarget: form.IsTarget, Sort: form.Sort, Status: form.Status,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Sys) NavigationDelete(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := sys.NewNavigation()(api.GetSession()(c).(*session.Admin)).Delete(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
@ -6,7 +6,6 @@ import (
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
@ -189,11 +188,8 @@ func (c *Examine) Launch(id uint64, identity, status int) error {
|
||||
|
||||
now := time.Now()
|
||||
|
||||
snowflake, _ := utils.NewSnowflake(1)
|
||||
|
||||
for _, v := range users {
|
||||
identitys = append(identitys, &model2.UserIdentity{
|
||||
UUID: uint64(snowflake.GetID()),
|
||||
UID: v.UUID,
|
||||
Identity: identity,
|
||||
ModelAt: model2.ModelAt{
|
||||
|
130
app/api/admin/controller/sys/navigation.go
Normal file
130
app/api/admin/controller/sys/navigation.go
Normal file
@ -0,0 +1,130 @@
|
||||
package sys
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Navigation struct {
|
||||
*session.Admin
|
||||
}
|
||||
|
||||
type NavigationHandle func(session *session.Admin) *Navigation
|
||||
|
||||
type (
|
||||
// NavigationInfo 导航信息
|
||||
NavigationInfo struct {
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
ParentID string `json:"parent_id"`
|
||||
*model2.SysNavigation
|
||||
Children []*NavigationInfo `json:"children"`
|
||||
}
|
||||
// NavigationParams 导航参数信息
|
||||
NavigationParams struct {
|
||||
ID, TenantID, PatentID uint64
|
||||
Title, Link string
|
||||
IsTarget, Sort, Status int
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Navigation) tree(src []*model.SysNavigationInfo, parentID uint64) []*NavigationInfo {
|
||||
out := make([]*NavigationInfo, 0)
|
||||
|
||||
for _, v := range src {
|
||||
if v.ParentID == parentID {
|
||||
out = append(out, &NavigationInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
TenantID: v.GetEncodeTenantID(),
|
||||
ParentID: (&model2.Model{ID: parentID}).GetEncodeID(),
|
||||
SysNavigation: v.SysNavigation,
|
||||
Children: c.tree(src, v.ID),
|
||||
})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Navigation) Instance(TenantID uint64) ([]*NavigationInfo, error) {
|
||||
mSysNavigation := model.NewSysNavigation()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("n.tenant_id", c.TenantID))
|
||||
}
|
||||
if TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("n.tenant_id", TenantID))
|
||||
}
|
||||
|
||||
out, err := mSysNavigation.Navigation(where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.tree(out, 0), nil
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *Navigation) Form(params *NavigationParams) error {
|
||||
mSysNavigation := model.NewSysNavigation()
|
||||
|
||||
if params.ID > 0 {
|
||||
mSysNavigation.ID = params.ID
|
||||
|
||||
if isExist, err := model2.First(mSysNavigation.SysNavigation); err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,导航信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && mSysNavigation.TenantID != c.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
}
|
||||
mSysNavigation.ParentID = params.PatentID
|
||||
mSysNavigation.Title = params.Title
|
||||
mSysNavigation.Link = params.Link
|
||||
mSysNavigation.IsTarget = params.IsTarget
|
||||
mSysNavigation.Sort = params.Sort
|
||||
mSysNavigation.Status = model2.SysNavigationStatus(params.Status)
|
||||
|
||||
if mSysNavigation.ID > 0 {
|
||||
if c.TenantID <= 0 {
|
||||
mSysNavigation.TenantID = params.TenantID
|
||||
}
|
||||
return model2.Updates(mSysNavigation.SysNavigation, mSysNavigation.SysNavigation)
|
||||
}
|
||||
mSysNavigation.TenantID = params.TenantID
|
||||
|
||||
if c.TenantID > 0 {
|
||||
mSysNavigation.TenantID = c.TenantID
|
||||
}
|
||||
return model2.Create(mSysNavigation.SysNavigation)
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *Navigation) Delete(id uint64) error {
|
||||
mSysNavigation := model.NewSysNavigation()
|
||||
mSysNavigation.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mSysNavigation.SysNavigation, []string{"id", "tenant_id"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,导航信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 && mSysNavigation.TenantID != c.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
return model2.Delete(mSysNavigation.SysNavigation)
|
||||
}
|
||||
|
||||
func NewNavigation() NavigationHandle {
|
||||
return func(session *session.Admin) *Navigation {
|
||||
return &Navigation{session}
|
||||
}
|
||||
}
|
@ -26,11 +26,11 @@ type (
|
||||
// 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",
|
||||
Select("a.id", "a.tenant_id", "a.identity", "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 %s AS t ON a.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)).
|
||||
|
@ -22,9 +22,9 @@ func (m *ActivityInstance) Activity(page, pageSize int, count *int64, where ...*
|
||||
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",
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT activity_id, COUNT(id) AS count FROM %s WHERE is_deleted = %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())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON a.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
|
@ -13,13 +13,16 @@ type ActivityJoin struct {
|
||||
|
||||
type ActivityJoinInfo struct {
|
||||
model.Model
|
||||
Identity int `json:"identity"`
|
||||
Name string `json:"name"`
|
||||
Mobile string `json:"mobile"`
|
||||
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").
|
||||
Select("j.id", "j.identity", "u_i.name", "u.mobile", "j.created_at").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u_i ON j.uid = u_i.uuid AND j.identity = u_i.identity", model.NewUserIdentity().TableName())).
|
||||
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)
|
||||
|
40
app/api/admin/model/sys_navigation.go
Normal file
40
app/api/admin/model/sys_navigation.go
Normal file
@ -0,0 +1,40 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type SysNavigation struct {
|
||||
*model.SysNavigation
|
||||
}
|
||||
|
||||
type SysNavigationInfo struct {
|
||||
*model.SysNavigation
|
||||
model.Area
|
||||
}
|
||||
|
||||
func (m *SysNavigation) Navigation(where ...*model.ModelWhere) ([]*SysNavigationInfo, error) {
|
||||
out := make([]*SysNavigationInfo, 0)
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS n").
|
||||
Select("n.*", "t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON n.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("n.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Order("n.sort " + model.OrderModeToAsc).Order("n.parent_id " + model.OrderModeToAsc).
|
||||
Order("n.id " + model.OrderModeToDesc)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
err := db.Scan(&out).Error
|
||||
|
||||
return out, err
|
||||
}
|
||||
|
||||
func NewSysNavigation() *SysNavigation {
|
||||
return &SysNavigation{model.NewSysNavigation()}
|
||||
}
|
@ -234,7 +234,6 @@ func (c *Identity) Switch(identity int) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
c.IdentityUID = mUserIdentity.UUID
|
||||
c.SelectIdentity = identity
|
||||
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccountEnterprise, c.UIDToString(), c.Enterprise)
|
||||
return nil
|
||||
|
@ -61,11 +61,26 @@ func (c *Index) industry(src, sep string) map[string]int {
|
||||
_ = utils.FromJSON(value, &_values)
|
||||
|
||||
for _, v := range _values {
|
||||
if _, has := out[v]; has {
|
||||
out[v]++
|
||||
// 解析
|
||||
title := "未知"
|
||||
|
||||
_industry := make([]string, 0)
|
||||
|
||||
objs := strings.Split(v, "-")
|
||||
|
||||
for _, obj := range objs {
|
||||
if data, has := config2.MemoryForIndustryInfo[obj]; has {
|
||||
_industry = append(_industry, data)
|
||||
}
|
||||
}
|
||||
if len(_industry) > 0 {
|
||||
title = strings.Join(_industry, "-")
|
||||
}
|
||||
if _, has := out[title]; has {
|
||||
out[title]++
|
||||
continue
|
||||
}
|
||||
out[v] = 1
|
||||
out[title] = 1
|
||||
}
|
||||
}
|
||||
return out
|
||||
@ -85,7 +100,7 @@ func (c *Index) distribution(src []*model.DataAreaDistributionInfo) map[string]*
|
||||
Code: v.Province,
|
||||
Name: config2.MemoryForAreaInfo[config.DefaultChinaAreaCode][v.Province],
|
||||
Industry: make(map[string]int, 0),
|
||||
Count: 105,
|
||||
Count: 1,
|
||||
Children: make(map[string]*InstanceDistributionDetailInfo, 0),
|
||||
}
|
||||
goto NEXT1
|
||||
@ -96,7 +111,7 @@ func (c *Index) distribution(src []*model.DataAreaDistributionInfo) map[string]*
|
||||
if _, has = out[v.Province].Children[v.City]; !has {
|
||||
out[v.Province].Children[v.City] = &InstanceDistributionDetailInfo{
|
||||
Code: v.City,
|
||||
Count: 105,
|
||||
Count: 1,
|
||||
Name: config2.MemoryForAreaInfo[v.Province][v.City],
|
||||
Industry: make(map[string]int, 0),
|
||||
Children: make(map[string]*InstanceDistributionDetailInfo, 0),
|
||||
@ -112,7 +127,7 @@ func (c *Index) distribution(src []*model.DataAreaDistributionInfo) map[string]*
|
||||
if _, has = out[v.Province].Children[v.City].Children[v.District]; !has {
|
||||
out[v.Province].Children[v.City].Children[v.District] = &InstanceDistributionDetailInfo{
|
||||
Code: v.District,
|
||||
Count: 105,
|
||||
Count: 1,
|
||||
Name: config2.MemoryForAreaInfo[v.City][v.District],
|
||||
Industry: industrys,
|
||||
}
|
||||
@ -204,73 +219,6 @@ func (c *Index) DistributionExpert(province, city string) (map[string]*InstanceD
|
||||
}
|
||||
_out := c.distribution(out)
|
||||
c.filter(_out)
|
||||
_out["500000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "500000",
|
||||
Name: "重庆",
|
||||
Count: 300,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"500100": &InstanceDistributionDetailInfo{
|
||||
Code: "500100",
|
||||
Name: "市辖区",
|
||||
Count: 300,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
_out["630000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "630000",
|
||||
Name: "青海省",
|
||||
Count: 1200,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"630200": &InstanceDistributionDetailInfo{
|
||||
Code: "630200",
|
||||
Name: "海东市",
|
||||
Count: 1200,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
_out["230000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "230000",
|
||||
Name: "黑龙江",
|
||||
Count: 6000,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"230100": &InstanceDistributionDetailInfo{
|
||||
Code: "230100",
|
||||
Name: "哈尔滨市",
|
||||
Count: 3000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
"230200": &InstanceDistributionDetailInfo{
|
||||
Code: "230200",
|
||||
Name: "齐齐哈尔市",
|
||||
Count: 3000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
_out["330000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "330000",
|
||||
Name: "浙江省",
|
||||
Count: 5000,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"330100": &InstanceDistributionDetailInfo{
|
||||
Code: "330100",
|
||||
Name: "杭州市",
|
||||
Count: 5000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
return _out, nil
|
||||
}
|
||||
|
||||
@ -284,43 +232,6 @@ func (c *Index) DistributionLaboratory(province, city string) (map[string]*Insta
|
||||
}
|
||||
_out := c.distribution(out)
|
||||
c.filter(_out)
|
||||
_out["230000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "230000",
|
||||
Name: "黑龙江",
|
||||
Count: 1000,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"230100": &InstanceDistributionDetailInfo{
|
||||
Code: "230100",
|
||||
Name: "哈尔滨市",
|
||||
Count: 500,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
"230200": &InstanceDistributionDetailInfo{
|
||||
Code: "230200",
|
||||
Name: "齐齐哈尔市",
|
||||
Count: 500,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
_out["330000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "330000",
|
||||
Name: "浙江省",
|
||||
Count: 5000,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"330100": &InstanceDistributionDetailInfo{
|
||||
Code: "330100",
|
||||
Name: "杭州市",
|
||||
Count: 5000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
return _out, nil
|
||||
}
|
||||
|
||||
@ -334,43 +245,6 @@ func (c *Index) DistributionDemand(province, city string) (map[string]*InstanceD
|
||||
}
|
||||
_out := c.distribution(out)
|
||||
c.filter(_out)
|
||||
_out["230000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "230000",
|
||||
Name: "黑龙江",
|
||||
Count: 6000,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"230100": &InstanceDistributionDetailInfo{
|
||||
Code: "230100",
|
||||
Name: "哈尔滨市",
|
||||
Count: 3000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
"230200": &InstanceDistributionDetailInfo{
|
||||
Code: "230200",
|
||||
Name: "齐齐哈尔市",
|
||||
Count: 3000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
_out["330000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "330000",
|
||||
Name: "浙江省",
|
||||
Count: 5000,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"330100": &InstanceDistributionDetailInfo{
|
||||
Code: "330100",
|
||||
Name: "杭州市",
|
||||
Count: 5000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
return _out, nil
|
||||
}
|
||||
|
||||
@ -384,43 +258,6 @@ func (c *Index) DistributionPatent(province, city string) (map[string]*InstanceD
|
||||
}
|
||||
_out := c.distribution(out)
|
||||
c.filter(_out)
|
||||
_out["230000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "230000",
|
||||
Name: "黑龙江",
|
||||
Count: 6000,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"230100": &InstanceDistributionDetailInfo{
|
||||
Code: "230100",
|
||||
Name: "哈尔滨市",
|
||||
Count: 3000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
"230200": &InstanceDistributionDetailInfo{
|
||||
Code: "230200",
|
||||
Name: "齐齐哈尔市",
|
||||
Count: 3000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
_out["330000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "330000",
|
||||
Name: "浙江省",
|
||||
Count: 5000,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"330100": &InstanceDistributionDetailInfo{
|
||||
Code: "330100",
|
||||
Name: "杭州市",
|
||||
Count: 5000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
return _out, nil
|
||||
}
|
||||
|
||||
@ -435,44 +272,6 @@ func (c *Index) DistributionAchievement(province, city string) (map[string]*Inst
|
||||
}
|
||||
_out := c.distribution(out)
|
||||
c.filter(_out)
|
||||
|
||||
_out["230000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "230000",
|
||||
Name: "黑龙江",
|
||||
Count: 6000,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"230100": &InstanceDistributionDetailInfo{
|
||||
Code: "230100",
|
||||
Name: "哈尔滨市",
|
||||
Count: 3000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
"230200": &InstanceDistributionDetailInfo{
|
||||
Code: "230200",
|
||||
Name: "齐齐哈尔市",
|
||||
Count: 3000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
_out["330000"] = &InstanceDistributionDetailInfo{
|
||||
Code: "330000",
|
||||
Name: "浙江省",
|
||||
Count: 5000,
|
||||
Industry: nil,
|
||||
Children: map[string]*InstanceDistributionDetailInfo{
|
||||
"330100": &InstanceDistributionDetailInfo{
|
||||
Code: "330100",
|
||||
Name: "杭州市",
|
||||
Count: 5000,
|
||||
Industry: nil,
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
return _out, nil
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ type NavigationHandle func() *Navigation
|
||||
type NavigationInfo struct {
|
||||
Title string `json:"title"`
|
||||
Link string `json:"link"`
|
||||
IsTarget bool `json:"is_target"`
|
||||
Children []*NavigationInfo `json:"children"`
|
||||
}
|
||||
|
||||
@ -24,6 +25,7 @@ func (c *Navigation) tree(src []*model2.SysNavigation, parentID uint64) []*Navig
|
||||
out = append(out, &NavigationInfo{
|
||||
Title: v.Title,
|
||||
Link: v.Link,
|
||||
IsTarget: v.IsTarget > 0,
|
||||
Children: c.tree(src, v.ID),
|
||||
})
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ func GetTenantID() ApiHandle {
|
||||
value := c.GetHeader(config.ContentForTenantID)
|
||||
|
||||
if value == "" {
|
||||
return 0
|
||||
return uint64(0)
|
||||
}
|
||||
return utils.StringToUnit64(value)
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/controller"
|
||||
"SciencesServer/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -26,7 +25,7 @@ func (a *Config) Industry(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data := controller.NewConfig().Industry(utils.StringToUnit64(form.ParentID))
|
||||
data := controller.NewConfig().Industry((&IDStringForm{ID: form.ParentID}).Convert())
|
||||
APISuccess(data)(c)
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
config2 "SciencesServer/config"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Config struct{}
|
||||
@ -53,7 +52,7 @@ func (c *Config) Industry(parentID uint64) []*IndustryInfo {
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &IndustryInfo{
|
||||
ID: fmt.Sprintf("%d", v.ID),
|
||||
ID: v.GetEncodeID(),
|
||||
Name: v.Name,
|
||||
})
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ package model
|
||||
type ActivityApply struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Identity int `gorm:"column:identity;type:tinyint(3);default:0;comment:身份信息" json:"-"`
|
||||
ActivityInstanceBasic
|
||||
Contact string `gorm:"column:contact;type:varchar(20);default:'';comment:联系人" json:"contact"`
|
||||
ContactMobile string `gorm:"column:contact_mobile;type:varchar(15);default:'';comment:联系方式" json:"contact_mobile"`
|
||||
|
@ -3,10 +3,12 @@ package model
|
||||
// SysNavigation 自定义导航栏数据模型
|
||||
type SysNavigation struct {
|
||||
Model
|
||||
ModelTenant
|
||||
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"parent_id"`
|
||||
Title string `gorm:"column:title;type:varchar(20);default:'';comment:区域名称" json:"title"`
|
||||
Link string `gorm:"column:link;type:varchar(255);default:'';comment:访问地址" json:"link"`
|
||||
Sort int `gorm:"column:sort;type:tinyint(3);default:0;comment:排序,从大到小" json:"-"`
|
||||
IsTarget int `gorm:"column:is_target;type:tinyint(1);default:0;comment:是否新窗口打开(0:否,1:是)" json:"is_target"`
|
||||
Sort int `gorm:"column:sort;type:tinyint(3);default:0;comment:排序,从小到小" json:"-"`
|
||||
Status SysNavigationStatus `gorm:"column:status;type:tinyint(1);default:1;comment:状态" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
|
@ -1,15 +1,8 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserIdentity 用户身份管理数据模型
|
||||
type UserIdentity struct {
|
||||
Model
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_manage_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;index:idx_user_manage_uid;type:int;default:0;comment:用户表UUID" json:"-"`
|
||||
Name string `gorm:"column:name;type:varchar(20);default:'';comment:真实姓名" json:"name"`
|
||||
Email string `gorm:"column:email;type:varchar(50);default:'';comment:邮箱" json:"email"`
|
||||
@ -36,13 +29,6 @@ func (m *UserIdentity) TableName() string {
|
||||
return m.NewTableName("user_identity")
|
||||
}
|
||||
|
||||
func (m *UserIdentity) BeforeCreate(db *gorm.DB) error {
|
||||
snowflake, _ := utils.NewSnowflake(1)
|
||||
m.UUID = uint64(snowflake.GetID())
|
||||
m.CreatedAt = time.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewUserIdentity() *UserIdentity {
|
||||
return &UserIdentity{}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ func (this *Cache) Init() {
|
||||
function(
|
||||
&caches{iModel: model.NewSysConfig(), iValues: func() interface{} {
|
||||
out := make([]*model.SysConfig, 0)
|
||||
_ = model.Find(model.NewSysConfig(), &out)
|
||||
_ = db.Table(model.NewSysConfig().TableName()).Find(&out)
|
||||
return out
|
||||
}, toCache: func(values interface{}) {
|
||||
out := values.([]*model.SysConfig)
|
||||
@ -48,7 +48,7 @@ func (this *Cache) Init() {
|
||||
function(
|
||||
&caches{iModel: model.NewSysIndustry(), iValues: func() interface{} {
|
||||
out := make([]*model.SysIndustry, 0)
|
||||
_ = model.ScanFields(model.NewSysIndustry(), &out, []string{"id", "name"})
|
||||
_ = db.Table(model.NewSysIndustry().TableName()).Select("id", "name").Scan(&out)
|
||||
return out
|
||||
}, toCache: func(values interface{}) {
|
||||
out := values.([]*model.SysIndustry)
|
||||
|
@ -166,6 +166,20 @@ func registerAdminAPI(app *gin.Engine) {
|
||||
_config.GET("/area", _api.Area)
|
||||
_config.GET("/identity", _api.Identity)
|
||||
_config.GET("/industry", _api.Industry)
|
||||
_api2 := new(api1.Config)
|
||||
_config.POST("/", _api2.Index)
|
||||
_config.POST("/add", _api2.Add)
|
||||
_config.POST("/edit", _api2.Edit)
|
||||
}
|
||||
// Sys 系统管理
|
||||
sys := v1.Group("/sys")
|
||||
{
|
||||
_api := new(api1.Sys)
|
||||
// 导航信息
|
||||
sys.GET("/navigation", _api.Navigation)
|
||||
sys.POST("/navigation/add", _api.NavigationForm)
|
||||
sys.POST("/navigation/edit", _api.NavigationForm)
|
||||
sys.POST("/navigation/delete", _api.NavigationDelete)
|
||||
}
|
||||
// User 用户管理
|
||||
user := v1.Group("/user")
|
||||
|
Reference in New Issue
Block a user