feat:完善项目
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@ doc/*
|
||||
data/*
|
||||
main
|
||||
SciencesServer
|
||||
dist/*
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
|
@ -23,10 +23,10 @@ func (a *Config) Index(c *gin.Context) {
|
||||
|
||||
func (a *Config) Add(c *gin.Context) {
|
||||
form := &struct {
|
||||
Kind int `json:"kind" form:"kind" binding:"required"`
|
||||
Name string `json:"name" form:"name" binding:"required"`
|
||||
Key string `json:"key" form:"key" binding:"required"`
|
||||
Value interface{} `json:"value" form:"value" binding:"required"`
|
||||
Kind int `json:"kind" form:"kind" binding:"required"`
|
||||
Name string `json:"name" form:"name" binding:"required"`
|
||||
Key string `json:"key" form:"key" binding:"required"`
|
||||
Value string `json:"value" form:"value" binding:"required"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
@ -39,8 +39,8 @@ func (a *Config) Add(c *gin.Context) {
|
||||
func (a *Config) Edit(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
Name string `json:"name" form:"name" binding:"required"`
|
||||
Value interface{} `json:"value" form:"value" binding:"required"`
|
||||
Name string `json:"name" form:"name" binding:"required"`
|
||||
Value string `json:"value" form:"value" binding:"required"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
|
@ -102,12 +102,13 @@ func (c *Account) Login(mode int, params *AccountLoginParams, equipment, ip stri
|
||||
|
||||
_uid := data.UUIDString()
|
||||
|
||||
_session.Token = utils.JWTEncrypt(config.SettingInfo.TokenEffectTime, map[string]interface{}{config.TokenForUID: _uid})
|
||||
_session.Token = utils.JWTEncrypt(utils.StringToInt(config.SystemConfig[config.SysTokenEffectTime]),
|
||||
map[string]interface{}{config.TokenForUID: _uid})
|
||||
|
||||
service.Publish(config.EventForRedisHashProduce, config.RedisKeyForAccountAdmin, _uid, _session)
|
||||
service.Publish(config.EventForAccountLoginProduce, data.TenantID, data.ID, equipment, ip)
|
||||
|
||||
return &AccountLoginResponse{Token: _session.Token, EffectTime: config.SettingInfo.TokenEffectTime}, nil
|
||||
return &AccountLoginResponse{Token: _session.Token, EffectTime: utils.StringToInt(config.SystemConfig[config.SysTokenEffectTime])}, nil
|
||||
}
|
||||
|
||||
// Logout 退出请求
|
||||
|
@ -63,7 +63,7 @@ func (c *Apply) Instance(tenantID uint64, title, contact string, page, pageSize
|
||||
list := make([]*ApplyInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
v.Image.Image = v.Analysis(config.SettingInfo.Domain)
|
||||
v.Image.Image = v.Analysis(config.SystemConfig[config.SysImageDomain])
|
||||
list = append(list, &ApplyInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
TenantID: v.GetEncodeTenantID(),
|
||||
@ -82,7 +82,7 @@ func (c *Apply) Detail(id uint64) (*ApplyDetailInfo, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.Image.Image = out.Analysis(config.SettingInfo.Domain)
|
||||
out.Image.Image = out.Analysis(config.SystemConfig[config.SysImageDomain])
|
||||
|
||||
return &ApplyDetailInfo{
|
||||
ID: out.GetEncodeID(),
|
||||
|
@ -27,6 +27,7 @@ func (c *Config) Config(kind, page, pageSize int) (*controller.ReturnPages, erro
|
||||
mSysConfig := model.NewSysConfig()
|
||||
|
||||
where := []*model2.ModelWhereOrder{
|
||||
&model2.ModelWhereOrder{Order: model2.NewOrder("sort", model2.OrderModeToAsc)},
|
||||
&model2.ModelWhereOrder{Order: model2.NewOrder("kind", model2.OrderModeToAsc)},
|
||||
}
|
||||
if kind > 0 {
|
||||
@ -50,7 +51,7 @@ func (c *Config) Config(kind, page, pageSize int) (*controller.ReturnPages, erro
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func (c *Config) Add(kind int, name, key string, value interface{}) error {
|
||||
func (c *Config) Add(kind int, name, key, value string) error {
|
||||
mSysConfig := model.NewSysConfig()
|
||||
|
||||
var count int64
|
||||
@ -75,7 +76,7 @@ func (c *Config) Add(kind int, name, key string, value interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Config) Form(id uint64, name string, value interface{}) error {
|
||||
func (c *Config) Form(id uint64, name, value string) error {
|
||||
mSysConfig := model.NewSysConfig()
|
||||
mSysConfig.ID = id
|
||||
|
||||
|
@ -85,7 +85,7 @@ func (c *SolutionCase) Instance(tenantID uint64, title string, kindID uint64, pa
|
||||
list := make([]*SolutionCaseInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
v.Image.Image = v.Image.Analysis(config2.SettingInfo.Domain)
|
||||
v.Image.Image = v.Image.Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
|
||||
list = append(list, &SolutionCaseInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
@ -108,7 +108,7 @@ func (c *SolutionCase) Detail(id uint64) (*SolutionCaseDetailInfo, error) {
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,案例信息不存在或已被删除")
|
||||
}
|
||||
mServiceSolutionCase.Image.Image = mServiceSolutionCase.Image.Analysis(config2.SettingInfo.Domain)
|
||||
mServiceSolutionCase.Image.Image = mServiceSolutionCase.Image.Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
|
||||
return &SolutionCaseDetailInfo{
|
||||
ID: mServiceSolutionCase.GetEncodeID(),
|
||||
@ -203,7 +203,7 @@ func (c *SolutionCase) Kind(tenantID uint64, mode int, title string, page, pageS
|
||||
list := make([]*SolutionCaseKindInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
v.Image.Image = v.Image.Analysis(config2.SettingInfo.Domain)
|
||||
v.Image.Image = v.Image.Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
|
||||
list = append(list, &SolutionCaseKindInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
|
@ -130,7 +130,7 @@ func (c *Banner) Instance(tenantID uint64, title, local string, page, pageSize i
|
||||
ID: v.GetEncodeID(), TenantID: v.GetEncodeTenantID(),
|
||||
SysBanner: v.SysBanner,
|
||||
Area: v.FormatBasic(),
|
||||
Images: v.Images.AnalysisSlice(config.SettingInfo.Domain),
|
||||
Images: v.Images.AnalysisSlice(config.SystemConfig[config.SysImageDomain]),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
|
@ -132,7 +132,7 @@ type (
|
||||
)
|
||||
|
||||
func (a *instanceForm) FilterProveImages() string {
|
||||
return strings.Replace(a.ProveImages, config2.SettingInfo.Domain, "", -1)
|
||||
return strings.Replace(a.ProveImages, config2.SystemConfig[config2.SysImageDomain], "", -1)
|
||||
}
|
||||
|
||||
func (a *productForm) FilterVideo() string {
|
||||
|
@ -35,7 +35,7 @@ type (
|
||||
|
||||
func (c *Instance) Login() InstanceLoginCallback {
|
||||
return func(params *InstanceLoginParams) *InstanceLoginReturn {
|
||||
token := utils.JWTEncrypt(config.SettingInfo.TokenEffectTime, map[string]interface{}{
|
||||
token := utils.JWTEncrypt(utils.StringToInt(config.SystemConfig[config.SysTokenEffectTime]), map[string]interface{}{
|
||||
config.TokenForUID: fmt.Sprintf("%d", params.UID),
|
||||
})
|
||||
_session := session.NewEnterprise()
|
||||
@ -53,7 +53,7 @@ func (c *Instance) Login() InstanceLoginCallback {
|
||||
|
||||
service.Publish(config.EventForRedisHashProduce, config.RedisKeyForAccountEnterprise, _session.UIDToString(), _session)
|
||||
|
||||
return &InstanceLoginReturn{Token: token, TokenEffectTime: config.SettingInfo.TokenEffectTime}
|
||||
return &InstanceLoginReturn{Token: token, TokenEffectTime: utils.StringToInt(config.SystemConfig[config.SysTokenEffectTime])}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ func loginForSmsCaptcha(params *LoginParams, tenantID uint64) (*InstanceLoginPar
|
||||
RETURNS:
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID,
|
||||
Avatar: mUserInstance.GetAvatarAttribute(config.SettingInfo.Domain), Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Avatar: mUserInstance.GetAvatarAttribute(config.SystemConfig[config.SysImageDomain]), Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Vip: mUserInstance.Vip, VipStatus: mUserInstance.VipStatus(), VipDeadline: mUserInstance.VipDeadline,
|
||||
Currency: mUserAssets.Currency, Identity: mUserInstance.Identity, SelectIdentity: mUserIdentity.Identity,
|
||||
Status: mUserInstance.Status,
|
||||
@ -139,7 +139,7 @@ func loginForPassword(params *LoginParams, tenantID uint64) (*InstanceLoginParam
|
||||
}
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID,
|
||||
Avatar: mUserInstance.GetAvatarAttribute(config.SettingInfo.Domain), Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Avatar: mUserInstance.GetAvatarAttribute(config.SystemConfig[config.SysImageDomain]), Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Vip: mUserInstance.Vip, VipStatus: mUserInstance.VipStatus(), VipDeadline: mUserInstance.VipDeadline,
|
||||
Currency: mUserAssets.Currency, Identity: mUserInstance.Identity, SelectIdentity: mUserIdentity.Identity,
|
||||
Status: mUserInstance.Status,
|
||||
|
@ -140,7 +140,7 @@ func (c *Company) Match(title string, industrys, keywords []string) ([]*CompanyM
|
||||
for _, v := range companys {
|
||||
list = append(list, &CompanyMatchInfo{
|
||||
ID: v.GetEncodeID(), Kind: v.Kind, Name: v.Name,
|
||||
Image: v.Image.Analysis(config2.SettingInfo.Domain),
|
||||
Image: v.Image.Analysis(config2.SystemConfig[config2.SysImageDomain]),
|
||||
Url: v.Url,
|
||||
Keywords: v.GetKeywordAttribute(),
|
||||
})
|
||||
|
@ -39,8 +39,8 @@ func (c *Company) Get(code string) (*CompanyInfo, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
mManageCompany.Image.Image = mManageCompany.Image.Analysis(config2.SettingInfo.Domain)
|
||||
mManageCompany.License = (&model2.Image{Image: mManageCompany.License}).Analysis(config2.SettingInfo.Domain)
|
||||
mManageCompany.Image.Image = mManageCompany.Image.Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
mManageCompany.License = (&model2.Image{Image: mManageCompany.License}).Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
|
||||
return &CompanyInfo{
|
||||
ID: mManageCompany.GetEncodeID(),
|
||||
|
@ -157,7 +157,7 @@ func (c *Product) Visit(id uint64, page, pageSize int) (*controller.ReturnPages,
|
||||
for _, v := range out {
|
||||
mManageCompany.Keyword = v.CompanyKeyword
|
||||
mManageCompany.Image.Image = v.CompanyImage
|
||||
v.CompanyImage = mManageCompany.Image.Analysis(config2.SettingInfo.Domain)
|
||||
v.CompanyImage = mManageCompany.Image.Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
|
||||
list = append(list, &ProductVisitInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
|
@ -74,7 +74,7 @@ func (c *Withdrawal) Transfer(id uint64) (*WithdrawalTransferInfo, error) {
|
||||
return nil, nil
|
||||
}
|
||||
return &WithdrawalTransferInfo{
|
||||
Images: mUserWithdrawalTransfer.Images.AnalysisSlice(config.SettingInfo.Domain),
|
||||
Images: mUserWithdrawalTransfer.Images.AnalysisSlice(config.SystemConfig[config.SysImageDomain]),
|
||||
Remark: mUserWithdrawalTransfer.Remark,
|
||||
}, nil
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ func (c *Activity) Detail(id uint64) (*ActivityDetail, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mActivityInstance.Image.Image = mActivityInstance.Image.Analysis(config.SettingInfo.Domain)
|
||||
mActivityInstance.Image.Image = mActivityInstance.Image.Analysis(config.SystemConfig[config.SysImageDomain])
|
||||
|
||||
return &ActivityDetail{
|
||||
ID: out.GetEncodeID(),
|
||||
|
@ -55,7 +55,7 @@ func (c *Company) Instance(id uint64) (*CompanyInstanceInfo, error) {
|
||||
return &CompanyInstanceInfo{
|
||||
CompanyBasicInfo: CompanyBasicInfo{
|
||||
ID: mManageCompany.GetEncodeID(), Kind: mManageCompany.Kind, Name: mManageCompany.Name,
|
||||
Image: mManageCompany.Image.Analysis(config2.SettingInfo.Domain),
|
||||
Image: mManageCompany.Image.Analysis(config2.SystemConfig[config2.SysImageDomain]),
|
||||
Url: mManageCompany.Url,
|
||||
Keywords: mManageCompany.GetKeywordAttribute(),
|
||||
},
|
||||
|
@ -46,7 +46,7 @@ func company(ids []uint64) (interface{}, error) {
|
||||
for _, v := range out {
|
||||
list = append(list, &CompanyBasicInfo{
|
||||
ID: v.GetEncodeID(), Kind: v.Kind, Name: v.Name,
|
||||
Image: v.Image.Analysis(config2.SettingInfo.Domain),
|
||||
Image: v.Image.Analysis(config2.SystemConfig[config2.SysImageDomain]),
|
||||
Url: v.Url,
|
||||
Keywords: v.GetKeywordAttribute(),
|
||||
})
|
||||
@ -65,7 +65,7 @@ func expert(ids []uint64) (interface{}, error) {
|
||||
list := make([]*ExpertBasicInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
v.Image.Image = v.Image.Analysis(config2.SettingInfo.Domain)
|
||||
v.Image.Image = v.Image.Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
|
||||
list = append(list, &ExpertBasicInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
|
@ -20,10 +20,11 @@ type InnovateHandle func(session *session.Enterprise, tenantID uint64) *Innovate
|
||||
type (
|
||||
// InnovateInfo 创新服务信息
|
||||
InnovateInfo struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Tags []string `json:"tags"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Tags []string `json:"tags"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
// InnovateKindInfo 创新服务分类信息
|
||||
InnovateKindInfo struct {
|
||||
@ -39,7 +40,7 @@ type (
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Innovate) Instance(kind uint64, title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
func (c *Innovate) Instance(kindID uint64, title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mServiceInnovate := model.NewServiceInnovate()
|
||||
|
||||
out := make([]*model2.ServiceInnovate, 0)
|
||||
@ -48,14 +49,14 @@ func (c *Innovate) Instance(kind uint64, title string, page, pageSize int) (*con
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{Order: model2.NewOrder("id", model2.OrderModeToDesc)}}
|
||||
|
||||
if kind > 0 {
|
||||
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhere("kind", kind)})
|
||||
if kindID > 0 {
|
||||
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhere("kind_id", kindID)})
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereLike("title", title)})
|
||||
}
|
||||
|
||||
if err := model2.PagesFields(mServiceInnovate.ServiceInnovate, &out, []string{"id", "title", "tag", "created_at"}, page, pageSize,
|
||||
if err := model2.PagesFields(mServiceInnovate.ServiceInnovate, &out, []string{"id", "title", "description", "tag", "created_at"}, page, pageSize,
|
||||
&count, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -63,7 +64,8 @@ func (c *Innovate) Instance(kind uint64, title string, page, pageSize int) (*con
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &InnovateInfo{
|
||||
ID: v.GetEncodeID(), Title: v.Title, Tags: v.GetTagAttribute(), CreatedAt: v.CreatedAt,
|
||||
ID: v.GetEncodeID(), Title: v.Title, Description: v.Description, Tags: v.GetTagAttribute(),
|
||||
CreatedAt: v.CreatedAt,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
|
@ -64,7 +64,7 @@ func (c *SolutionCase) Instance(mode int) ([]*SolutionCaseInfo, error) {
|
||||
|
||||
detail := &SolutionCaseBasic{
|
||||
ID: (&model2.Model{ID: v.DetailID}).GetEncodeID(), Title: v.DetailTitle,
|
||||
Image: (&model2.Image{Image: v.DetailImage}).Analysis(config.SettingInfo.Domain),
|
||||
Image: (&model2.Image{Image: v.DetailImage}).Analysis(config.SystemConfig[config.SysImageDomain]),
|
||||
Description: v.DetailDescription,
|
||||
}
|
||||
for _, val := range ret {
|
||||
@ -77,7 +77,7 @@ func (c *SolutionCase) Instance(mode int) ([]*SolutionCaseInfo, error) {
|
||||
if !isExist {
|
||||
ret = append(ret, &SolutionCaseInfo{
|
||||
ID: v.GetEncodeID(), MarkID: v.ID, Mode: v.Mode, Title: v.Title,
|
||||
Image: v.Image.Analysis(config.SettingInfo.Domain),
|
||||
Image: v.Image.Analysis(config.SystemConfig[config.SysImageDomain]),
|
||||
Description: v.Description,
|
||||
Children: []*SolutionCaseBasic{detail},
|
||||
})
|
||||
@ -109,7 +109,7 @@ func (c *SolutionCase) List(kindID uint64, page, pageSize int) (*controller.Retu
|
||||
for _, v := range out {
|
||||
list = append(list, &SolutionCaseBasic{
|
||||
ID: v.GetEncodeID(), Title: v.Title,
|
||||
Image: v.Image.Analysis(config.SettingInfo.Domain),
|
||||
Image: v.Image.Analysis(config.SystemConfig[config.SysImageDomain]),
|
||||
Description: v.Description,
|
||||
})
|
||||
}
|
||||
@ -135,7 +135,7 @@ func (c *SolutionCase) Detail(id uint64) (*SolutionCaseDetail, error) {
|
||||
SolutionCaseBasic: SolutionCaseBasic{
|
||||
ID: mServiceSolutionCase.GetEncodeID(),
|
||||
Title: mServiceSolutionCase.Title,
|
||||
Image: mServiceSolutionCase.Image.Analysis(config.SettingInfo.Domain),
|
||||
Image: mServiceSolutionCase.Image.Analysis(config.SystemConfig[config.SysImageDomain]),
|
||||
Description: mServiceSolutionCase.Description,
|
||||
},
|
||||
Visits: mServiceSolutionCase.Visits,
|
||||
|
@ -29,7 +29,7 @@ func (c *Banner) Instance(key string) (*BannerInfo, error) {
|
||||
ID: mSysBanner.GetEncodeID(),
|
||||
Title: mSysBanner.Title,
|
||||
IsMultiple: mSysBanner.IsMultiple,
|
||||
Images: mSysBanner.Images.AnalysisSlice(config.SettingInfo.Domain),
|
||||
Images: mSysBanner.Images.AnalysisSlice(config.SystemConfig[config.SysImageDomain]),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ func (c *Achievement) Instance(title, industry string, page, pageSize int) (*con
|
||||
list = append(list, &AchievementInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
Title: v.Title,
|
||||
Image: v.Image.Analysis(config.SettingInfo.Domain),
|
||||
Image: v.Image.Analysis(config.SystemConfig[config.SysImageDomain]),
|
||||
Industrys: v.GetIndustryAttribute(),
|
||||
Customers: v.GetCustomerAttribute(),
|
||||
Maturity: v.Maturity,
|
||||
@ -107,7 +107,7 @@ func (c *Achievement) Detail(id uint64) (*AchievementDetailInfo, error) {
|
||||
AchievementInfo: AchievementInfo{
|
||||
ID: out.GetEncodeID(),
|
||||
Title: out.Title,
|
||||
Image: out.Image.Analysis(config.SettingInfo.Domain),
|
||||
Image: out.Image.Analysis(config.SystemConfig[config.SysImageDomain]),
|
||||
Industrys: out.GetIndustryAttribute(),
|
||||
Customers: out.GetCustomerAttribute(),
|
||||
Maturity: out.Maturity,
|
||||
|
@ -45,7 +45,7 @@ type ImageForm struct {
|
||||
}
|
||||
|
||||
func (this *ImageForm) FilterImageURL() string {
|
||||
return strings.Replace(this.Image, config.SettingInfo.Domain, "", -1)
|
||||
return strings.Replace(this.Image, config.SystemConfig[config.SysImageDomain], "", -1)
|
||||
}
|
||||
|
||||
type ImagesForm struct {
|
||||
@ -56,7 +56,7 @@ func (this *ImagesForm) FilterImageURL() string {
|
||||
out := make([]string, 0)
|
||||
|
||||
for _, v := range strings.Split(this.Images, ",") {
|
||||
out = append(out, strings.Replace(v, config.SettingInfo.Domain, "", -1))
|
||||
out = append(out, strings.Replace(v, config.SystemConfig[config.SysImageDomain], "", -1))
|
||||
}
|
||||
return strings.Join(out, ",")
|
||||
}
|
||||
@ -66,7 +66,7 @@ type FileForm struct {
|
||||
}
|
||||
|
||||
func (this *FileForm) FilterURL() string {
|
||||
return strings.Replace(this.File, config.SettingInfo.Domain, "", -1)
|
||||
return strings.Replace(this.File, config.SystemConfig[config.SysImageDomain], "", -1)
|
||||
}
|
||||
|
||||
type PositionForm struct {
|
||||
|
@ -53,10 +53,8 @@ func (a *Upload) Upload(c *gin.Context) {
|
||||
}
|
||||
resp := new(lib.UploadHandle)
|
||||
|
||||
if resp, err = lib.Upload(config.SystemConfig[config.UploadPath].(string),
|
||||
strings.Split(config.SystemConfig[config.UploadExt].(string), ","),
|
||||
utils.StringToInt64(config.SystemConfig[config.UploadSize].(string)),
|
||||
true).Handle()(file, config.SettingInfo.Domain); err != nil {
|
||||
if resp, err = lib.Upload(config.SystemConfig[config.UploadPath], strings.Split(config.SystemConfig[config.UploadExt], ","),
|
||||
utils.StringToInt64(config.SystemConfig[config.UploadSize]), true).Handle()(file, config.SystemConfig[config.SysImageDomain]); err != nil {
|
||||
APIFailure(err)(c)
|
||||
return
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func (c *Config) Basic() {
|
||||
}
|
||||
|
||||
// Config 配置信息
|
||||
func (c *Config) Config() map[string]interface{} {
|
||||
func (c *Config) Config() map[string]string {
|
||||
return config2.SystemConfig
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ type SysConfig struct {
|
||||
Name string `gorm:"column:name;type:varchar(30);default:'';comment:名称" json:"name"`
|
||||
Key string `gorm:"column:key;type:varchar(100);default:'';comment:标识" json:"key"`
|
||||
Value string `gorm:"column:value;type:text;comment:内容" json:"value"`
|
||||
Sort int `gorm:"column:sort;type:tinyint(3);default:0;comment:排序,数值越小,优先排序" json:"sort"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
@ -37,7 +37,8 @@ func (this *AuthToken) Auth(key string, session logic.ISession) error {
|
||||
if err := json.Unmarshal([]byte(cache), session); err != nil {
|
||||
return err
|
||||
}
|
||||
if !config.SettingInfo.MultipleLogin && session.GetToken() != this.Token {
|
||||
if (config.SystemConfig[config.SysMultipleLogin] == "0" || config.SystemConfig[config.SysMultipleLogin] == "") &&
|
||||
session.GetToken() != this.Token {
|
||||
return errors.New("登陆错误,已在其他地方登录!")
|
||||
}
|
||||
return nil
|
||||
|
@ -44,11 +44,6 @@ type Redis struct {
|
||||
|
||||
// Setting 配置信息
|
||||
type Setting struct {
|
||||
Domain string `json:"domain" yaml:"domain"`
|
||||
Name string `yaml:"name"`
|
||||
TokenEffectTime int `yaml:"token_effect_time"`
|
||||
MultipleLogin bool `yaml:"multiple_login"`
|
||||
|
||||
// Server 配置
|
||||
Server struct {
|
||||
Port int `yaml:"port"`
|
||||
|
@ -1,15 +1,15 @@
|
||||
package config
|
||||
|
||||
var SystemConfig = make(map[string]interface{}, 0)
|
||||
var SystemConfig = make(map[string]string, 0)
|
||||
|
||||
//png,jpg,csv,xls,xlsx,pcm,wav,amr,mp3,mp4,json
|
||||
|
||||
// 基本配置
|
||||
const (
|
||||
Name string = "name" // 名称
|
||||
Domain string = "domain" // 域名
|
||||
TokenEffectTime string = "token_effect_time" // Token有效时间
|
||||
MultipleLogin string = "multiple_login" // 是否开启多地登录
|
||||
SysDomain string = "sys_domain" // 系统域名
|
||||
SysImageDomain string = "sys_image_domain" // 系统图片访问地址
|
||||
SysTokenEffectTime string = "sys_token_effect_time" // Token有效时间
|
||||
SysMultipleLogin string = "sys_multiple_login" // 是否开启多地登录
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -1,7 +1,6 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"SciencesServer/config"
|
||||
"SciencesServer/serve/logger"
|
||||
"context"
|
||||
"net/http"
|
||||
@ -96,19 +95,3 @@ func RecoveryHandler() gin.HandlerFunc {
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
// ContentAnalysisHandler 消息体解析
|
||||
func ContentAnalysisHandler() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
url := c.Request.URL
|
||||
|
||||
var data string
|
||||
|
||||
value, has := config.SystemConfig[url.String()]
|
||||
|
||||
if has {
|
||||
data = value.(string)
|
||||
}
|
||||
c.Set(config.ContentForTenantID, data)
|
||||
}
|
||||
}
|
||||
|
@ -37,12 +37,15 @@ func (this *Router) Init() *gin.Engine {
|
||||
if this.IsCors {
|
||||
app.Use(Cors())
|
||||
}
|
||||
app.NoRoute(NoRouteHandler())
|
||||
app.LoadHTMLFiles("./dist/*") // 添加资源路径
|
||||
app.StaticFS("/static", http.Dir("./dist/static"))
|
||||
app.StaticFile("/", "dist/index.html") //前端接口
|
||||
|
||||
//app.NoRoute(NoRouteHandler())
|
||||
app.NoMethod(NoMethodHandler())
|
||||
app.Use(LoggerHandle("log/gin.log", 3))
|
||||
app.Use(TimeoutHandle(time.Second * 30))
|
||||
//app.Use(RecoveryHandler())
|
||||
app.Use(ContentAnalysisHandler())
|
||||
|
||||
if this.RateLimitConfig != nil {
|
||||
if this.RateLimitConfig.IsRate {
|
||||
|
Reference in New Issue
Block a user