package eta_forum import ( "encoding/json" "eta/eta_api/models/system" "eta/eta_api/utils" "fmt" ) type RoleSaveReq struct { RoleId int `description:"角色ID"` RoleName string `description:"角色名称"` RoleType string `description:"角色类型"` RoleTypeCode string `description:"角色类型编码"` RoleLevel int `description:"角色等级:0-表示一级角色,每个账号只能绑定一个一级角色 ,1-表示二级角色,每个账号可以绑定多个二级 角色"` CreateTime string `description:"创建时间"` ModifyTime string BusinessCode string `description:"商家编码"` } // 上传角色信息 func RoleSave(roleId int) (err error) { if utils.BusinessCode == "" || (utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeDebug && utils.BusinessCode != utils.BusinessCodeSandbox) { return } //查询用户信息 roleInfo, err := system.GetRoleInfoById(roleId) if err != nil { if err.Error() == utils.ErrNoRow() { err = fmt.Errorf("用户不存在") return } err = fmt.Errorf("获取用户信息失败,Err:" + err.Error()) return } var req RoleSaveReq req.RoleId = roleInfo.RoleId req.RoleName = roleInfo.RoleName req.RoleTypeCode = roleInfo.RoleTypeCode req.RoleType = roleInfo.RoleType req.RoleLevel = roleInfo.RoleLevel req.CreateTime = roleInfo.CreateTime.Format(utils.FormatDateTime) req.ModifyTime = roleInfo.ModifyTime.Format(utils.FormatDateTime) reqJson, err := json.Marshal(req) if err != nil { err = fmt.Errorf("参数解析异常,Err:" + err.Error()) return } respItem, err := RoleSaveLib(string(reqJson)) if err != nil { err = fmt.Errorf("上传角色信息失败,Err:" + err.Error()) return } if respItem.Ret != 200 { err = fmt.Errorf("上传角色信息失败,Err:%v,errMsg:%v", respItem.Msg, respItem.ErrMsg) return } return } type RoleDeleteReq struct { RoleId int BusinessCode string `description:"商家编码"` } // 删除角色信息 func RoleDelete(roleId int) (err error) { if utils.BusinessCode == "" || (utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeDebug && utils.BusinessCode != utils.BusinessCodeSandbox) { return } var req RoleDeleteReq req.RoleId = roleId req.BusinessCode = utils.BusinessCode reqJson, err := json.Marshal(req) if err != nil { err = fmt.Errorf("参数解析异常,Err:" + err.Error()) return } respItem, err := RoleDeleteLib(string(reqJson)) if err != nil { err = fmt.Errorf("删除角色信息失败,Err:" + err.Error()) return } if respItem.Ret != 200 { err = fmt.Errorf("删除角色信息失败,Err:%v,errMsg:%v", respItem.Msg, respItem.ErrMsg) return } return } type SysDepartmentAddReq struct { DepartmentId int `description:"部门Id"` DepartmentName string `description:"部门名称"` Sort int `description:"排序"` CreateTime string `description:"创建时间"` } // 上传部门信息 func DepartmentSave(id int) (err error) { if utils.BusinessCode == "" || (utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeDebug && utils.BusinessCode != utils.BusinessCodeSandbox) { return } //查询用户信息 info, err := system.GetSysDepartmentById(id) if err != nil { if err.Error() == utils.ErrNoRow() { err = fmt.Errorf("用户不存在") return } err = fmt.Errorf("获取用户信息失败,Err:" + err.Error()) return } var req SysDepartmentAddReq req.DepartmentId = info.DepartmentId req.DepartmentName = info.DepartmentName req.Sort = info.Sort req.CreateTime = info.CreateTime.Format(utils.FormatDateTime) reqJson, err := json.Marshal(req) if err != nil { err = fmt.Errorf("参数解析异常,Err:" + err.Error()) return } respItem, err := DepartmentSaveLib(string(reqJson)) if err != nil { err = fmt.Errorf("上传角色信息失败,Err:" + err.Error()) return } if respItem.Ret != 200 { err = fmt.Errorf("上传角色信息失败,Err:%v,errMsg:%v", respItem.Msg, respItem.ErrMsg) return } return } type DepartmentDeleteReq struct { DepartmentId int `description:"部门Id"` BusinessCode string `description:"商家编码"` } // 删除部门信息 func DepartmentDelete(id int) (err error) { if utils.BusinessCode == "" || (utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeDebug && utils.BusinessCode != utils.BusinessCodeSandbox) { return } var req DepartmentDeleteReq req.DepartmentId = id req.BusinessCode = utils.BusinessCode reqJson, err := json.Marshal(req) if err != nil { err = fmt.Errorf("参数解析异常,Err:" + err.Error()) return } respItem, err := DepartmentDeleteLib(string(reqJson)) if err != nil { err = fmt.Errorf("删除角色信息失败,Err:" + err.Error()) return } if respItem.Ret != 200 { err = fmt.Errorf("删除角色信息失败,Err:%v,errMsg:%v", respItem.Msg, respItem.ErrMsg) return } return } type SysGroupAddReq struct { List []*system.SysGroup } // 新增分组信息 func GroupSave(ids []int) (err error) { if utils.BusinessCode == "" || (utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeDebug && utils.BusinessCode != utils.BusinessCodeSandbox) { return } //查询用户信息 if len(ids) == 0 { return } list, err := system.GetSysGroupByGroupIds(ids) if err != nil { err = fmt.Errorf("获取分组信息失败,Err:" + err.Error()) return } var req SysGroupAddReq req.List = list reqJson, err := json.Marshal(req) if err != nil { err = fmt.Errorf("参数解析异常,Err:" + err.Error()) return } respItem, err := GroupSaveLib(string(reqJson)) if err != nil { err = fmt.Errorf("上传角色信息失败,Err:" + err.Error()) return } if respItem.Ret != 200 { err = fmt.Errorf("上传角色信息失败,Err:%v,errMsg:%v", respItem.Msg, respItem.ErrMsg) return } return } type GroupDeleteReq struct { GroupId int `description:"分组ID"` BusinessCode string `description:"商家编码"` } // 删除分组信息 func GroupDelete(id int) (err error) { if utils.BusinessCode == "" || (utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeDebug && utils.BusinessCode != utils.BusinessCodeSandbox) { return } var req GroupDeleteReq req.GroupId = id req.BusinessCode = utils.BusinessCode reqJson, err := json.Marshal(req) if err != nil { err = fmt.Errorf("参数解析异常,Err:" + err.Error()) return } respItem, err := GroupDeleteLib(string(reqJson)) if err != nil { err = fmt.Errorf("删除角色信息失败,Err:" + err.Error()) return } if respItem.Ret != 200 { err = fmt.Errorf("删除角色信息失败,Err:%v,errMsg:%v", respItem.Msg, respItem.ErrMsg) return } return }