Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
95c168c6
Commit
95c168c6
authored
Nov 19, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://t-git.51gjj.com/fangbin/51business
parents
b6625b8d
9066950e
Pipeline
#16604
passed with stage
in 7 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
19 deletions
+17
-19
user.js
app/controller/course/v1/user.js
+4
-4
course_user.js
app/model/class/course_user.js
+4
-4
course_institution.js
app/model/class/v1/course_institution.js
+1
-1
course_user.js
app/model/class/v1/course_user.js
+4
-4
institution.js
app/service/course/v1/institution.js
+2
-4
user.js
app/service/course/v1/user.js
+2
-2
No files found.
app/controller/course/v1/user.js
View file @
95c168c6
...
...
@@ -18,10 +18,10 @@ class UserController extends Controller {
const
openid
=
wx_auth_ret
.
openid
;
//获取openid
//检查是否已授权过 是否已入用户表
let
user
=
await
ctx
.
classModel
.
v
1
.
CourseUser
.
one
({
where
:
{
openid
,
is_deleted
:
0
}
});
let
user
=
await
ctx
.
classModel
.
V
1
.
CourseUser
.
one
({
where
:
{
openid
,
is_deleted
:
0
}
});
if
(
!
user
||
!
user
.
uuid
)
{
const
uuid
=
uuidv4
();
user
=
await
ctx
.
classModel
.
v
1
.
CourseUser
.
create
({
uuid
,
openid
});
user
=
await
ctx
.
classModel
.
V
1
.
CourseUser
.
create
({
uuid
,
openid
});
// user.uuid = uuid;
}
console
.
info
(
user
);
...
...
@@ -47,8 +47,8 @@ class UserController extends Controller {
const
{
avatar
,
nickname
,
province
,
country
,
sex
,
city
}
=
input_params
;
//查找用户是否存在并更新
const
user
=
ctx
.
classModel
.
v
1
.
CourseUser
.
one
({
where
:
{
uuid
}
});
await
ctx
.
classModel
.
v
1
.
CourseUser
.
edit
({
params
:
{
avatar
,
nickname
,
sex
},
where
:
{
uuid
}
});
const
user
=
ctx
.
classModel
.
V
1
.
CourseUser
.
one
({
where
:
{
uuid
}
});
await
ctx
.
classModel
.
V
1
.
CourseUser
.
edit
({
params
:
{
avatar
,
nickname
,
sex
},
where
:
{
uuid
}
});
let
bindphone
=
0
;
if
(
user
.
phone
)
{
bindphone
=
1
;
...
...
app/model/class/course_user.js
View file @
95c168c6
...
...
@@ -23,19 +23,19 @@ module.exports = app => {
sex
:
STRING
,
openid
:
STRING
,
is_deleted
:
INTEGER
,
created_
time
:
{
created_
at
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_
time
'
);
const
date
=
this
.
getDataValue
(
'created_
at
'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
updated_
time
:
{
updated_
at
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'updated_
time
'
);
const
date
=
this
.
getDataValue
(
'updated_
at
'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
...
...
app/model/class/v1/course_institution.js
View file @
95c168c6
...
...
@@ -7,7 +7,7 @@ module.exports = app => {
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseArea
=
app
.
classModel
.
define
(
'course_area'
);
const
CourseArea
=
app
.
classModel
.
define
(
'course_area
_v1
'
);
const
CourseInstitution
=
app
.
classModel
.
define
(
'course_institution_v1'
,
{
id
:
{
...
...
app/model/class/v1/course_user.js
View file @
95c168c6
...
...
@@ -23,19 +23,19 @@ module.exports = app => {
sex
:
STRING
,
openid
:
STRING
,
is_deleted
:
INTEGER
,
created_
time
:
{
created_
at
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_
time
'
);
const
date
=
this
.
getDataValue
(
'created_
at
'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
updated_
time
:
{
updated_
at
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'updated_
time
'
);
const
date
=
this
.
getDataValue
(
'updated_
at
'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
...
...
app/service/course/v1/institution.js
View file @
95c168c6
...
...
@@ -56,7 +56,6 @@ class InstitutionService extends Service {
// const area_lbs = await this.computeDistance(institution_area_list, { lat, lng });// 计算距离信息
const
area_distance_list
=
await
this
.
calcDistance
(
institution_area_list
,
{
lat
,
lng
},
page
,
distance
);
const
area_distance
=
area_distance_list
.
rows
;
console
.
log
(
area_distance_list
);
const
institution_areas
=
await
this
.
computeDistance
(
area_distance
,
{
lat
,
lng
});
for
(
const
i
in
institution_areas
)
{
area_distance
[
i
].
distance
=
Number
(
institution_areas
[
i
].
distance
)
===
0
?
999999999.0
:
parseFloat
(
institution_areas
[
i
].
distance
);
...
...
@@ -307,7 +306,6 @@ class InstitutionService extends Service {
// 机构列表 并有多校区 {id:1,..., course_areas:[{},{}]
async
getInstitutionAreaList
(
institutions
)
{
const
{
ctx
}
=
this
;
if
(
!
Array
.
isArray
(
institutions
)
||
institutions
.
length
===
0
)
{
...
...
@@ -317,8 +315,8 @@ class InstitutionService extends Service {
const
ret
=
[];
for
(
const
i
in
institutions
)
{
const
institution
=
institutions
[
i
];
if
(
!
institution
.
course_area
s
||
institution
.
course_area
s
.
length
===
0
)
continue
;
const
course_areas
=
institution
.
course_areas
;
if
(
!
institution
.
course_area
_v1s
||
institution
.
course_area_v1
s
.
length
===
0
)
continue
;
const
course_areas
=
institution
.
course_area
_v1
s
;
for
(
const
j
in
course_areas
)
{
const
course_area
=
course_areas
[
j
];
ret
.
push
({
...
...
app/service/course/v1/user.js
View file @
95c168c6
...
...
@@ -118,8 +118,8 @@ class UserService extends Service {
async
requestWxAuth
(
code
)
{
const
{
ctx
}
=
this
;
const
APPID
=
'wx
4769ebba9b91f8ec
'
;
const
SECRET
=
'
680440637b4e38c9b66529cfd5dc590e
'
;
const
APPID
=
'wx
07a5f0ed5bdf4751
'
;
const
SECRET
=
'
a1b2d32b018988176181497bd74a0b7d
'
;
const
url
=
`https://api.weixin.qq.com/sns/jscode2session?appid=
${
APPID
}
&secret=
${
SECRET
}
&js_code=
${
code
}
&grant_type=authorization_code`
;
const
result
=
await
ctx
.
helper
.
send_request
(
url
,
{},
{
method
:
'GET'
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment