...
|
...
|
@@ -3,6 +3,7 @@ package user |
|
|
import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
|
|
|
"strconv"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
...
|
...
|
@@ -109,70 +110,108 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { |
|
|
// 初始设置文章标签
|
|
|
queryOption := domain.NewQueryOptions().WithCountOnly()
|
|
|
conn := l.svcCtx.DefaultDBConn()
|
|
|
cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, companyId, queryOption)
|
|
|
if err != nil {
|
|
|
return xerr.NewErrMsgErr("初始话公司数据失败", err)
|
|
|
categoryList := []*domain.ArticleCategory{
|
|
|
{
|
|
|
Name: "机会风险",
|
|
|
SortBy: 1,
|
|
|
Enable: 1,
|
|
|
Other: "",
|
|
|
CompanyId: companyId,
|
|
|
},
|
|
|
{
|
|
|
Name: "紧急重要",
|
|
|
SortBy: 2,
|
|
|
Enable: 1,
|
|
|
Other: "",
|
|
|
CompanyId: companyId,
|
|
|
},
|
|
|
}
|
|
|
|
|
|
articleTags := []*domain.ArticleTag{
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_01.png", Width: 0, Height: 0},
|
|
|
Name: "紧急重要", Category: "紧急重要", Remark: "优先解决", SortBy: 1,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_04.png", Width: 0, Height: 0},
|
|
|
Name: "不紧急不重要", Category: "紧急重要", Remark: "给别人做", SortBy: 2,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_03.png", Width: 0, Height: 0},
|
|
|
Name: "紧急不重要", Category: "紧急重要", Remark: "有空再做", SortBy: 3,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_02.png", Width: 0, Height: 0},
|
|
|
Name: "不紧急重要", Category: "紧急重要", Remark: "制定计划去做", SortBy: 4,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_03.png", Width: 0, Height: 0},
|
|
|
Name: "大机会高风险", Category: "机会风险", Remark: "谨慎考虑专项讨论", SortBy: 5,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_02.png", Width: 0, Height: 0},
|
|
|
Name: "大机会中风险", Category: "机会风险", Remark: "加大关注值得尝试", SortBy: 6,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_01.png", Width: 0, Height: 0},
|
|
|
Name: "大机会低风险", Category: "机会风险", Remark: "全员投入抓紧落实", SortBy: 7,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_04.png", Width: 0, Height: 0},
|
|
|
Name: "中机会高风险", Category: "机会风险", Remark: "专人跟踪成立项目", SortBy: 8,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_05.png", Width: 0, Height: 0},
|
|
|
Name: "中机会中风险", Category: "机会风险", Remark: "讨论落实", SortBy: 9,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_06.png", Width: 0, Height: 0},
|
|
|
Name: "中机会低风险", Category: "机会风险", Remark: "解决问题多手准备", SortBy: 10,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_07.png", Width: 0, Height: 0},
|
|
|
Name: "小机会高风险", Category: "机会风险", Remark: "有空看看", SortBy: 11,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_08.png", Width: 0, Height: 0},
|
|
|
Name: "小机会中风险", Category: "机会风险", Remark: "持续监控做好控制", SortBy: 12,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_09.png", Width: 0, Height: 0},
|
|
|
Name: "小机会低风险", Category: "机会风险", Remark: "全员警戒马上解决", SortBy: 13,
|
|
|
},
|
|
|
}
|
|
|
|
|
|
cnt, _, err := l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, companyId, queryOption)
|
|
|
if cnt == 0 {
|
|
|
articleTags := []*domain.ArticleTag{
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_01.png", Width: 0, Height: 0},
|
|
|
Name: "紧急重要", Category: "紧急重要", Remark: "优先解决", SortBy: 1,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_04.png", Width: 0, Height: 0},
|
|
|
Name: "不紧急不重要", Category: "紧急重要", Remark: "给别人做", SortBy: 2,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_03.png", Width: 0, Height: 0},
|
|
|
Name: "紧急不重要", Category: "紧急重要", Remark: "有空再做", SortBy: 3,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_02.png", Width: 0, Height: 0},
|
|
|
Name: "不紧急重要", Category: "紧急重要", Remark: "制定计划去做", SortBy: 4,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_03.png", Width: 0, Height: 0},
|
|
|
Name: "大机会高风险", Category: "机会风险", Remark: "谨慎考虑专项讨论", SortBy: 5,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_02.png", Width: 0, Height: 0},
|
|
|
Name: "大机会中风险", Category: "机会风险", Remark: "加大关注值得尝试", SortBy: 6,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_01.png", Width: 0, Height: 0},
|
|
|
Name: "大机会低风险", Category: "机会风险", Remark: "全员投入抓紧落实", SortBy: 7,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_04.png", Width: 0, Height: 0},
|
|
|
Name: "中机会高风险", Category: "机会风险", Remark: "专人跟踪成立项目", SortBy: 8,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_05.png", Width: 0, Height: 0},
|
|
|
Name: "中机会中风险", Category: "机会风险", Remark: "讨论落实", SortBy: 9,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_06.png", Width: 0, Height: 0},
|
|
|
Name: "中机会低风险", Category: "机会风险", Remark: "解决问题多手准备", SortBy: 10,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_07.png", Width: 0, Height: 0},
|
|
|
Name: "小机会高风险", Category: "机会风险", Remark: "有空看看", SortBy: 11,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_08.png", Width: 0, Height: 0},
|
|
|
Name: "小机会中风险", Category: "机会风险", Remark: "持续监控做好控制", SortBy: 12,
|
|
|
},
|
|
|
{
|
|
|
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_09.png", Width: 0, Height: 0},
|
|
|
Name: "小机会低风险", Category: "机会风险", Remark: "全员警戒马上解决", SortBy: 13,
|
|
|
},
|
|
|
}
|
|
|
err = l.svcCtx.ArticleTagRepository.CreateInBatches(l.ctx, conn, articleTags)
|
|
|
if err != nil {
|
|
|
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
|
|
|
for _, category := range categoryList {
|
|
|
category, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, category)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
cnt, _, err = l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, companyId, queryOption)
|
|
|
if err != nil {
|
|
|
return xerr.NewErrMsgErr("初始话公司数据失败", err)
|
|
|
}
|
|
|
for _, tag := range articleTags {
|
|
|
for _, category := range categoryList {
|
|
|
if category.Name == tag.Category {
|
|
|
tag.CategoryId = category.Id
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if cnt == 0 {
|
|
|
err = l.svcCtx.ArticleTagRepository.CreateInBatches(l.ctx, conn, articleTags)
|
|
|
if err != nil {
|
|
|
return xerr.NewErrMsgErr("初始话公司数据失败", err)
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
|
}, true); err != nil {
|
|
|
return xerr.NewErrMsgErr("初始话公司数据失败", err)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
} |
...
|
...
|
|