作者 yangfu

发布机会

@@ -207,7 +207,7 @@ func (this *ChanceController) Templates() { @@ -207,7 +207,7 @@ func (this *ChanceController) Templates() {
207 } 207 }
208 208
209 //ChanceSubmit 209 //ChanceSubmit
210 -//@router /chanceSubmit [post] 210 +//@router /submit [post]
211 func (this *ChanceController) ChanceSubmit() { 211 func (this *ChanceController) ChanceSubmit() {
212 var msg *protocol.ResponseMessage 212 var msg *protocol.ResponseMessage
213 defer func() { 213 defer func() {
@@ -224,5 +224,9 @@ func (this *ChanceController) ChanceSubmit() { @@ -224,5 +224,9 @@ func (this *ChanceController) ChanceSubmit() {
224 return 224 return
225 } 225 }
226 header := controllers.GetRequestHeader(this.Ctx) 226 header := controllers.GetRequestHeader(this.Ctx)
  227 + if request.Id>0{
  228 + msg = protocol.NewReturnResponse(chance.ChanceUpdate(header, request))
  229 + return
  230 + }
227 msg = protocol.NewReturnResponse(chance.ChanceSubmit(header, request)) 231 msg = protocol.NewReturnResponse(chance.ChanceSubmit(header, request))
228 } 232 }
@@ -34,6 +34,8 @@ func SetStructValueByType(s interface{}, columnType string, columnValue interfac @@ -34,6 +34,8 @@ func SetStructValueByType(s interface{}, columnType string, columnValue interfac
34 setValue.SetFloat(float64(columnValueV.Float())) 34 setValue.SetFloat(float64(columnValueV.Float()))
35 case reflect.String: 35 case reflect.String:
36 setValue.SetString(columnValueV.String()) 36 setValue.SetString(columnValueV.String())
  37 + case reflect.Struct:
  38 + setValue.Set(columnValueV)
37 default: 39 default:
38 return errors.New("columnValue err for:" + columnType) 40 return errors.New("columnValue err for:" + columnType)
39 } 41 }
@@ -30,8 +30,8 @@ func init() { @@ -30,8 +30,8 @@ func init() {
30 //}) 30 //})
31 err := redis.InitWithDb(100, beego.AppConfig.String("redis_add_port"), beego.AppConfig.String("redis_auth"), "0") 31 err := redis.InitWithDb(100, beego.AppConfig.String("redis_add_port"), beego.AppConfig.String("redis_auth"), "0")
32 if err != nil { 32 if err != nil {
33 - log.Fatal(err, beego.AppConfig.String("redis_add_port"), beego.AppConfig.String("redis_auth"))  
34 - //panic(err) 33 + log.Fatal("connect to redis error address:",beego.AppConfig.String("redis_add_port"), beego.AppConfig.String("redis_auth"),err)
  34 + panic(err)
35 } 35 }
36 dataSource := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?loc=Asia%%2FShanghai", 36 dataSource := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?loc=Asia%%2FShanghai",
37 beego.AppConfig.String("mysql_user"), 37 beego.AppConfig.String("mysql_user"),
@@ -10,7 +10,7 @@ import ( @@ -10,7 +10,7 @@ import (
10 type AuditTemplate struct { 10 type AuditTemplate struct {
11 Id int64 `orm:"column(id);pk" description:"唯一编号"` 11 Id int64 `orm:"column(id);pk" description:"唯一编号"`
12 CompanyId int `orm:"column(company_id)" description:"公司id"` 12 CompanyId int `orm:"column(company_id)" description:"公司id"`
13 - ChanceType int `orm:"column(chance_type)" description:"机会类型"` 13 + ChanceTypeId int `orm:"column(chance_type_id)" description:"机会类型编号"`
14 Name string `orm:"column(name);size(20)" description:"子分类名称"` 14 Name string `orm:"column(name);size(20)" description:"子分类名称"`
15 Doc string `orm:"column(doc);size(255)" description:"说明"` 15 Doc string `orm:"column(doc);size(255)" description:"说明"`
16 Icon string `orm:"column(icon);size(255)" description:"图标"` 16 Icon string `orm:"column(icon);size(255)" description:"图标"`
@@ -82,7 +82,7 @@ func DeleteAuditTemplate(id int64) (err error) { @@ -82,7 +82,7 @@ func DeleteAuditTemplate(id int64) (err error) {
82 82
83 func GetAuditTemplates(companyId int64, chanceType int) (v []*AuditTemplate, err error) { 83 func GetAuditTemplates(companyId int64, chanceType int) (v []*AuditTemplate, err error) {
84 o := orm.NewOrm() 84 o := orm.NewOrm()
85 - sql := "select * from audit_template where company_id=? and chance_type=? and enable_status=1" 85 + sql := "select * from audit_template where company_id=? and chance_type_id=? and enable_status=1"
86 if _, err = o.Raw(sql, companyId, chanceType).QueryRows(&v); err == nil { 86 if _, err = o.Raw(sql, companyId, chanceType).QueryRows(&v); err == nil {
87 return 87 return
88 } 88 }
@@ -11,16 +11,16 @@ import ( @@ -11,16 +11,16 @@ import (
11 ) 11 )
12 12
13 type Chance struct { 13 type Chance struct {
14 - Id int64 `orm:"column(id);pk" description:"id 主键"`  
15 - UserId int64 `orm:"column(user_id)" description:"表user.id 用户id"`  
16 - CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司id"`  
17 - DepartmentId int64 `orm:"column(department_id)" description:"表department.id 部门id"`  
18 - ChanceType int `orm:"column(chance_type)" description:"表chance_type.id 机会类型 "`  
19 - AuditTemplateId int64 `orm:"column(audit_template_id)" description:"表audit_template.id 所属审批模板编号"`  
20 - AuditTemplateConfig string `orm:"column(audit_template_config);size(255);null" description:"模板配置 (存旧的配置信息,对新改动的不影响)"`  
21 - Content string `orm:"column(content)" description:"格式化后的文本内容"`  
22 - SourceContent string `orm:"column(source_content)" description:"原始表单内容 json"`  
23 - ViewTotal int `orm:"column(view_total)" description:"查看总数"` 14 + Id int64 `orm:"column(id);pk" description:"id 主键"`
  15 + UserId int64 `orm:"column(user_id)" description:"表user.id 用户id"`
  16 + CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司id"`
  17 + DepartmentId int64 `orm:"column(department_id)" description:"表department.id 部门id"`
  18 + ChanceTypeId int `orm:"column(chance_type_id)" description:"表chance_type.id 机会类型 "`
  19 + AuditTemplateId int64 `orm:"column(audit_template_id)" description:"表audit_template.id 所属审批模板编号"`
  20 + AuditTemplateConfig string `orm:"column(audit_template_config);size(255);null" description:"模板配置 (存旧的配置信息,对新改动的不影响)"`
  21 + Content string `orm:"column(content)" description:"格式化后的文本内容"`
  22 + SourceContent string `orm:"column(source_content)" description:"原始表单内容 json"`
  23 + ViewTotal int `orm:"column(view_total)" description:"查看总数"`
24 CommentTotal int `orm:"column(comment_total)" description:"评论总数"` 24 CommentTotal int `orm:"column(comment_total)" description:"评论总数"`
25 ZanTotal int `orm:"column(zan_total)" description:"点赞总数"` 25 ZanTotal int `orm:"column(zan_total)" description:"点赞总数"`
26 ReviewStatus int8 `orm:"column(review_status)" description:"审核状态 0:待处理 1:待审核 2:被退回 3:已通过 "` 26 ReviewStatus int8 `orm:"column(review_status)" description:"审核状态 0:待处理 1:待审核 2:被退回 3:已通过 "`
  1 +package models
  2 +
  3 +import (
  4 + "fmt"
  5 + "time"
  6 +
  7 + "github.com/astaxie/beego/orm"
  8 +)
  9 +
  10 +type ChanceData struct {
  11 + Id int64 `orm:"column(id)" description:"唯一编号"`
  12 + ChanceId int64 `orm:"column(chance_id);null" description:"表chance.id 机会编号"`
  13 + Images string `orm:"column(images);size(1000);null" description:"图片 json"`
  14 + Speechs string `orm:"column(speechs);size(1000);null" description:"语音 json"`
  15 + Videos string `orm:"column(videos);size(1000);null" description:"视频 json"`
  16 + CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`
  17 + UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间"`
  18 +}
  19 +
  20 +func (t *ChanceData) TableName() string {
  21 + return "chance_data"
  22 +}
  23 +
  24 +func init() {
  25 + orm.RegisterModel(new(ChanceData))
  26 +}
  27 +
  28 +// AddChanceData insert a new ChanceData into database and returns
  29 +// last inserted Id on success.
  30 +func AddChanceData(m *ChanceData) (id int64, err error) {
  31 + o := orm.NewOrm()
  32 + id, err = o.Insert(m)
  33 + return
  34 +}
  35 +
  36 +// GetChanceDataById retrieves ChanceData by Id. Returns error if
  37 +// Id doesn't exist
  38 +func GetChanceDataById(id int64) (v *ChanceData, err error) {
  39 + o := orm.NewOrm()
  40 + v = &ChanceData{Id: id}
  41 + if err = o.Read(v); err == nil {
  42 + return v, nil
  43 + }
  44 + return nil, err
  45 +}
  46 +
  47 +// UpdateChanceData updates ChanceData by Id and returns error if
  48 +// the record to be updated doesn't exist
  49 +func UpdateChanceDataById(m *ChanceData) (err error) {
  50 + o := orm.NewOrm()
  51 + v := ChanceData{Id: m.Id}
  52 + // ascertain id exists in the database
  53 + if err = o.Read(&v); err == nil {
  54 + var num int64
  55 + if num, err = o.Update(m); err == nil {
  56 + fmt.Println("Number of records updated in database:", num)
  57 + }
  58 + }
  59 + return
  60 +}
  61 +
  62 +// DeleteChanceData deletes ChanceData by Id and returns error if
  63 +// the record to be deleted doesn't exist
  64 +func DeleteChanceData(id int64) (err error) {
  65 + o := orm.NewOrm()
  66 + v := ChanceData{Id: id}
  67 + // ascertain id exists in the database
  68 + if err = o.Read(&v); err == nil {
  69 + var num int64
  70 + if num, err = o.Delete(&ChanceData{Id: id}); err == nil {
  71 + fmt.Println("Number of records deleted in database:", num)
  72 + }
  73 + }
  74 + return
  75 +}
  76 +
  77 +func GetChanceDataByChanceId(chanceId int64) (v *ChanceData, err error) {
  78 + o := orm.NewOrm()
  79 + sql :=`select * from chance_data where chance_id=?`
  80 + if err = o.Raw(sql,chanceId).QueryRow(&v); err == nil {
  81 + return v, nil
  82 + }
  83 + return nil, err
  84 +}
@@ -154,3 +154,15 @@ func DeleteCompany(id int64) (err error) { @@ -154,3 +154,15 @@ func DeleteCompany(id int64) (err error) {
154 } 154 }
155 return 155 return
156 } 156 }
  157 +
  158 +func GetCompanyByPermission(uid int64) (v []*Company, err error) {
  159 + o := orm.NewOrm()
  160 + sql := `select * from company where id in(
  161 + select company_id from user_company where user_id=? and enable=1
  162 + ) and enable=1` //
  163 + if _,err = o.Raw(sql, uid).QueryRows(&v); err == nil {
  164 + return v, nil
  165 + }
  166 + return nil, err
  167 +}
  168 +
@@ -94,4 +94,4 @@ func GetUserCompanyFirst(uid int64) (v *UserCompany, err error) { @@ -94,4 +94,4 @@ func GetUserCompanyFirst(uid int64) (v *UserCompany, err error) {
94 return v, nil 94 return v, nil
95 } 95 }
96 return nil, err 96 return nil, err
97 -} 97 +}
@@ -7,6 +7,10 @@ const ( @@ -7,6 +7,10 @@ const (
7 LoginTypeSmdcode = "signInCaptcha" 7 LoginTypeSmdcode = "signInCaptcha"
8 ) 8 )
9 9
  10 +const(
  11 + DeviceType =1
  12 +)
  13 +
10 const TokenExpire = 3600 14 const TokenExpire = 3600
11 15
12 const SmscodeDayLimitTime = 10 //短信验证码每天最多发10次 16 const SmscodeDayLimitTime = 10 //短信验证码每天最多发10次
@@ -88,7 +88,7 @@ type ChanceTypeResponse struct { @@ -88,7 +88,7 @@ type ChanceTypeResponse struct {
88 88
89 /*Templates */ 89 /*Templates */
90 type TemplatesRequest struct { 90 type TemplatesRequest struct {
91 - ChanceType int `json:"chance_type" valid:"Required"` 91 + ChanceTypeId int `json:"chanceTypeId" valid:"Required"`
92 } 92 }
93 type TemplatesResponse struct { 93 type TemplatesResponse struct {
94 Templates []*Template `json:"list"` 94 Templates []*Template `json:"list"`
@@ -99,26 +99,27 @@ type Template struct { @@ -99,26 +99,27 @@ type Template struct {
99 Name string `json:"name"` 99 Name string `json:"name"`
100 Doc string `json:"doc"` 100 Doc string `json:"doc"`
101 Icon string `json:"icon"` 101 Icon string `json:"icon"`
102 - FormList []*Form `json:"form_list"` 102 + FormList []*Form `json:"formList"`
103 } 103 }
104 104
105 type Form struct { 105 type Form struct {
106 Id int `json:"id"` 106 Id int `json:"id"`
107 Lable string `json:"name"` 107 Lable string `json:"name"`
108 - InputType string `json:"input_type"`  
109 - SectionType int8 `json:"section_type"` 108 + InputType string `json:"inputType"`
  109 + SectionType int8 `json:"sectionType"`
110 Value string `json:"value"` 110 Value string `json:"value"`
111 Required int8 `json:"required"` 111 Required int8 `json:"required"`
112 } 112 }
113 113
114 type ChanceSubmitRequest struct { 114 type ChanceSubmitRequest struct {
115 - AuditTemplateId int64 `json:"audit_template_id" valid:"Required"` 115 + Id int64 `json:"id"` // = 0添加 >0 编辑
  116 + AuditTemplateId int64 `json:"auditTemplateId" valid:"Required"`
116 Content string `json:"content" valid:"Required"` 117 Content string `json:"content" valid:"Required"`
117 - FormList []*Form `json:"form_list" valid:"Required"` 118 + FormList []*Form `json:"formList" valid:"Required"`
118 Speechs []Speech `json:"speechs"` 119 Speechs []Speech `json:"speechs"`
119 Pictures []Picture `json:"pictures"` 120 Pictures []Picture `json:"pictures"`
120 Videos []Video `json:"videos"` 121 Videos []Video `json:"videos"`
121 - RelatedDepartment int64 `json:"related_departments" valid:"Required"` 122 + RelatedDepartment int64 `json:"relatedDepartments" valid:"Required"`
122 } 123 }
123 124
124 type ChanceSubmitResponse struct { 125 type ChanceSubmitResponse struct {
@@ -3,13 +3,14 @@ package protocol @@ -3,13 +3,14 @@ package protocol
3 import "time" 3 import "time"
4 4
5 const ( 5 const (
6 - DepartmentAll = iota + 1 //公司所有部门  
7 - DepartmentUser //用户所有部门 6 + DepartmentUser = iota //用户所有部门
  7 + DepartmentAll //公司所有部门
8 ) 8 )
9 9
10 /*Departments */ 10 /*Departments */
11 type DepartmentsRequest struct { 11 type DepartmentsRequest struct {
12 - Type int `json:"type" valid:"Required"` //1:公司所有部门 2:用户所在部门 12 + //Type int `json:"type" valid:"Required"` //1:公司所有部门 2:用户所在部门
  13 + Type int `json:"type"` //0:用户所在部门 1:公司所有部门
13 } 14 }
14 type DepartmentsResponse struct { 15 type DepartmentsResponse struct {
15 Departments []*Department `json:"departments,omitempty"` 16 Departments []*Department `json:"departments,omitempty"`
@@ -26,7 +26,7 @@ var errmessge ErrorMap = map[int]string{ @@ -26,7 +26,7 @@ var errmessge ErrorMap = map[int]string{
26 4140: "refreshToken过期,需要重新登录授权", 26 4140: "refreshToken过期,需要重新登录授权",
27 4141: "accessToken过期或无效,需要进行重新获取令牌", 27 4141: "accessToken过期或无效,需要进行重新获取令牌",
28 4142: "Uuid已存在,请求失败", 28 4142: "Uuid已存在,请求失败",
29 - 29 + 4201: "无该公司",
30 5000: "繁忙,请稍后再试", 30 5000: "繁忙,请稍后再试",
31 } 31 }
32 32
@@ -36,11 +36,12 @@ type ChangePasswordResponse struct { @@ -36,11 +36,12 @@ type ChangePasswordResponse struct {
36 type UserCompanysRequest struct { 36 type UserCompanysRequest struct {
37 } 37 }
38 type UserCompanysResponse struct { 38 type UserCompanysResponse struct {
  39 + Companys []Company `json:"companys"`
39 } 40 }
40 41
41 /*SwitchCompany */ 42 /*SwitchCompany */
42 type SwitchCompanyRequest struct { 43 type SwitchCompanyRequest struct {
43 - CompanyId int64 `json:"company_id" valid:"Required"` 44 + CompanyId int64 `json:"companyId" valid:"Required"`
44 } 45 }
45 type SwitchCompanyResponse struct { 46 type SwitchCompanyResponse struct {
46 } 47 }
@@ -103,3 +104,9 @@ type User struct { @@ -103,3 +104,9 @@ type User struct {
103 CompanyId int `json:"companyId"` 104 CompanyId int `json:"companyId"`
104 Company string `json:"company"` //公司名称 105 Company string `json:"company"` //公司名称
105 } 106 }
  107 +
  108 +
  109 +type Company struct {
  110 + Id int64 `json:"id"`
  111 + Name string `json:"name"`
  112 +}
@@ -9,266 +9,266 @@ func init() { @@ -9,266 +9,266 @@ func init() {
9 9
10 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], 10 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
11 beego.ControllerComments{ 11 beego.ControllerComments{
12 - Method: "AccessToken",  
13 - Router: `/accessToken`, 12 + Method: "AccessToken",
  13 + Router: `/accessToken`,
14 AllowHTTPMethods: []string{"post"}, 14 AllowHTTPMethods: []string{"post"},
15 - MethodParams: param.Make(),  
16 - Params: nil}) 15 + MethodParams: param.Make(),
  16 + Params: nil})
17 17
18 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], 18 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
19 beego.ControllerComments{ 19 beego.ControllerComments{
20 - Method: "Login",  
21 - Router: `/login`, 20 + Method: "Login",
  21 + Router: `/login`,
22 AllowHTTPMethods: []string{"post"}, 22 AllowHTTPMethods: []string{"post"},
23 - MethodParams: param.Make(),  
24 - Params: nil}) 23 + MethodParams: param.Make(),
  24 + Params: nil})
25 25
26 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], 26 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
27 beego.ControllerComments{ 27 beego.ControllerComments{
28 - Method: "RefreshToken",  
29 - Router: `/refreshToken`, 28 + Method: "RefreshToken",
  29 + Router: `/refreshToken`,
30 AllowHTTPMethods: []string{"post"}, 30 AllowHTTPMethods: []string{"post"},
31 - MethodParams: param.Make(),  
32 - Params: nil}) 31 + MethodParams: param.Make(),
  32 + Params: nil})
33 33
34 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], 34 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
35 beego.ControllerComments{ 35 beego.ControllerComments{
36 - Method: "Revoke",  
37 - Router: `/revoke`, 36 + Method: "Revoke",
  37 + Router: `/revoke`,
38 AllowHTTPMethods: []string{"post"}, 38 AllowHTTPMethods: []string{"post"},
39 - MethodParams: param.Make(),  
40 - Params: nil}) 39 + MethodParams: param.Make(),
  40 + Params: nil})
41 41
42 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], 42 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
43 beego.ControllerComments{ 43 beego.ControllerComments{
44 - Method: "SmsCode",  
45 - Router: `/smsCode`, 44 + Method: "SmsCode",
  45 + Router: `/smsCode`,
46 AllowHTTPMethods: []string{"post"}, 46 AllowHTTPMethods: []string{"post"},
47 - MethodParams: param.Make(),  
48 - Params: nil}) 47 + MethodParams: param.Make(),
  48 + Params: nil})
49 49
50 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], 50 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
51 beego.ControllerComments{ 51 beego.ControllerComments{
52 - Method: "UpdateDevice",  
53 - Router: `/updateDevice`, 52 + Method: "UpdateDevice",
  53 + Router: `/updateDevice`,
54 AllowHTTPMethods: []string{"post"}, 54 AllowHTTPMethods: []string{"post"},
55 - MethodParams: param.Make(),  
56 - Params: nil}) 55 + MethodParams: param.Make(),
  56 + Params: nil})
57 57
58 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 58 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
59 beego.ControllerComments{ 59 beego.ControllerComments{
60 - Method: "ChanceSubmit",  
61 - Router: `/chanceSubmit`, 60 + Method: "ChanceType",
  61 + Router: `/chanceType`,
62 AllowHTTPMethods: []string{"post"}, 62 AllowHTTPMethods: []string{"post"},
63 - MethodParams: param.Make(),  
64 - Params: nil}) 63 + MethodParams: param.Make(),
  64 + Params: nil})
65 65
66 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 66 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
67 beego.ControllerComments{ 67 beego.ControllerComments{
68 - Method: "ChanceType",  
69 - Router: `/chanceType`, 68 + Method: "CommentDetailsMulti",
  69 + Router: `/commentDetailsMulti`,
70 AllowHTTPMethods: []string{"post"}, 70 AllowHTTPMethods: []string{"post"},
71 - MethodParams: param.Make(),  
72 - Params: nil}) 71 + MethodParams: param.Make(),
  72 + Params: nil})
