作者 唐旭辉

新增修改公司名称

... ... @@ -420,6 +420,7 @@ func (c *CompanyController) InitCompany() {
return
}
// GetCompanyForUCenter 总后台调用
//@router /ucenter/company/info [post]
func (c *CompanyController) GetCompanyForUCenter() {
var msg *protocol.ResponseMessage
... ... @@ -427,6 +428,28 @@ func (c *CompanyController) GetCompanyForUCenter() {
c.ResposeJson(msg)
}()
type Paremeter struct {
Companyid int64 `json:"company_id"`
CompanyName string `json:"company_name"`
}
var param Paremeter
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil {
log.Error("json 解析失败 err:%s", err)
msg = protocol.BadRequestParam("1")
return
}
err := servecompany.CompanyEditFromUcenter(param.Companyid, param.CompanyName)
msg = protocol.NewReturnResponse(nil, err)
return
}
//EditCompanyForUCenter
//@router /ucenter/company/edit [post]
func (c *CompanyController) EditCompanyForUCenter() {
var msg *protocol.ResponseMessage
defer func() {
c.ResposeJson(msg)
}()
type Paremeter struct {
Companyid int64 `json:"company_id"`
}
var param Paremeter
... ...
... ... @@ -112,6 +112,7 @@ type UserListItem struct {
Positions string `json:"positions" orm:"-"`
Roles string `json:"roles" orm:"-"`
Departments string `json:"departments" orm:"-"`
Phone string `json:"phone" orm:"column(phone)"`
Enable int8 `json:"enable" orm:"column(enable)"`
}
... ... @@ -123,16 +124,15 @@ type ResponseCompanyBase struct {
//CenterCompanyInfo 统一用户中心调用的公司数据
type CenterCompanyInfo struct {
CompanyId int64 `json:"company_id"` //总后台的公司id
CompanyName string `json:"company_name"` //
// AdminId int64 `json:"admin_id"` //统一用户中心的用户id
CompanyId int64 `json:"company_id"` //总后台的公司id
CompanyName string `json:"company_name"` //
AdminAccount string `json:"admin_account"`
AdminName string `json:"admin_name"`
Status int8 `json:"status"` //公司的状态 【1:启用】【2:禁用】
}
func (c CenterCompanyInfo) IsEnable() bool {
if c.Status == 1 || c.Status == 0 {
if c.Status == 1 {
return true
}
return false
... ...
... ... @@ -97,6 +97,7 @@ func init() {
beego.NSBefore(middleware.LogRequestData),
beego.NSRouter("/company", &controllers.CompanyController{}, "post:InitCompany"),
beego.NSRouter("/company/info", &controllers.CompanyController{}, "post:GetCompanyForUCenter"),
beego.NSRouter("/company/edit", &controllers.CompanyController{}, "post:EditCompanyForUCenter"),
)
beego.AddNamespace(nsV1)
... ...
... ... @@ -403,6 +403,23 @@ func CompanyInfoEdit(companyid int64, logo string) error {
return nil
}
//
func CompanyEditFromUcenter(companyid int64, companyname string) error {
companyinfo, err := models.GetCompanyByUCenter(companyid)
if err != nil {
log.Error("获取公司数据失败")
return protocol.NewErrWithMessage("1")
}
companyinfo.Name = companyname
err = models.UpdateCompanyById(companyinfo, []string{"Name"})
if err != nil {
log.Info("更新公司数据失败:%s", err)
return protocol.NewErrWithMessage("1")
}
return nil
}
func CompanyBaseInfo(companyid int64) (*protocol.ResponseCompanyBase, error) {
var (
err error
... ...
... ... @@ -538,9 +538,9 @@ func UserList(param protocol.RequestUserList) (protocol.ResponseUserList, error)
}
for k, v := range result {
var (
pname []string
dname []string
rname []string
pname = make([]string, 0)
dname = make([]string, 0)
rname = make([]string, 0)
)
positions := GetUserPosition(v.UserCompanydId)
for i := range positions {
... ... @@ -570,7 +570,7 @@ func GetUserDepartment(usercompanyid int64) []protocol.DepartmentBase {
WHERE a.enable_status =1 AND a.user_company_id =? `
var (
err error
data []protocol.DepartmentBase
data = make([]protocol.DepartmentBase, 0)
)
err = utils.ExecuteQueryAll(&data, datasql, usercompanyid)
if err != nil {
... ...