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
18e92d1b
Commit
18e92d1b
authored
Aug 17, 2022
by
唐聪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成抽奖模块
parent
769c29ea
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
283 additions
and
50 deletions
+283
-50
api-server/src/main/java/com/zq/api/feign/UserFeign.java
+5
-0
api-server/src/main/java/com/zq/api/service/IApiLogic.java
+17
-0
api-server/src/main/java/com/zq/api/service/impl/ApiV100Logic.java
+22
-0
user-server/src/main/java/com/zq/user/controller/LotteryInfoController.java
+28
-4
user-server/src/main/java/com/zq/user/controller/PrizeController.java
+15
-5
user-server/src/main/java/com/zq/user/controller/QuestionController.java
+19
-5
user-server/src/main/java/com/zq/user/controller/api/PrizeApi.java
+19
-13
user-server/src/main/java/com/zq/user/controller/api/QuestionApi.java
+9
-1
user-server/src/main/java/com/zq/user/controller/api/lotteryInfoApi.java
+31
-5
user-server/src/main/java/com/zq/user/entity/AnswerRec.java
+2
-0
user-server/src/main/java/com/zq/user/entity/LotteryPrize.java
+6
-0
user-server/src/main/java/com/zq/user/entity/LotteryRec.java
+12
-0
user-server/src/main/java/com/zq/user/service/LotteryInfoService.java
+40
-5
user-server/src/main/java/com/zq/user/service/PrizeService.java
+0
-0
user-server/src/main/java/com/zq/user/service/QuestionService.java
+16
-11
user-server/src/main/java/com/zq/user/vo/AnswerRecVo.java
+1
-1
user-server/src/main/java/com/zq/user/vo/LotteryPrizeVo.java
+8
-0
user-server/src/main/java/com/zq/user/vo/LotteryRecFindVo.java
+33
-0
No files found.
api-server/src/main/java/com/zq/api/feign/UserFeign.java
View file @
18e92d1b
...
...
@@ -65,4 +65,9 @@ public interface UserFeign {
@PostMapping
(
value
=
"/api/question/getAnswerRecs"
)
ResultVo
getAnswerRecs
(
@RequestBody
Map
<
String
,
Object
>
paramsMap
);
@PostMapping
(
value
=
"/api/question/randomDraw"
)
ResultVo
randomDraw
(
Map
<
String
,
Object
>
paramsMap
);
// @PostMapping(value = "/api/lotteryInfo/like")
// ResultVo likeByName(@RequestBody Map<String, Object> paramsMap);
}
api-server/src/main/java/com/zq/api/service/IApiLogic.java
View file @
18e92d1b
...
...
@@ -133,4 +133,21 @@ public interface IApiLogic extends IApiCommon {
*/
ApiResp
getDefaultAddress
(
ApiForm
form
);
/**
* 有奖问答随机抽奖
*
* @param form
* @return
*/
ApiResp
randomDraw
(
ApiForm
form
);
// /**
////// * 根据姓名模糊查询货单信息
////// *
////// * @param form
////// * @return
////// */
////// ApiResp likeByName(ApiForm form);
}
api-server/src/main/java/com/zq/api/service/impl/ApiV100Logic.java
View file @
18e92d1b
...
...
@@ -144,4 +144,26 @@ public class ApiV100Logic extends BaseApiLogic implements IApiLogic {
return
ApiUtils
.
toApiResp
(
form
,
userFeign
.
getDefaultAddress
(
form
.
getString
(
"userId"
)));
}
/**
* 有奖问答随机抽奖
* @param form
* @return
*/
@Override
public
ApiResp
randomDraw
(
ApiForm
form
)
{
return
ApiUtils
.
toApiResp
(
form
,
userFeign
.
randomDraw
(
form
.
getParamsMap
()));
}
// /**
// * 根据姓名模糊查询货单信息
// *
// * @param form
// * @return
// */
// @Override
// public ApiResp likeByName(ApiForm form) {
// return ApiUtils.toApiResp(form, userFeign.likeByName(form.getParamsMap()));
// }
}
user-server/src/main/java/com/zq/user/controller/LotteryInfoController.java
View file @
18e92d1b
...
...
@@ -2,6 +2,8 @@ package com.zq.user.controller;
import
cn.hutool.core.bean.BeanUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.zq.common.utils.AssertUtils
;
...
...
@@ -113,9 +115,15 @@ public class LotteryInfoController {
@PostMapping
(
value
=
"/isOpen"
)
public
ResultVo
isOpen
(
@RequestBody
LotteryInfoVo
vo
)
{
AssertUtils
.
isTrue
(
vo
.
getIsOpen
()
!=
null
,
"传入开关状态为空"
);
AssertUtils
.
isTrue
(
lotteryInfoDao
.
selectList
(
new
QueryWrapper
<
LotteryInfo
>().
eq
(
"is_open"
,
1
))
!=
null
,
"已经存在一个开启的活动"
);
lotteryInfoService
.
isOpen
(
vo
);
return
ResultVo
.
success
(
"操作成功"
);
if
(
vo
.
getIsOpen
()
==
2
)
{
lotteryInfoService
.
isOpen
(
vo
);
return
ResultVo
.
success
(
"操作成功"
);
}
else
if
(
vo
.
getIsOpen
()
==
1
)
{
AssertUtils
.
isTrue
(
lotteryInfoDao
.
selectList
(
new
QueryWrapper
<
LotteryInfo
>().
eq
(
"is_open"
,
1
)).
size
()
==
0
,
"已经存在一个已经开启的活动"
);
lotteryInfoService
.
isOpen
(
vo
);
return
ResultVo
.
success
(
"操作成功"
);
}
return
ResultVo
.
fail
(
"操作失败"
);
}
/**
...
...
@@ -127,10 +135,15 @@ public class LotteryInfoController {
@PostMapping
(
value
=
"/getIsOpen"
)
public
ResultVo
getIsOpen
(
@RequestBody
LotteryInfoVo
vo
)
{
LotteryInfo
lotteryInfo
=
lotteryInfoDao
.
selectOne
(
new
QueryWrapper
<
LotteryInfo
>().
eq
(
"is_open"
,
1
));
LotteryInfoVo
vo1
=
new
LotteryInfoVo
();
BeanUtil
.
copyProperties
(
lotteryInfo
,
vo1
);
LambdaQueryWrapper
<
LotteryPrize
>
wrapper
=
new
LambdaQueryWrapper
<>();
List
<
LotteryPrize
>
prizes
=
lotteryPrizeDao
.
selectList
(
wrapper
.
eq
(
LotteryPrize:
:
getLotteryInfoId
,
vo
.
getId
()));
vo1
.
setPrizeVos
(
prizes
);
if
(
lotteryInfo
==
null
)
{
ResultVo
.
fail
(
"不存在开启成功的抽奖活动"
);
}
return
ResultVo
.
success
(
lotteryInfo
);
return
ResultVo
.
success
(
vo1
);
}
...
...
@@ -147,5 +160,16 @@ public class LotteryInfoController {
return
ResultVo
.
success
(
"操作成功"
);
}
// /**
// * 根据姓名模糊查询活动信息
// *
// * @param vo
// * @return
// */
// @ApiOperation("模糊查询活动信息")
// @PostMapping(value = "/like")
// public ResultVo likeByName(@RequestBody LotteryInfoVo vo) {
// return ResultVo.success(lotteryInfoService.getLotteryInfoByLike(vo));
// }
}
user-server/src/main/java/com/zq/user/controller/PrizeController.java
View file @
18e92d1b
...
...
@@ -120,11 +120,11 @@ public class PrizeController {
/************************************************************************************/
@ApiOperation
(
"获取抽奖记录"
)
@PostMapping
(
value
=
"/getLotteryRecList"
)
public
ResultVo
<
PageVo
<
LotteryRec
>>
getLotteryRecList
(
@RequestBody
LotteryRecFindVo
vo
)
{
return
ResultVo
.
success
(
prizeService
.
getLotteryRecList
(
vo
));
}
//
@ApiOperation("获取抽奖记录")
//
@PostMapping(value = "/getLotteryRecList")
//
public ResultVo<PageVo<LotteryRec>> getLotteryRecList(@RequestBody LotteryRecFindVo vo) {
//
return ResultVo.success(prizeService.getLotteryRecList(vo));
//
}
@ApiOperation
(
"确认派奖"
)
@PutMapping
(
value
=
"/confirmAward"
)
...
...
@@ -134,4 +134,14 @@ public class PrizeController {
return
ResultVo
.
success
();
}
// @ApiOperation("获取抽奖记录")
// @PostMapping(value = "/getLotteryRecList")
// public ResultVo<PageVo<LotteryRec>> getLotteryRecList(@RequestBody LotteryRecFindVo vo) {
// return ResultVo.success(prizeService.getLotteryRecList(vo));
// }
@ApiOperation
(
"抽奖记录列表"
)
@PostMapping
(
value
=
"/getLotteryRecList"
)
public
ResultVo
getLotteryRecList
(
@RequestBody
LotteryRecFindVo
vo
)
{
return
ResultVo
.
success
(
prizeService
.
getLotteryRecList
(
vo
));
}
}
user-server/src/main/java/com/zq/user/controller/QuestionController.java
View file @
18e92d1b
package
com
.
zq
.
user
.
controller
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.vo.IdVo
;
import
com.zq.common.vo.PageVo
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.user.
entity.AnswerRec
;
import
com.zq.user.entity.
Question
;
import
com.zq.user.
entity.QuestionTyp
e
;
import
com.zq.user.
dao.AnswerRecDao
;
import
com.zq.user.entity.
*
;
import
com.zq.user.
service.PrizeServic
e
;
import
com.zq.user.service.QuestionService
;
import
com.zq.user.vo.LotteryInfoVo
;
import
com.zq.user.vo.LotteryRecFindVo
;
import
com.zq.user.vo.QuestionFindVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -26,7 +29,11 @@ import java.util.List;
@RequestMapping
(
value
=
"/user/question"
)
public
class
QuestionController
{
private
final
QuestionService
questionService
;
private
final
PrizeService
prizeService
;
private
final
AnswerRecDao
answerRecDao
;
@ApiOperation
(
"获取全部题型"
)
@GetMapping
(
value
=
"/getAllQuestionType"
)
...
...
@@ -73,9 +80,15 @@ public class QuestionController {
}
@ApiOperation
(
"获取答题记录"
)
@
Ge
tMapping
(
value
=
"/getAnswerRecs"
)
@
Pos
tMapping
(
value
=
"/getAnswerRecs"
)
public
ResultVo
getAnswerRecs
(
@RequestBody
AnswerRec
answerRec
)
{
return
ResultVo
.
success
(
questionService
.
getAnswerRec
(
answerRec
));
}
}
@ApiOperation
(
"有奖问答随机抽奖 randomDraw"
)
@PostMapping
(
value
=
"/randomDraw"
)
public
ResultVo
randomDraw
(
@RequestBody
LotteryRecFindVo
vo
)
{
AssertUtils
.
isTrue
(
answerRecDao
.
selectCount
(
new
LambdaQueryWrapper
<
AnswerRec
>().
eq
(
AnswerRec:
:
getLotteryId
,
vo
.
getId
()))
==
0
,
"该活动已经抽过奖了"
);
return
ResultVo
.
success
(
prizeService
.
randomDraw
(
vo
));
}
}
\ No newline at end of file
user-server/src/main/java/com/zq/user/controller/api/PrizeApi.java
View file @
18e92d1b
...
...
@@ -9,6 +9,7 @@ import com.zq.user.entity.PrizeType;
import
com.zq.user.service.PrizeService
;
import
com.zq.user.vo.LotteryRecFindVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -33,18 +34,23 @@ public class PrizeApi {
return
ResultVo
.
success
(
prizeService
.
getAllPrizeType
());
}
@ApiOperation
(
"抽奖"
)
@GetMapping
(
value
=
"/luckDraw"
)
public
ResultVo
<
Prize
>
luckDraw
(
@RequestParam
String
userId
)
{
return
ResultVo
.
success
(
prizeService
.
luckDraw
(
userId
));
}
@ApiOperation
(
"抽奖记录列表"
)
@PostMapping
(
value
=
"/getLotteryRecList"
)
public
ResultVo
<
PageVo
<
LotteryRec
>>
getLotteryRecList
(
@RequestBody
LotteryRecFindVo
vo
)
{
AssertUtils
.
hasText
(
vo
.
getUserId
(),
"缺少用户ID"
);
return
ResultVo
.
success
(
prizeService
.
getLotteryRecList
(
vo
));
}
// @ApiOperation("抽奖")
// @GetMapping(value = "/luckDraw")
// public ResultVo<Prize> luckDraw(@RequestParam String userId) {
// return ResultVo.success(prizeService.luckDraw(userId));
// }
// @ApiOperation("抽奖记录列表")
// @PostMapping(value = "/getLotteryRecList")
// public ResultVo<PageVo<LotteryRec>> getLotteryRecList(@RequestBody LotteryRecFindVo vo) {
// AssertUtils.hasText(vo.getUserId(), "缺少用户ID");
// return ResultVo.success(prizeService.getLotteryRecList(vo));
// }
@ApiOperation
(
"抽奖记录列表(传入用户id返回用户,不传入返回全部) getLotteryRecList"
)
@PostMapping
(
value
=
"/getLotteryRecList"
)
public
ResultVo
getLotteryRecList
(
@RequestBody
LotteryRecFindVo
vo
)
{
return
ResultVo
.
success
(
prizeService
.
getLotteryRecList
(
vo
));
}
}
user-server/src/main/java/com/zq/user/controller/api/QuestionApi.java
View file @
18e92d1b
...
...
@@ -3,7 +3,9 @@ package com.zq.user.controller.api;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.user.entity.AnswerRec
;
import
com.zq.user.service.PrizeService
;
import
com.zq.user.service.QuestionService
;
import
com.zq.user.vo.LotteryRecFindVo
;
import
com.zq.user.vo.QuestionFindVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping
(
value
=
"/user/api/question"
)
public
class
QuestionApi
{
private
final
PrizeService
prizeService
;
private
final
QuestionService
questionService
;
@ApiOperation
(
"获取题目列表"
)
...
...
@@ -33,10 +36,15 @@ public class QuestionApi {
public
ResultVo
answer
(
@RequestBody
AnswerRec
vo
)
{
AssertUtils
.
hasText
(
vo
.
getUserId
(),
"缺少用户ID"
);
AssertUtils
.
hasText
(
vo
.
getAnswerList
(),
"缺少答案"
);
return
ResultVo
.
success
(
questionService
.
answer
(
vo
));
}
@ApiOperation
(
"有奖问答随机抽奖"
)
@PostMapping
(
value
=
"/randomDraw"
)
public
ResultVo
randomDraw
(
@RequestBody
LotteryRecFindVo
vo
)
{
return
ResultVo
.
success
(
prizeService
.
randomDraw
(
vo
));
}
@ApiOperation
(
"获取答题记录"
)
@PostMapping
(
value
=
"/getAnswerRecs"
)
public
ResultVo
getAnswerRecs
(
@RequestBody
AnswerRec
answerRec
)
{
...
...
user-server/src/main/java/com/zq/user/controller/api/lotteryInfoApi.java
View file @
18e92d1b
package
com
.
zq
.
user
.
controller
.
api
;
import
cn.hutool.core.bean.BeanUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.vo.ResultVo
;
...
...
@@ -15,6 +17,7 @@ import lombok.RequiredArgsConstructor;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* @Author: jcm
...
...
@@ -103,9 +106,15 @@ public class lotteryInfoApi {
@PostMapping
(
value
=
"/isOpen"
)
public
ResultVo
isOpen
(
@RequestBody
LotteryInfoVo
vo
)
{
AssertUtils
.
isTrue
(
vo
.
getIsOpen
()
!=
null
,
"传入开关状态为空"
);
AssertUtils
.
isTrue
(
lotteryInfoDao
.
selectList
(
new
QueryWrapper
<
LotteryInfo
>().
eq
(
"is_open"
,
1
))
!=
null
,
"已经存在一个开启的活动"
);
lotteryInfoService
.
isOpen
(
vo
);
return
ResultVo
.
success
(
"操作成功"
);
if
(
vo
.
getIsOpen
()
==
2
)
{
lotteryInfoService
.
isOpen
(
vo
);
return
ResultVo
.
success
(
"操作成功"
);
}
else
if
(
vo
.
getIsOpen
()
==
1
)
{
AssertUtils
.
isTrue
(
lotteryInfoDao
.
selectList
(
new
QueryWrapper
<
LotteryInfo
>().
eq
(
"is_open"
,
1
)).
size
()
==
0
,
"已经存在一个已经开启的活动"
);
lotteryInfoService
.
isOpen
(
vo
);
return
ResultVo
.
success
(
"操作成功"
);
}
return
ResultVo
.
fail
(
"操作失败"
);
}
/**
...
...
@@ -117,10 +126,15 @@ public class lotteryInfoApi {
@PostMapping
(
value
=
"/getIsOpen"
)
public
ResultVo
getIsOpen
(
@RequestBody
LotteryInfoVo
vo
)
{
LotteryInfo
lotteryInfo
=
lotteryInfoDao
.
selectOne
(
new
QueryWrapper
<
LotteryInfo
>().
eq
(
"is_open"
,
1
));
LotteryInfoVo
vo1
=
new
LotteryInfoVo
();
BeanUtil
.
copyProperties
(
lotteryInfo
,
vo1
);
LambdaQueryWrapper
<
LotteryPrize
>
wrapper
=
new
LambdaQueryWrapper
<>();
List
<
LotteryPrize
>
prizes
=
lotteryPrizeDao
.
selectList
(
wrapper
.
eq
(
LotteryPrize:
:
getLotteryInfoId
,
vo1
.
getId
()));
vo1
.
setPrizeVos
(
prizes
);
if
(
lotteryInfo
==
null
)
{
ResultVo
.
fail
(
"不存在开启成功的抽奖活动"
);
}
return
ResultVo
.
success
(
lotteryInfo
);
return
ResultVo
.
success
(
vo1
);
}
...
...
@@ -132,9 +146,21 @@ public class lotteryInfoApi {
@ApiOperation
(
"删除该活动"
)
@PostMapping
(
value
=
"/delete"
)
public
ResultVo
delete
(
@RequestBody
LotteryInfoVo
vo
)
{
AssertUtils
.
isTrue
(
vo
.
getId
()
!=
null
,
"传入
开关状态
为空"
);
AssertUtils
.
isTrue
(
vo
.
getId
()
!=
null
,
"传入
活动id
为空"
);
lotteryInfoService
.
delete
(
vo
);
return
ResultVo
.
success
(
"操作成功"
);
}
/**
* 根据姓名模糊查询活动信息
*
* @param vo
* @return
*/
@ApiOperation
(
"模糊查询活动信息"
)
@PostMapping
(
value
=
"/like"
)
public
ResultVo
likeByName
(
@RequestBody
LotteryInfoVo
vo
)
{
return
ResultVo
.
success
(
lotteryInfoService
.
getLotteryInfoByLike
(
vo
));
}
}
user-server/src/main/java/com/zq/user/entity/AnswerRec.java
View file @
18e92d1b
...
...
@@ -58,11 +58,13 @@ public class AnswerRec {
/**
* 抽奖活动ID
*/
@ApiModelProperty
(
"抽奖活动ID"
)
private
Integer
lotteryId
;
/**
* 抽奖活动名
*/
@ApiModelProperty
(
"抽奖活动名"
)
private
String
lotteryName
;
}
user-server/src/main/java/com/zq/user/entity/LotteryPrize.java
View file @
18e92d1b
...
...
@@ -32,6 +32,12 @@ class LotteryPrize implements Serializable {
private
Integer
id
;
/**
* 奖品类型 关联奖品类型(t_prize)表id
*/
@ApiModelProperty
(
value
=
"奖品id 关联奖品类型(t_prize)表id"
)
private
Long
prizeId
;
/**
* 奖品类型 关联奖品类型(t_prize_type)表id
*/
@ApiModelProperty
(
value
=
"奖品类型 关联奖品类型(t_prize_type)表id"
)
...
...
user-server/src/main/java/com/zq/user/entity/LotteryRec.java
View file @
18e92d1b
...
...
@@ -100,4 +100,16 @@ public class LotteryRec {
@TableField
(
exist
=
false
)
private
Address
address
;
/**
* 抽奖活动ID
*/
@ApiModelProperty
(
"抽奖活动ID"
)
private
Integer
lotteryId
;
/**
* 抽奖活动名
*/
@ApiModelProperty
(
"抽奖活动名"
)
private
String
lotteryName
;
}
user-server/src/main/java/com/zq/user/service/LotteryInfoService.java
View file @
18e92d1b
...
...
@@ -55,7 +55,7 @@ public class LotteryInfoService {
// List<LotteryPrizeVo> list = vo.getPrizeVos();
Integer
id
=
Integer
.
parseInt
(
generateRandom
());
vo
.
setId
(
id
);
// todo 2022813 这里的关联的类型标是
type而不是type_id
// todo 2022813 这里的关联的类型标是
prize而不是prize_type
LotteryInfo
lotteryInfo
=
new
LotteryInfo
();
BeanUtil
.
copyProperties
(
vo
,
lotteryInfo
);
lotteryInfo
.
setIsOpen
(
2
);
...
...
@@ -67,6 +67,7 @@ public class LotteryInfoService {
LotteryPrize
lotteryPrize
=
LotteryPrize
.
builder
()
.
lotteryInfoId
(
vo
.
getId
())
.
prizeId
(
type
.
getId
())
.
prizeTypeId
(
type
.
getPrizeTypeId
())
.
prizeName
(
type
.
getPrizeName
())
.
createTime
(
DateUtil
.
date
())
...
...
@@ -76,7 +77,7 @@ public class LotteryInfoService {
}
public
static
synchronized
String
generateRandom
(){
public
static
synchronized
String
generateRandom
()
{
//使用当前时间生成时间戳yyyyMMddHHmmssSSS
StringBuffer
suf
=
new
StringBuffer
(
DateFormatUtils
.
format
(
Calendar
.
getInstance
(),
"ssSSS"
));
//生成3位随机数
...
...
@@ -85,7 +86,7 @@ public class LotteryInfoService {
}
// public PageVo<Prize> getPrizeList(PrizeFindVo vo) {
// public PageVo<Prize> getPrizeList(PrizeFindVo vo) {
// LambdaQueryWrapper<Prize> lambdaQuery = Wrappers.lambdaQuery(Prize.class);
// lambdaQuery.orderByDesc(Prize::getCreateTime);
//
...
...
@@ -105,7 +106,13 @@ public class LotteryInfoService {
public
PageVo
<
LotteryInfoVo
>
getLotteryInfo
(
LotteryInfoVo
vo
)
{
LambdaQueryWrapper
<
LotteryInfo
>
lambdaQuery
=
Wrappers
.
lambdaQuery
(
LotteryInfo
.
class
);
// 模糊查询活动名
if
(
vo
.
getLotteryInfoName
()
!=
null
)
{
lambdaQuery
.
like
(
LotteryInfo:
:
getLotteryInfoName
,
vo
.
getLotteryInfoName
());
}
lambdaQuery
.
orderByDesc
(
LotteryInfo:
:
getCreateTime
);
PageVo
<
LotteryInfo
>
paging
=
PagingUtils
.
paging
(
vo
,
lotteryInfoDao
,
lambdaQuery
,
LotteryInfo
.
class
);
...
...
@@ -129,9 +136,7 @@ public class LotteryInfoService {
public
void
isOpen
(
LotteryInfoVo
vo
)
{
System
.
out
.
println
(
vo
);
Integer
id
=
vo
.
getId
();
System
.
out
.
println
(
id
);
LotteryInfo
info
=
new
LotteryInfo
();
info
.
setId
(
id
);
if
(
vo
.
getIsOpen
()
!=
null
)
{
...
...
@@ -181,6 +186,7 @@ public class LotteryInfoService {
LotteryPrize
lotteryPrize
=
LotteryPrize
.
builder
()
.
lotteryInfoId
(
vo
.
getId
())
.
prizeId
(
type
.
getId
())
.
prizeTypeId
(
type
.
getPrizeTypeId
())
.
prizeName
(
type
.
getPrizeName
())
.
createTime
(
DateUtil
.
date
())
...
...
@@ -195,5 +201,34 @@ public class LotteryInfoService {
lotteryPrizeDao
.
deleteBatchIds
(
lotteryPrizeDao
.
selectList
(
new
QueryWrapper
<
LotteryPrize
>().
eq
(
"lottery_info_id"
,
vo
.
getId
())));
}
/**
* 根据姓名模糊查询活动介绍
*
* @param vo
* @return
*/
public
PageVo
<
LotteryInfoVo
>
getLotteryInfoByLike
(
LotteryInfoVo
vo
)
{
LambdaQueryWrapper
<
LotteryInfo
>
lambdaQuery
=
Wrappers
.
lambdaQuery
(
LotteryInfo
.
class
);
lambdaQuery
.
like
(
LotteryInfo:
:
getLotteryInfoName
,
vo
.
getLotteryInfoName
()).
orderByDesc
(
LotteryInfo:
:
getCreateTime
);
PageVo
<
LotteryInfo
>
paging
=
PagingUtils
.
paging
(
vo
,
lotteryInfoDao
,
lambdaQuery
,
LotteryInfo
.
class
);
List
<
LotteryInfoVo
>
infoVos
=
new
ArrayList
<>();
List
<
LotteryInfo
>
infos
=
paging
.
getRows
();
for
(
LotteryInfo
info
:
infos
)
{
LotteryInfoVo
infoVo
=
new
LotteryInfoVo
();
BeanUtil
.
copyProperties
(
info
,
infoVo
);
List
<
LotteryPrize
>
lotteryPrizeVos
=
lotteryPrizeDao
.
selectList
(
new
QueryWrapper
<
LotteryPrize
>().
eq
(
"lottery_info_id"
,
info
.
getId
()));
infoVo
.
setPrizeVos
(
lotteryPrizeVos
);
infoVos
.
add
(
infoVo
);
}
PageVo
<
LotteryInfoVo
>
page
=
new
PageVo
<>();
page
.
setTotal
(
paging
.
getTotal
());
page
.
setRows
(
infoVos
);
page
.
setSize
(
paging
.
getSize
());
page
.
setStart
(
paging
.
getStart
());
return
page
;
}
}
user-server/src/main/java/com/zq/user/service/PrizeService.java
View file @
18e92d1b
This diff is collapsed.
Click to expand it.
user-server/src/main/java/com/zq/user/service/QuestionService.java
View file @
18e92d1b
...
...
@@ -179,17 +179,22 @@ public class QuestionService {
public
List
<
AnswerRec
>
getAnswerRec
(
AnswerRec
answerRec
)
{
LambdaQueryWrapper
<
AnswerRec
>
wrapper
=
new
LambdaQueryWrapper
<
AnswerRec
>();
List
<
LotteryInfo
>
infos
=
lotteryInfoDao
.
selectList
(
new
QueryWrapper
<
LotteryInfo
>());
System
.
out
.
println
(
"info="
+
infos
);
List
<
AnswerRec
>
recs
=
new
ArrayList
<>();
for
(
LotteryInfo
info
:
infos
)
{
wrapper
.
eq
(
AnswerRec:
:
getLotteryId
,
info
.
getId
()).
eq
(
AnswerRec:
:
getUserId
,
answerRec
.
getUserId
()).
orderByDesc
(
AnswerRec:
:
getScore
).
last
(
"limit 1"
);
AnswerRec
rec
=
answerRecDao
.
selectOne
(
wrapper
);
recs
.
add
(
rec
);
if
(
answerRec
.
getUserId
()
!=
null
)
{
LambdaQueryWrapper
<
AnswerRec
>
wrapper
=
new
LambdaQueryWrapper
<
AnswerRec
>();
List
<
AnswerRec
>
recs
=
answerRecDao
.
selectList
(
wrapper
.
eq
(
AnswerRec:
:
getUserId
,
answerRec
.
getUserId
()));
return
recs
;
}
else
{
LambdaQueryWrapper
<
AnswerRec
>
wrapper
=
new
LambdaQueryWrapper
<
AnswerRec
>();
List
<
LotteryInfo
>
infos
=
lotteryInfoDao
.
selectList
(
new
QueryWrapper
<
LotteryInfo
>());
System
.
out
.
println
(
"info="
+
infos
);
List
<
AnswerRec
>
recs
=
new
ArrayList
<>();
for
(
LotteryInfo
info
:
infos
)
{
wrapper
.
eq
(
AnswerRec:
:
getLotteryId
,
info
.
getId
()).
eq
(
AnswerRec:
:
getUserId
,
answerRec
.
getUserId
()).
orderByDesc
(
AnswerRec:
:
getScore
).
last
(
"limit 1"
);
AnswerRec
rec
=
answerRecDao
.
selectOne
(
wrapper
);
recs
.
add
(
rec
);
}
AssertUtils
.
isTrue
(
recs
!=
null
,
"没有历史答题记录,请先完成答题"
);
return
recs
;
}
AssertUtils
.
isTrue
(
recs
!=
null
,
"没有历史答题记录,请先完成答题"
);
return
recs
;
}
}
user-server/src/main/java/com/zq/user/vo/AnswerRecVo.java
View file @
18e92d1b
...
...
@@ -15,7 +15,6 @@ import java.util.Date;
* @Author: TangCong
* @Date: 2022-8-13 10:45
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
...
...
@@ -55,4 +54,5 @@ public class AnswerRecVo extends PageReqVo {
* 抽奖活动名
*/
private
String
lotteryName
;
}
user-server/src/main/java/com/zq/user/vo/LotteryPrizeVo.java
View file @
18e92d1b
...
...
@@ -29,12 +29,20 @@ public class LotteryPrizeVo extends PageReqVo {
private
Integer
id
;
/**
* 奖品类型 关联奖品类型(t_prize)表id
*/
@ApiModelProperty
(
value
=
"奖品id 关联奖品类型(t_prize)表id"
)
private
Long
prizeId
;
/**
* 奖品类型 关联奖品类型(t_prize_type)表id
*/
@ApiModelProperty
(
value
=
"奖品类型 关联奖品类型(t_prize_type)表id"
)
private
Integer
prizeTypeId
;
/**
* 奖品名
*/
...
...
user-server/src/main/java/com/zq/user/vo/LotteryRecFindVo.java
View file @
18e92d1b
...
...
@@ -93,4 +93,37 @@ public class LotteryRecFindVo extends PageReqVo {
@TableField
(
exist
=
false
)
private
String
displayName
;
/**
* 抽奖活动ID
*/
@ApiModelProperty
(
"抽奖活动ID"
)
private
Integer
lotteryId
;
/**
* 抽奖活动名
*/
@ApiModelProperty
(
"抽奖活动名"
)
private
String
lotteryName
;
/**
* 收货人
*/
@ApiModelProperty
(
"收货人"
)
private
String
consignee
;
/**
* 收货人手机号
*/
@ApiModelProperty
(
"收货人手机号"
)
private
String
consigneePhone
;
/**
* 地址
*/
@ApiModelProperty
(
"地址"
)
private
String
consigneeAddress
;
@ApiModelProperty
(
"用户昵称"
)
private
String
nickName
;
}
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