Skip to content

Commit

Permalink
替掉go默认的gopath, 修改包的引入路径
Browse files Browse the repository at this point in the history
  • Loading branch information
shen100 committed May 13, 2017
1 parent df87f7b commit 5621f56
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 25 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ go run main.go
* 数据库: mysql

## 项目结构
| 目录或文件 |目录或文件| 说明 |
|:--------|:--------|:-------:|
| 目录或文件 | 目录或文件 | 说明 |
|:---------|:-----------------------|:-------:|
| docs | | 文档|
| go | | 后台代码目录|
| | config | 配置|
Expand All @@ -86,5 +86,6 @@ go run main.go
| configuration.json | | 项目配置文件 |
| main.go | | go主程序入口|


## 最后
求star,star就是继续下去的动力

2 changes: 1 addition & 1 deletion go/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"../utils"
"wemall/go/utils"
)

var jsonData map[string]interface{}
Expand Down
4 changes: 2 additions & 2 deletions go/controller/category/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"unicode/utf8"
"strings"
"strconv"
"../../config"
"../../model"
"github.com/jinzhu/gorm"
"gopkg.in/kataras/iris.v6"
"wemall/go/config"
"wemall/go/model"
)

// Save 保存分类(创建或更新)
Expand Down
2 changes: 1 addition & 1 deletion go/controller/order/order.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package order

import (
"../../model"
"gopkg.in/kataras/iris.v6"
"time"
"wemall/go/model"
)

// TodayCount 今日总订单数
Expand Down
4 changes: 2 additions & 2 deletions go/controller/product/product.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package product

import (
"../../config"
"../../model"
"strconv"
"strings"
"unicode/utf8"
"github.com/jinzhu/gorm"
"gopkg.in/kataras/iris.v6"
"wemall/go/config"
"wemall/go/model"
)

// List 产品列表
Expand Down
2 changes: 1 addition & 1 deletion go/controller/user/user.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package user

import (
"../../model"
"time"
"gopkg.in/kataras/iris.v6"
"wemall/go/model"
)

// YesterdayRegisterUser 昨日注册的用户数
Expand Down
4 changes: 2 additions & 2 deletions go/controller/visit/visit.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package visit

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

// Latest30Day 近30天,每天的PV
Expand Down
2 changes: 1 addition & 1 deletion go/model/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package model
import (
"strings"
"time"
"../config"
"github.com/jinzhu/gorm"
"wemall/go/config"
)

// Order 订单
Expand Down
2 changes: 1 addition & 1 deletion go/model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package model
import (
"strings"
"time"
"../config"
"github.com/jinzhu/gorm"
"wemall/go/config"
)

// User 用户
Expand Down
2 changes: 1 addition & 1 deletion go/model/uservisit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package model

import (
"time"
"../config"
"strings"
"github.com/jinzhu/gorm"
"wemall/go/config"
)

// UserVisit 访客记录
Expand Down
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package main

import (
"./go/config"
"./go/model"
"./go/controller/admin"
"./go/controller/category"
"./go/controller/product"
"./go/controller/order"
"./go/controller/user"
"./go/controller/visit"
_ "github.com/jinzhu/gorm/dialects/mysql"
"gopkg.in/kataras/iris.v6"
"gopkg.in/kataras/iris.v6/adaptors/httprouter"
"strconv"
"wemall/go/config"
"wemall/go/model"
"wemall/go/controller/admin"
"wemall/go/controller/category"
"wemall/go/controller/product"
"wemall/go/controller/order"
"wemall/go/controller/user"
"wemall/go/controller/visit"
)

func main() {
Expand Down
25 changes: 25 additions & 0 deletions nodejs/static/javascripts/admin/actions/product/requestProduct.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
REQUEST_PRODUCT,
REQUEST_PRODUCT_SUCCESS
} from '../../constants';

function receive(data) {
return {
type : REQUEST_PRODUCT_SUCCESS,
product : data
};
}

export default function(id) {
return dispatch => {
dispatch({
type: REQUEST_PRODUCT,
});
var url = pageConfig.apiURL + '/admin/product/:id';
url = url.replace(':id', id);
return fetch(url)
.then(response => response.json())
.then(json => dispatch(receive(json.data)));
};
};

102 changes: 102 additions & 0 deletions nodejs/static/javascripts/admin/containers/product/EditProduct.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';

import {
Row,
Col,
Form,
Input,
TreeSelect
} from 'antd';

import requestProduct from '../actions/product/requestProduct';
import requestCategoryList from '../actions/category/requestCategoryList';
import Software from './Software';
import utils from '../utils';
import analyze from '../../sdk/analyze';
import '../../../styles/admin/editProduct.css';

/*
* 管理后台,新建或编辑商品
*/
class EditProduct extends Component {
constructor(props) {
super(props);
this.state = {
productId : this.props.routeParams.id,
parents : [] //父分类
};
}
componentDidMount() {
analyze.pv();
const { dispatch } = this.props;
if (this.state.productId) {
dispatch(requestProduct(this.state.productId));
}
dispatch(requestCategoryList());
}
onParentsChange(value) {
console.log('onChange ', value, arguments);
this.setState({ value });
}
render() {
let { data } = this.props;
let isLoading = this.state.productId && !data.category ? true : false;
let editLabel = this.state.productId ? '编' : '添';

const FormItem = Form.Item;
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 3 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 12 },
}
};

let treeData = utils.parseCategoryTree(data.categories);

const treeProps = {
treeData,
value : this.state.value,
onChange : this.onParentsChange.bind(this),
multiple : true,
treeCheckable: true,
showCheckedStrategy: TreeSelect.SHOW_PARENT,
searchPlaceholder: '选择父分类',
style: {
width: '100%',
}
};

return (
<div>
<Row gutter={24}>
<Col span={24}>
<div id="productBox" className="product-box">
<div className="product-title">{editLabel}商品</div>
<Form>
<FormItem {...formItemLayout} label="父分类">
<TreeSelect {...treeProps} />
</FormItem>
</Form>

</div>
</Col>
</Row>
<Software />
</div>
);
}
}

const mapStateToProps = (state) => {
return {
data: state.category
};
}

export default connect(mapStateToProps)(EditProduct);

2 changes: 1 addition & 1 deletion nodejs/static/javascripts/admin/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import software from './software';
import systemIndex from './systemIndex';
import userAnalyze from './userAnalyze';
import orderAnalyze from './orderAnalyze';
import productAnalyze from './productAnalyze';
import product from './product';
import category from './category';

const reducers = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {

let initState = {
hotProducts: [],
products: []
products : [], //产品列表
category : null //当前查询出的产品
};

export default (state = initState, action) => {
Expand Down Expand Up @@ -36,6 +37,18 @@ export default (state = initState, action) => {
products: products
};
}
case REQUEST_CATEGORY: {
return {
...state,
product: null
};
}
case REQUEST_CATEGORY_SUCCESS: {
return {
...state,
product: action.product
};
}
default: {
return state
}
Expand Down
15 changes: 15 additions & 0 deletions nodejs/static/styles/admin/product/editProduct.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.product-box {

}

.product-title {
font-size: 20px;
margin-bottom: 6px;
color: #000;
}

.ant-select-tree-noline_close:after {
-webkit-transform: rotate(270deg) scale(.59) !important;
-ms-transform: rotate(270deg) scale(.59) !important;
transform: rotate(270deg) scale(.59) !important;
}

0 comments on commit 5621f56

Please sign in to comment.