73 73
74 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 74 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
75 beego.ControllerComments{ 75 beego.ControllerComments{
76 - Method: "CommentDetailsMulti",  
77 - Router: `/commentDetailsMulti`, 76 + Method: "CommentDetailsSingle",
  77 + Router: `/commentDetailsSingle`,
78 AllowHTTPMethods: []string{"post"}, 78 AllowHTTPMethods: []string{"post"},
79 - MethodParams: param.Make(),  
80 - Params: nil}) 79 + MethodParams: param.Make(),
  80 + Params: nil})
81 81
82 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 82 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
83 beego.ControllerComments{ 83 beego.ControllerComments{
84 - Method: "CommentDetailsSingle",  
85 - Router: `/commentDetailsSingle`, 84 + Method: "Comments",
  85 + Router: `/comments`,
86 AllowHTTPMethods: []string{"post"}, 86 AllowHTTPMethods: []string{"post"},
87 - MethodParams: param.Make(),  
88 - Params: nil}) 87 + MethodParams: param.Make(),
  88 + Params: nil})
89 89
90 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 90 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
91 beego.ControllerComments{ 91 beego.ControllerComments{
92 - Method: "Comments",  
93 - Router: `/comments`, 92 + Method: "Favorite",
  93 + Router: `/favorite`,
94 AllowHTTPMethods: []string{"post"}, 94 AllowHTTPMethods: []string{"post"},
95 - MethodParams: param.Make(),  
96 - Params: nil}) 95 + MethodParams: param.Make(),
  96 + Params: nil})
