...
|
...
|
@@ -3,8 +3,10 @@ package user |
|
|
import (
|
|
|
"context"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
...
|
...
|
@@ -32,6 +34,7 @@ func (l *MiniUserApplyJoinCompanyLogic) MiniUserApplyJoinCompany(req *types.Mini |
|
|
conn = l.svcCtx.DefaultDBConn()
|
|
|
company *domain.Company
|
|
|
user *domain.User
|
|
|
name = fmt.Sprintf("用户%s", tool.Krand(6, tool.KC_RAND_KIND_NUM))
|
|
|
)
|
|
|
if company, err = l.svcCtx.CompanyRepository.FindOneByCode(l.ctx, conn, req.Code); err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("公司不存在", err)
|
...
|
...
|
@@ -52,14 +55,25 @@ func (l *MiniUserApplyJoinCompanyLogic) MiniUserApplyJoinCompany(req *types.Mini |
|
|
return nil, xerr.NewErrMsgErr("公司已申请", err)
|
|
|
}
|
|
|
}
|
|
|
queryOptions := domain.NewQueryOptions().
|
|
|
WithOffsetLimit(1, 1).
|
|
|
MustWithKV("phone", req.Phone).
|
|
|
MustWithKV("auditStatus", []int{domain.UserAuditStatusWait, domain.UserAuditStatusPassed})
|
|
|
if _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); len(users) >= 1 {
|
|
|
name = users[0].Name
|
|
|
}
|
|
|
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
|
|
|
user = &domain.User{
|
|
|
CompanyId: company.Id,
|
|
|
Phone: req.Phone,
|
|
|
Enable: domain.UserEnable,
|
|
|
Roles: make([]int64, 0),
|
|
|
Follower: make([]int64, 0),
|
|
|
Following: make([]int64, 0),
|
|
|
CompanyId: company.Id,
|
|
|
Phone: req.Phone,
|
|
|
Name: name,
|
|
|
Flag: domain.UserCommon,
|
|
|
Enable: domain.UserEnable,
|
|
|
Roles: make([]int64, 0),
|
|
|
Follower: make([]int64, 0),
|
|
|
Following: make([]int64, 0),
|
|
|
AccountFrom: domain.AccountFromQr,
|
|
|
Departments: make([]int64, 0),
|
|
|
}
|
|
|
if user, err = l.svcCtx.UserRepository.Insert(ctx, conn, user); err != nil {
|
|
|
return err
|
...
|
...
|
|