- 新增联系人保存与删除逻辑处理 - 新增工厂信息保存逻辑,支持银行、财务等详细信息 - 部门与员工模块接口参数调整,统一使用实体对象返回 - 优化部门与员工的增删改查操作,去除冗余代码 - 统一使用 constant 包管理业务类型常量 - 增加性别转换与整型数组转字符串工具函数 - RPC 注册新增工厂与联系人服务路由 - 调整客户端调用参数结构,增强代码可读性与维护性
This commit is contained in:
@@ -6,14 +6,12 @@ import (
|
||||
"ik3cloud/app/common"
|
||||
"ik3cloud/app/config"
|
||||
"ik3cloud/app/lib/ik3cloud"
|
||||
"ik3cloud/app/lib/logger"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
ik3cloud2 "git.kumo.work/shama/service/ik3cloud"
|
||||
"git.kumo.work/shama/service/ik3cloud/constant"
|
||||
"git.kumo.work/shama/service/lib/bean"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var StaffLogic = &staffLogic{}
|
||||
@@ -85,7 +83,7 @@ func (s *staffLogic) List(page bean.Page, search ik3cloud2.StaffSearch) (list []
|
||||
}
|
||||
}
|
||||
raw, err := ik3cloud.Client.BillQuery(map[string]interface{}{
|
||||
"FormId": "BD_Empinfo",
|
||||
"FormId": constant.ActionStaff,
|
||||
"FieldKeys": "FName,FStaffNumber,FBaseProperty,FMobile,FTel,FForbidStatus",
|
||||
"FilterString": where,
|
||||
"StartRow": page.GetStart(),
|
||||
@@ -118,50 +116,24 @@ func (s *staffLogic) List(page bean.Page, search ik3cloud2.StaffSearch) (list []
|
||||
}
|
||||
|
||||
// Add @TITLE 添加员工
|
||||
func (s *staffLogic) Add(data ik3cloud2.ArgsStaffAdd) (staffId int64, err error) {
|
||||
raw, err := ik3cloud.Client.Save("BD_Empinfo", map[string]any{
|
||||
"Model": map[string]any{
|
||||
"FCreateOrgId": map[string]any{
|
||||
"FNumber": config.Config.Ik3cloud.OrganizationNumber,
|
||||
},
|
||||
"FName": data.Name,
|
||||
"FStaffNumber": data.Number,
|
||||
"FUseOrgId": map[string]any{
|
||||
"FNumber": config.Config.Ik3cloud.OrganizationNumber,
|
||||
},
|
||||
"FMobile": data.Mobile,
|
||||
"FTel": data.Tel,
|
||||
"FEmail": data.Email,
|
||||
"FCreateSaler": false,
|
||||
"FCreateUser": false,
|
||||
"FCreateCashier": false,
|
||||
"FJoinDate": time.Now().Format("2006-01-02 15:04:05"),
|
||||
func (s *staffLogic) Add(data ik3cloud2.ArgsStaffAdd) (entity ik3cloud2.Entity, err error) {
|
||||
return ik3cloud.Client.Save(constant.ActionStaff, nil, map[string]any{
|
||||
"FCreateOrgId": map[string]any{
|
||||
"FNumber": config.Config.Ik3cloud.OrganizationNumber,
|
||||
},
|
||||
"FName": data.Name,
|
||||
"FStaffNumber": data.Number,
|
||||
"FUseOrgId": map[string]any{
|
||||
"FNumber": config.Config.Ik3cloud.OrganizationNumber,
|
||||
},
|
||||
"FMobile": data.Mobile,
|
||||
"FTel": data.Tel,
|
||||
"FEmail": data.Email,
|
||||
"FCreateSaler": false,
|
||||
"FCreateUser": false,
|
||||
"FCreateCashier": false,
|
||||
"FJoinDate": time.Now().Format("2006-01-02 15:04:05"),
|
||||
})
|
||||
if err != nil {
|
||||
err = errors.New("添加员工失败")
|
||||
return
|
||||
}
|
||||
result, err := ik3cloud.Client.GetResult(raw)
|
||||
if err != nil {
|
||||
err = errors.New("添加员工失败")
|
||||
return
|
||||
}
|
||||
if !result.Result.ResponseStatus.IsSuccess {
|
||||
for _, item := range result.Result.ResponseStatus.Errors {
|
||||
return staffId, errors.New(item.Message)
|
||||
}
|
||||
}
|
||||
staffId = result.Result.Id
|
||||
if err1 := s.submit([]string{data.Number}); err1 != nil {
|
||||
logger.Logger.Error("员工提交失败", zap.Error(err1))
|
||||
return
|
||||
}
|
||||
if err1 := s.audit([]string{data.Number}); err1 != nil {
|
||||
logger.Logger.Error("员工审核失败", zap.Error(err1))
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Edit @TITLE 员工编辑
|
||||
@@ -169,151 +141,30 @@ func (s *staffLogic) Edit(staffId int64, data ik3cloud2.ArgsStaffAdd) error {
|
||||
if staffId == 0 {
|
||||
return errors.New("员工错误")
|
||||
}
|
||||
raw, err := ik3cloud.Client.Save("BD_Empinfo", map[string]any{
|
||||
"NeedUpDateFields": []string{"FStaffNumber", "FName", "FMobile", "FTel", "FEmail"},
|
||||
"Model": map[string]any{
|
||||
"FID": staffId,
|
||||
"FStaffNumber": data.Number,
|
||||
"FName": data.Name,
|
||||
"FMobile": data.Mobile,
|
||||
"FTel": data.Tel,
|
||||
"FEmail": data.Email,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return errors.New("编辑员工失败")
|
||||
}
|
||||
result, _ := ik3cloud.Client.GetResult(raw)
|
||||
if !result.Result.ResponseStatus.IsSuccess {
|
||||
for _, item := range result.Result.ResponseStatus.Errors {
|
||||
return errors.New(item.Message)
|
||||
}
|
||||
if _, err := ik3cloud.Client.Save(constant.ActionStaff, []string{"FStaffNumber", "FName", "FMobile", "FTel", "FEmail"}, map[string]any{
|
||||
"FID": staffId,
|
||||
"FStaffNumber": data.Number,
|
||||
"FName": data.Name,
|
||||
"FMobile": data.Mobile,
|
||||
"FTel": data.Tel,
|
||||
"FEmail": data.Email,
|
||||
}); err != nil {
|
||||
return errors.New("编辑员工失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Disable @TITLE 禁用账户
|
||||
func (s *staffLogic) Disable(numbers []string) error {
|
||||
raw, err := ik3cloud.Client.ExecuteOperation("BD_Empinfo", "Forbid", map[string]any{
|
||||
"CreateOrgId": config.Config.Ik3cloud.OrganizationId,
|
||||
"Numbers": strings.Join(numbers, ","),
|
||||
})
|
||||
if err != nil {
|
||||
return errors.New("禁用员工失败")
|
||||
}
|
||||
result, _ := ik3cloud.Client.GetResult(raw)
|
||||
if !result.Result.ResponseStatus.IsSuccess {
|
||||
for _, item := range result.Result.ResponseStatus.Errors {
|
||||
return errors.New(item.Message)
|
||||
}
|
||||
return errors.New("禁用员工失败")
|
||||
}
|
||||
return nil
|
||||
func (s *staffLogic) Disable(numbers []string, ids []int64) error {
|
||||
return ik3cloud.Client.Disable(constant.ActionStaff, numbers, ids)
|
||||
}
|
||||
|
||||
// Enable @TITLE 启用账户
|
||||
func (s *staffLogic) Enable(numbers []string) error {
|
||||
raw, err := ik3cloud.Client.ExecuteOperation("BD_Empinfo", "Enable", map[string]any{
|
||||
"CreateOrgId": config.Config.Ik3cloud.OrganizationId,
|
||||
"Numbers": strings.Join(numbers, ","),
|
||||
})
|
||||
if err != nil {
|
||||
return errors.New("启用员工失败")
|
||||
}
|
||||
result, _ := ik3cloud.Client.GetResult(raw)
|
||||
if !result.Result.ResponseStatus.IsSuccess {
|
||||
for _, item := range result.Result.ResponseStatus.Errors {
|
||||
return errors.New(item.Message)
|
||||
}
|
||||
return errors.New("启用员工失败")
|
||||
}
|
||||
return nil
|
||||
func (s *staffLogic) Enable(numbers []string, ids []int64) error {
|
||||
return ik3cloud.Client.Enable(constant.ActionStaff, numbers, ids)
|
||||
}
|
||||
|
||||
// Delete @TITLE 删除
|
||||
func (s *staffLogic) Delete(numbers []string) error {
|
||||
if err := s.unAudit(numbers); err != nil {
|
||||
logger.Logger.Error("部门反审失败", zap.Error(err))
|
||||
}
|
||||
raw, err := ik3cloud.Client.Delete("BD_Empinfo", map[string]any{
|
||||
"CreateOrgId": config.Config.Ik3cloud.OrganizationId,
|
||||
"Numbers": strings.Join(numbers, ","),
|
||||
})
|
||||
if err != nil {
|
||||
return errors.New("删除员工失败")
|
||||
}
|
||||
result, err := ik3cloud.Client.GetResult(raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !result.Result.ResponseStatus.IsSuccess {
|
||||
for _, item := range result.Result.ResponseStatus.Errors {
|
||||
return errors.New(item.Message)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// @Title 提交
|
||||
func (s *staffLogic) submit(numbers []string) error {
|
||||
raw, err := ik3cloud.Client.Submit("BD_Empinfo", map[string]any{
|
||||
"CreateOrgId": config.Config.Ik3cloud.OrganizationId,
|
||||
"Numbers": strings.Join(numbers, ","),
|
||||
})
|
||||
if err != nil {
|
||||
return errors.New("员工提交失败")
|
||||
}
|
||||
result, err := ik3cloud.Client.GetResult(raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !result.Result.ResponseStatus.IsSuccess {
|
||||
for _, item := range result.Result.ResponseStatus.Errors {
|
||||
return errors.New(item.Message)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// @Title 审核
|
||||
func (s *staffLogic) audit(numbers []string) error {
|
||||
raw, err := ik3cloud.Client.Audit("BD_Empinfo", map[string]any{
|
||||
"CreateOrgId": config.Config.Ik3cloud.OrganizationId,
|
||||
"Numbers": strings.Join(numbers, ","),
|
||||
})
|
||||
if err != nil {
|
||||
return errors.New("员工审核失败")
|
||||
}
|
||||
result, err := ik3cloud.Client.GetResult(raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !result.Result.ResponseStatus.IsSuccess {
|
||||
for _, item := range result.Result.ResponseStatus.Errors {
|
||||
return errors.New(item.Message)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// @Title 反审
|
||||
func (s *staffLogic) unAudit(numbers []string) error {
|
||||
raw, err := ik3cloud.Client.UnAudit("BD_Empinfo", map[string]any{
|
||||
"CreateOrgId": config.Config.Ik3cloud.OrganizationId,
|
||||
"Numbers": strings.Join(numbers, ","),
|
||||
})
|
||||
if err != nil {
|
||||
return errors.New("员工反审失败")
|
||||
}
|
||||
result, err := ik3cloud.Client.GetResult(raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !result.Result.ResponseStatus.IsSuccess {
|
||||
for _, item := range result.Result.ResponseStatus.Errors {
|
||||
return errors.New(item.Message)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
func (s *staffLogic) Delete(numbers []string, ids []int64) error {
|
||||
return ik3cloud.Client.Delete(constant.ActionStaff, numbers, ids)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user