97 97
98 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 98 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
99 beego.ControllerComments{ 99 beego.ControllerComments{
100 - Method: "Favorite",  
101 - Router: `/favorite`, 100 + Method: "IComment",
  101 + Router: `/iComment`,
102 AllowHTTPMethods: []string{"post"}, 102 AllowHTTPMethods: []string{"post"},
103 - MethodParams: param.Make(),  
104 - Params: nil}) 103 + MethodParams: param.Make(),
  104 + Params: nil})
105 105
106 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 106 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
107 beego.ControllerComments{ 107 beego.ControllerComments{
108 - Method: "IComment",  
109 - Router: `/iComment`, 108 + Method: "IComments",
  109 + Router: `/iComments`,
110 AllowHTTPMethods: []string{"post"}, 110 AllowHTTPMethods: []string{"post"},
111 - MethodParams: param.Make(),  
112 - Params: nil}) 111 + MethodParams: param.Make(),
  112 + Params: nil})
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: "IComments",  
117 - Router: `/iComments`, 116 + Method: "ChanceSubmit",
  117 + Router: `/submit`,
118 AllowHTTPMethods: []string{"post"}, 118 AllowHTTPMethods: []string{"post"},
119 - MethodParams: param.Make(),  
120 - Params: nil}) 119 + MethodParams: param.Make(),
  120 + Params: nil})
