Passed
Push — master ( 1adf40...f067da )
by lv
01:05
created

app/controller/catering/session.js   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 48
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
wmc 1
eloc 12
c 0
b 0
f 0
nc 1
mnd 0
bc 1
fnc 1
dl 0
loc 48
rs 10
bpm 1
cpm 1
noi 3

1 Function

Rating   Name   Duplication   Size   Complexity  
A module.exports.wxLogin 0 13 1
1
const ServiceSession = require('../../services/catering/session')
2
const Validate = require('request-validate');
3
const Response = require('../../util/response');
4
const Config = require('../../../config/config')
0 ignored issues
show
Unused Code introduced by
The constant Config seems to be never used. Consider removing it.
Loading history...
5
6
module.exports = {
7
    /**
8
     * @api {post} /api/catering/v1/sessions 用户微信登陆
9
     * @apiGroup session
10
     * @apiPermission guest
11
     * @apiParam {String} wx_js_code 小程序js_code
12
     * @apiParam {String} wx_encrypted_data 小程序用户加密数据
13
     * @apiParam {String} wx_iv 小程序微信iv
14
     * @apiParam {String} store_id 访问的小程序id,从header传递
15
     * @apiVersion 1.0.0
16
     * @apiSuccessExample {json} Visual Preview:
17
    {
18
        "code": 200,
19
        "message": "请求成功",
20
        "data": {
21
            "id": 2,
22
            "username": "oTj1As__sB0-n5qv8Cs5Le99k1jk",
23
            "unionid": "oTj1As__sB0-n5qv8Cs5Le99k1jk",
24
            "nickname": "大飞",
25
            "avatar": "https://wx.qlogo.cn/mmopen/vi_32/2I8gWeWUwNEXSNXaMVAmaCm48ibXBcCPWFc7pYT3b1XXD5KdkIIzd4Vyyoc3UHQQ2OgOFsialBJHv4MsI3YgHaCA/0",
26
            "user_balance": 0,
27
            "status": 1,
28
            "uid": 2,
29
            "gender": "0",
30
            "token": "1102e330-07bf-11e8-a078-1ff77849336d",
31
            "wx_openid": "oAXj6jnk9PEyDlTZRxktZ3kfUifo"
32
        }
33
    }
34
     */
35
    wxLogin:async function (ctx, next) {
0 ignored issues
show
Unused Code introduced by
The parameter next is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
36
        Validate(ctx.input, {
37
            // 'wx_js_code': 'required',
38
            // 'wx_encrypted_data': 'required',
39
            // 'wx_iv': 'required',
40
            'code': 'required',
41
        })
42
        let storeId = ctx.header['store-id']
0 ignored issues
show
Unused Code introduced by
The variable storeId seems to be never used. Consider removing it.
Loading history...
43
        let config = ctx.header['mina-source']
44
        
45
        let result = await ServiceSession.wxLogin(ctx.input.code, config)
46
        return Response.output(ctx, result);
47
    },
48
}