chance.go 23.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912
package v1

import (
	"encoding/json"
	"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
	"opp/controllers"
	"opp/protocol"
	"opp/services/chance"
	"strings"
)

type ChanceController struct {
	controllers.BaseController
}

//IComment 我来评论
// @router /iComment [post]
func (this *ChanceController) IComment() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ICommentRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.IComment(header, request))
}

//IComments
// @router /iComments [post]
func (this *ChanceController) IComments() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ICommentsRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.IComments(header, request))
}

//Comments 评论列表
// @router /comments [post]
func (this *ChanceController) Comments() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.CommentsRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	//request.SourceType = protocol.SourceTypeChance
	msg = protocol.NewReturnResponse(chance.Comments(header, request))
}

//Thumbsups 点赞列表
// @router /thumbsups [post]
func (this *ChanceController) Thumbsups() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ThumbsupsRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.Thumbsups(header, request))
}

//Favorite
// @router /favorite [post]
func (this *ChanceController) Favorite() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.FavoriteRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.Favorite(header, request))
}

//CommentDetailsSingle
//@router /commentDetailsSingle [post]
func (this *ChanceController) CommentDetailsSingle() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.CommentDetailsSingleRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.CommentDetailsSingle(header, request))
}

//CommentDetailsMulti
//@router /commentDetailsMulti [post]
func (this *ChanceController) CommentDetailsMulti() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.CommentDetailsMultiRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.CommentDetailsMulti(header, request))
}

//SympathyAction 机会点赞/收藏
//@router /sympathyAction [post]
func (this *ChanceController) SympathyAction() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.SympathyActionRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	if !(request.SourceType == protocol.SourceTypeChance || request.SourceType == protocol.SourceTypeComment) {
		msg = protocol.BadRequestParam(2)
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.SympathyAction(header, request))
}

//ChanceType
//@router /chanceType [post]
func (this *ChanceController) ChanceType() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChanceTypeRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.ChanceType(header, request))
}

//ChanceReserveType 机会储备类型
//@router /chanceReserveType [post]
func (this *ChanceController) ChanceReserveType() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChanceReserveTypeRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.ChanceReserveType(header, request))
}

//Templates
//@router /templates [post]
func (this *ChanceController) Templates() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.TemplatesRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.Templates(header, request))
}

//Template 模板详情
//@router /template [post]
func (this *ChanceController) Template() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.TemplateRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.Template(header, request))
}

//ChanceSubmit 提交机会
//@router /submit [post]
func (this *ChanceController) ChanceSubmit() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChanceSubmitRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	if e := request.SelfChecks.SetSelfChecksLevel1ByRule(); e != nil {
		log.Error(e)
		msg = protocol.NewReturnResponse(nil, e)
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.ChanceSubmit(header, request))
}

//ChanceUpdate 机会更新
//@router /update [post]
func (this *ChanceController) ChanceUpdate() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChanceUpdateRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	if e := request.SelfChecks.SetSelfChecksLevel1ByRule(); e != nil {
		log.Error(e)
		msg = protocol.NewReturnResponse(nil, e)
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.ChanceUpdate(header, request))
}

//ChanceStatistics 机会统计
//@router /statistics [post]
func (this *ChanceController) ChanceStatistics() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChanceStatisticsRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.ChanceStatistics(header, request))
}

//MySubmitChance 我提交的机会
//@router /mySubmitChance [post]
func (this *ChanceController) MySubmitChance() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.MySubmitChanceRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.MySubmitChance(header, request))
}

//ChanceDetail 机会详情
//@router /chanceDetail [post]
func (this *ChanceController) ChanceDetail() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChanceDetailRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	if request.IsDraft {
		msg = protocol.NewReturnResponse(chance.ChanceDraftDetail(header, request))
		return
	}
	msg = protocol.NewReturnResponse(chance.ChanceDetail(header, request))
}

//ChanceApproveProcess 机会审核流程信息
//func(this *ChanceController)ChanceApproveProcess(){
//	var msg *protocol.ResponseMessage
//	defer func() {
//		this.Resp(msg)
//	}()
//	var request *protocol.ChanceApproveProcessRequest
//	if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{
//		log.Error(err)
//		msg = protocol.BadRequestParam(1)
//		return
//	}
//	if b,m :=this.Valid(request);!b{
//		msg = m
//		return
//	}
//	header := controllers.GetRequestHeader(this.Ctx)
//	msg = protocol.NewReturnResponse(chance.ChanceApproveProcess(header,request))
//}

//ChanceDelete 机会删除
//@router /delete [post]
func (this *ChanceController) ChanceDelete() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChanceDeleteRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.ChanceDelete(header, request))
}

//ChanceApprove  机会审核
//@router /approve [post]
func (this *ChanceController) ChanceApprove() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChanceApproveRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(2)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	if request.ReviewStatus == protocol.ReviewStatusPass {
		status := request.ApproveData.PublicData.PublishStatus
		if !(status == protocol.NoPublic || status == protocol.PublicToDepartment || status == protocol.PublicToCompany) {
			msg = protocol.BadRequestParam(5204)
			return
		}
	}
	if request.ReviewStatus != protocol.ReviewStatusReturn && len(request.Reason) > 0 {
		msg = protocol.BadRequestParamWithMessage(2, "机会退回时才需要填写理由")
		log.Error(msg)
		return
	}
	if e := request.SelfChecks.SetSelfChecksLevel1ByRule(); e != nil {
		log.Error(e)
		msg = protocol.NewReturnResponse(nil, e)
		return
	}
	if !(request.Type == 0 || request.Type == 1) {
		msg = protocol.BadRequestParamWithMessage(2, "机会类型错误 (0,1)")
		log.Error(msg)
		return
	}
	if len([]rune(request.Reason)) > 100 {
		msg = protocol.BadRequestParamWithMessage(2, "填写理由长度有误,最多输入100个字符")
		log.Error(msg)
		return
	}
	request.Reason = strings.TrimSpace(request.Reason)
	header := controllers.GetRequestHeader(this.Ctx)
	request.ApproveData.Reason = request.Reason
	msg = protocol.NewReturnResponse(chance.ChanceApprove(header, request))
}

