正在显示
10 个修改的文件
包含
164 行增加
和
3 行删除
@@ -42,6 +42,10 @@ service Core { | @@ -42,6 +42,10 @@ service Core { | ||
42 | @doc "公司搜索" | 42 | @doc "公司搜索" |
43 | @handler systemCompanySearch | 43 | @handler systemCompanySearch |
44 | post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse) | 44 | post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse) |
45 | + | ||
46 | + @doc "公司职位搜索" | ||
47 | + @handler systemCompanyPositionsSearch | ||
48 | + post /system/company/positions/search(CompanyPositionsSearchRequest) returns (CompanyPositionsSearchResponse) | ||
45 | } | 49 | } |
46 | 50 | ||
47 | type ( | 51 | type ( |
@@ -63,3 +67,17 @@ type ( | @@ -63,3 +67,17 @@ type ( | ||
63 | Logo string `json:"logo,omitempty"` // 公司LOGO | 67 | Logo string `json:"logo,omitempty"` // 公司LOGO |
64 | } | 68 | } |
65 | ) | 69 | ) |
70 | + | ||
71 | +// 公司职位搜索 | ||
72 | +type( | ||
73 | + CompanyPositionsSearchRequest{ | ||
74 | + | ||
75 | + } | ||
76 | + CompanyPositionsSearchResponse { | ||
77 | + List []Position `json:"list"` | ||
78 | + Total int64 `json:"total"` | ||
79 | + } | ||
80 | + Position{ | ||
81 | + Name string `json:"name"` | ||
82 | + } | ||
83 | +) |
@@ -105,6 +105,7 @@ type( | @@ -105,6 +105,7 @@ type( | ||
105 | MiniUserApplyJoinCompanyRequest{ | 105 | MiniUserApplyJoinCompanyRequest{ |
106 | Phone string `json:"phone"` | 106 | Phone string `json:"phone"` |
107 | Code string `json:"code"` | 107 | Code string `json:"code"` |
108 | + IsFromQr bool `json:"isFromQr,optional"` // true:扫码添加 false:手动查找添加 | ||
108 | } | 109 | } |
109 | MiniUserApplyJoinCompanyResponse{ | 110 | MiniUserApplyJoinCompanyResponse{ |
110 | 111 |
1 | +package company | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/company" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
10 | +) | ||
11 | + | ||
12 | +func SystemCompanyPositionsSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
14 | + var req types.CompanyPositionsSearchRequest | ||
15 | + if err := httpx.Parse(r, &req); err != nil { | ||
16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
17 | + return | ||
18 | + } | ||
19 | + | ||
20 | + l := company.NewSystemCompanyPositionsSearchLogic(r.Context(), svcCtx) | ||
21 | + resp, err := l.SystemCompanyPositionsSearch(&req) | ||
22 | + if err != nil { | ||
23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
24 | + } else { | ||
25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
26 | + } | ||
27 | + } | ||
28 | +} |
@@ -347,6 +347,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -347,6 +347,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
347 | Path: "/system/company/search", | 347 | Path: "/system/company/search", |
348 | Handler: company.SystemCompanySearchHandler(serverCtx), | 348 | Handler: company.SystemCompanySearchHandler(serverCtx), |
349 | }, | 349 | }, |
350 | + { | ||
351 | + Method: http.MethodPost, | ||
352 | + Path: "/system/company/positions/search", | ||
353 | + Handler: company.SystemCompanyPositionsSearchHandler(serverCtx), | ||
354 | + }, | ||
350 | }..., | 355 | }..., |
351 | ), | 356 | ), |
352 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 357 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
1 | +package company | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
8 | + | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | + | ||
12 | + "github.com/zeromicro/go-zero/core/logx" | ||
13 | +) | ||
14 | + | ||
15 | +type SystemCompanyPositionsSearchLogic struct { | ||
16 | + logx.Logger | ||
17 | + ctx context.Context | ||
18 | + svcCtx *svc.ServiceContext | ||
19 | +} | ||
20 | + | ||
21 | +func NewSystemCompanyPositionsSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemCompanyPositionsSearchLogic { | ||
22 | + return &SystemCompanyPositionsSearchLogic{ | ||
23 | + Logger: logx.WithContext(ctx), | ||
24 | + ctx: ctx, | ||
25 | + svcCtx: svcCtx, | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | +func (l *SystemCompanyPositionsSearchLogic) SystemCompanyPositionsSearch(req *types.CompanyPositionsSearchRequest) (resp *types.CompanyPositionsSearchResponse, err error) { | ||
30 | + var ( | ||
31 | + conn = l.svcCtx.DefaultDBConn() | ||
32 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
33 | + users []*domain.User | ||
34 | + total int64 | ||
35 | + ) | ||
36 | + resp = &types.CompanyPositionsSearchResponse{ | ||
37 | + List: make([]types.Position, 0), | ||
38 | + } | ||
39 | + total, users, err = l.svcCtx.UserRepository.FindCompanyPositions(l.ctx, conn, userToken.CompanyId, domain.NewQueryOptions().WithFindOnly()) | ||
40 | + if err != nil { | ||
41 | + return nil, xerr.NewErrMsgErr("查找公司部门失败", err) | ||
42 | + } | ||
43 | + | ||
44 | + for _, user := range users { | ||
45 | + resp.List = append(resp.List, types.Position{ | ||
46 | + Name: user.Position, | ||
47 | + }) | ||
48 | + } | ||
49 | + resp.Total = total | ||
50 | + return | ||
51 | +} |
@@ -72,9 +72,13 @@ func (l *MiniUserApplyJoinCompanyLogic) MiniUserApplyJoinCompany(req *types.Mini | @@ -72,9 +72,13 @@ func (l *MiniUserApplyJoinCompanyLogic) MiniUserApplyJoinCompany(req *types.Mini | ||
72 | Roles: make([]int64, 0), | 72 | Roles: make([]int64, 0), |
73 | Follower: make([]int64, 0), | 73 | Follower: make([]int64, 0), |
74 | Following: make([]int64, 0), | 74 | Following: make([]int64, 0), |
75 | - AccountFrom: domain.AccountFromQr, | 75 | + AccountFrom: domain.AccountFromSearchJoin, |
76 | Departments: make([]int64, 0), | 76 | Departments: make([]int64, 0), |
77 | } | 77 | } |
78 | + if req.IsFromQr { | ||
79 | + user.AuditStatus = domain.UserAuditStatusPassed | ||
80 | + user.AccountFrom = domain.AccountFromQr | ||
81 | + } | ||
78 | user.WithName(name) | 82 | user.WithName(name) |
79 | if user, err = l.svcCtx.UserRepository.Insert(ctx, conn, user); err != nil { | 83 | if user, err = l.svcCtx.UserRepository.Insert(ctx, conn, user); err != nil { |
80 | return err | 84 | return err |
@@ -36,14 +36,15 @@ func (l *MiniUserAuditListLogic) MiniUserAuditList(req *types.UserSearchRequest) | @@ -36,14 +36,15 @@ func (l *MiniUserAuditListLogic) MiniUserAuditList(req *types.UserSearchRequest) | ||
36 | ) | 36 | ) |
37 | queryOptions := domain.NewQueryOptions(). | 37 | queryOptions := domain.NewQueryOptions(). |
38 | WithOffsetLimit(req.Page, req.Size). | 38 | WithOffsetLimit(req.Page, req.Size). |
39 | - MustWithKV("companyId", userToken.CompanyId) | 39 | + MustWithKV("companyId", userToken.CompanyId). |
40 | + MustWithKV("accountFrom", []string{domain.AccountFromSearchJoin}) | ||
40 | if req.AuditFlag != nil && *req.AuditFlag >= 0 { | 41 | if req.AuditFlag != nil && *req.AuditFlag >= 0 { |
41 | queryOptions.MustWithKV("auditStatus", []int{*req.AuditFlag}) | 42 | queryOptions.MustWithKV("auditStatus", []int{*req.AuditFlag}) |
42 | } | 43 | } |
43 | if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil { | 44 | if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil { |
44 | return nil, xerr.NewErrMsgErr("查询审核列表失败", err) | 45 | return nil, xerr.NewErrMsgErr("查询审核列表失败", err) |
45 | } | 46 | } |
46 | - resp = &types.UserSearchResponse{Total: total} | 47 | + resp = &types.UserSearchResponse{Total: total, List: make([]*types.UserItem, 0)} |
47 | lo.ForEach(users, func(item *domain.User, index int) { | 48 | lo.ForEach(users, func(item *domain.User, index int) { |
48 | company, _ := domain.LazyLoad(companyMap, l.ctx, conn, item.CompanyId, l.svcCtx.CompanyRepository.FindOne) | 49 | company, _ := domain.LazyLoad(companyMap, l.ctx, conn, item.CompanyId, l.svcCtx.CompanyRepository.FindOne) |
49 | resp.List = append(resp.List, NewUserItemSimple(item, company)) | 50 | resp.List = append(resp.List, NewUserItemSimple(item, company)) |
@@ -434,6 +434,7 @@ type MiniUserInfoResponse struct { | @@ -434,6 +434,7 @@ type MiniUserInfoResponse struct { | ||
434 | type MiniUserApplyJoinCompanyRequest struct { | 434 | type MiniUserApplyJoinCompanyRequest struct { |
435 | Phone string `json:"phone"` | 435 | Phone string `json:"phone"` |
436 | Code string `json:"code"` | 436 | Code string `json:"code"` |
437 | + IsFromQr bool `json:"isFromQr,optional"` // true:扫码添加 false:手动查找添加 | ||
437 | } | 438 | } |
438 | 439 | ||
439 | type MiniUserApplyJoinCompanyResponse struct { | 440 | type MiniUserApplyJoinCompanyResponse struct { |
@@ -726,6 +727,18 @@ type Company struct { | @@ -726,6 +727,18 @@ type Company struct { | ||
726 | Logo string `json:"logo,omitempty"` // 公司LOGO | 727 | Logo string `json:"logo,omitempty"` // 公司LOGO |
727 | } | 728 | } |
728 | 729 | ||
730 | +type CompanyPositionsSearchRequest struct { | ||
731 | +} | ||
732 | + | ||
733 | +type CompanyPositionsSearchResponse struct { | ||
734 | + List []Position `json:"list"` | ||
735 | + Total int64 `json:"total"` | ||
736 | +} | ||
737 | + | ||
738 | +type Position struct { | ||
739 | + Name string `json:"name"` | ||
740 | +} | ||
741 | + | ||
729 | type Location struct { | 742 | type Location struct { |
730 | Longitude float64 `json:"longitude,optional"` //经度 | 743 | Longitude float64 `json:"longitude,optional"` //经度 |
731 | Latitude float64 `json:"latitude,optional"` //纬度 | 744 | Latitude float64 `json:"latitude,optional"` //纬度 |
@@ -155,6 +155,9 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con | @@ -155,6 +155,9 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con | ||
155 | if v, ok := queryOptions["auditStatus"]; ok { | 155 | if v, ok := queryOptions["auditStatus"]; ok { |
156 | tx.Where("audit_status in (?)", v) | 156 | tx.Where("audit_status in (?)", v) |
157 | } | 157 | } |
158 | + if v, ok := queryOptions["accountFrom"]; ok { | ||
159 | + tx.Where("account_from in (?)", v) | ||
160 | + } | ||
158 | 161 | ||
159 | // 列表查询条件 | 162 | // 列表查询条件 |
160 | if v, ok := queryOptions["likeName"]; ok { | 163 | if v, ok := queryOptions["likeName"]; ok { |
@@ -236,6 +239,41 @@ func (repository *UserRepository) FindDepartmentUsers(ctx context.Context, conn | @@ -236,6 +239,41 @@ func (repository *UserRepository) FindDepartmentUsers(ctx context.Context, conn | ||
236 | return total, dms, nil | 239 | return total, dms, nil |
237 | } | 240 | } |
238 | 241 | ||
242 | +func (repository *UserRepository) FindCompanyPositions(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*domain.User, error) { | ||
243 | + var ( | ||
244 | + tx = conn.DB() | ||
245 | + ms []*models.User | ||
246 | + dms = make([]*domain.User, 0) | ||
247 | + total int64 | ||
248 | + ) | ||
249 | + queryFunc := func() (interface{}, error) { | ||
250 | + tx = tx.Model(&ms) | ||
251 | + tx.Select("distinct position") | ||
252 | + tx.Where("company_id = ?", companyId) | ||
253 | + tx.Where("position <> ''") | ||
254 | + tx.Where("audit_status in (?)", domain.UserAuditStatusPassed) | ||
255 | + tx.Where("enable = ?", domain.UserEnable) | ||
256 | + tx.Order("position asc") | ||
257 | + if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | ||
258 | + return dms, tx.Error | ||
259 | + } | ||
260 | + return dms, nil | ||
261 | + } | ||
262 | + | ||
263 | + if _, err := repository.Query(queryFunc); err != nil { | ||
264 | + return 0, nil, err | ||
265 | + } | ||
266 | + | ||
267 | + for _, item := range ms { | ||
268 | + if dm, err := repository.ModelToDomainModel(item); err != nil { | ||
269 | + return 0, dms, err | ||
270 | + } else { | ||
271 | + dms = append(dms, dm) | ||
272 | + } | ||
273 | + } | ||
274 | + return total, dms, nil | ||
275 | +} | ||
276 | + | ||
239 | func (repository *UserRepository) ModelToDomainModel(from *models.User) (*domain.User, error) { | 277 | func (repository *UserRepository) ModelToDomainModel(from *models.User) (*domain.User, error) { |
240 | to := &domain.User{} | 278 | to := &domain.User{} |
241 | err := copier.Copy(to, from) | 279 | err := copier.Copy(to, from) |
@@ -40,6 +40,7 @@ type UserRepository interface { | @@ -40,6 +40,7 @@ type UserRepository interface { | ||
40 | FindOneByCompanyIdAndPhone(ctx context.Context, conn transaction.Conn, companyId int64, phone string, status []int) (*User, error) | 40 | FindOneByCompanyIdAndPhone(ctx context.Context, conn transaction.Conn, companyId int64, phone string, status []int) (*User, error) |
41 | Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*User, error) | 41 | Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*User, error) |
42 | FindDepartmentUsers(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*User, error) | 42 | FindDepartmentUsers(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*User, error) |
43 | + FindCompanyPositions(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*User, error) | ||
43 | } | 44 | } |
44 | 45 | ||
45 | func (m *User) Identify() interface{} { | 46 | func (m *User) Identify() interface{} { |
@@ -68,6 +69,7 @@ const ( | @@ -68,6 +69,7 @@ const ( | ||
68 | ) | 69 | ) |
69 | 70 | ||
70 | const ( | 71 | const ( |
72 | + AccountFromSearchJoin = "搜索添加" | ||
71 | AccountFromQr = "扫码注册" | 73 | AccountFromQr = "扫码注册" |
72 | AccountFromMr = "后台新增" | 74 | AccountFromMr = "后台新增" |
73 | ) | 75 | ) |
-
请 注册 或 登录 后发表评论