作者 唐旭辉

提交存储

... ... @@ -4,7 +4,7 @@ ENV GOPROXY https://goproxy.cn
ENV GOPATH /go
ENV APP_DIR $GOPATH/src/oppmg
# Recompile the standard library without CGO
RUN CGO_ENABLED=0 go install -a std
# RUN CGO_ENABLED=0 go install -a std
RUN mkdir -p $APP_DIR
# Set the entrypoint
... ... @@ -15,3 +15,4 @@ ADD . $APP_DIR
RUN cd $APP_DIR && CGO_ENABLED=0 go build -mod=vendor -ldflags '-d -w -s' -o oppmg
WORKDIR $APP_DIR
EXPOSE 8080
CMD [ "./oppmg" ]
... ...
... ... @@ -410,3 +410,23 @@ func (c *CompanyController) InitCompany() {
msg = protocol.NewReturnResponse(nil, err)
return
}
//GetDepartmentUser 获取部门下成员
func (c *CommonController) GetDepartmentUser() {
var msg *protocol.ResponseMessage
defer func() {
c.ResposeJson(msg)
}()
type Parameter struct {
DepartmentId int64 `json:"id"`
}
var param Parameter
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil {
log.Error("json 解析失败 err:%s", err)
msg = protocol.BadRequestParam("1")
return
}
msg = protocol.NewReturnResponse(nil, nil)
return
}
... ...
... ... @@ -35,3 +35,9 @@ type PositionBase struct {
Name string `json:"name" orm:"column(name)"`
ParentId int64 `json:"parent_id" orm:"column(parent_id)"`
}
//DepartUserBase 下拉选择列表-部门下的人员
type DepartUserBase struct {
UserCompanyId int64 `json:"id" orm:"column(user_company_id)"`
Name string `json:"name" orm:"-"`
}
... ...
... ... @@ -370,3 +370,49 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro
return departs, nil
}
//获取部门下的人员
func GetDepartmentUser(companyid int64, departmentid int64) ([]protocol.DepartUserBase, error) {
var (
department *models.Department
err error
)
department, err = models.GetDepartmentById(departmentid)
if err != nil {
log.Error("获取部门失败:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
if department.CompanyId != companyid {
log.Error("deparment.CompanyId err")
return nil, protocol.NewErrWithMessage("1")
}
const dataSql string = `SELECT b.user_id,b.id AS user_company_id FROM user_department AS a
JOIN user_company AS b ON a.user_company_id = b.id
WHERE a.department_id=? AND b.delete_at=0 `
type UsercompanyId struct {
UserCompanyId int64 `orm:"column(user_company_id)"`
UserId int64 `orm:"column(user_id)"`
}
var (
usercompanyData []UsercompanyId
returnData []protocol.DepartUserBase
)
err = utils.ExecuteQueryAll(&usercompanyData, dataSql, department.Id)
if err != nil {
log.Error("EXECUTE SQL err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
for _, v := range usercompanyData {
udata, err := models.GetUserById(v.UserId)
if err != nil {
log.Error("获取user数据失败:%s", err)
continue
}
d := protocol.DepartUserBase{
UserCompanyId: v.UserCompanyId,
Name: udata.NickName,
}
returnData = append(returnData, d)
}
return nil, nil
}
... ...
... ... @@ -78,6 +78,20 @@ func ExecuteSQLWithOrmer(o orm.Ormer, sqlstr string, param ...interface{}) error
return nil
}
//ExecuteQuerySql 执行原生sql查询多条记录
func ExecuteQueryValue(result *[]orm.Params, sqlstr string, param ...interface{}) error {
PrintLogSql(sqlstr, param...)
var (
err error
)
o := orm.NewOrm()
_, err = o.Raw(sqlstr, param).Values(result)
if err != nil {
return err
}
return nil
}
type QueryDataByPage struct {
CountSql string
DataSql string
... ...