//ChanceChangePublish 修改公开状态
//@router /changePublish [post]
func (this *ChanceController) ChanceChangePublish() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChanceChangePublishRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.ChanceChangePublish(header, request))
}

//ChanceChangeScore 修改评分
//@router /changeScore [post]
func (this *ChanceController) ChanceChangeScore() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChanceChangeScoreRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.ChanceChangeScore(header, request))
}

//ChanceCalculateScore 计算发现分
//@router /calculateScore [post]
func (this *ChanceController) ChanceCalculateScore() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChanceCalculateScoreRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.ChanceCalculateScore(header, request))
}

//MyApproveChance 我审核的机会
//@router /myApproveChance [post]
func (this *ChanceController) MyApproveChance() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.MyApproveChanceRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.MyApproveChance(header, request))
}

//MyCollectChance 我的收藏
//@router /myCollectChance [post]
func (this *ChanceController) MyCollectChance() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.MyCollectChanceRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.MyCollectChance(header, request))
}

//MyThumbUpChance  我点赞的机会
//@router /myThumbUpChance [post]
func (this *ChanceController) MyThumbUpChance() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.MyThumbUpChanceRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.MyThumbUpChance(header, request))
}

//MyComment 我的评论
//@router /myComment [post]
func (this *ChanceController) MyComment() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.MyCommentRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.MyComment(header, request))
}

//ChancePool 机会池
//@router /chancePool [post]
func (this *ChanceController) ChancePool() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChancePoolRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	request.IncludeSubDepartment = false
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.ChancePool(header, request))
}

//ChanceReservePool 储备池
//@router /chanceReservePool [post]
func (this *ChanceController) ChanceReservePool() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChancePoolRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	request.Type = 1
	msg = protocol.NewReturnResponse(chance.ChancePool(header, request))
}

//SearchChance 搜索
//@router /search [post]
func (this *ChanceController) SearchChance() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChancePoolRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	if len(strings.TrimSpace(request.KeyWord)) == 0 {
		msg = protocol.BadRequestParamWithMessage(2, "请输入机会内容、员工姓名")
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.ChancePool(header, request))
}

//ChanceReviseDetail 机会补充详情
//@router /chanceReviseDetail [post]
func (this *ChanceController) ChanceReviseDetail() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.ChanceReviseDetailRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.ChanceReviseDetail(header, request))
}

//CheckQuestions 自查问题列表
//@router /checkQuestions [post]
func (this *ChanceController) CheckQuestions() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.CheckQuestionsRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.CheckQuestions(header, request))
}

//SiftingPool 筛选池
//@router /siftingPool [post]
func (this *ChanceController) SiftingPool() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.SiftingPoolRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	if !(request.SubmitStatus == protocol.Submiting || request.SubmitStatus == protocol.Submited) {
		msg = protocol.BadRequestParamWithMessage(2, "obj.SubmitStatus must in (0,1)")
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.SiftingPool(header, request))
}

//SiftingResults 筛选结果
//@router /siftingResults [post]
func (this *ChanceController) SiftingResults() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.SiftingResultsRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.SiftingResults(header, request))
}

//SubmitChecks 提交自查
//@router /submitSiftingResult [post]
func (this *ChanceController) SubmitChecks() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.SubmitChecksRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.SubmitChecks(header, request))
}

//SiftingResultsItemHistory 筛选历史
//@router /siftingResults/itemHistory [post]
func (this *ChanceController) SiftingResultsItemHistory() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.SiftingResultsItemHistoryRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.SiftingResultsItemHistory(header, request))
}

//SiftingResultsItemDetail 筛选历史详情
//@router /siftingResults/itemDetail [post]
func (this *ChanceController) SiftingResultsItemDetail() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.SiftingResultsItemDetailRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.SiftingResultsItemDetail(header, request))
}

//DraftSaveChance 机会保存到草稿箱
//@router /draftSaveChance [post]
func (this *ChanceController) DraftSaveChance() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.DraftSaveChanceRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	request.SelfChecks.SetSelfChecksLevel1ByRule()
	msg = protocol.NewReturnResponse(chance.DraftSaveChance(header, request))
}

//DraftDelete 草稿删除(清空)
//@router /draftDelete [post]
func (this *ChanceController) DraftDelete() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.DraftDeleteRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.DraftDelete(header, request))
}

//DraftByChance 草稿箱-机会列表
//@router /draftByChance [post]
func (this *ChanceController) DraftByChance() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocol.DraftByChanceRequest
	if err := json.Unmarshal(this.ByteBody, &request); err != nil {
		log.Error(err)
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := controllers.GetRequestHeader(this.Ctx)
	msg = protocol.NewReturnResponse(chance.DraftByChance(header, request))
}