diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..6b4df2a Binary files /dev/null and b/.DS_Store differ diff --git a/.config.yaml b/.config.yaml new file mode 100644 index 0000000..308bfa8 --- /dev/null +++ b/.config.yaml @@ -0,0 +1,70 @@ +name: 中科元 +# domain 域名 +domain: http://192.168.0.145:8000 +# token有效时间(秒) +token_effect_time: 604800 +# multiple_login 多地登录 +multiple_login: true + +server: + port: 8000 + read_timeout: 5 + write_timeout: 5 + idle_timeout: 5 + +# RATE 限流器 +rate: + # 每秒注入容器中数量 + limit: 50 + # 每个IP每秒请求最大次数 + capacity: 100 + +# ENGINE 配置 +engine: + # 开启会输出sql日志 + debug: true + # db_mode - mysql | sqlite + db_mode: mysql + max_lifetime: 3600 + max_open_conns: 2000 + max_idle_conns: 1000 + table_prefix: + # 是否采用数据表复数 + complex: false + # MYSQL 配置 + mysql: + host: 127.0.0.1 + port: 3306 + user: appuser + password: ABCabc01 + db_name: sciences + parameters: charset=utf8mb4,utf8&parseTime=True&loc=Local + # SQLITE 配置 + sqlite: + path: data + name: app.db + +cache: + # memory | redis + type: redis + redis: + addr: "192.168.0.188:6379" + password: ABCabc01 + db: 0 + max_active: 0 + max_idle: 1000 + idle_timeout: 240 + +# UPLOAD 上传文件配置 +upload: + path: upload/ + ext: png,jpg,csv,xls,xlsx,pcm,wav,amr,mp3,mp4,json + # size 4<<20,不支持位运算,文件最大限制 + size: 4194304 + rename: true + +#LOG 日志管理 +log: + file: log/logs.log + least_day: 7 + level: debug # debug | info | warn | error \ No newline at end of file diff --git a/.gitignore b/.gitignore index 678031a..132b59e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ SciencesServer *.prof upload/* log/* -cmd/ctl/ctl \ No newline at end of file +cmd/ctl/ctl +./config.yaml \ No newline at end of file diff --git a/app/api/website/controller/service/innovate.go b/app/api/website/controller/service/innovate.go index 482fa17..3504fee 100644 --- a/app/api/website/controller/service/innovate.go +++ b/app/api/website/controller/service/innovate.go @@ -34,6 +34,7 @@ type ( InnovateDetailInfo struct { ID string `json:"id"` *model2.ServiceInnovate + Tags []string `json:"tags"` } ) @@ -103,6 +104,7 @@ func (c *Innovate) Detail(id uint64) (*InnovateDetailInfo, error) { return &InnovateDetailInfo{ ID: mServiceInnovate.GetEncodeID(), ServiceInnovate: mServiceInnovate.ServiceInnovate, + Tags: mServiceInnovate.GetTagAttribute(), }, nil } diff --git a/app/common/init.go b/app/common/init.go index 2b09ca7..e2e4ee7 100644 --- a/app/common/init.go +++ b/app/common/init.go @@ -132,6 +132,7 @@ func initModel() { &synchronized{iModel: model.NewTechnologyProject()}, &synchronized{iModel: model.NewTechnologyTopic()}, &synchronized{iModel: model.NewServiceDocking()}, &synchronized{iModel: model.NewServiceMessage()}, &synchronized{iModel: model.NewServiceSolutionCase()}, &synchronized{iModel: model.NewServiceSolutionCaseDetail()}, + &synchronized{iModel: model.NewServiceInnovate()}, &synchronized{iModel: model.NewServiceInnovateKind()}, // 活动管理 &synchronized{iModel: model.NewActivityInstance()}, &synchronized{iModel: model.NewActivityApply()}, &synchronized{iModel: model.NewActivityExamine()}, &synchronized{iModel: model.NewActivityJoin()}, diff --git a/app/common/model/service_innovate.go b/app/common/model/service_innovate.go new file mode 100644 index 0000000..5a48742 --- /dev/null +++ b/app/common/model/service_innovate.go @@ -0,0 +1,33 @@ +package model + +import "encoding/json" + +// ServiceInnovate 创新服务数据模型 +type ServiceInnovate struct { + Model + Kind uint64 `gorm:"column:kind;type:int(11);default:0;comment:创新服务类型" json:"kind"` + Title string `gorm:"column:title;type:varchar(50);default:'';comment:创新服务标题" json:"title"` + Content string `gorm:"column:content;type:text;comment:创新服务内容" json:"content"` + Tag string `gorm:"column:tag;type:varchar(255);default:'';comment:创新服务标签" json:"-"` + ModelDeleted + ModelAt +} + +func (m *ServiceInnovate) TableName() string { + return "service_innovate" +} + +func (m *ServiceInnovate) GetTagAttribute() []string { + out := make([]string, 0) + _ = json.Unmarshal([]byte(m.Tag), &out) + return out +} + +func (m *ServiceInnovate) SetTagAttribute(value []string) { + _bytes, _ := json.Marshal(value) + m.Tag = string(_bytes) +} + +func NewServiceInnovate() *ServiceInnovate { + return &ServiceInnovate{} +} diff --git a/app/common/model/service_innovate_kind.go b/app/common/model/service_innovate_kind.go new file mode 100644 index 0000000..f575494 --- /dev/null +++ b/app/common/model/service_innovate_kind.go @@ -0,0 +1,18 @@ +package model + +// ServiceInnovateKind 创新服务分类数据模型 +type ServiceInnovateKind struct { + Model + Title string `gorm:"column:title;type:varchar(50);default:'';comment:创新服务分类标题" json:"title"` + Sort int `gorm:"column:sort;type:tinyint(1);default:0;comment:创新服务分类排序" json:"sort"` + ModelDeleted + ModelAt +} + +func (m *ServiceInnovateKind) TableName() string { + return "service_innovate_kind" +} + +func NewServiceInnovateKind() *ServiceInnovateKind { + return &ServiceInnovateKind{} +} diff --git a/config.yaml b/config.yaml index 4bcd755..d018a07 100644 --- a/config.yaml +++ b/config.yaml @@ -37,7 +37,7 @@ engine: host: 192.168.0.188 port: 3306 user: appuser - password: ABCabc01! + password: ABCabc01 db_name: sciences parameters: charset=utf8mb4,utf8&parseTime=True&loc=Local # SQLITE 配置 @@ -50,8 +50,8 @@ cache: type: redis redis: addr: "192.168.0.188:6379" - password: ABCabc01! - db: 6 + password: ABCabc01 + db: 0 max_active: 0 max_idle: 1000 idle_timeout: 240 diff --git a/file/.DS_Store b/file/.DS_Store new file mode 100644 index 0000000..23d1a66 Binary files /dev/null and b/file/.DS_Store differ diff --git a/router/address.go b/router/address.go index 8310ad5..7ce81a6 100644 --- a/router/address.go +++ b/router/address.go @@ -56,7 +56,7 @@ func registerAPI(app *gin.Engine) { serviceV1.POST("/solution_case/list", _api.SolutionCaseList) serviceV1.POST("/solution_case/detail", _api.SolutionCaseDetail) serviceV1.POST("/innovate", _api.Innovate) - serviceV1.POST("/innovate/kind", _api.InnovateKind) + serviceV1.GET("/innovate/kind", _api.InnovateKind) serviceV1.POST("/innovate/detail", _api.InnovateDetail) } }