作者 yangfu

机会统计

@@ -122,9 +122,9 @@ func FilterComm(ctx *context.Context) { @@ -122,9 +122,9 @@ func FilterComm(ctx *context.Context) {
122 // return 122 // return
123 //} 123 //}
124 124
125 - if !CheckSign(ctx) {  
126 - return  
127 - } 125 + //if !CheckSign(ctx) {
  126 + // return
  127 + //}
128 //2.检查token是否有效 128 //2.检查token是否有效
129 if !CheckToken(ctx) { 129 if !CheckToken(ctx) {
130 return 130 return
@@ -230,3 +230,24 @@ func (this *ChanceController) ChanceSubmit() { @@ -230,3 +230,24 @@ func (this *ChanceController) ChanceSubmit() {
230 } 230 }
231 msg = protocol.NewReturnResponse(chance.ChanceSubmit(header, request)) 231 msg = protocol.NewReturnResponse(chance.ChanceSubmit(header, request))
232 } 232 }
  233 +
  234 +//ChanceStatistics
  235 +//@router /statistics [post]
  236 +func (this *ChanceController) ChanceStatistics() {
  237 + var msg *protocol.ResponseMessage
  238 + defer func() {
  239 + this.Resp(msg)
  240 + }()
  241 + var request *protocol.ChanceStatisticsRequest
  242 + if err := json.Unmarshal(this.ByteBody, &request); err != nil {
  243 + log.Error(err)
  244 + msg = protocol.BadRequestParam(1)
  245 + return
  246 + }
  247 + if b, m := this.Valid(request); !b {
  248 + msg = m
  249 + return
  250 + }
  251 + header := controllers.GetRequestHeader(this.Ctx)
  252 + msg = protocol.NewReturnResponse(chance.ChanceStatistics(header, request))
  253 +}
@@ -158,3 +158,24 @@ func (this *UserController) UserInfo() { @@ -158,3 +158,24 @@ func (this *UserController) UserInfo() {
158 header := controllers.GetRequestHeader(this.Ctx) 158 header := controllers.GetRequestHeader(this.Ctx)
159 msg = protocol.NewReturnResponse(user.UserInfo(header, request)) 159 msg = protocol.NewReturnResponse(user.UserInfo(header, request))
160 } 160 }
  161 +
  162 +//UserStatistics 用户中心-统计信息
  163 +//@router /statistics [post]
  164 +func (this *UserController) UserStatistics() {
  165 + var msg *protocol.ResponseMessage
  166 + defer func() {
  167 + this.Resp(msg)
  168 + }()
  169 + var request *protocol.UserStatisticsRequest
  170 + if err := json.Unmarshal(this.ByteBody, &request); err != nil {
  171 + log.Error(err)
  172 + msg = protocol.BadRequestParam(1)
  173 + return
  174 + }
  175 + if b, m := this.Valid(request); !b {
  176 + msg = m
  177 + return
  178 + }
  179 + header := controllers.GetRequestHeader(this.Ctx)
  180 + msg = protocol.NewReturnResponse(user.UserStatistics(header, request))
  181 +}
@@ -109,7 +109,7 @@ type Template struct { @@ -109,7 +109,7 @@ type Template struct {
109 109
110 type Form struct { 110 type Form struct {
111 Id int `json:"id"` 111 Id int `json:"id"`
112 - Lable string `json:"lable"` 112 + Label string `json:"label"`
113 InputType string `json:"inputType"` 113 InputType string `json:"inputType"`
114 SectionType int8 `json:"sectionType"` 114 SectionType int8 `json:"sectionType"`
115 Value string `json:"value"` 115 Value string `json:"value"`
@@ -141,10 +141,24 @@ type Picture struct { @@ -141,10 +141,24 @@ type Picture struct {
141 } 141 }
142 type Video struct { 142 type Video struct {
143 Path string `json:"path"` 143 Path string `json:"path"`
144 - Cover string `json:"cover"` //封面 144 + Cover Cover `json:"cover"` //封面
145 Duration int `json:"duration"` 145 Duration int `json:"duration"`
146 } 146 }
147 147
148 type AuditConfig struct { 148 type AuditConfig struct {
149 NoApprover int8 `json:"no_approver"` //审核人空时:【1:自动通过】【2:转交给管理员】 149 NoApprover int8 `json:"no_approver"` //审核人空时:【1:自动通过】【2:转交给管理员】
150 } 150 }
  151 +
  152 +/*ChanceStatistics */
  153 +type ChanceStatisticsRequest struct {
  154 +}
  155 +type ChanceStatisticsResponse struct {
  156 + ChanceTotal int `json:"chanceTotal"`
  157 + List []ChanceTotalItem `json:"list"`
  158 +}
  159 +
  160 +type ChanceTotalItem struct {
  161 + Id int `json:"id"` //类型
  162 + Name string `json:"name"` //总数
  163 + Total int `json:"total"`
  164 +}
@@ -21,3 +21,18 @@ const ( @@ -21,3 +21,18 @@ const (
21 InValid = 0 //无效 21 InValid = 0 //无效
22 Valid = 1 //有效 22 Valid = 1 //有效
23 ) 23 )
  24 +
  25 +//统计 注意:只能往后面加,不然会乱序
  26 +const (
  27 + CollectStatic = 1 << iota //收藏
  28 + ZanStatic //点赞
  29 + CommentStatic //评论
  30 + MyCommitChance //我提交的机会
  31 + MyCommitChanceWait //我提交的机会-待审批
  32 + MyCommitChanceReturn //我提交的机会-退回
  33 + MyCommitChancePass //我提交的机会-已通过
  34 + MyAuditChance //我审核的机会
  35 + MyAuditChanceWait //我审核的机会-待我审批
  36 + MyAuditChancePass //我审核的机会-待我审批
  37 + MyAuditChanceReturn //我审核的机会-已退回
  38 +)
@@ -68,18 +68,35 @@ type User struct { @@ -68,18 +68,35 @@ type User struct {
68 Companys []Company `json:"companys"` 68 Companys []Company `json:"companys"`
69 } 69 }
70 70
  71 +//公司
71 type Company struct { 72 type Company struct {
72 Id int64 `json:"id"` 73 Id int64 `json:"id"`
73 Name string `json:"name"` 74 Name string `json:"name"`
74 } 75 }
75 76
  77 +//部门
76 type Dep struct { 78 type Dep struct {
77 Id int `json:"id"` 79 Id int `json:"id"`
78 Name string `json:"name"` 80 Name string `json:"name"`
79 } 81 }
80 82
  83 +//岗位
81 type Job struct { 84 type Job struct {
82 Id int `json:"id"` 85 Id int `json:"id"`
83 Name string `json:"name"` 86 Name string `json:"name"`
84 Level int `json:"level"` 87 Level int `json:"level"`
85 } 88 }
  89 +
  90 +//用户统计信息
  91 +/*UserStatistics */
  92 +type UserStatisticsRequest struct {
  93 + TypeTotal int64 `json:"typeTotal" valid:"Required"`
  94 +}
  95 +type UserStatisticsResponse struct {
  96 + Totals []TypeTotalItem `json:"totals"`
  97 +}
  98 +type TypeTotalItem struct {
  99 + Type int64 `json:"type"` //类型
  100 + Total int `json:"total"` //总数
  101 + HaveUpdate int `json:"haveUpdate"` //是否含有更新(0无更新,1有更新)
  102 +}
@@ -113,6 +113,14 @@ func init() { @@ -113,6 +113,14 @@ func init() {
113 113
114 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 114 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
115 beego.ControllerComments{ 115 beego.ControllerComments{
  116 + Method: "ChanceStatistics",
  117 + Router: `/statistics`,
  118 + AllowHTTPMethods: []string{"post"},
  119 + MethodParams: param.Make(),
  120 + Params: nil})
  121 +
  122 + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
  123 + beego.ControllerComments{
116 Method: "ChanceSubmit", 124 Method: "ChanceSubmit",
117 Router: `/submit`, 125 Router: `/submit`,
118 AllowHTTPMethods: []string{"post"}, 126 AllowHTTPMethods: []string{"post"},
@@ -273,6 +281,14 @@ func init() { @@ -273,6 +281,14 @@ func init() {
273 281
274 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], 282 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
275 beego.ControllerComments{ 283 beego.ControllerComments{
  284 + Method: "UserStatistics",
  285 + Router: `/statistics`,
  286 + AllowHTTPMethods: []string{"post"},
  287 + MethodParams: param.Make(),
  288 + Params: nil})
  289 +
  290 + beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
  291 + beego.ControllerComments{
276 Method: "SwitchCompany", 292 Method: "SwitchCompany",
277 Router: `/switchCompany`, 293 Router: `/switchCompany`,
278 AllowHTTPMethods: []string{"post"}, 294 AllowHTTPMethods: []string{"post"},
@@ -195,7 +195,7 @@ func Templates(header *protocol.RequestHeader, request *protocol.TemplatesReques @@ -195,7 +195,7 @@ func Templates(header *protocol.RequestHeader, request *protocol.TemplatesReques
195 form := forms[j] 195 form := forms[j]
196 template.FormList[j] = &protocol.Form{ 196 template.FormList[j] = &protocol.Form{
197 Id: form.Id, 197 Id: form.Id,
198 - Lable: form.Label, 198 + Label: form.Label,
199 Value: "", 199 Value: "",
200 InputType: form.InputType, 200 InputType: form.InputType,
201 SectionType: form.Section, 201 SectionType: form.Section,
@@ -562,3 +562,23 @@ func getParentDepartmentors(pid int) (ids []int64) { @@ -562,3 +562,23 @@ func getParentDepartmentors(pid int) (ids []int64) {
562 } 562 }
563 return getParentDepartmentors(department.ParentId) 563 return getParentDepartmentors(department.ParentId)
564 } 564 }
  565 +
  566 +//首页机会池统计
  567 +func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceStatisticsRequest) (rsp *protocol.ChanceStatisticsResponse, err error) {
  568 + var (
  569 + chanceType []*models.ChanceType
  570 + )
  571 + if chanceType, err = models.GetChanceTypeAll(header.CompanyId); err != nil {
  572 + log.Error(err)
  573 + return
  574 + }
  575 + rsp = &protocol.ChanceStatisticsResponse{}
  576 + for i := range chanceType {
  577 + item := chanceType[i]
  578 + rsp.List = append(rsp.List, protocol.ChanceTotalItem{
  579 + Id: item.Id,
  580 + Name: item.Name,
  581 + })
  582 + }
  583 + return
  584 +}
@@ -315,3 +315,19 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) @@ -315,3 +315,19 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest)
315 } 315 }
316 return 316 return
317 } 317 }
  318 +
  319 +//用户中心-统计信息
  320 +func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatisticsRequest) (rsp *protocol.UserStatisticsResponse, err error) {
  321 + var (
  322 + flag int64
  323 + )
  324 + rsp = &protocol.UserStatisticsResponse{}
  325 + for flag = 1; flag < (1 << 20); flag = flag << 1 {
  326 + if flag&request.TypeTotal > 0 {
  327 + rsp.Totals = append(rsp.Totals, protocol.TypeTotalItem{
  328 + Type: flag,
  329 + })
  330 + }
  331 + }
  332 + return
  333 +}