作者 yangfu

用户导入修改

... ... @@ -119,3 +119,22 @@ func (srv CooperationProjectService) PersonSearchCooperationProject(projectQuery
}
return int(result.Total), result.List, nil
}
// PersonSearchCooperationProject 共创用户获取共创项目列表
//func (srv CooperationProjectService) PersonRecommendCooperationProject(projectQuery *command.PersonSearchCooperationProjectQuery) (int, interface{}, error) {
// creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
// projectQuery.Operator)
// //orgidStr := strconv.Itoa(projectQuery.OrgId)
// result, err := creationCooperationGateway.CooperationProjectsSearch(allied_creation_cooperation.ReqCooperationProjectSearch{
// PageNumber: projectQuery.PageNumber + 1, //手机序号从0开始的
// PageSize: projectQuery.PageSize,
// OrgId: projectQuery.OrgId,
// Status: 1, //搜索状态为“招标中”项目
// Keyword: projectQuery.Keyword,
// //UserBaseId: projectQuery.Operator.UserBaseId,
// })
// if err != nil {
// return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
// return int(result.Total), result.List, nil
//}
... ...
... ... @@ -158,8 +158,9 @@ func (srv PersonStatisticsService) CooperationProjectRecommend(projectQuery *com
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
projectQuery.Operator)
result, err := creationCooperationGateway.CooperationProjectsSearch(allied_creation_cooperation.ReqCooperationProjectSearch{
PageNumber: projectQuery.PageNumber,
PageSize: projectQuery.PageSize,
PageNumber: projectQuery.PageNumber,
PageSize: projectQuery.PageSize,
CooperationProjectUndertakerType: 3,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ...
... ... @@ -12,7 +12,7 @@ type ImportDataCommand struct {
Operator domain.Operator `json:"-"`
Reader io.Reader `json:"-"`
// 业务编码
Code string `json:"code"`
Code string `form:"code"`
}
func (importDataCommand *ImportDataCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -182,13 +182,13 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD
excelImport := excel.NewExcelImport()
excelImport.RowBegin = 2 //第二行开始读取
excelImport.DataFields = []excel.DataField{
{EnName: "UserCode", CnName: "*用户编号"},
{EnName: "UserName", CnName: "*用户姓名"},
{EnName: "Organization", CnName: "*组织机构"},
{EnName: "Department", CnName: "*所属部门"},
{EnName: "Phone", CnName: "*手机号"},
{EnName: "Email", CnName: "邮箱"},
{EnName: "Status", CnName: "状态"},
{EnName: "userCode", CnName: "*用户编号"},
{EnName: "userName", CnName: "*用户姓名"},
{EnName: "organization", CnName: "*组织机构"},
{EnName: "department", CnName: "*所属部门"},
{EnName: "phone", CnName: "*手机号"},
{EnName: "email", CnName: "邮箱"},
{EnName: "enableStatus", CnName: "状态"},
}
excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
if err != nil {
... ... @@ -199,15 +199,15 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD
item := allied_creation_user.BatchAddUserItem{
CompanyId: importDataCommand.Operator.CompanyId,
UserType: domain.UserTypeEmployee,
UserCode: v["UserCode"],
Org: v["Organization"],
Department: v["Department"],
UserName: v["UserName"],
Phone: v["Phone"],
Email: v["Email"],
UserCode: v["userCode"],
Org: v["organization"],
Department: v["department"],
UserName: v["userName"],
Phone: v["phone"],
Email: v["email"],
EnableStatus: domain.UserStatusEnable,
}
if status, ok := v["Status"]; ok {
if status, ok := v["status"]; ok {
if strings.TrimSpace(status) != "启用" {
item.EnableStatus = domain.UserStatusDisable
}
... ... @@ -222,7 +222,15 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return result, nil
return srv.importResultWithHeader(map[string]interface{}{
"userCode": "*用户编号",
"userName": "*用户姓名",
"organization": "*组织机构",
"department": "*所属部门",
"phone": "*手机号",
"email": "邮箱",
"enableStatus": "状态",
}, result.FailRows, len(excelData)), nil
}
func (srv ExcelDataService) ImportOrganization(importDataCommand *command.ImportDataCommand) (interface{}, error) {
... ... @@ -256,3 +264,22 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import
}
return result, nil
}
// 导入结果
func (srv ExcelDataService) importResultWithHeader(header interface{}, failRows []interface{}, totalRow int) interface{} {
var result = map[string]interface{}{
"successCount": 0,
"fail": struct{}{},
}
if len(failRows) == 0 {
result["successCount"] = totalRow
}
if len(failRows) > 0 {
fail := map[string]interface{}{
"body": failRows,
}
fail["header"] = header
result["fail"] = fail
}
return result
}
... ...
... ... @@ -166,6 +166,8 @@ type (
//OffsetLimitFlag bool `json:"offsetLimitFlag"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
// 共创项目承接对象,1员工,2共创用户,4公开,可以多选
CooperationProjectUndertakerType int32 `json:"cooperationProjectUndertakerType"`
}
DataCooperationProjectSearchItem struct {
CooperationProjectID string `json:"cooperationProjectId"`
... ...
... ... @@ -238,7 +238,7 @@ func (gateway HttplibAlliedCreationUser) UserBatchResetPassword(param ReqBatchRe
}
// UserBatchAdd 批量添加用户
func (gateway HttplibAlliedCreationUser) UserBatchAdd(param ReqBatchAddUser) (*DataBatchAddUser, error) {
func (gateway HttplibAlliedCreationUser) UserBatchAdd(param ReqBatchAddUser) (*DataImportResponse, error) {
url := fmt.Sprintf("%s%s", gateway.baseUrL, "/user/batch-add2")
method := "post"
req := gateway.CreateRequest(url, method)
... ... @@ -264,7 +264,7 @@ func (gateway HttplibAlliedCreationUser) UserBatchAdd(param ReqBatchAddUser) (*D
if err != nil {
return nil, fmt.Errorf("解析批量添加用户:%w", err)
}
var data DataBatchAddUser
var data DataImportResponse
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
... ... @@ -350,7 +350,8 @@ type (
Password string `json:"password"`
}
DataBatchAddUser struct {
DataImportResponse struct {
FailRows []interface{} `json:"failRows"`
}
//BatchAddUserItem struct {
... ... @@ -396,5 +397,7 @@ type (
CooperationCompany string `json:"cooperationCompany"`
// 共创到期时间 (yyyy-MM-dd) cooperationDeadline
CooperationDeadline time.Time `json:"cooperationDeadline"`
// 失败理由
FailReason string `json:"failReason"`
}
)
... ...
... ... @@ -227,6 +227,19 @@ func (controller *CooperationController) PersonSearchCooperationProject() {
controller.ReturnPageListData(int64(total), data, err, cmd.PageNumber)
}
//func (controller *CooperationController) PersonRecommendCooperationProject() {
// svr := service.CooperationProjectService{}
// cmd := &command.PersonSearchCooperationProjectQuery{}
// err := controller.Unmarshal(cmd)
// if err != nil {
// controller.Response(nil, err)
// return
// }
// cmd.Operator = controller.GetOperator()
// total, data, err := svr.PersonRecommendCooperationProject(cmd)
// controller.ReturnPageListData(int64(total), data, err, cmd.PageNumber)
//}
/***** CompanyCreditAccountService 企业端账期结算 *****/
func (controller *CooperationController) CreditAccountSearch() {
svr := service.CompanyCreditAccountService{}
... ...