提交 e93be1df 编写于 作者: 夏天。。's avatar 夏天。。

改了部分bug,且优化部分功能

上级 c0aef6b0
......@@ -7,6 +7,7 @@ import com.mobius.modules.ums.dto.CheckDto;
import com.mobius.modules.ums.model.UmsCheck;
import com.mobius.modules.ums.service.UmsCheckService;
import com.mobius.modules.ums.vo.CheckVo;
import com.mobius.utils.DateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -45,11 +46,10 @@ public class UmsCheckController {
return checkService.checkListByMonth(date);
}
@GetMapping("/day")
@ApiOperation(value = "获取今日签到信息")
public CommonResult getDailyCheck(){
CheckDto dailyCheck = checkService.getDailyCheck();
return CommonResult.success(dailyCheck);
@GetMapping("")
@ApiOperation(value = "获取某日签到信息")
public CommonResult getDailyCheck(Date date){
return checkService.getCheckRewardsByDate(DateUtils.getZeroTime(date));
}
@PutMapping("")
......
......@@ -37,4 +37,6 @@ public interface UmsCheckService extends IService<UmsCheck> {
CheckDto getCheckDto(UmsCheck check);
CommonResult getCheckRewardsByDate(Date date);
}
......@@ -139,4 +139,10 @@ public class UmsCheckServiceImpl extends ServiceImpl<UmsCheckMapper, UmsCheck> i
}
@Override
public CommonResult getCheckRewardsByDate(Date date) {
UmsCheck checkByValidDate = getCheckByValidDate(date);
return CommonResult.success(checkByValidDate.getRewards());
}
}
......@@ -9,10 +9,7 @@ import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import javax.validation.constraints.*;
import java.util.Date;
/**
......@@ -30,7 +27,8 @@ public class RewardVo {
@NotNull(message = "奖励类型不能为空")
@ApiModelProperty("奖励类型 0积分 1邮票")
@Pattern(regexp = "[1|0]")
@Max(value = 1,message = "奖励类型只能是0或者1")
@Min(value = 0,message = "奖励类型只能是0或者1")
private Integer type;
@NotEmpty(message = "奖励描述不能为空")
......
......@@ -27,6 +27,12 @@
<version>1.1.8</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<!--Bean Validation-->
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -43,4 +43,7 @@ public class PenBriefDTO {
@ApiModelProperty(value = "是否读")
private Integer isRead;
@ApiModelProperty(value = "发信人昵称")
private String nickName;
}
......@@ -45,5 +45,8 @@ public class PenInfoDTO {
@ApiModelProperty(value = "延迟时间,以小时作为单位")
private Integer delayTime;
@ApiModelProperty(value = "发信人昵称")
private String nickName;
}
......@@ -23,13 +23,13 @@ import java.util.Date;
public interface LmsPenMapper extends BaseMapper<LmsPen> {
@Select("select * from lms_pen where sender_id = #{senderId} and is_delete = 0 order by is_read asc,id desc")
@Select("select * from ums_user,lms_pen where sender_id = #{senderId} and is_delete = 0 and ums_user.id = lms_pen.sender_id order by is_read asc,id desc")
IPage<PenBriefDTO> selectSenderPenBriefList(Long senderId, IPage<PenBriefDTO> page);
@Select("select * from lms_pen where sender_id = #{senderId} and receiver_Id = #{receiverId} and arrive_time > #{arriveTime} and is_delete = 0 order by is_read asc,arrive_time desc")
@Select("select * from ums_user,lms_pen where sender_id = #{senderId} and receiver_Id = #{receiverId} and arrive_time > #{arriveTime} and is_delete = 0 and ums_user.id = lms_pen.sender_id order by is_read asc,arrive_time desc")
IPage<PenBriefDTO> selectSenderPenBriefList(@Param("senderId") Long senderId, @Param("receiverId") Long receiverId, @Param("arriveTime") Date arriveTime,IPage<PenBriefDTO> page);
@Select("select * from lms_pen,lms_incident,lms_letter_content where lms_pen.id = #{id} and lms_pen.incident_id = lms_incident.id and lms_pen.content_id = lms_letter_content.id")
@Select("select * from ums_user,lms_pen,lms_incident,lms_letter_content where lms_pen.id = #{id} and lms_pen.incident_id = lms_incident.id and lms_pen.content_id = lms_letter_content.id and ums_user.id = lms_pen.sender_id")
PenInfoDTO selectPenInfo(Long id);
}
......@@ -39,7 +39,7 @@ public class UmsCheckController {
@ApiOperation("签到")
@GetMapping("")
public CommonResult userCheck(){
return CommonResult.success(ResultCode.SUCCESS);
return checkService.userCheck();
}
}
package com.mobius.modules.ums.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author Sqh
* @since 2022-06-17
*/
@RestController
@RequestMapping("/ums/umsUserCheckRecord")
public class UmsUserCheckRecordController {
}
package com.mobius.modules.ums.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mobius.modules.ums.model.UmsUserCheckRecord;
/**
* <p>
* Mapper 接口
* </p>
*
* @author Sqh
* @since 2022-06-17
*/
public interface UmsUserCheckRecordMapper extends BaseMapper<UmsUserCheckRecord> {
}
package com.mobius.modules.ums.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author Sqh
* @since 2022-06-17
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("ums_user_check_record")
@ApiModel(value="UmsUserCheckRecord对象", description="")
@AllArgsConstructor
@NoArgsConstructor
public class UmsUserCheckRecord implements Serializable {
private static final long serialVersionUID=1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "签到用户id")
private Integer userId;
@ApiModelProperty(value = "记录时间")
private Date createDate;
@ApiModelProperty(value = "奖励id")
private Integer checkId;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
}
......@@ -4,9 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.*;
import java.io.Serializable;
import java.util.Date;
......@@ -23,6 +21,8 @@ import java.util.Date;
@EqualsAndHashCode(callSuper = false)
@TableName("ums_user_stamp_relation")
@ApiModel(value="UmsUserStampRelation对象", description="")
@AllArgsConstructor
@NoArgsConstructor
public class UmsUserStampRelation implements Serializable {
private static final long serialVersionUID=1L;
......
......@@ -27,4 +27,6 @@ public interface UmsCheckService extends IService<UmsCheck> {
CheckDto getDailyCheck();
CheckDto getCheckDto(UmsCheck check);
}
package com.mobius.modules.ums.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mobius.modules.ums.model.UmsUserCheckRecord;
/**
* <p>
* 服务类
* </p>
*
* @author Sqh
* @since 2022-06-17
*/
public interface UmsUserCheckRecordService extends IService<UmsUserCheckRecord> {
UmsUserCheckRecord getUserCheckRecord(Integer userId, Integer checkId);
}
package com.mobius.modules.ums.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mobius.common.api.CommonResult;
......@@ -9,10 +11,10 @@ import com.mobius.common.service.RedisService;
import com.mobius.common.util.DateUtils;
import com.mobius.modules.ums.dto.CheckDto;
import com.mobius.modules.ums.mapper.UmsCheckMapper;
import com.mobius.modules.ums.model.UmsCheck;
import com.mobius.modules.ums.model.UmsReward;
import com.mobius.modules.ums.service.UmsCheckService;
import com.mobius.modules.ums.service.UmsRewardService;
import com.mobius.modules.ums.mapper.UmsUserCheckRecordMapper;
import com.mobius.modules.ums.model.*;
import com.mobius.modules.ums.service.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -40,6 +42,12 @@ public class UmsCheckServiceImpl extends ServiceImpl<UmsCheckMapper, UmsCheck> i
private RedisService redisService;
@Autowired
private UmsRewardService rewardService;
@Autowired
private UmsUserCheckRecordService recordService;
@Autowired
private UmsUserService userService;
@Autowired
private UmsUserStampRelationService relationService;
......@@ -51,10 +59,19 @@ public class UmsCheckServiceImpl extends ServiceImpl<UmsCheckMapper, UmsCheck> i
@Override
public CommonResult userCheck() {
UmsUser currentUser = userService.getCurrentUser();
CheckDto dailyCheck = getDailyCheck();
if (dailyCheck!=null){
if (dailyCheck==null){
return CommonResult.success("今日无签到");
}
UmsUserCheckRecord userCheckRecord = recordService.getUserCheckRecord(currentUser.getId(), dailyCheck.getId());
if (userCheckRecord!=null){
return CommonResult.failed("今日已经签到过了");
}
getCheckReward(dailyCheck.getRewards(),currentUser);
recordService.save(new UmsUserCheckRecord(0,currentUser.getId(),new Date(),dailyCheck.getId(),new Date()));
return CommonResult.success(ResultCode.SUCCESS);
}
......@@ -96,4 +113,24 @@ public class UmsCheckServiceImpl extends ServiceImpl<UmsCheckMapper, UmsCheck> i
return new CheckDto(check.getId(),check.getValidTime(),rewards);
}
void getCheckReward(List<UmsReward> rewards, UmsUser user){
List<UmsUserStampRelation> relations = new ArrayList<>();
Integer value = 0;
for (UmsReward reward: rewards){
if (reward.getType()==0){
value+=reward.getValue();
}else if(reward.getType()==1) {
relations.add(new UmsUserStampRelation(0L,user.getId(),1L,new Date(),new Date()));
}
}
user.setGrowValue(user.getGrowValue()+value);
userService.updateUserById(user);
for(UmsUserStampRelation relation:relations) {
relationService.save(relation);
}
}
}
package com.mobius.modules.ums.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mobius.modules.ums.mapper.UmsUserCheckRecordMapper;
import com.mobius.modules.ums.model.UmsUserCheckRecord;
import com.mobius.modules.ums.service.UmsUserCheckRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author Sqh
* @since 2022-06-17
*/
@Service
public class UmsUserCheckRecordServiceImpl extends ServiceImpl<UmsUserCheckRecordMapper, UmsUserCheckRecord> implements UmsUserCheckRecordService {
@Autowired
private UmsUserCheckRecordMapper recordMapper;
@Override
public UmsUserCheckRecord getUserCheckRecord(Integer userId, Integer checkId) {
QueryWrapper<UmsUserCheckRecord> wrapper = new QueryWrapper<>();
wrapper.eq("user_id",userId);
wrapper.eq("check_id",checkId);
return recordMapper.selectOne(wrapper);
}
}
......@@ -7,6 +7,8 @@ spring:
profiles:
active: dev
cache:
type: redis
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
global-config:
......
package com.mobius.modules.lms.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mobius.modules.lms.dto.PenBriefDTO;
import com.mobius.modules.lms.dto.PenInfoDTO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
/**
* @Author: hocztms
* @Description:
* @Date Created in 2022-05-13-0:37
* @Modified By:
*/
@SpringBootTest
class LmsPenMapperTest {
@Autowired
private LmsPenMapper lmsPenMapper;
@Test
public void test(){
IPage<PenBriefDTO> senderPenBriefList = lmsPenMapper.selectSenderPenBriefList(3L, new Page<>(1, 3));
System.out.println(senderPenBriefList.getRecords().toString());
PenInfoDTO penInfoDTO = lmsPenMapper.selectPenInfo(2L);
System.out.println(penInfoDTO.toString());
}
}
\ No newline at end of file
//package com.mobius.modules.lms.mapper;
//
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.mobius.modules.lms.dto.PenBriefDTO;
//import com.mobius.modules.lms.dto.PenInfoDTO;
//import org.junit.jupiter.api.Test;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//
///**
// * @Author: hocztms
// * @Description:
// * @Date Created in 2022-05-13-0:37
// * @Modified By:
// */
//@SpringBootTest
//class LmsPenMapperTest {
//
// @Autowired
// private LmsPenMapper lmsPenMapper;
//
// @Test
// public void test(){
// IPage<PenBriefDTO> senderPenBriefList = lmsPenMapper.selectSenderPenBriefList(3L, new Page<>(1, 3));
// System.out.println(senderPenBriefList.getRecords().toString());
// PenInfoDTO penInfoDTO = lmsPenMapper.selectPenInfo(2L);
// System.out.println(penInfoDTO.toString());
// }
//
//}
\ No newline at end of file
package com.mobius.modules.lms.service.impl;
import com.mobius.modules.lms.service.LmsVerifyLetterService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.jupiter.api.Assertions.*;
/**
* @author Sqh
* @date 2022/5/12
*/
@SpringBootTest
class LmsVerifyLetterServiceImplTest {
@Autowired
private LmsVerifyLetterService verifyLetterService;
@Test
void verifyLetterContent() {
String testContent = "ausdhauhduahsdas";
verifyLetterService.verifyLetterContent(testContent);
}
}
\ No newline at end of file
//package com.mobius.modules.lms.service.impl;
//
//import com.mobius.modules.lms.service.LmsVerifyLetterService;
//import org.junit.jupiter.api.Test;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//
//import static org.junit.jupiter.api.Assertions.*;
//
///**
// * @author Sqh
// * @date 2022/5/12
// */
//@SpringBootTest
//class LmsVerifyLetterServiceImplTest {
// @Autowired
// private LmsVerifyLetterService verifyLetterService;
//
// @Test
// void verifyLetterContent() {
// String testContent = "ausdhauhduahsdas";
// verifyLetterService.verifyLetterContent(testContent);
// }
//}
\ No newline at end of file
package com.mobius.modules.ums.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mobius.modules.ums.dto.UserListDto;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.jupiter.api.Assertions.*;
/**
* @Author: hocztms
* @Description:
* @Date Created in 2022-06-07-21:57
* @Modified By:
*/
@SpringBootTest
class UmsUserMapperTest {
@Autowired
private UmsUserMapper userMapper;
@Test
void selectUserListByNickName() {
IPage<UserListDto> h = userMapper.selectUserListByNickName("h", new Page<>(1, 5));
System.out.println(h.getRecords().toString());
}
}
\ No newline at end of file
//package com.mobius.modules.ums.mapper;
//
// import com.baomidou.mybatisplus.core.metadata.IPage;
// import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
// import com.mobius.modules.ums.dto.UserListDto;
// import org.junit.jupiter.api.Test;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.boot.test.context.SpringBootTest;
//
// import static org.junit.jupiter.api.Assertions.*;
//
///**
// * @Author: hocztms
// * @Description:
// * @Date Created in 2022-06-07-21:57
// * @Modified By:
// */
//@SpringBootTest
//class UmsUserMapperTest {
//
// @Autowired
// private UmsUserMapper userMapper;
// @Test
// void selectUserListByNickName() {
// IPage<UserListDto> h = userMapper.selectUserListByNickName("h", new Page<>(1, 5));
// System.out.println(h.getRecords().toString());
// }
//}
\ No newline at end of file
package com.mobius.modules.ums.service.impl;
import com.mobius.modules.lms.service.LmsVerifyLetterService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.junit.jupiter.api.Assertions.*;
/**
* @author Sqh
* @date 2022/6/13
*/
class UserInfoServiceImplTest {
public static final Pattern timeRegex= Pattern.compile("^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$");
@Test
void verifyLetterContent() {
String str = "25:15:00";
Matcher matcher = timeRegex.matcher(str);
System.out.println(matcher.find());
str = "23:15:00";
matcher = timeRegex.matcher(str);
System.out.println(matcher.find());
str = "00:15:00";
matcher = timeRegex.matcher(str);
System.out.println(matcher.find());
str = "02:15:00";
matcher = timeRegex.matcher(str);
System.out.println(matcher.find());
str = "2:15:00";
matcher = timeRegex.matcher(str);
System.out.println(matcher.find());
}
}
\ No newline at end of file
//package com.mobius.modules.ums.service.impl;
//
//import com.mobius.modules.lms.service.LmsVerifyLetterService;
//import org.junit.jupiter.api.Test;
//import org.springframework.beans.factory.annotation.Autowired;
//
//import java.util.regex.Matcher;
//import java.util.regex.Pattern;
//
//import static org.junit.jupiter.api.Assertions.*;
//
///**
// * @author Sqh
// * @date 2022/6/13
// */
//class UserInfoServiceImplTest {
//
// public static final Pattern timeRegex= Pattern.compile("^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$");
//
// @Test
// void verifyLetterContent() {
// String str = "25:15:00";
// Matcher matcher = timeRegex.matcher(str);
// System.out.println(matcher.find());
//
// str = "23:15:00";
// matcher = timeRegex.matcher(str);
// System.out.println(matcher.find());
//
// str = "00:15:00";
// matcher = timeRegex.matcher(str);
// System.out.println(matcher.find());
//
// str = "02:15:00";
// matcher = timeRegex.matcher(str);
// System.out.println(matcher.find());
//
// str = "2:15:00";
// matcher = timeRegex.matcher(str);
// System.out.println(matcher.find());
//
// }
//
//}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册