Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
answer-backend
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
answer
answer-backend
Commits
22870a4a
Commit
22870a4a
authored
Feb 11, 2023
by
wqc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一天提交5次
parent
68962b2c
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
76 deletions
+16
-76
user-server/src/main/java/com/zq/user/controller/api/QuestionApi.java
+0
-27
user-server/src/main/java/com/zq/user/dao/AnswerRecDao.java
+1
-0
user-server/src/main/java/com/zq/user/dao/ReplyCountDao.java
+0
-11
user-server/src/main/java/com/zq/user/entity/ReplyCount.java
+0
-35
user-server/src/main/java/com/zq/user/service/QuestionService.java
+7
-3
user-server/src/main/resources/mapper/AnswerRecMapper.xml
+8
-0
No files found.
user-server/src/main/java/com/zq/user/controller/api/QuestionApi.java
View file @
22870a4a
package
com
.
zq
.
user
.
controller
.
api
;
package
com
.
zq
.
user
.
controller
.
api
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.user.dao.AnswerRecDao
;
import
com.zq.user.dao.ReplyCountDao
;
import
com.zq.user.entity.AnswerRec
;
import
com.zq.user.entity.AnswerRec
;
import
com.zq.user.entity.ReplyCount
;
import
com.zq.user.service.PrizeService
;
import
com.zq.user.service.PrizeService
;
import
com.zq.user.service.QuestionService
;
import
com.zq.user.service.QuestionService
;
import
com.zq.user.utils.LimitRequest
;
import
com.zq.user.vo.LotteryRecFindVo
;
import
com.zq.user.vo.LotteryRecFindVo
;
import
com.zq.user.vo.QuestionFindVo
;
import
com.zq.user.vo.QuestionFindVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -18,8 +12,6 @@ import io.swagger.annotations.ApiOperation;
...
@@ -18,8 +12,6 @@ import io.swagger.annotations.ApiOperation;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
/**
* @author wilmiam
* @author wilmiam
* @since 2022/6/15 9:51
* @since 2022/6/15 9:51
...
@@ -32,7 +24,6 @@ public class QuestionApi {
...
@@ -32,7 +24,6 @@ public class QuestionApi {
private
final
PrizeService
prizeService
;
private
final
PrizeService
prizeService
;
private
final
QuestionService
questionService
;
private
final
QuestionService
questionService
;
private
final
ReplyCountDao
replyCountDao
;
@ApiOperation
(
"获取题目列表"
)
@ApiOperation
(
"获取题目列表"
)
@PostMapping
(
value
=
"/getQuestionList"
)
@PostMapping
(
value
=
"/getQuestionList"
)
...
@@ -47,24 +38,6 @@ public class QuestionApi {
...
@@ -47,24 +38,6 @@ public class QuestionApi {
AssertUtils
.
hasText
(
vo
.
getUserId
(),
"缺少用户ID"
);
AssertUtils
.
hasText
(
vo
.
getUserId
(),
"缺少用户ID"
);
AssertUtils
.
hasText
(
vo
.
getAnswerList
(),
"缺少答案"
);
AssertUtils
.
hasText
(
vo
.
getAnswerList
(),
"缺少答案"
);
ReplyCount
replyCount2
=
replyCountDao
.
selectOne
(
Wrappers
.
lambdaQuery
(
ReplyCount
.
builder
().
userId
(
vo
.
getUserId
()).
build
()));
if
(
replyCount2
==
null
)
{
ReplyCount
reply
=
new
ReplyCount
();
reply
.
setUserId
(
vo
.
getUserId
());
reply
.
setReplyCount
(
vo
.
getReplyCount
());
replyCountDao
.
insert
(
reply
);
}
else
{
Integer
count
=
replyCount2
.
getReplyCount
();
count
+=
count
;
ReplyCount
reply
=
new
ReplyCount
();
reply
.
setReplyCount
(
count
);
replyCountDao
.
update
(
reply
);
}
if
(
replyCount2
.
getReplyCount
().
intValue
()>
5
){
return
ResultVo
.
fail
(
"今日已达5次题,请明日再答"
);
}
return
ResultVo
.
success
(
questionService
.
answer
(
vo
));
return
ResultVo
.
success
(
questionService
.
answer
(
vo
));
}
}
...
...
user-server/src/main/java/com/zq/user/dao/AnswerRecDao.java
View file @
22870a4a
...
@@ -13,4 +13,5 @@ import org.springframework.stereotype.Repository;
...
@@ -13,4 +13,5 @@ import org.springframework.stereotype.Repository;
@Repository
@Repository
public
interface
AnswerRecDao
extends
BaseMapper
<
AnswerRec
>
{
public
interface
AnswerRecDao
extends
BaseMapper
<
AnswerRec
>
{
int
selectReplyCount
(
AnswerRec
vo
);
}
}
user-server/src/main/java/com/zq/user/dao/ReplyCountDao.java
deleted
100644 → 0
View file @
68962b2c
package
com
.
zq
.
user
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.zq.user.entity.ReplyCount
;
import
org.springframework.stereotype.Repository
;
@Repository
public
interface
ReplyCountDao
extends
BaseMapper
<
ReplyCount
>
{
void
update
(
ReplyCount
reply
);
}
user-server/src/main/java/com/zq/user/entity/ReplyCount.java
deleted
100644 → 0
View file @
68962b2c
package
com
.
zq
.
user
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName
(
value
=
"reply_count"
)
public
class
ReplyCount
{
/**
* id
*/
@TableId
(
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
* 答题次数
*/
@ApiModelProperty
(
"答题次数"
)
private
Integer
replyCount
;
/**
* 用户ID
*/
@ApiModelProperty
(
"用户ID"
)
private
String
userId
;
}
user-server/src/main/java/com/zq/user/service/QuestionService.java
View file @
22870a4a
...
@@ -193,16 +193,20 @@ public class QuestionService {
...
@@ -193,16 +193,20 @@ public class QuestionService {
vo
.
setScore
(
score
.
setScale
(
2
,
RoundingMode
.
HALF_UP
).
floatValue
());
vo
.
setScore
(
score
.
setScale
(
2
,
RoundingMode
.
HALF_UP
).
floatValue
());
vo
.
setCreateTime
(
DateUtil
.
date
());
vo
.
setCreateTime
(
DateUtil
.
date
());
vo
.
setReplyCount
(
vo
.
getReplyCount
());
int
i
=
answerRecDao
.
selectReplyCount
(
vo
);
if
(
i
>=
5
){
return
"今日已达5次题,请明日再来"
;
}
else
{
answerRecDao
.
insert
(
vo
);
answerRecDao
.
insert
(
vo
);
Map
<
String
,
Object
>
returnData
=
new
HashMap
<>();
Map
<
String
,
Object
>
returnData
=
new
HashMap
<>();
returnData
.
put
(
"wrongQuestionList"
,
wrongQuestionList
);
returnData
.
put
(
"wrongQuestionList"
,
wrongQuestionList
);
returnData
.
put
(
"score"
,
vo
.
getScore
());
returnData
.
put
(
"score"
,
vo
.
getScore
());
return
returnData
;
return
returnData
;
}
}
}
public
List
<
AnswerRec
>
getAnswerRec
(
AnswerRec
answerRec
)
{
public
List
<
AnswerRec
>
getAnswerRec
(
AnswerRec
answerRec
)
{
if
(
answerRec
.
getUserId
()
!=
null
)
{
if
(
answerRec
.
getUserId
()
!=
null
)
{
...
...
user-server/src/main/resources/mapper/AnswerRecMapper.xml
0 → 100644
View file @
22870a4a
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.zq.user.dao.AnswerRecDao"
>
<select
id=
"selectReplyCount"
resultType=
"java.lang.Integer"
>
SELECT COUNT(1) FROM t_answer_rec WHERE date_format(create_time,'yyyy-mm-dd') = date_format(NOW(),'yyyy-mm-dd')
AND user_id=#{userId}
</select>
</mapper>
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