正在显示
5 个修改的文件
包含
88 行增加
和
1 行删除
| @@ -4,7 +4,7 @@ ENV GOPROXY https://goproxy.cn | @@ -4,7 +4,7 @@ ENV GOPROXY https://goproxy.cn | ||
| 4 | ENV GOPATH /go | 4 | ENV GOPATH /go |
| 5 | ENV APP_DIR $GOPATH/src/oppmg | 5 | ENV APP_DIR $GOPATH/src/oppmg |
| 6 | # Recompile the standard library without CGO | 6 | # Recompile the standard library without CGO |
| 7 | -RUN CGO_ENABLED=0 go install -a std | 7 | +# RUN CGO_ENABLED=0 go install -a std |
| 8 | 8 | ||
| 9 | RUN mkdir -p $APP_DIR | 9 | RUN mkdir -p $APP_DIR |
| 10 | # Set the entrypoint | 10 | # Set the entrypoint |
| @@ -15,3 +15,4 @@ ADD . $APP_DIR | @@ -15,3 +15,4 @@ ADD . $APP_DIR | ||
| 15 | RUN cd $APP_DIR && CGO_ENABLED=0 go build -mod=vendor -ldflags '-d -w -s' -o oppmg | 15 | RUN cd $APP_DIR && CGO_ENABLED=0 go build -mod=vendor -ldflags '-d -w -s' -o oppmg |
| 16 | WORKDIR $APP_DIR | 16 | WORKDIR $APP_DIR |
| 17 | EXPOSE 8080 | 17 | EXPOSE 8080 |
| 18 | +CMD [ "./oppmg" ] |
| @@ -410,3 +410,23 @@ func (c *CompanyController) InitCompany() { | @@ -410,3 +410,23 @@ func (c *CompanyController) InitCompany() { | ||
| 410 | msg = protocol.NewReturnResponse(nil, err) | 410 | msg = protocol.NewReturnResponse(nil, err) |
| 411 | return | 411 | return |
| 412 | } | 412 | } |
| 413 | + | ||
| 414 | +//GetDepartmentUser 获取部门下成员 | ||
| 415 | +func (c *CommonController) GetDepartmentUser() { | ||
| 416 | + var msg *protocol.ResponseMessage | ||
| 417 | + defer func() { | ||
| 418 | + c.ResposeJson(msg) | ||
| 419 | + }() | ||
| 420 | + type Parameter struct { | ||
| 421 | + DepartmentId int64 `json:"id"` | ||
| 422 | + } | ||
| 423 | + var param Parameter | ||
| 424 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
| 425 | + log.Error("json 解析失败 err:%s", err) | ||
| 426 | + msg = protocol.BadRequestParam("1") | ||
| 427 | + return | ||
| 428 | + } | ||
| 429 | + | ||
| 430 | + msg = protocol.NewReturnResponse(nil, nil) | ||
| 431 | + return | ||
| 432 | +} |
| @@ -35,3 +35,9 @@ type PositionBase struct { | @@ -35,3 +35,9 @@ type PositionBase struct { | ||
| 35 | Name string `json:"name" orm:"column(name)"` | 35 | Name string `json:"name" orm:"column(name)"` |
| 36 | ParentId int64 `json:"parent_id" orm:"column(parent_id)"` | 36 | ParentId int64 `json:"parent_id" orm:"column(parent_id)"` |
| 37 | } | 37 | } |
| 38 | + | ||
| 39 | +//DepartUserBase 下拉选择列表-部门下的人员 | ||
| 40 | +type DepartUserBase struct { | ||
| 41 | + UserCompanyId int64 `json:"id" orm:"column(user_company_id)"` | ||
| 42 | + Name string `json:"name" orm:"-"` | ||
| 43 | +} |
| @@ -370,3 +370,49 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro | @@ -370,3 +370,49 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro | ||
| 370 | 370 | ||
| 371 | return departs, nil | 371 | return departs, nil |
| 372 | } | 372 | } |
| 373 | + | ||
| 374 | +//获取部门下的人员 | ||
| 375 | +func GetDepartmentUser(companyid int64, departmentid int64) ([]protocol.DepartUserBase, error) { | ||
| 376 | + var ( | ||
| 377 | + department *models.Department | ||
| 378 | + err error | ||
| 379 | + ) | ||
| 380 | + department, err = models.GetDepartmentById(departmentid) | ||
| 381 | + if err != nil { | ||
| 382 | + log.Error("获取部门失败:%s", err) | ||
| 383 | + return nil, protocol.NewErrWithMessage("1") | ||
| 384 | + } | ||
| 385 | + if department.CompanyId != companyid { | ||
| 386 | + log.Error("deparment.CompanyId err") | ||
| 387 | + return nil, protocol.NewErrWithMessage("1") | ||
| 388 | + } | ||
| 389 | + const dataSql string = `SELECT b.user_id,b.id AS user_company_id FROM user_department AS a | ||
| 390 | + JOIN user_company AS b ON a.user_company_id = b.id | ||
| 391 | + WHERE a.department_id=? AND b.delete_at=0 ` | ||
| 392 | + type UsercompanyId struct { | ||
| 393 | + UserCompanyId int64 `orm:"column(user_company_id)"` | ||
| 394 | + UserId int64 `orm:"column(user_id)"` | ||
| 395 | + } | ||
| 396 | + var ( | ||
| 397 | + usercompanyData []UsercompanyId | ||
| 398 | + returnData []protocol.DepartUserBase | ||
| 399 | + ) | ||
| 400 | + err = utils.ExecuteQueryAll(&usercompanyData, dataSql, department.Id) | ||
| 401 | + if err != nil { | ||
| 402 | + log.Error("EXECUTE SQL err:%s", err) | ||
| 403 | + return nil, protocol.NewErrWithMessage("1") | ||
| 404 | + } | ||
| 405 | + for _, v := range usercompanyData { | ||
| 406 | + udata, err := models.GetUserById(v.UserId) | ||
| 407 | + if err != nil { | ||
| 408 | + log.Error("获取user数据失败:%s", err) | ||
| 409 | + continue | ||
| 410 | + } | ||
| 411 | + d := protocol.DepartUserBase{ | ||
| 412 | + UserCompanyId: v.UserCompanyId, | ||
| 413 | + Name: udata.NickName, | ||
| 414 | + } | ||
| 415 | + returnData = append(returnData, d) | ||
| 416 | + } | ||
| 417 | + return nil, nil | ||
| 418 | +} |
| @@ -78,6 +78,20 @@ func ExecuteSQLWithOrmer(o orm.Ormer, sqlstr string, param ...interface{}) error | @@ -78,6 +78,20 @@ func ExecuteSQLWithOrmer(o orm.Ormer, sqlstr string, param ...interface{}) error | ||
| 78 | return nil | 78 | return nil |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | +//ExecuteQuerySql 执行原生sql查询多条记录 | ||
| 82 | +func ExecuteQueryValue(result *[]orm.Params, sqlstr string, param ...interface{}) error { | ||
| 83 | + PrintLogSql(sqlstr, param...) | ||
| 84 | + var ( | ||
| 85 | + err error | ||
| 86 | + ) | ||
| 87 | + o := orm.NewOrm() | ||
| 88 | + _, err = o.Raw(sqlstr, param).Values(result) | ||
| 89 | + if err != nil { | ||
| 90 | + return err | ||
| 91 | + } | ||
| 92 | + return nil | ||
| 93 | +} | ||
| 94 | + | ||
| 81 | type QueryDataByPage struct { | 95 | type QueryDataByPage struct { |
| 82 | CountSql string | 96 | CountSql string |
| 83 | DataSql string | 97 | DataSql string |
-
请 注册 或 登录 后发表评论