Skip to content

Commit

Permalink
前端构建脚本完成
Browse files Browse the repository at this point in the history
  • Loading branch information
shen100 committed May 17, 2017
1 parent 89c08bb commit 358f90c
Show file tree
Hide file tree
Showing 23 changed files with 435 additions and 562 deletions.
3 changes: 0 additions & 3 deletions .gitattributes

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dist
.idea
*.swp
.bashrc
debug
debug
wemall
23 changes: 12 additions & 11 deletions configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@
"go": {
"Debug" : true, /*是否是debug模式*/
"UploadImgDir" : "/Users/liushen/dev/uploads/img", /*图片上传的目录*/
"ImgPath" : "/img", /*上传后的图片请求地址前缀*/
"Port" : 8012, /*go监听的端口*/
"MaxOrder" : 10000, /*最大的排序号*/
"MinOrder" : 0, /*最小的排序号*/
"PageSize" : 20, /*默认每页的条数*/
"MaxPageSize" : 100, /*每页最大的条数*/
"MinPageSize" : 20, /*每页最小的条数*/
"MaxNameLen" : 100, /*最大的名称长度*/
"MaxRemarkLen" : 500, /*最大的备注长度*/
"MaxContentLen" : 10000, /*最大的内容长度*/
"MaxProductCateCount" : 6 /*产品最多的分类个数*/
"ImgPath" : "/img", /*上传后的图片请求地址前缀*/
"Port" : 8012, /*go监听的端口*/
"SessionID" : "iris.sid", /*后台设置的session id*/
"MaxOrder" : 10000, /*最大的排序号*/
"MinOrder" : 0, /*最小的排序号*/
"PageSize" : 20, /*默认每页的条数*/
"MaxPageSize" : 100, /*每页最大的条数*/
"MinPageSize" : 20, /*每页最小的条数*/
"MaxNameLen" : 100, /*最大的名称长度*/
"MaxRemarkLen" : 500, /*最大的备注长度*/
"MaxContentLen" : 10000, /*最大的内容长度*/
"MaxProductCateCount" : 6 /*产品最多的分类个数*/
},
"software": {
"name" : "wemall微商城", /*软件名称*/
Expand Down
56 changes: 56 additions & 0 deletions configuration.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"webPoweredBy": "wemall", /*前端node.js加的X-Powered-By*/
"apiPoweredBy": "wemall api", /*后台go加的X-Powered-By*/
"database": {
"Dialect" : "mysql",
"Database" : "wemall",
"User" : "root",
"Password" : "test1234",
"Charset" : "utf8",
"SQLLog" : true, /*是否输出SQL*/
"URL" : "" /*数据库连接地址*/
},
"nodejs": {
"page": {
"title" : "wemall-微商城", /*网站标题*/
"sitePath" : "", /*网站前缀,适用于子应用的场景*/
"jsPath" : "/javascripts", /*前端JS请求地址前缀*/
"imagePath" : "/images", /*前端图片请求地址前缀*/
"cssPath" : "/styles", /*前端css请求地址前缀*/
"ueditorURL" : "/ueditor/" /*前端ueditor请求地址前缀*/
},
"env" : "production", /*模式(开发,测试,产品)*/
"useProxy" : false, /*node.js发请求是否使用代理*/
"proxyUri" : "http://127.0.0.1:8881", /*代理地址及端口*/
"port" : 8010, /*前端node.js监听的端口*/
"staticPort" : 8011 /*前端静态文件服务器监听的端口(本地开发时使用)*/
},
"go": {
"Debug" : true, /*是否是debug模式*/
"UploadImgDir" : "/Users/liushen/dev/uploads/img", /*图片上传的目录*/
"ImgPath" : "/img", /*上传后的图片请求地址前缀*/
"Port" : 8012, /*go监听的端口*/
"SessionID" : "iris.sid", /*后台设置的session id*/
"MaxOrder" : 10000, /*最大的排序号*/
"MinOrder" : 0, /*最小的排序号*/
"PageSize" : 20, /*默认每页的条数*/
"MaxPageSize" : 100, /*每页最大的条数*/
"MinPageSize" : 20, /*每页最小的条数*/
"MaxNameLen" : 100, /*最大的名称长度*/
"MaxRemarkLen" : 500, /*最大的备注长度*/
"MaxContentLen" : 10000, /*最大的内容长度*/
"MaxProductCateCount" : 6 /*产品最多的分类个数*/
},
"software": {
"name" : "wemall微商城", /*软件名称*/
"version" : "1.0.0", /*软件版本*/
"officialURL" : "https://www.shen100.com" /*官网地址*/
},
"api": {
"Prefix" : "/api", /*api服务请求前缀*/
"URL" : "http://127.0.0.1:8012/api" /*api服务请求地址(给node.js调用)*/
},
"docs": {
"github": "https://github.com/shen100/wemall" /*wemall项目github地址*/
}
}
175 changes: 0 additions & 175 deletions docs/api/后台管理/系统概况.md

