作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into dev

... ... @@ -2,9 +2,11 @@ package controllers
import (
"encoding/json"
"fmt"
"oppmg/common/log"
"oppmg/models"
"oppmg/protocol"
serverbac "oppmg/services/rbac"
serveaudit "oppmg/services/audit"
servecommon "oppmg/services/common"
)
type AuditController struct {
... ... @@ -18,22 +20,42 @@ func (c *AuditController) AuditList() {
defer func() {
c.ResposeJson(msg)
}()
// var request *protocol.ConfigScoreRequest
// if err := json.Unmarshal(this.Ctx.Input.RequestBody, &request); err != nil {
// log.Error("json 解析失败", err)
// msg = protocol.BadRequestParam("1")
// return
// }
// uid := this.GetUserId()
// companyId := this.GetCompanyId()
msg = protocol.NewReturnResponse(nil, nil)
var param protocol.RequestAuditList
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil {
log.Error("json 解析失败", err)
msg = protocol.BadRequestParam("1")
return
}
uid := c.GetUserId()
companyId := c.GetCompanyId()
list, err := serveaudit.GetAuditList(param, companyId, uid)
msg = protocol.NewReturnResponse(list, err)
return
}
func (c *AuditController) Test() {
data, err := serverbac.GetUserPermission(11)
fmt.Println(err)
bt, err := json.Marshal(data)
fmt.Println(err)
fmt.Println(string(bt))
//AuditListBefore
//@router /v1/audit/list/before
func (c *AuditController) AuditListBefore() {
var msg *protocol.ResponseMessage
defer func() {
c.ResposeJson(msg)
}()
// uid := c.GetUserId()
companyId := c.GetCompanyId()
templatelist := servecommon.SelectGetTemplateList(companyId)
chanceTypeList := servecommon.SeleteGetChanceTypeList(companyId)
departmentList := servecommon.SelectorDepartment(companyId, -1)
publicStatus := models.ChancePublishStatusMap
enableStatus := models.ChanceEnableStatusMap
reviewStatus := models.ChanceReviewStatusMap
data := map[string]interface{}{
"template": templatelist,
"chance_type": chanceTypeList,
"public_status": publicStatus,
"enable_status": enableStatus,
"review_status": reviewStatus,
"department": departmentList,
}
msg = protocol.NewReturnResponse(data, nil)
return
}
... ...
... ... @@ -43,8 +43,8 @@ func (this *BaseController) GetAppHead() (appHead protocol.BaseHeader) {
func (this *BaseController) Finish() {
strByte, _ := json.Marshal(this.Data["json"])
length := len(strByte)
if length > 5000 {
log.Info(fmt.Sprintf("<====Send to client: RspBodyData: %s......", string(strByte[:5000])))
if length > 1000 {
log.Info(fmt.Sprintf("<====Send to client: RspBodyData: %s......", string(strByte[:1000])))
} else {
log.Info(fmt.Sprintf("<====Send to client: RspBodyData: %s", string(strByte)))
}
... ...
package models
import (
"fmt"
"time"
"github.com/astaxie/beego/orm"
)
type Chance struct {
Id int64 `orm:"column(id);pk" description:"id 主键"`
UserId int64 `orm:"column(user_id)" description:"表user_company.id id"`
DepartmentId int64 `orm:"column(department_id)" description:"表department.id 部门id (提交机会指定的部门)"`
ChanceTypeId int `orm:"column(chance_type_id)" description:"表chance_type.id 机会类型 "`
CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"`
AuditTemplateId int64 `orm:"column(audit_template_id)" description:"表audit_template.id 所属审批模板编号"`
AuditTemplateConfig string `orm:"column(audit_template_config);size(255);null" description:"模板配置 (存旧的配置信息,对新改动的不影响)"`
Content string `orm:"column(content)" description:"格式化后的文本内容"`
SourceContent string `orm:"column(source_content)" description:"原始表单内容 json"`
ViewTotal int `orm:"column(view_total)" description:"查看总数"`
CommentTotal int `orm:"column(comment_total)" description:"评论总数"`
ZanTotal int `orm:"column(zan_total)" description:"点赞总数"`
ReviewStatus int8 `orm:"column(review_status)" description:"审核状态 0:待处理 1:待审核 2:被退回 3:已通过 "`
EnableStatus int8 `orm:"column(enable_status)" description:"有效状态 0:无效 1:有效 "`
UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`
BasicScore float64 `orm:"column(basic_score);null;digits(4);decimals(1)" description:"基础评分"`
ExtraScore float64 `orm:"column(extra_score);null;digits(4);decimals(1)" description:"附加评分"`
ValueScore float64 `orm:"column(value_score);null;digits(4);decimals(1)" description:"价值评分"`
DiscoveryScore float64 `orm:"column(discovery_score);null;digits(4);decimals(1)" description:"发现得分(发现得分=基础评分*系数 + 附加评分*系数 + 价值评分*系数)"`
PublishStatus int `orm:"column(publish_status)" description:"公开状态 -1 未公开、1部门公开、2公司公开"`
AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"`
ApproveData string `orm:"column(approve_data);size(500);null" description:"公开数据 (公开状态 公开对象)"`
}
func (t *Chance) TableName() string {
return "chance"
}
func init() {
orm.RegisterModel(new(Chance))
}
// 公开状态 0未设置、1部门公开、2公司公开
const (
ChancePublishStatus0 int = 0
ChancePublishStatus1 int = 1
ChancePublishStatus2 int = 2
)
var ChancePublishStatusMap = map[int]string{
ChancePublishStatus0: "未设置",
ChancePublishStatus1: "部门公开",
ChancePublishStatus2: "公司公开",
}
// 审核状态 0:待处理 1:待审核 2:被退回 3:已通过
const (
ChanceReviewStatusWait int = 0
ChanceReviewStatusIng int = 1
ChanceReviewStatusNo int = 2
ChanceReviewStatusYes int = 3
)
var ChanceReviewStatusMap = map[int]string{
ChanceReviewStatusWait: "待处理",
ChanceReviewStatusIng: "待审核",
ChanceReviewStatusNo: "被退回",
ChanceReviewStatusYes: "已通过",
}
//有效状态 0:无效 1:有效
const (
ChanceEnableStatusYes int = 1
ChanceEnableStatusNo int = 0
)
var ChanceEnableStatusMap = map[int]string{
0: "无效",
1: "有效",
}
// AddChance insert a new Chance into database and returns
// last inserted Id on success.
func AddChance(m *Chance) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
// GetChanceById retrieves Chance by Id. Returns error if
// Id doesn't exist
func GetChanceById(id int64) (v *Chance, err error) {
o := orm.NewOrm()
v = &Chance{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
// UpdateChance updates Chance by Id and returns error if
// the record to be updated doesn't exist
func UpdateChanceById(m *Chance, col []string) (err error) {
o := orm.NewOrm()
var num int64
if num, err = o.Update(m, col...); err == nil {
fmt.Println("Number of records updated in database:", num)
}
return
}
... ...
package models
import (
"time"
"github.com/astaxie/beego/orm"
)
type ChanceData struct {
Id int `orm:"column(id);pk" description:"唯一编号"`
ChanceId int64 `orm:"column(chance_id);null" description:"表chance.id 机会编号"`
Images string `orm:"column(images);null" description:"图片 json"`
Speechs string `orm:"column(speechs);null" description:"语音 json"`
Videos string `orm:"column(videos);null" description:"视频 json"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间"`
}
func (t *ChanceData) TableName() string {
return "chance_data"
}
func init() {
orm.RegisterModel(new(ChanceData))
}
type ChanceDataImage struct {
Path string `json:"path"`
W int `json:"w"`
H int `json:"h"`
}
type ChanceDataSpeechs struct {
Path string `json:"path"`
Duration int `json:"duration"`
}
type ChanceDataVideos struct {
Path string
Cover ChanceDataImage `json:"cover"`
Duration int `json:"duration"`
}
... ...
package protocol
import "sort"
import (
"sort"
)
//输入框类型
const (
... ... @@ -16,12 +18,11 @@ type InputElement struct {
Lable string `json:"lable"` //标题
InputType string `json:"inputType"` //输入类型
Required int `json:"required"` //是否必填
CurrentValue string `json:"-"` //"当前填写的值"
// CurrentValue string `json:"-"` //"当前填写的值"
SectionType int8 `json:"sectionType"`
ValueList string `json:"-"` //输入候选值 value_list
Placeholder string `json:"-"` //帮助用户填写输入字段的提示 Placeholder
Disable bool `json:"-"` //"显示隐藏",
// ValueList string `json:"-"` //输入候选值 value_list
// Placeholder string `json:"-"` //帮助用户填写输入字段的提示 Placeholder
// Disable bool `json:"-"` //"显示隐藏",
}
//自定义表单
... ... @@ -246,7 +247,7 @@ type ResponseAuditList struct {
}
type RspAuditList struct {
Id int64 `json:"id"` //机会的id
Id string `json:"id"` //机会的id
Code string `json:"code"`
ChanceType string `json:"chance_type"` //一级分类
TemplateName string `json:"template_name"` //二级分类
... ... @@ -258,5 +259,11 @@ type RspAuditList struct {
ReviewStatus int `json:"review_status"` //审批状态
ReviewStatusName string `json:"review_status_name"`
EnableStatus int `json:"enable_status"`
EnableStatusName int `json:"enable_status_name"`
EnableStatusName string `json:"enable_status_name"`
}
type ChanceFlowLog struct {
CreateTime string `json:"create_time"`
Content string `json:"content"`
UserrName string `json:"user_name"`
}
... ...
... ... @@ -64,3 +64,16 @@ type RoleHasUser struct {
UserCompanyId int64 `json:"user_company_id" orm:"column(user_company_id)"`
Name string `json:"name" orm:"column(nick_name)"`
}
//下拉选择框的内容模板 -机会二级分类
type TemplateBase struct {
TemplateId int64 `orm:"column(template_id)" json:"template_id"`
ChanceTypeId int64 `orm:"column(chance_type_id)" json:"chance_type_id"`
Name string `orm:"column(name)" json:"name"`
}
//下拉选择框的内容机会分类 - 机会一级分类
type ChanceTypeBase struct {
ChanceTypeId int64 `orm:"column(chance_type_id)" json:"chance_type_id"`
Name string `orm:"column(name)" json:"name"`
}
... ...
... ... @@ -75,5 +75,21 @@ type ResponseRoleMenus struct {
MenuId []int64 `json:"menu_ids"`
}
// type ResponseRolePermission struct {
// }
type ResponseUserHasMenu struct {
Id int64 `json:"id" orm:"column(id)"`
Name string `json:"name" orm:"column(name)"`
Icon string `json:"icon" orm:"column(icon)"`
ParentId int64 `json:"parent_id" orm:"column(parent_id)"`
SeniorStatus int8 `json:"senior_status" orm:"column(senior_status)"`
Code string `json:"code" orm:"column(code)"`
Sort int `json:"sort" orm:"column(sort)"`
Status int `json:"status" orm:"column(status)"`
}
func (c *ResponseUserHasMenu) StatusYes() {
c.Status = 1
}
func (c *ResponseUserHasMenu) StatusNo() {
c.Status = 0
}
... ...
... ... @@ -99,6 +99,7 @@ func init() {
),
beego.NSNamespace("/audit",
beego.NSRouter("/list", &controllers.AuditController{}, "post:AuditList"),
beego.NSRouter("/list/before", &controllers.AuditController{}, "post:AuditListBefore"),
),
)
... ... @@ -130,5 +131,4 @@ func init() {
beego.SetStaticPath("/file/opp", beego.AppConfig.String("file_save_path"))
beego.SetStaticPath("/static", "./static")
beego.Router("/test", &controllers.AuditController{}, "get:Test")
}
... ...
package audit
import (
"encoding/json"
"fmt"
"oppmg/common/log"
"oppmg/models"
"oppmg/protocol"
... ... @@ -21,9 +23,11 @@ type SqlData struct {
EnableStatus int `orm:"column(enable_status)"`
DiscoveryScore string `orm:"column(discovery_score)"`
CommentTotal string `orm:"column(comment_total)"`
Code string `orm:"column(code)"`
TemplateName string `orm:"column(template_name)"`
}
func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.ResponseAuditList, error) {
func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64) (protocol.ResponseAuditList, error) {
var (
datasql = strings.Builder{}
... ... @@ -31,7 +35,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re
data []SqlData
cnt int
err error
//listdata = make([]protocol.RspAuditList, 0)
cond []interface{}
)
returnData := protocol.ResponseAuditList{
ResponsePageInfo: protocol.ResponsePageInfo{
... ... @@ -40,15 +44,63 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re
},
List: make([]protocol.RspAuditList, 0),
}
dataStart := (param.PageIndex - 1) * param.PageSize
datasql.WriteString(`SELECT id,user_id,department_id,audit_template_id,chance_type_id
,publish_status,create_at,review_status,enable_status
,discovery_score,comment_total
FROM chance
limit ?,? `)
datasql.WriteString(`SELECT a.id,a.user_id,a.department_id,a.audit_template_id,a.chance_type_id
,a.publish_status,a.create_at,a.review_status,a.enable_status
,a.discovery_score,a.comment_total,b.name AS template_name ,b.code
FROM chance AS a
JOIN audit_template AS b on a.audit_template_id = b.id
where a.company_id=? `)
countsql.WriteString(`SELECT count(*) FROM chance`)
err = utils.ExecuteQueryOne(&cnt, countsql.String())
countsql.WriteString(`SELECT count(*) FROM chance as a
JOIN audit_template AS b on a.audit_template_id = b.id
where a.company_id=? `)
cond = append(cond, companyid)
if param.ChanceTypeId > 0 {
//一级分类过滤
cond = append(cond, param.ChanceTypeId)
s := ` And a.chance_type_id=? `
datasql.WriteString(s)
countsql.WriteString(s)
}
if param.TempalteId > 0 {
cond = append(cond, param.TempalteId)
s := ` AND a.audit_template_id=? `
datasql.WriteString(s)
countsql.WriteString(s)
}
if param.PublishStatus >= 0 {
cond = append(cond, param.PublishStatus)
s := ` And a.publish_status=? `
datasql.WriteString(s)
countsql.WriteString(s)
}
if param.EnableStatus >= 0 {
cond = append(cond, param.EnableStatus)
s := ` AND a.enable_status=? `
datasql.WriteString(s)
countsql.WriteString(s)
}
if param.ReviewStatus >= 0 {
cond = append(cond, param.ReviewStatus)
s := ` AND a.review_status=? `
datasql.WriteString(s)
countsql.WriteString(s)
}
if param.CreateTimeBegin > 0 && param.CreateTimeEnd > 0 {
cond = append(cond, param.CreateTimeBegin, param.CreateTimeEnd)
s := ` AND (UNIX_TIMESTAMP(a.create_at) BETWEEN ? AND ? ) `
datasql.WriteString(s)
countsql.WriteString(s)
}
if len(param.Code) > 0 {
cond = append(cond, param.Code)
s := ` And b.code=? `
datasql.WriteString(s)
countsql.WriteString(s)
}
dataStart := (param.PageIndex - 1) * param.PageSize
datasql.WriteString(fmt.Sprintf(` limit %d,%d `, dataStart, param.PageSize))
err = utils.ExecuteQueryOne(&cnt, countsql.String(), cond...)
if err != nil {
log.Error("EXCUTE SQL ERR:%s", err)
return returnData, nil
... ... @@ -56,7 +108,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re
if cnt <= 0 {
return returnData, nil
}
err = utils.ExecuteQueryOne(&data, datasql.String(), dataStart, param.PageSize)
err = utils.ExecuteQueryAll(&data, datasql.String(), cond...)
if err != nil {
log.Error("EXCUTE SQL ERR:%s", err)
return returnData, nil
... ... @@ -64,10 +116,17 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re
for _, v := range data {
t := v.CreateAt.Unix()
item := protocol.RspAuditList{
Id: v.Id,
Id: fmt.Sprint(v.Id),
EnableStatus: v.EnableStatus,
EnableStatusName: models.ChanceEnableStatusMap[v.EnableStatus],
PublishStatus: v.PublishStatus,
PublishStatusName: models.ChancePublishStatusMap[v.PublishStatus],
ReviewStatus: v.ReviewStatus,
ReviewStatusName: models.ChanceReviewStatusMap[v.ReviewStatus],
Code: v.Code,
TemplateName: v.TemplateName,
}
if t < 0 {
item.CreateTime = 0
} else {
... ... @@ -79,15 +138,61 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re
if d, err := models.GetDepartmentById(v.DepartmentId); err == nil {
item.Department = d.Name
}
if at, err := models.GetAuditTemplateById(v.AuditTemplateId); err == nil {
item.TemplateName = at.Name
item.Code = at.Code
}
if ct, err := models.GetChanceTypeById(v.ChanceTypeId); err == nil {
item.ChanceType = ct.Name
}
returnData.List = append(returnData.List, item)
}
returnData.TotalPage = cnt
returnData.CurrentPage = param.PageIndex
return returnData, nil
}
type ResponseChanceInfo struct {
BaseContent []protocol.InputElement `json:"base_content"`
ExtraContent []protocol.InputElement `json:"extra_content"`
ImageData []models.ChanceDataImage `json:"image_data"`
VideoData []models.ChanceDataVideos `json:"video_data"`
SpeechData []models.ChanceDataSpeechs `json:"speech_data"`
FlowLog []protocol.ChanceFlowLog `json:"flow_log"`
}
//机会详情
func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error) {
var (
chanceInfo *models.Chance
err error
returnData = ResponseChanceInfo{
BaseContent: make([]protocol.InputElement, 0),
ExtraContent: make([]protocol.InputElement, 0),
ImageData: make([]models.ChanceDataImage, 0),
VideoData: make([]models.ChanceDataVideos, 0),
SpeechData: make([]models.ChanceDataSpeechs, 0),
FlowLog: make([]protocol.ChanceFlowLog, 0),
}
)
chanceInfo, err = models.GetChanceById(chanceid)
if err != nil {
log.Error("获取机会详情失败:%s", err)
return returnData, protocol.NewErrWithMessage("1")
}
if chanceInfo.CompanyId != companyid {
log.Error("机会的公司不匹配")
return returnData, protocol.NewErrWithMessage("1")
}
var (
chanceContent []protocol.InputElement
)
json.Unmarshal([]byte(chanceInfo.Content), &chanceContent)
for i := range chanceContent {
if chanceContent[i].SectionType == 1 {
returnData.BaseContent = append(returnData.BaseContent, chanceContent[i])
}
if chanceContent[i].SectionType == 2 {
returnData.ExtraContent = append(returnData.ExtraContent, chanceContent[i])
}
}
return returnData, nil
}
... ...
... ... @@ -332,16 +332,27 @@ func UserHasCompanys(userid int64) ([]protocol.MeCompany, error) {
return mecompanys, nil
}
func GetUserHasMenu(userid, companyid int64) ([]protocol.PermissionItem, error) {
func GetUserHasMenu(userid, companyid int64) ([]protocol.ResponseUserHasMenu, error) {
var (
list = make([]protocol.PermissionItem, 0)
list = make([]protocol.ResponseUserHasMenu, 0)
err error
companyinfo *models.Company
ucompany *models.UserCompany
)
const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code
FROM menu WHERE enabled=1 ORDER BY sort `
err = utils.ExecuteQueryAll(&list, datasql)
if err != nil {
log.Error("EXECUTE SQL err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
companyinfo, err = models.GetCompanyById(companyid)
if companyinfo.AdminId == userid {
return getAdminHasMenu()
//主管人员
for i := range list {
list[i].StatusYes()
}
return list, nil
}
//非主管人员
ucompany, err = models.GetUserCompanyBy(userid, companyid)
... ... @@ -349,43 +360,43 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.PermissionItem, error)
log.Error("user_company数据获取失败:%s", err)
return list, protocol.NewErrWithMessage("1")
}
const datasql string = `SELECT DISTINCT(a.menu_id)
const datasql2 string = `SELECT DISTINCT(a.menu_id)
FROM role_menu AS a
JOIN user_role AS b ON a.role_id = b.role_id
JOIN role AS c ON a.role_id = c.id
WHERE b.user_company_id=? AND c.delete_at =0 `
var menuids []string
var menuids []int64
err = utils.ExecuteQueryAll(&menuids, datasql, ucompany.Id)
if err != nil {
log.Error("EXECUTE SQL err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
datasql2 := `SELECT id,name,icon,parent_id,senior_status,sort,code
FROM menu WHERE enabled=1 AND id in(%s) ORDER BY sort`
datasql2 = fmt.Sprintf(datasql2, strings.Join(menuids, ","))
err = utils.ExecuteQueryAll(&list, datasql2)
if err != nil {
log.Error("EXECUTE SQL err:%s", err)
return nil, protocol.NewErrWithMessage("1")
for i := range list {
for _, v := range menuids {
if list[i].Id == v {
list[i].StatusYes()
break
}
}
}
return list, nil
}
//主管拥有全部的菜单
func getAdminHasMenu() ([]protocol.PermissionItem, error) {
const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code
FROM menu WHERE enabled=1 ORDER BY sort `
var (
list = make([]protocol.PermissionItem, 0)
err error
)
err = utils.ExecuteQueryAll(&list, datasql)
if err != nil {
log.Error("EXECUTE SQL err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
return list, nil
}
// func getAdminHasMenu() ([]protocol.PermissionItem, error) {
// const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code
// FROM menu WHERE enabled=1 ORDER BY sort `
// var (
// list = make([]protocol.PermissionItem, 0)
// err error
// )
// err = utils.ExecuteQueryAll(&list, datasql)
// if err != nil {
// log.Error("EXECUTE SQL err:%s", err)
// return nil, protocol.NewErrWithMessage("1")
// }
// return list, nil
// }
func LoginAuthBySmsCode(phone string, code string) (protocol.LoginAuthToken, error) {
var (
... ...
... ... @@ -157,3 +157,30 @@ func SelectorUserAndDepartment(departid int64, companyId int64) (*protocol.Depar
departsUser.Departments = departbase
return &departsUser, nil
}
//获取机会二级分类
func SelectGetTemplateList(companyid int64) []protocol.TemplateBase {
datasql := `SELECT id AS template_id,chance_type_id,name
FROM audit_template
where company_id = ? AND enable_status = 1`
data := make([]protocol.TemplateBase, 0)
err := utils.ExecuteQueryAll(&data, datasql, companyid)
if err != nil {
log.Error("EXECUTE SQL ERR :%s", err)
}
return data
}
//获取机会一级级分类
func SeleteGetChanceTypeList(companyid int64) []protocol.ChanceTypeBase {
datasql := ` SELECT id AS chance_type_id,name
FROM chance_type
WHERE company_id = ?`
data := make([]protocol.ChanceTypeBase, 0)
err := utils.ExecuteQueryAll(&data, datasql, companyid)
if err != nil {
log.Error("EXECUTE SQL ERR :%s", err)
}
return data
}
... ...
... ... @@ -141,13 +141,18 @@ func RoleMenuEdit(companyid int64, roleId int64, menuids []int64) error {
return protocol.NewErrWithMessage("1")
}
}
opptionbt, _ := json.Marshal(&PermissionOptionBase{Check: 1})
for _, v := range addMenu {
m := models.RoleMenu{
RoleId: roleId,
MenuId: v.Id,
Code: v.Code,
Opption: string(opptionbt),
}
if fn, ok := CodePermissionObject[v.Code]; ok {
obj := fn()
optionbt, _ := json.Marshal(obj)
m.Opption = string(optionbt)
}
if _, err = o.Insert(&m); err != nil {
log.Error("添加角色和菜单关系失败:%s", err)
... ... @@ -251,7 +256,7 @@ func GetSetOpportunity(roleid int64, companyid int64) (*OptionOpportunity, error
log.Error("获取部门失败GetDepartmentById(%d):%s", v.Id, err)
continue
}
if d.DeleteAt.Unix() <= 0 {
if d.DeleteAt.Unix() > 0 {
//部门已被删除
continue
}
... ...
... ... @@ -20,7 +20,9 @@ var (
)
func NewPermissionOptionBase() PermissionOptionObject {
return &PermissionOptionBase{}
return &PermissionOptionBase{
Check: 1,
}
}
func (p *PermissionOptionBase) ValidDefault(obj UserObject) bool {
... ... @@ -120,6 +122,7 @@ var (
func NewOptionOpportunity() PermissionOptionObject {
return &OptionOpportunity{
Check: OpportunityCheckLv4,
CheckMap: make(map[int]int),
CheckOption: CheckOpp{
Departments: []CheckDeparment{},
... ...