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
dac77dcf
Commit
dac77dcf
authored
Dec 13, 2019
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unlike
parent
8bab5c76
Pipeline
#18120
passed with stage
in 10 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
institution.js
app/controller/course/v3/institution.js
+12
-0
course_v3.js
app/router/course_v3.js
+1
-0
institution.js
app/service/course/v3/institution.js
+34
-0
No files found.
app/controller/course/v3/institution.js
View file @
dac77dcf
...
@@ -180,6 +180,18 @@ class InstitutionController extends Controller {
...
@@ -180,6 +180,18 @@ class InstitutionController extends Controller {
const
ret
=
await
service
.
course
.
v3
.
institution
.
like
(
inputParams
);
const
ret
=
await
service
.
course
.
v3
.
institution
.
like
(
inputParams
);
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
// 取消点赞
async
unlike
()
{
const
{
ctx
,
service
}
=
this
;
const
inputParams
=
ctx
.
request
.
body
;
if
(
ctx
.
isEmpty
(
inputParams
)
||
ctx
.
isEmpty
(
inputParams
.
type
)
||
ctx
.
isEmpty
(
inputParams
.
type_id
))
{
ctx
.
failed
(
'参数错误'
);
}
const
ret
=
await
service
.
course
.
v3
.
institution
.
unlike
(
inputParams
);
ctx
.
success
(
ret
);
}
}
}
module
.
exports
=
InstitutionController
;
module
.
exports
=
InstitutionController
;
app/router/course_v3.js
View file @
dac77dcf
...
@@ -44,5 +44,6 @@ module.exports = app => {
...
@@ -44,5 +44,6 @@ module.exports = app => {
router
.
get
(
'third'
,
'/article/:id'
,
miniAuth
,
'course.v3.institution.getArticle'
);
// 获取选课指南详情
router
.
get
(
'third'
,
'/article/:id'
,
miniAuth
,
'course.v3.institution.getArticle'
);
// 获取选课指南详情
router
.
post
(
'third'
,
'/like'
,
miniAuth
,
'course.v3.institution.like'
);
// 点赞
router
.
post
(
'third'
,
'/like'
,
miniAuth
,
'course.v3.institution.like'
);
// 点赞
router
.
post
(
'third'
,
'/unlike'
,
miniAuth
,
'course.v3.institution.unlike'
);
// 取消点赞
};
};
app/service/course/v3/institution.js
View file @
dac77dcf
...
@@ -744,6 +744,40 @@ class InstitutionSubService extends Service {
...
@@ -744,6 +744,40 @@ class InstitutionSubService extends Service {
return
;
return
;
}
}
//取消点赞
async
unlike
(
input
)
{
const
{
ctx
}
=
this
;
const
type
=
Number
(
input
.
type
)
||
0
;
const
typeId
=
Number
(
input
.
type_id
)
||
0
;
let
tmp
=
{};
if
(
type
===
0
||
typeId
===
0
)
{
ctx
.
failed
(
'参数异常'
);
}
// 是否重复点赞
const
userLike
=
await
ctx
.
classModel
.
V3
.
CourseLike
.
findOne
({
where
:
{
user_uuid
:
ctx
.
userUuid
,
type
,
type_id
:
typeId
,
is_deleted
:
0
}
});
if
(
ctx
.
isEmpty
(
userLike
))
{
ctx
.
failed
(
'尚未点赞'
);
}
// 校验点赞对象是否存在
switch
(
type
)
{
case
1
:
tmp
=
await
ctx
.
classModel
.
V3
.
CourseArticle
.
findOne
({
where
:
{
id
:
typeId
,
status
:
'online'
,
is_deleted
:
0
}
});
if
(
ctx
.
isEmpty
(
tmp
))
{
ctx
.
failed
(
'数据不存在'
);
}
// 更新点赞数
await
ctx
.
classModel
.
V3
.
CourseArticle
.
update
({
read_count
:
sequelize
.
literal
(
'`read_count` - 1'
)
},
{
where
:
{
id
:
typeId
}
});
break
;
default
:
break
;
}
await
ctx
.
classModel
.
V3
.
CourseLike
.
update
({
is_deleted
:
1
},
{
where
:{
id
:
userLike
.
id
}});
return
;
}
}
}
module
.
exports
=
InstitutionSubService
;
module
.
exports
=
InstitutionSubService
;
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