feat:完善项目信息
This commit is contained in:
@ -1,48 +1,3 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/controller/config"
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Config struct{}
|
||||
|
||||
func (a *Config) Identity(c *gin.Context) {
|
||||
data := config.NewConfig().Identity()
|
||||
api.APISuccess(data)(c)
|
||||
}
|
||||
|
||||
func (a *Config) Transaction(c *gin.Context) {
|
||||
data := config.NewConfig().Transaction()
|
||||
api.APISuccess(data)(c)
|
||||
}
|
||||
|
||||
func (a *Config) Industry(c *gin.Context) {
|
||||
form := &struct {
|
||||
ParentID string `json:"parent_id" form:"parent_id"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data := config.NewConfig().Industry(utils.StringToUnit64(form.ParentID))
|
||||
api.APISuccess(data)(c)
|
||||
}
|
||||
|
||||
func (a *Config) Research(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func (a *Config) Area(c *gin.Context) {
|
||||
form := &struct {
|
||||
Code string `json:"code" form:"code"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data := config.NewConfig().Area(form.Code)
|
||||
api.APIResponse(nil, data)(c)
|
||||
}
|
||||
|
@ -63,9 +63,7 @@ func (c *Apply) List(title string, page, pageSize int) (*controller.ReturnPages,
|
||||
// Launch 发起操作
|
||||
func (c *Apply) Launch(params *ApplyLaunchParams) error {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
mActivityApply.Local.Local = c.local
|
||||
mActivityApply.IdentityUID = c.IdentityUID
|
||||
mActivityApply.Mode = model2.ActivityInstanceMode(params.Mode)
|
||||
mActivityApply.UID = c.UID
|
||||
mActivityApply.Title = params.Title
|
||||
mActivityApply.Amount = params.Amount
|
||||
mActivityApply.Content = params.Content
|
||||
@ -87,9 +85,9 @@ func (c *Apply) Revoke(id uint64) error {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,活动信息不存在或已被删除")
|
||||
} else if mActivityApply.Status != model2.ActivityApplyStatusForExamining {
|
||||
} else if mActivityApply.Status != model2.ActivityApplyStatusForProcessing {
|
||||
return errors.New("操作错误,当前活动状态易发生变化,不可撤销")
|
||||
} else if mActivityApply.IdentityUID != c.IdentityUID {
|
||||
} else if mActivityApply.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
}
|
||||
return model2.Updates(mActivityApply.ActivityApply, map[string]interface{}{
|
||||
@ -108,7 +106,7 @@ func (c *Apply) Delete(id uint64) error {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,活动信息不存在或已被删除")
|
||||
} else if mActivityApply.IdentityUID != c.IdentityUID {
|
||||
} else if mActivityApply.UID != c.IdentityUID {
|
||||
return errors.New("无权限操作")
|
||||
}
|
||||
return model2.Delete(mActivityApply.ActivityApply)
|
||||
|
@ -1,80 +1 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
config2 "SciencesServer/config"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Config struct{}
|
||||
|
||||
type (
|
||||
// IndustryInfo 所属领域信息
|
||||
IndustryInfo struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
)
|
||||
|
||||
// Basic 基础配置信息
|
||||
func (c *Config) Basic() {
|
||||
|
||||
}
|
||||
|
||||
// Config 配置信息
|
||||
func (c *Config) Config() map[string]interface{} {
|
||||
return config2.SystemConfig
|
||||
}
|
||||
|
||||
// Identity 身份信息
|
||||
func (c *Config) Identity() map[int]string {
|
||||
return config.TenantUserIdentityData
|
||||
}
|
||||
|
||||
// Transaction 交易信息
|
||||
func (c *Config) Transaction() map[int]string {
|
||||
return config.TechnologyTransactionData
|
||||
}
|
||||
|
||||
// Industry 行业信息
|
||||
func (c *Config) Industry(parentID uint64) []*IndustryInfo {
|
||||
mSysIndustry := model.NewSysIndustry()
|
||||
out := make([]*model2.SysIndustry, 0)
|
||||
|
||||
err := model2.ScanFields(mSysIndustry.SysIndustry, &out, []string{"id", "name"}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("parent_id", parentID),
|
||||
})
|
||||
|
||||
list := make([]*IndustryInfo, 0)
|
||||
|
||||
if err != nil {
|
||||
return list
|
||||
}
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &IndustryInfo{
|
||||
ID: fmt.Sprintf("%d", v.ID),
|
||||
Name: v.Name,
|
||||
})
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
// Research 研究领域信息
|
||||
func (c *Config) Research() {
|
||||
|
||||
}
|
||||
|
||||
// Area 区域信息
|
||||
func (c *Config) Area(key string) map[string]string {
|
||||
if key == "" {
|
||||
key = config2.DefaultChinaAreaCode
|
||||
}
|
||||
return config.MemoryForAreaInfo[key]
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
return &Config{}
|
||||
}
|
||||
|
Reference in New Issue
Block a user