121 121
122 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 122 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
123 beego.ControllerComments{ 123 beego.ControllerComments{
124 - Method: "SympathyAction",  
125 - Router: `/sympathyAction`, 124 + Method: "SympathyAction",
  125 + Router: `/sympathyAction`,
126 AllowHTTPMethods: []string{"post"}, 126 AllowHTTPMethods: []string{"post"},
127 - MethodParams: param.Make(),  
128 - Params: nil}) 127 + MethodParams: param.Make(),
  128 + Params: nil})
129 129
130 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 130 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
131 beego.ControllerComments{ 131 beego.ControllerComments{
132 - Method: "Templates",  
133 - Router: `/templates`, 132 + Method: "Templates",
  133 + Router: `/templates`,
134 AllowHTTPMethods: []string{"post"}, 134 AllowHTTPMethods: []string{"post"},
135 - MethodParams: param.Make(),  
136 - Params: nil}) 135 + MethodParams: param.Make(),
  136 + Params: nil})
137 137
138 beego.GlobalControllerRouter["opp/controllers/v1:CommendController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:CommendController"], 138 beego.GlobalControllerRouter["opp/controllers/v1:CommendController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:CommendController"],
139 beego.ControllerComments{ 139 beego.ControllerComments{
140 - Method: "Company",  
141 - Router: `/company`, 140 + Method: "Company",
  141 + Router: `/company`,
142 AllowHTTPMethods: []string{"post"}, 142 AllowHTTPMethods: []string{"post"},
143 - MethodParams: param.Make(),  
144 - Params: nil}) 143 + MethodParams: param.Make(),
  144 + Params: nil})
