feat:完善项目信息

This commit is contained in:
henry
2022-01-12 15:05:14 +08:00
parent 0d49575e06
commit 4ec0953a29
33 changed files with 817 additions and 249 deletions

View File

@ -52,7 +52,7 @@ func Bind(req interface{}) ApiHandle {
}
if err != nil {
logger.ErrorF("Request URL【%s】Params Bind Error%v", c.Request.URL, err)
return errors.New("参数异常/缺失")
return errors.New("参数异常/缺失【" + err.Error() + "】")
}
c.Set("params", utils.AnyToJSON(req))
return nil

47
app/basic/api/config.go Normal file
View File

@ -0,0 +1,47 @@
package api
import (
"SciencesServer/app/basic/controller"
"SciencesServer/utils"
"github.com/gin-gonic/gin"
)
type Config struct{}
func (*Config) Identity(c *gin.Context) {
data := controller.NewConfig().Identity()
APISuccess(data)(c)
}
func (a *Config) Transaction(c *gin.Context) {
data := controller.NewConfig().Transaction()
APISuccess(data)(c)
}
func (a *Config) Industry(c *gin.Context) {
form := &struct {
ParentID string `json:"parent_id" form:"parent_id"`
}{}
if err := Bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data := controller.NewConfig().Industry(utils.StringToUnit64(form.ParentID))
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 := Bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data := controller.NewConfig().Area(form.Code)
APIResponse(nil, data)(c)
}

View File

@ -0,0 +1,73 @@
package controller
import (
"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 {
out := make([]*model2.SysIndustry, 0)
err := model2.ScanFields(model2.NewSysIndustry(), &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
}
// Area 区域信息
func (c *Config) Area(key string) map[string]string {
if key == "" {
key = config2.DefaultChinaAreaCode
}
return config.MemoryForAreaInfo[key]
}
func NewConfig() *Config {
return &Config{}
}