正在显示
5 个修改的文件
包含
109 行增加
和
13 行删除
| @@ -8,7 +8,7 @@ mysql_db_name = "${MYSQL_DB_NAME||opportunity}" | @@ -8,7 +8,7 @@ mysql_db_name = "${MYSQL_DB_NAME||opportunity}" | ||
| 8 | 8 | ||
| 9 | #日志 | 9 | #日志 |
| 10 | log_level = "${LOG_LEVEL||debug}" | 10 | log_level = "${LOG_LEVEL||debug}" |
| 11 | -aliyun_logs_access ="app.log" | 11 | +aliyun_logs_access ="${aliyun_logs_access||app.log}" |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | #redis相关配置 | 14 | #redis相关配置 |
| @@ -22,9 +22,12 @@ yunpian_app_key ="0bf6fb10a11a68a95dee80901eb545b5" | @@ -22,9 +22,12 @@ yunpian_app_key ="0bf6fb10a11a68a95dee80901eb545b5" | ||
| 22 | #存储 http://ability.fjmaimaimai.com:8080/ | 22 | #存储 http://ability.fjmaimaimai.com:8080/ |
| 23 | source_host ="http://192.168.139.137:8080/" | 23 | source_host ="http://192.168.139.137:8080/" |
| 24 | source_virtual_path=file/opp | 24 | source_virtual_path=file/opp |
| 25 | -source_path =~/www/opp | 25 | +source_path ="${aliyun_file_access||~/www/opp} |
| 26 | 26 | ||
| 27 | #网易云信 IM | 27 | #网易云信 IM |
| 28 | net_im_base_url ="https://api.netease.im/nimserver" | 28 | net_im_base_url ="https://api.netease.im/nimserver" |
| 29 | net_im_app_secret ="a8d231f5c13a" | 29 | net_im_app_secret ="a8d231f5c13a" |
| 30 | -net_im_app_key ="9c5410602597a7fe367aeeebd8210262" | ||
| 30 | +net_im_app_key ="9c5410602597a7fe367aeeebd8210262" | ||
| 31 | + | ||
| 32 | +#统一用户中心 | ||
| 33 | +user_center_url ="http://user.fjmaimaimai.com" |
| @@ -51,6 +51,8 @@ spec: | @@ -51,6 +51,8 @@ spec: | ||
| 51 | volumeMounts: | 51 | volumeMounts: |
| 52 | - mountPath: /opt/logs | 52 | - mountPath: /opt/logs |
| 53 | name: accesslogs | 53 | name: accesslogs |
| 54 | + - mountPath: /var/www/opp/file | ||
| 55 | + name: suplusupload-pvc1 | ||
| 54 | env: | 56 | env: |
| 55 | - name: ENTERPRISE_SERVICE_HOST | 57 | - name: ENTERPRISE_SERVICE_HOST |
| 56 | valueFrom: | 58 | valueFrom: |
| @@ -87,6 +89,11 @@ spec: | @@ -87,6 +89,11 @@ spec: | ||
| 87 | value: "stdout" | 89 | value: "stdout" |
| 88 | - name: aliyun_logs_access | 90 | - name: aliyun_logs_access |
| 89 | value: "/opt/logs/opp_app.log" | 91 | value: "/opt/logs/opp_app.log" |
| 92 | + - name: aliyun_file_access | ||
| 93 | + value: "/var/www/opp/file" | ||
| 90 | volumes: | 94 | volumes: |
| 91 | - name: accesslogs | 95 | - name: accesslogs |
| 92 | - emptyDir: {} | ||
| 96 | + emptyDir: {} | ||
| 97 | + - name: suplusupload-pvc1 | ||
| 98 | + persistentVolumeClaim: | ||
| 99 | + claimName: suplusupload-pvc |
| @@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
| 6 | "github.com/astaxie/beego/orm" | 6 | "github.com/astaxie/beego/orm" |
| 7 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 7 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
| 8 | "reflect" | 8 | "reflect" |
| 9 | + "strings" | ||
| 9 | ) | 10 | ) |
| 10 | 11 | ||
| 11 | // 更新指定表的几个列 | 12 | // 更新指定表的几个列 |
| @@ -88,3 +89,70 @@ func ExecuteSqlByRoll(isCheck bool, sqlSlice ...*SqlData) bool { | @@ -88,3 +89,70 @@ func ExecuteSqlByRoll(isCheck bool, sqlSlice ...*SqlData) bool { | ||
| 88 | } | 89 | } |
| 89 | return true | 90 | return true |
| 90 | } | 91 | } |
| 92 | + | ||
| 93 | +//PrintLogSql 打印sql语句 | ||
| 94 | +func PrintLogSql(sql string, param ...interface{}) { | ||
| 95 | + format := `SQL EXCEUTE:[%s]-%s` | ||
| 96 | + parmformat := `[%v]` | ||
| 97 | + var p strings.Builder | ||
| 98 | + for i := range param { | ||
| 99 | + p.WriteString(fmt.Sprintf(parmformat, param[i])) | ||
| 100 | + } | ||
| 101 | + log.Debug(format, sql, p.String()) | ||
| 102 | +} | ||
| 103 | + | ||
| 104 | +//ExecuteQueryOne 执行原生sql查询单条记录;结果用结构体接收 | ||
| 105 | +func ExecuteQueryOne(result interface{}, sqlstr string, param ...interface{}) error { | ||
| 106 | + PrintLogSql(sqlstr, param...) | ||
| 107 | + var err error | ||
| 108 | + o := orm.NewOrm() | ||
| 109 | + err = ExecuteQueryOneWithOrmer(o, result, sqlstr, param) | ||
| 110 | + return err | ||
| 111 | +} | ||
| 112 | + | ||
| 113 | +//ExecuteQueryOneWithOrmer 执行原生sql查询单条 | ||
| 114 | +func ExecuteQueryOneWithOrmer(o orm.Ormer, result interface{}, sqlstr string, param ...interface{}) error { | ||
| 115 | + PrintLogSql(sqlstr, param...) | ||
| 116 | + var err error | ||
| 117 | + err = o.Raw(sqlstr, param).QueryRow(result) | ||
| 118 | + if err != nil { | ||
| 119 | + return err | ||
| 120 | + } | ||
| 121 | + return nil | ||
| 122 | +} | ||
| 123 | + | ||
| 124 | +//ExecuteQuerySql 执行原生sql查询多条记录 | ||
| 125 | +func ExecuteQueryAll(result interface{}, sqlstr string, param ...interface{}) error { | ||
| 126 | + PrintLogSql(sqlstr, param...) | ||
| 127 | + var err error | ||
| 128 | + o := orm.NewOrm() | ||
| 129 | + err = ExecuteQueryAllWithOrmer(o, result, sqlstr, param) | ||
| 130 | + return err | ||
| 131 | +} | ||
| 132 | + | ||
| 133 | +//ExecuteQueryOneWithOrmer 执行原生sql查询多条记录 | ||
| 134 | +func ExecuteQueryAllWithOrmer(o orm.Ormer, result interface{}, sqlstr string, param ...interface{}) error { | ||
| 135 | + PrintLogSql(sqlstr, param...) | ||
| 136 | + var ( | ||
| 137 | + err error | ||
| 138 | + ) | ||
| 139 | + _, err = o.Raw(sqlstr, param).QueryRows(result) | ||
| 140 | + if err != nil { | ||
| 141 | + return err | ||
| 142 | + } | ||
| 143 | + return nil | ||
| 144 | +} | ||
| 145 | + | ||
| 146 | +func ExecuteSQLWithOrmer(o orm.Ormer, sqlstr string, param ...interface{}) error { | ||
| 147 | + PrintLogSql(sqlstr, param...) | ||
| 148 | + var ( | ||
| 149 | + err error | ||
| 150 | + ) | ||
| 151 | + r, err := o.Raw(sqlstr, param...).Exec() | ||
| 152 | + if err != nil { | ||
| 153 | + return err | ||
| 154 | + } | ||
| 155 | + num, _ := r.RowsAffected() | ||
| 156 | + log.Debug("RowsAffected:%d", num) | ||
| 157 | + return nil | ||
| 158 | +} |
| @@ -9,7 +9,7 @@ const ( | @@ -9,7 +9,7 @@ const ( | ||
| 9 | 9 | ||
| 10 | const TokenExpire = 3600 | 10 | const TokenExpire = 3600 |
| 11 | 11 | ||
| 12 | -const SmscodeDayLimitTime =10 //短信验证码每天最多发10次 | 12 | +const SmscodeDayLimitTime = 10 //短信验证码每天最多发10次 |
| 13 | 13 | ||
| 14 | var Nums = []byte("0123456789") | 14 | var Nums = []byte("0123456789") |
| 15 | 15 | ||
| @@ -36,6 +36,21 @@ type LoginResponse struct { | @@ -36,6 +36,21 @@ type LoginResponse struct { | ||
| 36 | AuthCode string `json:"authCode"` | 36 | AuthCode string `json:"authCode"` |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | +/*统一用户中心登录*/ | ||
| 40 | +type LoginUserCenterRequest struct { | ||
| 41 | + Phone string `json:"phone"` | ||
| 42 | + PassWord string `json:"password"` | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +type LoginUserCenterResponse struct { | ||
| 46 | + Id int64 `json:"id"` | ||
| 47 | + Phone string `json:"phone"` | ||
| 48 | + NickName string `json:"nickname"` | ||
| 49 | + Avatar string `json:"avatar"` | ||
| 50 | + Token string `json:"token"` | ||
| 51 | + Accid string `json:"accid"` | ||
| 52 | +} | ||
| 53 | + | ||
| 39 | /*SmsCode*/ | 54 | /*SmsCode*/ |
| 40 | type SmsCodeRequest struct { | 55 | type SmsCodeRequest struct { |
| 41 | Phone string `json:"phone" valid:"Required;Mobile"` | 56 | Phone string `json:"phone" valid:"Required;Mobile"` |
| @@ -48,6 +48,9 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp | @@ -48,6 +48,9 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp | ||
| 48 | } | 48 | } |
| 49 | switch request.GrantType { | 49 | switch request.GrantType { |
| 50 | case protocol.LoginTypePassPord: | 50 | case protocol.LoginTypePassPord: |
| 51 | + if beego.BConfig.RunMode != "dev" { | ||
| 52 | + | ||
| 53 | + } | ||
| 51 | if strings.Compare(user.Passwd, request.PassWord) == 0 { | 54 | if strings.Compare(user.Passwd, request.PassWord) == 0 { |
| 52 | goto Success | 55 | goto Success |
| 53 | } else { | 56 | } else { |
| @@ -279,7 +282,7 @@ func SmsCode(request *protocol.SmsCodeRequest) (rsp *protocol.SmsCodeResponse, e | @@ -279,7 +282,7 @@ func SmsCode(request *protocol.SmsCodeRequest) (rsp *protocol.SmsCodeResponse, e | ||
| 279 | smsInfo.CreateTime = time.Now().Unix() | 282 | smsInfo.CreateTime = time.Now().Unix() |
| 280 | } | 283 | } |
| 281 | if smsInfo.Count >= protocol.SmscodeDayLimitTime { //TODO:limit send time | 284 | if smsInfo.Count >= protocol.SmscodeDayLimitTime { //TODO:limit send time |
| 282 | - err=protocol.NewErrWithMessage(1011) | 285 | + err = protocol.NewErrWithMessage(1011) |
| 283 | return | 286 | return |
| 284 | } | 287 | } |
| 285 | goto Send | 288 | goto Send |
| @@ -321,7 +324,7 @@ func CheckSmsCode(phone, code, sendType string) (result bool, err error) { | @@ -321,7 +324,7 @@ func CheckSmsCode(phone, code, sendType string) (result bool, err error) { | ||
| 321 | result = false | 324 | result = false |
| 322 | if value, err = redis.Hget(sendType, phone); err != nil { //protocol.SmsLoginCode | 325 | if value, err = redis.Hget(sendType, phone); err != nil { //protocol.SmsLoginCode |
| 323 | log.Error(fmt.Sprintf("smscode not exists")) | 326 | log.Error(fmt.Sprintf("smscode not exists")) |
| 324 | - err =protocol.NewErrWithMessage(1009,fmt.Errorf("smscode expire")) | 327 | + err = protocol.NewErrWithMessage(1009, fmt.Errorf("smscode expire")) |
| 325 | return | 328 | return |
| 326 | } | 329 | } |
| 327 | if err = json.Unmarshal([]byte(value), &smsInfo); err != nil { | 330 | if err = json.Unmarshal([]byte(value), &smsInfo); err != nil { |
| @@ -330,19 +333,19 @@ func CheckSmsCode(phone, code, sendType string) (result bool, err error) { | @@ -330,19 +333,19 @@ func CheckSmsCode(phone, code, sendType string) (result bool, err error) { | ||
| 330 | } | 333 | } |
| 331 | if smsInfo.ErrorCount >= 5 { | 334 | if smsInfo.ErrorCount >= 5 { |
| 332 | log.Error(fmt.Sprintf("smscode over error times")) | 335 | log.Error(fmt.Sprintf("smscode over error times")) |
| 333 | - err =protocol.NewErrWithMessage(1009) | 336 | + err = protocol.NewErrWithMessage(1009) |
| 334 | return | 337 | return |
| 335 | } | 338 | } |
| 336 | if (smsInfo.LastTime + 60*5) < time.Now().Unix() { | 339 | if (smsInfo.LastTime + 60*5) < time.Now().Unix() { |
| 337 | - log.Error(fmt.Sprintf("smscode expire %v < %v", (smsInfo.LastTime+60*5), time.Now().Unix())) | ||
| 338 | - err =protocol.NewErrWithMessage(1009) | 340 | + log.Error(fmt.Sprintf("smscode expire %v < %v", (smsInfo.LastTime + 60*5), time.Now().Unix())) |
| 341 | + err = protocol.NewErrWithMessage(1009) | ||
| 339 | goto Fail | 342 | goto Fail |
| 340 | } | 343 | } |
| 341 | if smsInfo.Code == code { | 344 | if smsInfo.Code == code { |
| 342 | result = true | 345 | result = true |
| 343 | return | 346 | return |
| 344 | } else { | 347 | } else { |
| 345 | - log.Error("smscode not equal:",smsInfo.Code,code) | 348 | + log.Error("smscode not equal:", smsInfo.Code, code) |
| 346 | err = protocol.NewErrWithMessage(1012) | 349 | err = protocol.NewErrWithMessage(1012) |
| 347 | goto Fail | 350 | goto Fail |
| 348 | } | 351 | } |
| @@ -351,8 +354,8 @@ Fail: | @@ -351,8 +354,8 @@ Fail: | ||
| 351 | smsInfo.ErrorCount += 1 | 354 | smsInfo.ErrorCount += 1 |
| 352 | if e := redis.Hset(sendType, phone, common.AssertJson(smsInfo), -1); e != nil { | 355 | if e := redis.Hset(sendType, phone, common.AssertJson(smsInfo), -1); e != nil { |
| 353 | log.Error(e) | 356 | log.Error(e) |
| 354 | - if err==nil{ | ||
| 355 | - err =e | 357 | + if err == nil { |
| 358 | + err = e | ||
| 356 | } | 359 | } |
| 357 | return | 360 | return |
| 358 | } | 361 | } |
-
请 注册 或 登录 后发表评论