145 145
146 beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"], 146 beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"],
147 beego.ControllerComments{ 147 beego.ControllerComments{
148 - Method: "Departments",  
149 - Router: `/departments`, 148 + Method: "Departments",
  149 + Router: `/departments`,
150 AllowHTTPMethods: []string{"post"}, 150 AllowHTTPMethods: []string{"post"},
151 - MethodParams: param.Make(),  
152 - Params: nil}) 151 + MethodParams: param.Make(),
  152 + Params: nil})
153 153
154 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], 154 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
155 beego.ControllerComments{ 155 beego.ControllerComments{
156 - Method: "MessageCenter",  
157 - Router: `/messageCenter`, 156 + Method: "MessageCenter",
  157 + Router: `/messageCenter`,
158 AllowHTTPMethods: []string{"post"}, 158 AllowHTTPMethods: []string{"post"},
159 - MethodParams: param.Make(),  
160 - Params: nil}) 159 + MethodParams: param.Make(),
  160 + Params: nil})
161 161
162 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], 162 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
163 beego.ControllerComments{ 163 beego.ControllerComments{
164 - Method: "MsgCenterAllRead",  
165 - Router: `/msgCenterAllRead`, 164 + Method: "MsgCenterAllRead",
  165 + Router: `/msgCenterAllRead`,
166 AllowHTTPMethods: []string{"post"}, 166 AllowHTTPMethods: []string{"post"},
167 - MethodParams: param.Make(),  
168 - Params: nil}) 167 + MethodParams: param.Make(),
  168 + Params: nil})
169 169
170 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], 170 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
171 beego.ControllerComments{ 171 beego.ControllerComments{
172 - Method: "MsgCenterRead",  
173 - Router: `/msgCenterRead`, 172 + Method: "MsgCenterRead",
  173 + Router: `/msgCenterRead`,
174 AllowHTTPMethods: []string{"post"}, 174 AllowHTTPMethods: []string{"post"},
175 - MethodParams: param.Make(),  
176 - Params: nil}) 175 + MethodParams: param.Make(),
  176 + Params: nil})
177 177
178 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], 178 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
179 beego.ControllerComments{ 179 beego.ControllerComments{
180 - Method: "MsgInteractive",  
181 - Router: `/msgInteractive`, 180 + Method: "MsgInteractive",
  181 + Router: `/msgInteractive`,
182 AllowHTTPMethods: []string{"post"}, 182 AllowHTTPMethods: []string{"post"},
183 - MethodParams: param.Make(),  
184 - Params: nil}) 183 + MethodParams: param.Make(),
  184 + Params: nil})
185 185
186 beego.GlobalControllerRouter["opp/controllers/v1:UcenterController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UcenterController"], 186 beego.GlobalControllerRouter["opp/controllers/v1:UcenterController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UcenterController"],
187 beego.ControllerComments{ 187 beego.ControllerComments{
188 - Method: "UCenterLogin",  
189 - Router: `/login`, 188 + Method: "UCenterLogin",
  189 + Router: `/login`,
190 AllowHTTPMethods: []string{"post"}, 190 AllowHTTPMethods: []string{"post"},
191 - MethodParams: param.Make(),  
192 - Params: nil}) 191 + MethodParams: param.Make(),
  192 + Params: nil})
193 193
194 beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"], 194 beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
195 beego.ControllerComments{ 195 beego.ControllerComments{
196 - Method: "Image",  
197 - Router: `/image`, 196 + Method: "Image",
  197 + Router: `/image`,
198 AllowHTTPMethods: []string{"post"}, 198 AllowHTTPMethods: []string{"post"},
199 - MethodParams: param.Make(),  
200 - Params: nil}) 199 + MethodParams: param.Make(),
  200 + Params: nil})
201 201
202 beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"], 202 beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
203 beego.ControllerComments{ 203 beego.ControllerComments{
204 - Method: "Video",  
205 - Router: `/video`, 204 + Method: "Video",
  205 + Router: `/video`,
206 AllowHTTPMethods: []string{"post"}, 206 AllowHTTPMethods: []string{"post"},
207 - MethodParams: param.Make(),  
208 - Params: nil}) 207 + MethodParams: param.Make(),
  208 + Params: nil})
209 209
210 beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"], 210 beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
211 beego.ControllerComments{ 211 beego.ControllerComments{
212 - Method: "Voice",  
213 - Router: `/voice`, 212 + Method: "Voice",
  213 + Router: `/voice`,
214 AllowHTTPMethods: []string{"post"}, 214 AllowHTTPMethods: []string{"post"},
215 - MethodParams: param.Make(),  
216 - Params: nil}) 215 + MethodParams: param.Make(),
  216 + Params: nil})
217 217
218 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], 218 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
219 beego.ControllerComments{ 219 beego.ControllerComments{
220 - Method: "ChangePassword",  
221 - Router: `/changePassword`, 220 + Method: "ChangePassword",
  221 + Router: `/changePassword`,
222 AllowHTTPMethods: []string{"post"}, 222 AllowHTTPMethods: []string{"post"},
223 - MethodParams: param.Make(),  
224 - Params: nil}) 223 + MethodParams: param.Make(),
  224 + Params: nil})
225 225
226 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], 226 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
227 beego.ControllerComments{ 227 beego.ControllerComments{
228 - Method: "ChangePhone",  
229 - Router: `/changePhone`, 228 + Method: "ChangePhone",
  229 + Router: `/changePhone`,
230 AllowHTTPMethods: []string{"post"}, 230 AllowHTTPMethods: []string{"post"},
231 - MethodParams: param.Make(),  
232 - Params: nil}) 231 + MethodParams: param.Make(),
  232 + Params: nil})
233 233
234 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], 234 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
235 beego.ControllerComments{ 235 beego.ControllerComments{
236 - Method: "CheckSmsCode",  
237 - Router: `/checkSmsCode`, 236 + Method: "CheckSmsCode",
  237 + Router: `/checkSmsCode`,
238 AllowHTTPMethods: []string{"post"}, 238 AllowHTTPMethods: []string{"post"},
239 - MethodParams: param.Make(),  
240 - Params: nil}) 239 + MethodParams: param.Make(),
  240 + Params: nil})
241 241
242 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], 242 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
243 beego.ControllerComments{ 243 beego.ControllerComments{
244 - Method: "ResetPassword",  
245 - Router: `/resetPassword`, 244 + Method: "ResetPassword",
  245 + Router: `/resetPassword`,
246 AllowHTTPMethods: []string{"post"}, 246 AllowHTTPMethods: []string{"post"},
247 - MethodParams: param.Make(),  
248 - Params: nil}) 247 + MethodParams: param.Make(),
  248 + Params: nil})
