feat:优化项目信息
This commit is contained in:
@ -26,14 +26,6 @@ cache:
|
|||||||
max_idle: 1000
|
max_idle: 1000
|
||||||
idle_timeout: 240
|
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 日志管理
|
||||||
log:
|
log:
|
||||||
file: log/logs.log
|
file: log/logs.log
|
||||||
|
58
README.md
58
README.md
@ -1,7 +1,57 @@
|
|||||||
# SciencesServer
|
简体中文
|
||||||
|
|
||||||
中科元系统管理
|
<h1 align="center">Sciences Server</h1>
|
||||||
|
<div align="center">
|
||||||
|
中科云管理系统
|
||||||
|
</div>
|
||||||
|
|
||||||
### 迁移数据
|
[comment]: <> (- 预览: https://preview.pro.antdv.com)
|
||||||
|
|
||||||
./SciencesServer init -H 192.168.0.188 -P 3306 -d sciences -u appuser -p ABCabc01
|
环境和依赖
|
||||||
|
----
|
||||||
|
|
||||||
|
- Go>=1.15
|
||||||
|
- [Gin](https://github.com/gin-gonic/gin) - Web Router
|
||||||
|
- [Gorm.v2](https://github.com/go-gorm/gorm) - Data Engine
|
||||||
|
- [Cacbin](https://github.com/casbin/casbin) - Auth(RBAC)
|
||||||
|
- [Redis](https://github.com/redis/redis)
|
||||||
|
|
||||||
|
项目编译和运行
|
||||||
|
----
|
||||||
|
|
||||||
|
- 编译项目
|
||||||
|
```bash
|
||||||
|
go bulid [-x|-o]
|
||||||
|
```
|
||||||
|
|
||||||
|
- 运行项目
|
||||||
|
```bash
|
||||||
|
./项目文件 start -m ['debug'|'release'] -s ['./default_setting.yaml'] -a ['./default_engine.yaml']
|
||||||
|
```
|
||||||
|
> 请注意:
|
||||||
|
>
|
||||||
|
> 复制[.default_setting.yaml](./.default_setting.yaml)文件,去除前面的`.`,参考基本配置信息
|
||||||
|
>
|
||||||
|
> 在运行项目开始,请先执行初始化命令 `init` (./项目文件 init -H 地址 -P 端口 -d 数据库 -u 用户名 -p 密码 )
|
||||||
|
>
|
||||||
|
> 参考案例:./SciencesServer init -H 192.168.0.188 -P 3306 -d sciences -u appuser -p ABCabc01
|
||||||
|
>
|
||||||
|
> 支持mysql,sqlite,建议使用mysql作为数据引擎,详细请参考 [default_engine.yaml](./default_engine.yaml) ,初始化会生成此文件
|
||||||
|
|
||||||
|
- 打包项目
|
||||||
|
```bash
|
||||||
|
pack
|
||||||
|
```
|
||||||
|
> 请注意,需要node.js支持,安装 `pack` (npm install -g @penggy/pack)命令
|
||||||
|
|
||||||
|
- 发布项目
|
||||||
|
```bash
|
||||||
|
linux:一:./server.sh(请注意修改文件提示的地方);二:nohup ./项目 &;三:DockerFile
|
||||||
|
```
|
||||||
|
|
||||||
|
- 其他说明
|
||||||
|
- 项目目录
|
||||||
|
- file 配置文件,不可删除
|
||||||
|
- key 密钥管理,不可删除
|
||||||
|
- cmd 项目执行入口
|
||||||
|
- log 日志管理,自动生成
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
config2 "SciencesServer/config"
|
config2 "SciencesServer/config"
|
||||||
"SciencesServer/utils"
|
"SciencesServer/utils"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -152,7 +151,6 @@ func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) erro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println(utils.AnyToJSON(other))
|
|
||||||
mManageExpert.TenantID = c.TenantID
|
mManageExpert.TenantID = c.TenantID
|
||||||
mManageExpert.ResearchID = other.ConvertResearch()
|
mManageExpert.ResearchID = other.ConvertResearch()
|
||||||
mManageExpert.LaboratoryID = other.ConvertLaboratory()
|
mManageExpert.LaboratoryID = other.ConvertLaboratory()
|
||||||
|
@ -2,10 +2,13 @@ package technology
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"SciencesServer/app/api/admin/model"
|
"SciencesServer/app/api/admin/model"
|
||||||
|
"SciencesServer/app/basic/config"
|
||||||
"SciencesServer/app/basic/controller"
|
"SciencesServer/app/basic/controller"
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/service"
|
||||||
"SciencesServer/app/session"
|
"SciencesServer/app/session"
|
||||||
"errors"
|
"errors"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Achievement struct {
|
type Achievement struct {
|
||||||
@ -87,7 +90,8 @@ func (c *Achievement) Examine(id uint64, status int, remark string) error {
|
|||||||
mTechnologyAchievement := model.NewTechnologyAchievement()
|
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||||
mTechnologyAchievement.ID = id
|
mTechnologyAchievement.ID = id
|
||||||
|
|
||||||
isExist, err := model2.FirstField(mTechnologyAchievement.TechnologyAchievement, []string{"id", "tenant_id", "status"})
|
isExist, err := model2.FirstField(mTechnologyAchievement.TechnologyAchievement, []string{"id", "tenant_id", "title",
|
||||||
|
"industry", "keyword", "status"})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -100,7 +104,28 @@ func (c *Achievement) Examine(id uint64, status int, remark string) error {
|
|||||||
if mTechnologyAchievement.Status != model2.TechnologyStatusKindForExamining {
|
if mTechnologyAchievement.Status != model2.TechnologyStatusKindForExamining {
|
||||||
return errors.New("操作错误,当前成果状态不允许审核")
|
return errors.New("操作错误,当前成果状态不允许审核")
|
||||||
}
|
}
|
||||||
return handleExamine(mTechnologyAchievement.TechnologyAchievement, c.UID, model2.SysUserExamineLogKindForAchievement, status, remark)
|
if err = handleExamine(mTechnologyAchievement.TechnologyAchievement, c.UID, model2.SysUserExamineLogKindForAchievement, status, remark, func() error {
|
||||||
|
if model2.ExamineStatusKind(status) == model2.ExamineStatusForAgree {
|
||||||
|
_industrys := make([]string, 0)
|
||||||
|
|
||||||
|
for _, v := range mTechnologyAchievement.GetIndustryAttribute() {
|
||||||
|
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "-").Value)
|
||||||
|
}
|
||||||
|
// 存放ES中
|
||||||
|
manage := service.NewESAchievement(
|
||||||
|
service.WithAchievementID(mTechnologyAchievement.ID),
|
||||||
|
service.WithAchievementTitle(mTechnologyAchievement.Title),
|
||||||
|
service.WithAchievementIndustry(strings.Join(_industrys, ";")),
|
||||||
|
service.WithAchievementKeyword(strings.Join(mTechnologyAchievement.GetKeywordAttribute(), ";")),
|
||||||
|
)
|
||||||
|
return manage.Create()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shelf 上下架
|
// Shelf 上下架
|
||||||
|
@ -8,7 +8,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func handleExamine(iModel model2.IModel, uid uint64, kind model2.SysUserExamineLogKind, status int, remark string) error {
|
type callback func() error
|
||||||
|
|
||||||
|
func handleExamine(iModel model2.IModel, uid uint64, kind model2.SysUserExamineLogKind, status int, remark string, callback2 callback) error {
|
||||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||||
err := model2.Updates(iModel, map[string]interface{}{
|
err := model2.Updates(iModel, map[string]interface{}{
|
||||||
"status": status, "updated_at": time.Now(),
|
"status": status, "updated_at": time.Now(),
|
||||||
@ -23,6 +25,13 @@ func handleExamine(iModel model2.IModel, uid uint64, kind model2.SysUserExamineL
|
|||||||
mSysUserExamineLog.ObjectID = iModel.GetID()
|
mSysUserExamineLog.ObjectID = iModel.GetID()
|
||||||
mSysUserExamineLog.Status = status
|
mSysUserExamineLog.Status = status
|
||||||
mSysUserExamineLog.Remark = remark
|
mSysUserExamineLog.Remark = remark
|
||||||
return model2.Create(mSysUserExamineLog.SysUserExamineLog, tx)
|
|
||||||
|
if err = model2.Create(mSysUserExamineLog.SysUserExamineLog, tx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if callback2 != nil {
|
||||||
|
return callback2()
|
||||||
|
}
|
||||||
|
return err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ func (c *Demand) Examine(id uint64, status int, remark string) error {
|
|||||||
if mTechnologyDemand.Status != model2.TechnologyStatusKindForExamining {
|
if mTechnologyDemand.Status != model2.TechnologyStatusKindForExamining {
|
||||||
return errors.New("操作错误,当前需求状态不允许审核")
|
return errors.New("操作错误,当前需求状态不允许审核")
|
||||||
}
|
}
|
||||||
return handleExamine(mTechnologyDemand.TechnologyDemand, c.UID, model2.SysUserExamineLogKindForDemandTechnology, status, remark)
|
return handleExamine(mTechnologyDemand.TechnologyDemand, c.UID, model2.SysUserExamineLogKindForDemandTechnology, status, remark, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete 删除操作
|
// Delete 删除操作
|
||||||
|
@ -100,7 +100,7 @@ func (c *Product) Examine(id uint64, status int, remark string) error {
|
|||||||
if mTechnologyProduct.Status != model2.TechnologyStatusKindForExamining {
|
if mTechnologyProduct.Status != model2.TechnologyStatusKindForExamining {
|
||||||
return errors.New("操作错误,当前产品状态不允许审核")
|
return errors.New("操作错误,当前产品状态不允许审核")
|
||||||
}
|
}
|
||||||
return handleExamine(mTechnologyProduct.TechnologyProduct, c.UID, model2.SysUserExamineLogKindForProduct, status, remark)
|
return handleExamine(mTechnologyProduct.TechnologyProduct, c.UID, model2.SysUserExamineLogKindForProduct, status, remark, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shelf 上下架操作
|
// Shelf 上下架操作
|
||||||
|
@ -53,7 +53,7 @@ func (m *TechnologyAchievement) Achievements(page, pageSize int, count *int64, w
|
|||||||
// Achievement 成果信息
|
// Achievement 成果信息
|
||||||
func (m *TechnologyAchievement) Achievement(where ...*model.ModelWhere) ([]*TechnologyAchievementInfo, error) {
|
func (m *TechnologyAchievement) Achievement(where ...*model.ModelWhere) ([]*TechnologyAchievementInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||||
Select("a.id", "a.title", "a.mode", "a.image", "a.charge_info", "a.industry", "a.customer", "a.maturity",
|
Select("a.id", "a.title", "a.mode", "a.image", "a.config", "a.industry", "a.customer", "a.maturity",
|
||||||
"a.cooperation_mode", "a.keyword", "v.count AS visit_count", "c.count AS collect_count").
|
"a.cooperation_mode", "a.keyword", "v.count AS visit_count", "c.count AS collect_count").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON a.id = v.object_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON a.id = v.object_id",
|
||||||
model.NewUserVisit().TableName(), model.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
|
model.NewUserVisit().TableName(), model.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
|
||||||
|
@ -20,9 +20,6 @@ func (this *ESAchievement) Index() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *ESAchievement) Create() error {
|
func (this *ESAchievement) Create() error {
|
||||||
if this.Industry != "" {
|
|
||||||
this.Title = this.Industry + " - " + this.Title
|
|
||||||
}
|
|
||||||
_bytes, _ := json.Marshal(this)
|
_bytes, _ := json.Marshal(this)
|
||||||
return es.Create(this.Index(), fmt.Sprintf("%d", this.ID), _bytes)
|
return es.Create(this.Index(), fmt.Sprintf("%d", this.ID), _bytes)
|
||||||
}
|
}
|
||||||
|
14
app/service/es_test.go
Normal file
14
app/service/es_test.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestESAchievement_Create(t *testing.T) {
|
||||||
|
manage := NewESAchievement(
|
||||||
|
WithAchievementID(1),
|
||||||
|
WithAchievementTitle("测试一"),
|
||||||
|
WithAchievementIndustry("测试测试"),
|
||||||
|
WithAchievementKeyword("关键词1;关键词2"),
|
||||||
|
)
|
||||||
|
err := manage.Create()
|
||||||
|
t.Log(err)
|
||||||
|
}
|
@ -17,7 +17,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -43,7 +42,6 @@ func run() {
|
|||||||
// 载入配置信息
|
// 载入配置信息
|
||||||
utils.LoadConfig(configFile, config.SettingInfo, func(i interface{}) {
|
utils.LoadConfig(configFile, config.SettingInfo, func(i interface{}) {
|
||||||
obj := i.(*config.Setting)
|
obj := i.(*config.Setting)
|
||||||
obj.Upload.Exts = strings.Split(obj.Upload.Ext, ",")
|
|
||||||
logger.NewLogger().Init(&logger.Option{File: obj.Log.File, LeastDay: obj.Log.LeastDay, Level: obj.Log.Level, IsStdout: false}).Load()
|
logger.NewLogger().Init(&logger.Option{File: obj.Log.File, LeastDay: obj.Log.LeastDay, Level: obj.Log.Level, IsStdout: false}).Load()
|
||||||
})
|
})
|
||||||
// 载入数据引擎配置
|
// 载入数据引擎配置
|
||||||
|
@ -69,15 +69,6 @@ type Setting struct {
|
|||||||
Redis *Redis `yaml:"redis"`
|
Redis *Redis `yaml:"redis"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload 配置
|
|
||||||
Upload struct {
|
|
||||||
Path string `yaml:"path"`
|
|
||||||
Ext string `yaml:"ext"`
|
|
||||||
Exts []string `yaml:"-"`
|
|
||||||
Size int64 `yaml:"size"`
|
|
||||||
Rename bool `yaml:"rename"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Log 配置
|
// Log 配置
|
||||||
Log struct {
|
Log struct {
|
||||||
File string `yaml:"file"`
|
File string `yaml:"file"`
|
||||||
|
@ -33,13 +33,27 @@ func _new() *elastic.Client {
|
|||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ESAchievement struct {
|
||||||
|
ID uint64 `json:"id"` // 成果ID
|
||||||
|
Title string `json:"title"` // 成果名称
|
||||||
|
Industry string `json:"industry"` // 行业领域
|
||||||
|
Keyword string `json:"keyword"` // 关键词
|
||||||
|
}
|
||||||
|
|
||||||
func TestNewInstanceCreate(t *testing.T) {
|
func TestNewInstanceCreate(t *testing.T) {
|
||||||
client := _new()
|
client := _new()
|
||||||
//client.Delete()
|
//client.Delete()
|
||||||
|
|
||||||
src := Student{ID: 2, Name: "henry", Age: 28}
|
//src := Student{ID: 2, Name: "henry", Age: 28}
|
||||||
client.Index().Index("student").Id(fmt.Sprintf("%d", src.ID)).BodyJson(utils.AnyToJSON(src)).
|
src := &ESAchievement{
|
||||||
|
ID: 6,
|
||||||
|
Title: "测试6",
|
||||||
|
Industry: "测试测试",
|
||||||
|
Keyword: "关键词1;关键词2",
|
||||||
|
}
|
||||||
|
_, err := client.Index().Index("es_achievement_index").Id(fmt.Sprintf("%d", src.ID)).BodyJson(utils.AnyToJSON(src)).
|
||||||
Do(context.Background())
|
Do(context.Background())
|
||||||
|
t.Log(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewInstanceUpdate(t *testing.T) {
|
func TestNewInstanceUpdate(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user