大维 发布的文章

1.注意事项

服务器web服务必须是nginx,apache暂未做适配,php必须以php-fpm启动,即LNMP才支持,LNAMP和LAMP不支持。

服务器同时安装了php5.6和php7.1,php5.6和php7.1已经同时启动。

2.开始配置

修改nginx配置文件

宝塔站点管理点击您想配置的站点,选择配置文件,我们先将33行左右的include enable-php-xx.conf前加#注释掉然后加入如下代码

location ~ [^/]\.php(/|$)

    {    

        fastcgi_pass unix:/tmp/php-cgi-71.sock; 

        fastcgi_index index.php;

        include fastcgi.conf;

        include pathinfo.conf;

        if ($request_uri ~* "ndot_ladderbuy"){   

            fastcgi_pass unix:/tmp/php-cgi-72.sock;    

        }   

    }

  1. 安装vetur(vue) 和 prettier 两个插件
  2. 打开vscode软件,左下角点击设置 》打开设置》唤出快速搜索条界面。
  3. 设定自动保存文件,搜索框贴入files.autoSave筛出设置项,并把设置项属性选择为onFocuschange。
  4. 设定编辑器默认代码格式化(美化)的插件为Prettier,同理在搜索设置框贴入editor.defaultFormatter,将配置项选择为Vetur。
  5. 设定Prettier插件保存时自动格式化代码,搜索设置项贴入editor.formatOnSave,将搜索到的项目打钩即可

使用ma实现

func BuildCondition(where map[string]interface{}) (whereSql string,
    values []interface{}, err error) {
    for key, value := range where {
        conditionKey := strings.Split(key, " ")
        if len(conditionKey) > 2 {
            return "", nil, fmt.Errorf("" +
                "map构建的条件格式不对,类似于'age >'")
        }
        if whereSql != "" {
            whereSql += " AND "
        }
        switch len(conditionKey) {
        case 1:
            whereSql += fmt.Sprint(conditionKey[0], " = ?")
            values = append(values, value)
            break
        case 2:
            field := conditionKey[0]
            switch conditionKey[1] {
            case "=":
                whereSql += fmt.Sprint(field, " = ?")
                values = append(values, value)
                break
            case ">":
                whereSql += fmt.Sprint(field, " > ?")
                values = append(values, value)
                break
            case ">=":
                whereSql += fmt.Sprint(field, " >= ?")
                values = append(values, value)
                break
            case "<":
                whereSql += fmt.Sprint(field, " < ?")
                values = append(values, value)
                break
            case "<=":
                whereSql += fmt.Sprint(field, " <= ?")
                values = append(values, value)
                break
            case "in":
                whereSql += fmt.Sprint(field, " in (?)")
                values = append(values, value)
                break
            case "like":
                whereSql += fmt.Sprint(field, " like ?")
                values = append(values, value)
                break
            case "<>":
                whereSql += fmt.Sprint(field, " != ?")
                values = append(values, value)
                break
            case "!=":
                whereSql += fmt.Sprint(field, " != ?")
                values = append(values, value)
                break
            }
            break
        }
    }
    return
}

用法

conditionString, values, _ := tool.BuildCondition(map[string]interface{}{
        "itemNO":        "02WZ05133",
        "itemName like": "%22220",
        "id in":         []int{20, 19, 30},
        "num !=" : 20,
    })
var student model.Student
db.where(conditionString,values).Find(&student)

1.注意事项

a、服务器web服务必须是nginx,php必须以php-fpm启动。

b、服务器同时安装了php5.6和php7.1。

2.开始配置

修改nginx配置文件

宝塔站点管理点击你想配置的站点,选择配置文件,我们先将33行左右的include enable-php-xx.conf前加#注释掉然后加入如下代码

location ~ 1.php(/|$)

{    

    fastcgi_pass unix:/tmp/php-cgi-71.sock; 

    fastcgi_index index.php;

    include fastcgi.conf;

    include pathinfo.conf;

    if ($request_uri ~* "ndot_blindbox"){   

        fastcgi_pass unix:/tmp/php-cgi-72.sock;    

    }   

}

  1. /

登录阿里云控制台/对象存储/Bucket列表/xxx/权限控制/跨域设置/创建规则。设置如下:

来源:*
允许 Methods:GET|POST
允许 Headers:access-control-allow-origin:*
              access-control-allow-credentials:true
暴露 Headers:空白不写
缓存时间(秒):600
返回 Vary: Origin:勾选