249 249
250 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], 250 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
251 beego.ControllerComments{ 251 beego.ControllerComments{
252 - Method: "SwitchCompany",  
253 - Router: `/switchCompany`, 252 + Method: "SwitchCompany",
  253 + Router: `/switchCompany`,
254 AllowHTTPMethods: []string{"post"}, 254 AllowHTTPMethods: []string{"post"},
255 - MethodParams: param.Make(),  
256 - Params: nil}) 255 + MethodParams: param.Make(),
  256 + Params: nil})
257 257
258 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], 258 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
259 beego.ControllerComments{ 259 beego.ControllerComments{
260 - Method: "UserCompanys",  
261 - Router: `/userCompanys`, 260 + Method: "UserCompanys",
  261 + Router: `/userCompanys`,
262 AllowHTTPMethods: []string{"post"}, 262 AllowHTTPMethods: []string{"post"},
263 - MethodParams: param.Make(),  
264 - Params: nil}) 263 + MethodParams: param.Make(),
  264 + Params: nil})
265 265
266 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], 266 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
267 beego.ControllerComments{ 267 beego.ControllerComments{
268 - Method: "UserInfo",  
269 - Router: `/userInfo`, 268 + Method: "UserInfo",
  269 + Router: `/userInfo`,
270 AllowHTTPMethods: []string{"post"}, 270 AllowHTTPMethods: []string{"post"},
271 - MethodParams: param.Make(),  
272 - Params: nil}) 271 + MethodParams: param.Make(),
  272 + Params: nil})
273 273
274 } 274 }
@@ -147,7 +147,7 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.ChanceDetail, err e @@ -147,7 +147,7 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.ChanceDetail, err e
147 Provider: baseUserInfo, 147 Provider: baseUserInfo,
148 148
149 Content: c.Content, 149 Content: c.Content,
150 - ChanceType: c.ChanceType, 150 + ChanceType: c.ChanceTypeId,
151 ViewTotal: c.ViewTotal, 151 ViewTotal: c.ViewTotal,
152 CommentTotal: c.CommentTotal, 152 CommentTotal: c.CommentTotal,
153 ZanTotal: c.ZanTotal, 153 ZanTotal: c.ZanTotal,
@@ -76,7 +76,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc @@ -76,7 +76,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
76 log.Error("机会不存在", err) 76 log.Error("机会不存在", err)
77 return 77 return
78 } 78 }
79 - chanceType = chance.ChanceType 79 + chanceType = chance.ChanceTypeId
80 table = "chance" 80 table = "chance"
81 } 81 }
82 if chanceFavoirte != nil { 82 if chanceFavoirte != nil {
@@ -159,7 +159,7 @@ func Templates(header *protocol.RequestHeader, request *protocol.TemplatesReques @@ -159,7 +159,7 @@ func Templates(header *protocol.RequestHeader, request *protocol.TemplatesReques
159 forms []*models.AuditForm 159 forms []*models.AuditForm
160 ) 160 )
161 rsp = &protocol.TemplatesResponse{} 161 rsp = &protocol.TemplatesResponse{}
162 - if templates, err = models.GetAuditTemplates(header.CompanyId, request.ChanceType); err != nil { 162 + if templates, err = models.GetAuditTemplates(header.CompanyId, request.ChanceTypeId); err != nil {
163 log.Error(err) 163 log.Error(err)
164 return 164 return
165 } 165 }
@@ -225,7 +225,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -225,7 +225,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
225 Id: idgen.Next(), 225 Id: idgen.Next(),
226 UserId: header.Uid, 226 UserId: header.Uid,
227 CompanyId: header.CompanyId, 227 CompanyId: header.CompanyId,
228 - ChanceType: template.ChanceType, 228 + ChanceTypeId: template.ChanceTypeId,
229 AuditTemplateId: template.Id, 229 AuditTemplateId: template.Id,
230 AuditTemplateConfig: common.AssertJson(auditConfig), 230 AuditTemplateConfig: common.AssertJson(auditConfig),
231 Content: request.Content, 231 Content: request.Content,
@@ -255,28 +255,117 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -255,28 +255,117 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
255 orm.Rollback() 255 orm.Rollback()
256 return 256 return
257 } 257 }
258 -  
259 } 258 }
260 //6.文件 259 //6.文件
261 - for _, v := range GenSpeechs(chance.Id, request.Speechs) {  
262 - if _, err = orm.Insert(v); err != nil { 260 + {
  261 + data :=&models.ChanceData{
  262 + Id:idgen.Next(),
  263 + ChanceId:chance.Id,
  264 + Speechs:common.AssertJson(request.Speechs),
  265 + Images:common.AssertJson(request.Pictures),
  266 + Videos:common.AssertJson(request.Videos),
  267 + CreateAt:time.Now(),
  268 + UpdateAt:time.Now(),
  269 + }
  270 + if _, err = orm.Insert(data); err != nil {
263 log.Error(err) 271 log.Error(err)
264 orm.Rollback() 272 orm.Rollback()
265 return 273 return
266 } 274 }
267 } 275 }
268 - for _, v := range GenVideos(chance.Id, request.Videos) {  
269 - if _, err = orm.Insert(v); err != nil { 276 + orm.Commit()
  277 +
  278 + //6.激活审核流
  279 + //TODO:7.发送消息通知给审核人(审核消息)
  280 + rsp = &protocol.ChanceSubmitResponse{}
  281 + return
  282 +}
  283 +
  284 +func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmitRequest) (rsp *protocol.ChanceSubmitResponse, err error) {
  285 + var (
  286 + template *models.AuditTemplate
  287 + chance *models.Chance
  288 + auditConfig *protocol.AuditConfig
  289 + chanceData *models.ChanceData
  290 + //auditFlows []*models.AuditFlowProcess
  291 + updateMap =make(map[string]interface{})
  292 + )
  293 + if chance,err =models.GetChanceById(request.Id);err!=nil{
  294 + log.Error(err)
  295 + return
  296 + }
  297 + //TODO:非本人 1.需要验证角色权限,是否是审核人
  298 + if chance.UserId!=header.Uid{
  299 + err = protocol.NewErrWithMessage(1)
  300 + log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v",header.Uid,chance.Id))
  301 + return
  302 + }
  303 + //TODO:验证机会当前是否在审核中
  304 + //1.模板是否存在
  305 + if template, err = models.GetAuditTemplateById(request.AuditTemplateId); err != nil {
  306 + log.Error("模板不存在:", request.AuditTemplateId, err)
  307 + return
  308 + }
  309 + auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover}
  310 + orm := orm.NewOrm()
  311 + orm.Begin()
  312 + {
  313 + updateMap["AuditTemplateConfig"] = common.AssertJson(auditConfig)
  314 + updateMap["Content"] = request.Content
  315 + updateMap["SourceContent"] = common.AssertJson(request.FormList)
  316 + updateMap["DepartmentId"] = request.RelatedDepartment
  317 +
  318 + if err = utils.UpdateTableByMapWithOrmer(orm,&models.Chance{Id:chance.Id},updateMap); err != nil {
270 log.Error(err) 319 log.Error(err)
271 orm.Rollback() 320 orm.Rollback()
272 return 321 return
273 } 322 }
274 } 323 }
275 - for _, v := range GenImages(chance.Id, request.Pictures) {  
276 - if _, err = orm.Insert(v); err != nil {  
277 - log.Error(err)  
278 - orm.Rollback()  
279 - return 324 +
  325 +
  326 + //4.查询审核配置
  327 + //5.生成审核流 删除旧的 生成新的
  328 + //if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil {
  329 + // log.Error(err)
  330 + // orm.Rollback()
  331 + // return
  332 + //}
  333 + //for i := 0; i < len(auditFlows); i++ {
  334 + // if _, err = orm.Insert(auditFlows[i]); err != nil {
  335 + // log.Error(err)
  336 + // orm.Rollback()
  337 + // return
  338 + // }
  339 + //}
  340 +
  341 + //6.更新文件
  342 + {
  343 + if chanceData,err = models.GetChanceDataByChanceId(chance.Id);err==nil{
  344 + if err = utils.UpdateTableByMapWithOrmer(orm,chanceData,map[string]interface{}{
  345 + "Speechs":common.AssertJson(request.Speechs),
  346 + "Images":common.AssertJson(request.Pictures),
  347 + "Videos":common.AssertJson(request.Videos),
  348 + "UpdateAt":time.Now(),
  349 + });err!=nil{
  350 + log.Error(err)
  351 + orm.Rollback()
  352 + return
  353 + }
  354 + }else{
  355 + data :=&models.ChanceData{
  356 + Id:idgen.Next(),
  357 + ChanceId:chance.Id,
  358 + Speechs:common.AssertJson(request.Speechs),
  359 + Images:common.AssertJson(request.Pictures),
  360 + Videos:common.AssertJson(request.Videos),
  361 + CreateAt:time.Now(),
  362 + UpdateAt:time.Now(),
  363 + }
  364 + if _, err = orm.Insert(data); err != nil {
  365 + log.Error(err)
  366 + orm.Rollback()
  367 + return
  368 + }
280 } 369 }
281 } 370 }
282 orm.Commit() 371 orm.Commit()
@@ -179,8 +179,21 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass @@ -179,8 +179,21 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
179 179
180 //用户公司 180 //用户公司
181 func UserCompanys(header *protocol.RequestHeader, request *protocol.UserCompanysRequest) (rsp *protocol.UserCompanysResponse, err error) { 181 func UserCompanys(header *protocol.RequestHeader, request *protocol.UserCompanysRequest) (rsp *protocol.UserCompanysResponse, err error) {
182 - var () 182 + var (
  183 + companys []*models.Company
  184 + )
183 rsp = &protocol.UserCompanysResponse{} 185 rsp = &protocol.UserCompanysResponse{}
  186 + if companys,err =models.GetCompanyByPermission(header.Uid);err!=nil{
  187 + log.Error(err)
  188 + err = protocol.NewErrWithMessage(4201) //找不到这家公司
  189 + return
  190 + }
  191 + for i:=range companys{
  192 + rsp.Companys =append(rsp.Companys,protocol.Company{
  193 + Id:companys[i].Id,
  194 + Name:companys[i].Name,
  195 + })
  196 + }
184 return 197 return
185 } 198 }
186 199
@@ -193,12 +206,17 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa @@ -193,12 +206,17 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa
193 rsp = &protocol.SwitchCompanyResponse{} 206 rsp = &protocol.SwitchCompanyResponse{}
194 if company, err = repository.UserCompany.GetUserCompanyByUserId(header.Uid, int64(request.CompanyId)); err != nil { 207 if company, err = repository.UserCompany.GetUserCompanyByUserId(header.Uid, int64(request.CompanyId)); err != nil {
195 log.Error(err) 208 log.Error(err)
  209 + err = protocol.NewErrWithMessage(4201) //找不到这家公司
196 return 210 return
197 } 211 }
198 - if auth, err = repository.UserAuth.GetUserAuthByUserId(header.Uid, header.DeviceType); err != nil { 212 + if auth, err = repository.UserAuth.GetUserAuthByUserId(header.Uid, protocol.DeviceType); err != nil {
199 log.Error(err) 213 log.Error(err)
200 return 214 return
201 } 215 }
  216 + if auth.CurrentCompanyId == request.CompanyId{
  217 + log.Error(fmt.Sprintf("uid:%v 当前公司已经是:%v",header.Uid,request.CompanyId))
  218 + return
  219 + }