This file was deleted.

13 changes: 13 additions & 0 deletions docs/nginx配置.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# nginx配置

## 开启gzip压缩

```
gzip on;
gzip_min_length 10k;
gzip_buffers 4 16k;
gzip_comp_level 2;
gzip_types application/x-javascript text/javascript application/javascript text/plain text/css application/json application/xml image/jpeg image/gif image/png;
gzip_vary off;
gzip_disable "MSIE [1-6]\.";
```
2 changes: 1 addition & 1 deletion go/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type serverConfig struct {
ImgPath string
UploadImgDir string
Port int
StaticPort int
SessionID string
MaxOrder int
MinOrder int
PageSize int
Expand Down
71 changes: 71 additions & 0 deletions go/controller/user/user.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package user

import (
"fmt"
"time"
"gopkg.in/kataras/iris.v6"
"github.com/jinzhu/gorm"
"wemall/go/config"
"wemall/go/model"
"wemall/go/utils"
)

// YesterdayRegisterUser 昨日注册的用户数
Expand Down Expand Up @@ -77,4 +81,71 @@ func Analyze(ctx *iris.Context) {
"msg" : "success",
"data" : data,
})
}

// Login 用户登录
func Login(ctx *iris.Context) {
var user model.User
session := ctx.Session()

session.Get("user")

if err := ctx.ReadJSON(&user); err != nil {
fmt.Println(err.Error());
ctx.JSON(iris.StatusOK, iris.Map{
"errNo" : model.ErrorCode.ERROR,
"msg" : "参数无效",
"data" : iris.Map{},
})
return
}

hash, pwdErr := utils.HashPassword(user.Password)

if pwdErr != nil {
ctx.JSON(iris.StatusOK, iris.Map{
"errNo" : model.ErrorCode.LoginError,
"msg" : "用户名或密码错误",
"data" : iris.Map{},
})
}

db, connErr := gorm.Open(config.DBConfig.Dialect, config.DBConfig.URL)
if connErr != nil {
ctx.JSON(iris.StatusOK, iris.Map{
"errNo" : model.ErrorCode.ERROR,
"msg" : "error",
"data" : iris.Map{},
})
return
}

defer db.Close()
var queryUser model.User

err := db.Model(&queryUser).Where("password = ?", user.Email).Error

if err != nil {
ctx.JSON(iris.StatusOK, iris.Map{
"errNo" : model.ErrorCode.ERROR,
"msg" : "error",
"data" : iris.Map{},
})
return
}

if utils.CheckPasswordHash(queryUser.Password, hash) {
ctx.JSON(iris.StatusOK, iris.Map{
"errNo" : model.ErrorCode.SUCCESS,
"msg" : "success",
"data" : iris.Map{},
})
} else {
ctx.JSON(iris.StatusOK, iris.Map{
"errNo" : model.ErrorCode.LoginError,
"msg" : "用户名或密码错误",
"data" : iris.Map{},
})
return
}
}
Loading

0 comments on commit 358f90c

Please sign in to comment.