作者 唐旭辉

提交保存

@@ -229,12 +229,27 @@ type CategoryEditSortResponse struct { @@ -229,12 +229,27 @@ type CategoryEditSortResponse struct {
229 //RequestAuditList 机会管理-获取机会列表 229 //RequestAuditList 机会管理-获取机会列表
230 type RequestAuditList struct { 230 type RequestAuditList struct {
231 RequestPageInfo 231 RequestPageInfo
  232 + ChanceTypeId int `json:"chance_type_id"` //一级分类
  233 + TempalteId int `json:"template_id"` // 二级分类
  234 + PublishStatus int `json:"publish_status"` //公开状态
  235 + ReviewStatus int `json:"review_status"` //
  236 + EnableStatus int `json:"enable_status"` //关闭状态
  237 + DepartmentID int `json:"department_id"` //提交部门
  238 + CreateTimeBegin int `json:"create_time_begin"` //
  239 + CreateTimeEnd int `json:"create_time_end"` //
  240 + Code string `json:"code"` //机会编码
232 } 241 }
233 242
234 type ResponseAuditList struct { 243 type ResponseAuditList struct {
235 - Id int64 `json:"id"` //机会的id  
236 - ChanceType1 string `json:"chance_type_1"` //一级分类  
237 - ChanceType2 string `json:"chance_type_2"` //二级分类 244 + ResponsePageInfo
  245 + List []RspAuditList `json:"lists"`
  246 +}
  247 +
  248 +type RspAuditList struct {
  249 + Id int64 `json:"id"` //机会的id
  250 + Code string `json:"code"`
  251 + ChanceType string `json:"chance_type"` //一级分类
  252 + TemplateName string `json:"template_name"` //二级分类
238 UserName string `json:"user_name"` // 提交人 253 UserName string `json:"user_name"` // 提交人
239 Department string `json:"department"` //提交部门 254 Department string `json:"department"` //提交部门
240 CreateTime int64 `json:"create_time"` //提交时间 255 CreateTime int64 `json:"create_time"` //提交时间
@@ -242,4 +257,6 @@ type ResponseAuditList struct { @@ -242,4 +257,6 @@ type ResponseAuditList struct {
242 PublishStatusName string `json:"publish_status_name"` // 257 PublishStatusName string `json:"publish_status_name"` //
243 ReviewStatus int `json:"review_status"` //审批状态 258 ReviewStatus int `json:"review_status"` //审批状态
244 ReviewStatusName string `json:"review_status_name"` 259 ReviewStatusName string `json:"review_status_name"`
  260 + EnableStatus int `json:"enable_status"`
  261 + EnableStatusName int `json:"enable_status_name"`
245 } 262 }
1 package audit 1 package audit
2 2
3 -func GetAuditList() error {  
4 - /*  
5 - SELECT user_id,department_id,audit_template_id,chance_type_id,publish_status,create_at  
6 - ,review_status,enable_status,discovery_score,comment_total  
7 - FROM chance  
8 - */  
9 -  
10 - return nil 3 +import (
  4 + "oppmg/common/log"
  5 + "oppmg/models"
  6 + "oppmg/protocol"
  7 + "oppmg/utils"
  8 + "strings"
  9 +)
  10 +
  11 +type SqlData struct {
  12 + UserId int64 `orm:"column(user_id)"`
  13 + DepartmentId int64 `orm:"column(department_id)"`
  14 + AuditTemplateId int64 `orm:"column(audit_template_id)"`
  15 + ChanceTypeId int `orm:"column(chance_type_id)"`
  16 + PublishStatus int `orm:"column(publish_status)"`
  17 + CreateAt string `orm:"column(create_at);type(timestamp)"`
  18 + ReviewStatus int `orm:"column(review_status)"`
  19 + EnableStatus int `orm:"column(enable_status)"`
  20 + DiscoveryScore string `orm:"column(discovery_score)"`
  21 + CommentTotal string `orm:"column(comment_total)"`
  22 +}
  23 +
  24 +func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.ResponseAuditList, error) {
  25 +
  26 + var (
  27 + datasql = strings.Builder{}
  28 + countsql = strings.Builder{}
  29 + data []SqlData
  30 + cnt int
  31 + err error
  32 + //listdata = make([]protocol.RspAuditList, 0)
  33 + )
  34 + returnData := protocol.ResponseAuditList{
  35 + ResponsePageInfo: protocol.ResponsePageInfo{
  36 + TotalPage: 0,
  37 + CurrentPage: param.PageIndex,
  38 + },
  39 + List: make([]protocol.RspAuditList, 0),
  40 + }
  41 + dataStart := (param.PageIndex - 1) * param.PageSize
  42 + datasql.WriteString(`SELECT user_id,department_id,audit_template_id,chance_type_id
  43 + ,publish_status,create_at,review_status,enable_status
  44 + ,discovery_score,comment_total
  45 + FROM chance
  46 + limit ?,? `)
  47 +
  48 + countsql.WriteString(`SELECT count(*) FROM chance`)
  49 + err = utils.ExecuteQueryOne(&cnt, countsql.String())
  50 + if err != nil {
  51 + log.Error("EXCUTE SQL ERR:%s", err)
  52 + return returnData, nil
  53 + }
  54 + if cnt <= 0 {
  55 + return returnData, nil
  56 + }
  57 + err = utils.ExecuteQueryOne(&data, datasql.String(), dataStart, param.PageSize)
  58 + if err != nil {
  59 + log.Error("EXCUTE SQL ERR:%s", err)
  60 + return returnData, nil
  61 + }
  62 + for _, v := range data {
  63 + item := protocol.RspAuditList{}
  64 + if u, err := models.GetUserById(v.UserId); err == nil {
  65 + item.UserName = u.NickName
  66 + }
  67 + if d, err := models.GetDepartmentById(v.DepartmentId); err == nil {
  68 + item.Department = d.Name
  69 + }
  70 + if at, err := models.GetAuditTemplateById(v.AuditTemplateId); err == nil {
  71 + item.TemplateName = at.Name
  72 + item.Code = at.Code
  73 + }
  74 +
  75 + if ct, err := models.GetChanceTypeById(v.ChanceTypeId); err == nil {
  76 + item.ChanceType = ct.Name
  77 + }
  78 + returnData.List = append(returnData.List, item)
  79 +
  80 + }
  81 + return returnData, nil
11 } 82 }
@@ -58,6 +58,32 @@ var routerPermission = map[string]PermissionBase{ @@ -58,6 +58,32 @@ var routerPermission = map[string]PermissionBase{
58 "/v1/rbac/menu/edit": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"}, 58 "/v1/rbac/menu/edit": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"},
59 "/v1/rbac/menu/opportunity": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"}, 59 "/v1/rbac/menu/opportunity": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"},
60 "/v1/rbac/menu/opportunity/edit": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"}, 60 "/v1/rbac/menu/opportunity/edit": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"},
  61 + "/v1/user/list": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE, ActionName: "default"},
  62 + "/v1/user/add": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE, ActionName: "default"},
  63 + "/v1/user/edit": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE, ActionName: "default"},
  64 + "/v1/user/delete": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE, ActionName: "default"},
  65 + "/v1/user/allow_forbid": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE, ActionName: "default"},
  66 + "/v1/user/info": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE, ActionName: "default"},
  67 + "/v1/bulletin/add": PermissionBase{CodeName: M_SYSTEM_ANNOUNCEMENT, ActionName: "default"},
  68 + "/v1/bulletin/list": PermissionBase{CodeName: M_SYSTEM_ANNOUNCEMENT, ActionName: "default"},
  69 + "/v1/bulletin/get": PermissionBase{CodeName: M_SYSTEM_ANNOUNCEMENT, ActionName: "default"},
  70 + "/v1/bulletin/update": PermissionBase{CodeName: M_SYSTEM_ANNOUNCEMENT, ActionName: "default"},
  71 + "/v1/bulletin/operate": PermissionBase{CodeName: M_SYSTEM_ANNOUNCEMENT, ActionName: "default"},
  72 + "/v1/bulletin/feedbacks": PermissionBase{CodeName: M_SYSTEM_ANNOUNCEMENT, ActionName: "default"},
  73 + "/v1/bulletin/exportFeedBacks": PermissionBase{CodeName: M_SYSTEM_ANNOUNCEMENT, ActionName: "default"},
  74 + "/v1/template/add": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"},
  75 + "/v1/template/sortCategory": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"},
  76 + "/v1/template/list": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"},
  77 + "/v1/template/get": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"},
  78 + "/v1/template/update": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"},
  79 + "/v1/template/delete": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"},
  80 + "/v1/template/editVisible": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"},
  81 + "/v1/template/editEnable": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"},
  82 + "/v1/template/editSort": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"},
  83 + "/v1/template/operateCategory": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"},
  84 + "/v1/template/deleteCategory": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"},
  85 + "/v1/config/score": PermissionBase{CodeName: M_SYSTEM_RATING, ActionName: "default"},
  86 + "/v1/config/score/get": PermissionBase{CodeName: M_SYSTEM_RATING, ActionName: "default"},
61 } 87 }
62 88
63 type CodeToObject func() PermissionOptionObject 89 type CodeToObject func() PermissionOptionObject