202 if err = utils.UpdateTableByMap(&models.UserAuth{Id: auth.Id}, map[string]interface{}{"CurrentCompanyId": company.CompanyId}); err != nil { 220 if err = utils.UpdateTableByMap(&models.UserAuth{Id: auth.Id}, map[string]interface{}{"CurrentCompanyId": company.CompanyId}); err != nil {
203 log.Error(err) 221 log.Error(err)
204 return 222 return
@@ -270,4 +270,328 @@ @@ -270,4 +270,328 @@
270 } 270 }
271 } 271 }
272 } 272 }
  273 +```
  274 +
  275 +### 公司列表
  276 +* URL: /v1/user/userCompanys
  277 +* 格式: JSON
  278 +* HTTP请求方式: POST
  279 +* 请求示例
  280 +```json
  281 +{
  282 +}
  283 +```
  284 +
  285 +* 应答示例
  286 +```json
  287 +{
  288 + "code": 0,
  289 + "msg": "成功",
  290 + "data": {
  291 + "companys": [
  292 + {
  293 + "id": 1,
  294 + "name": "test_company"
  295 + },
  296 + {
  297 + "id": 2,
  298 + "name": "dyt_company"
  299 + }
  300 + ]
  301 + }
  302 +}
  303 +```
  304 +
  305 +
  306 +### 切换公司
  307 +* URL: /v1/user/switchCompany
  308 +* 格式: JSON
  309 +* HTTP请求方式: POST
  310 +* 请求示例
  311 +```json
  312 +{
  313 + "companyId":1
  314 +}
  315 +```
  316 +
  317 +* 应答示例
  318 +```json
  319 +{
  320 + "code": 0,
  321 + "msg": "成功",
  322 + "data": {}
  323 +}
  324 +```
  325 +
  326 +
  327 +## 机会
  328 +
  329 +### 机会类型
  330 +* URL: /v1/chance/chanceType
  331 +* 格式: JSON
  332 +* HTTP请求方式: POST
  333 +* 请求示例
  334 +```json
  335 +{
  336 +}
  337 +```
  338 +
  339 +* 应答示例
  340 +```json
  341 +{
  342 + "code": 0,
  343 + "msg": "成功",
  344 + "data": {
  345 + "list": [
  346 + {
  347 + "id": 1,
  348 + "name": "产品",
  349 + "icon": ""
  350 + },
  351 + {
  352 + "id": 2,
  353 + "name": "渠道",
  354 + "icon": ""
  355 + },
  356 + {
  357 + "id": 3,
  358 + "name": "客户",
  359 + "icon": ""
  360 + },
  361 + {
  362 + "id": 4,
  363 + "name": "区域",
  364 + "icon": ""
  365 + },
  366 + {
  367 + "id": 5,
  368 + "name": "其他",
  369 + "icon": ""
  370 + }
  371 + ]
  372 + }
  373 +}
  374 +```
  375 +
  376 +### 机会模板
  377 +* URL: /v1/chance/templates
  378 +* 格式: JSON
  379 +* HTTP请求方式: POST
  380 +* 请求示例
  381 +```json
  382 +{
  383 + "chanceTypeId":1
  384 +}
  385 +```
  386 +
  387 +* 应答示例
  388 +```json
  389 +{
  390 + "code": 0,
  391 + "msg": "成功",
  392 + "data": {
  393 + "list": [
  394 + {
  395 + "id": 1,
  396 + "name": "产品-1",
  397 + "doc": "新型产品1",
  398 + "icon": "",
  399 + "formList": [
  400 + {
  401 + "id": 1,
  402 + "name": "产品名称",
  403 + "inputType": "text",
  404 + "sectionType": 1,
  405 + "value": "",
  406 + "required": 0
  407 + },
  408 + {
  409 + "id": 2,
  410 + "name": "竞品",
  411 + "inputType": "text",
  412 + "sectionType": 2,
  413 + "value": "",
  414 + "required": 0
  415 + }
  416 + ]
  417 + }
  418 + ]
  419 + }
  420 +}
  421 +```
  422 +
  423 +### 提交机会
  424 +* URL: /v1/chance/submit
  425 +* 格式: JSON
  426 +* HTTP请求方式: POST
  427 +* 请求示例
  428 +```json
  429 +{
  430 + "id":279802775016046593,
  431 + "auditTemplateId": 1,
  432 + "content": "是否素:是\n 出厂价格:¥100 \n",
  433 + "formList": [{
  434 + "lable": "是否素食",
  435 + "inputType": "text",
  436 + "section": 1,
  437 + "value": ""
  438 + },
  439 + {
  440 + "lable": "竞品",
  441 + "inputType": "text",
  442 + "section": 2,
  443 + "value": ""
  444 + }
  445 + ],
  446 + "speechs": [{
  447 + "path": "www.xx.com/file/xx/xx...",
  448 + "duration": 60
  449 + },
  450 + {
  451 + "path": "www.xx.com/file/xx/xx...",
  452 + "duration": 30
  453 + }
  454 + ],
  455 + "pictures": [{
  456 + "path": "www.xx.com/file/xx/xx...",
  457 + "w": 600,
  458 + "h": 600
  459 + },
  460 + {
  461 + "path": "www.xx.com/file/xx/xx...",
  462 + "w": 600,
  463 + "h": 600
  464 + }
  465 + ],
  466 + "videos": [{
  467 + "path": "www.xx.com/file/xx/xx...",
  468 + "cover": "www.xx.com/file/xx/xx...",
  469 + "duration": 60
  470 + },
  471 + {
  472 + "path": "www.xx.com/file/xx/xx...",
  473 + "cover": "www.xx.com/file/xx/xx...",
  474 + "duration": 30
  475 + }
  476 + ],
  477 + "relatedDepartments": 1
  478 +}
  479 +```
  480 +
  481 +* 应答示例
  482 +```json
  483 +{
  484 + "code": 0,
  485 + "msg": "成功",
  486 + "data": {}
  487 +}
  488 +```
  489 +
  490 +
  491 +## 文件上传
  492 +
  493 +### 上传图片
  494 +* URL: /v1/upload/image
  495 +* 格式: JSON
  496 +* HTTP请求方式: POST
  497 +* 请求示例
  498 +```json
  499 +{
  500 +}
  501 +```
  502 +
  503 +```
  504 +form-data: file
  505 +```
  506 +
  507 +* 应答示例
  508 +```json
  509 +{
  510 + "code": 0,
  511 + "msg": "成功",
  512 + "data": {
  513 + "paths": [
  514 + "http:/192.168.139.137:8080/file/opp/image/20191214/1576290273_H7WDQpksZyXaGxmwKQDC5T6mhQBMTF3M.png"
  515 + ]
  516 + }
  517 +}
  518 +```
  519 +
  520 +### 上传语音
  521 +* URL: /v1/upload/voice
  522 +* 格式: JSON
  523 +* HTTP请求方式: POST
  524 +* 请求示例
  525 +```json
  526 +{
  527 +}
  528 +```
  529 +
  530 +```
  531 +form-data: file
  532 +```
  533 +
  534 +* 应答示例
  535 +```json
  536 +{
  537 + "code": 0,
  538 + "msg": "成功",
  539 + "data": {
  540 + "paths": [
  541 + "http:/192.168.139.137:8080/file/opp/voice/20191214/1576290273_H7WDQpksZyXaGxmwKQDC5T6mhQBMTF3M.wav"
  542 + ]
  543 + }
  544 +}
  545 +```
  546 +
  547 +### 上传视频
  548 +* URL: /v1/upload/video
  549 +* 格式: JSON
  550 +* HTTP请求方式: POST
  551 +* 请求示例
  552 +```json
  553 +{
  554 +}
  555 +```
  556 +
  557 +* 应答示例
  558 +```json
  559 +{
  560 + "code": 0,
  561 + "msg": "成功",
  562 + "data": {
  563 + "paths": [
  564 + "http:/192.168.139.137:8080/file/opp/video/20191214/1576290351_R3h4nQxxcMJ7ympktMsYBBQ6bAcFC6xj.mp3"
  565 + ]
  566 + }
  567 +}
  568 +```
  569 +
  570 +## 部门统计
  571 +
  572 +### 部门列表
  573 +* URL: /v1/department/departments
  574 +* 格式: JSON
  575 +* HTTP请求方式: POST
  576 +* 请求示例
  577 +```json
  578 +{
  579 + "type": 0
  580 +}
  581 +```
  582 +
  583 +* 应答示例
  584 +```json
  585 +{
  586 + "code": 0,
  587 + "msg": "成功",
  588 + "data": {
  589 + "departments": [
  590 + {
  591 + "id": 1,
  592 + "name": "部门1"
  593 + }
  594 + ]
  595 + }
  596 +}
273 ``` 597 ```