Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
antai-sport-http-server
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
antai-sport
antai-sport-http-server
Commits
fb4d6b1c
Commit
fb4d6b1c
authored
Aug 09, 2022
by
liming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加用户登录日志接口
parent
ede8e269
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
395 additions
and
10 deletions
+395
-10
Achievement.java
...ttp/server/repository/achievement/entity/Achievement.java
+106
-0
AchievementForSportUser.java
...epository/achievement/entity/AchievementForSportUser.java
+51
-0
AchievementForSportUserMapper.java
...ory/achievement/mapper/AchievementForSportUserMapper.java
+16
-0
AchievementMapper.java
...rver/repository/achievement/mapper/AchievementMapper.java
+16
-0
SportUserContinuousLoginDays.java
...repository/sport/entity/SportUserContinuousLoginDays.java
+46
-0
SportUserLoginLog.java
...ttp/server/repository/sport/entity/SportUserLoginLog.java
+41
-0
SportUserContinuousLoginDaysMapper.java
...tory/sport/mapper/SportUserContinuousLoginDaysMapper.java
+16
-0
SportUserLoginLogMapper.java
...rver/repository/sport/mapper/SportUserLoginLogMapper.java
+16
-0
AchievementForSportUserMapper.xml
...rces/mapper/achievement/AchievementForSportUserMapper.xml
+5
-0
AchievementMapper.xml
...c/main/resources/mapper/achievement/AchievementMapper.xml
+5
-0
SportUserContinuousLoginDaysMapper.xml
...urces/mapper/sport/SportUserContinuousLoginDaysMapper.xml
+5
-0
SportUserLoginLogMapper.xml
...c/main/resources/mapper/sport/SportUserLoginLogMapper.xml
+5
-0
SportUserController.java
...ver/api/business/user/controller/SportUserController.java
+7
-0
SportUserService.java
...er/server/api/business/user/service/SportUserService.java
+60
-10
No files found.
repository/src/main/java/com/antai/sport/http/server/repository/achievement/entity/Achievement.java
0 → 100644
View file @
fb4d6b1c
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
achievement
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.time.LocalDateTime
;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* <p>
*
* </p>
*
* @author liming
* @since 2022-08-09
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
Achievement
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
* 分类 10 运动数值型 20 参与型
*/
private
Integer
type
;
/**
* 级别 10 初级 20 中级 30 高级
*/
private
Integer
level
;
/**
* 条件 10 登录天数 20 团练完成场数 30 日常赛完成场数 40 娱乐赛场数 50 里程 60 爬升高度 70 卡路里消耗
*/
private
Integer
condition
;
/**
* 成就名称
*/
private
String
achievementName
;
/**
* 条件数值
*/
private
Integer
conditionValue
;
/**
* 成就名称
*/
private
String
name
;
/**
* 成就logo
*/
private
String
logo
;
/**
* 备注
*/
private
String
remark
;
/**
* 排序号
*/
private
Integer
showOrder
;
/**
* 数据版本号
*/
private
Integer
version
;
/**
* 删除标记
*/
private
Integer
deleted
;
/**
* 创建人
*/
private
Long
createBy
;
/**
* 创建时间
*/
private
LocalDateTime
ctDate
;
/**
* 修改人
*/
private
Long
updateBy
;
/**
* 修改时间
*/
private
LocalDateTime
updateDate
;
}
repository/src/main/java/com/antai/sport/http/server/repository/achievement/entity/AchievementForSportUser.java
0 → 100644
View file @
fb4d6b1c
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
achievement
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.time.LocalDateTime
;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* <p>
*
* </p>
*
* @author liming
* @since 2022-08-09
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
AchievementForSportUser
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
* 用户id
*/
private
Long
sportUserId
;
/**
* 成就id
*/
private
Long
achievementId
;
/**
* 已读状态
*/
private
Boolean
read
;
/**
* 创建时间
*/
private
LocalDateTime
createTime
;
}
repository/src/main/java/com/antai/sport/http/server/repository/achievement/mapper/AchievementForSportUserMapper.java
0 → 100644
View file @
fb4d6b1c
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
achievement
.
mapper
;
import
com.antai.sport.http.server.repository.achievement.entity.AchievementForSportUser
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* <p>
* Mapper 接口
* </p>
*
* @author liming
* @since 2022-08-09
*/
public
interface
AchievementForSportUserMapper
extends
BaseMapper
<
AchievementForSportUser
>
{
}
repository/src/main/java/com/antai/sport/http/server/repository/achievement/mapper/AchievementMapper.java
0 → 100644
View file @
fb4d6b1c
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
achievement
.
mapper
;
import
com.antai.sport.http.server.repository.achievement.entity.Achievement
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* <p>
* Mapper 接口
* </p>
*
* @author liming
* @since 2022-08-09
*/
public
interface
AchievementMapper
extends
BaseMapper
<
Achievement
>
{
}
repository/src/main/java/com/antai/sport/http/server/repository/sport/entity/SportUserContinuousLoginDays.java
0 → 100644
View file @
fb4d6b1c
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
sport
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
java.time.LocalDate
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* <p>
*
* </p>
*
* @author liming
* @since 2022-08-09
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
SportUserContinuousLoginDays
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
* 用户id
*/
private
Long
sportUserId
;
/**
* 连续登录天数
*/
private
Integer
days
;
/**
* 最后连续登录日期
*/
private
LocalDate
lastLoginDate
;
}
repository/src/main/java/com/antai/sport/http/server/repository/sport/entity/SportUserLoginLog.java
0 → 100644
View file @
fb4d6b1c
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
sport
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.time.LocalDateTime
;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* <p>
*
* </p>
*
* @author liming
* @since 2022-08-09
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
SportUserLoginLog
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
* 用户id
*/
private
Long
sportUserId
;
/**
* 创建时间
*/
private
LocalDateTime
createTime
;
}
repository/src/main/java/com/antai/sport/http/server/repository/sport/mapper/SportUserContinuousLoginDaysMapper.java
0 → 100644
View file @
fb4d6b1c
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
sport
.
mapper
;
import
com.antai.sport.http.server.repository.sport.entity.SportUserContinuousLoginDays
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* <p>
* Mapper 接口
* </p>
*
* @author liming
* @since 2022-08-09
*/
public
interface
SportUserContinuousLoginDaysMapper
extends
BaseMapper
<
SportUserContinuousLoginDays
>
{
}
repository/src/main/java/com/antai/sport/http/server/repository/sport/mapper/SportUserLoginLogMapper.java
0 → 100644
View file @
fb4d6b1c
package
com
.
antai
.
sport
.
http
.
server
.
repository
.
sport
.
mapper
;
import
com.antai.sport.http.server.repository.sport.entity.SportUserLoginLog
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* <p>
* Mapper 接口
* </p>
*
* @author liming
* @since 2022-08-09
*/
public
interface
SportUserLoginLogMapper
extends
BaseMapper
<
SportUserLoginLog
>
{
}
repository/src/main/resources/mapper/achievement/AchievementForSportUserMapper.xml
0 → 100644
View file @
fb4d6b1c
<?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.antai.sport.http.server.repository.achievement.mapper.AchievementForSportUserMapper"
>
</mapper>
repository/src/main/resources/mapper/achievement/AchievementMapper.xml
0 → 100644
View file @
fb4d6b1c
<?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.antai.sport.http.server.repository.achievement.mapper.AchievementMapper"
>
</mapper>
repository/src/main/resources/mapper/sport/SportUserContinuousLoginDaysMapper.xml
0 → 100644
View file @
fb4d6b1c
<?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.antai.sport.http.server.repository.sport.mapper.SportUserContinuousLoginDaysMapper"
>
</mapper>
repository/src/main/resources/mapper/sport/SportUserLoginLogMapper.xml
0 → 100644
View file @
fb4d6b1c
<?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.antai.sport.http.server.repository.sport.mapper.SportUserLoginLogMapper"
>
</mapper>
server-api/src/main/java/com/antai/sport/http/server/server/api/business/user/controller/SportUserController.java
View file @
fb4d6b1c
...
...
@@ -62,4 +62,11 @@ public class SportUserController {
public
ResponseEntity
<
Result
<
TrainingDetailVO
>>
getSportUserTrainingLogRank
(
@PathVariable
(
"id"
)
Long
Id
)
{
return
success
(
sportUserTrainingLogService
.
getTrainingDetail
(
Id
));
}
@ApiOperation
(
"用户登录日志处理"
)
@GetMapping
(
"/sign/in/{sportUserId}"
)
public
ResponseEntity
<
Result
>
signIn
(
@PathVariable
(
"sportUserId"
)
Long
sportUserId
)
{
sportUserService
.
signIn
(
sportUserId
);
return
success
();
}
}
server-api/src/main/java/com/antai/sport/http/server/server/api/business/user/service/SportUserService.java
View file @
fb4d6b1c
package
com
.
antai
.
sport
.
http
.
server
.
server
.
api
.
business
.
user
.
service
;
import
com.antai.sport.http.server.constants.SportType
;
import
com.antai.sport.http.server.repository.sport.entity.
SportUser
;
import
com.antai.sport.http.server.repository.sport.
entity.SportUserSummary
;
import
com.antai.sport.http.server.repository.sport.
entity.SportUserTrainingLog
;
import
com.antai.sport.http.server.repository.sport.entity.
*
;
import
com.antai.sport.http.server.repository.sport.
mapper.SportUserContinuousLoginDaysMapper
;
import
com.antai.sport.http.server.repository.sport.
mapper.SportUserLoginLogMapper
;
import
com.antai.sport.http.server.repository.sport.mapper.SportUserMapper
;
import
com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogSummaryVO
;
import
com.antai.sport.http.server.server.api.business.traininglog.service.SportUserTrainingLogService
;
import
com.antai.sport.http.server.server.api.business.user.dto.RespUserHomeInfo
;
import
com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogSummaryVO
;
import
com.antai.sport.http.server.server.api.business.user.mapper.SportUserSummaryBusinessMapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
@Service
public
class
SportUserService
{
@Resource
private
SportUserMapper
sportUserMapper
;
@Resource
private
SportUserLoginLogMapper
sportUserLoginLogMapper
;
@Resource
private
SportUserContinuousLoginDaysMapper
sportUserContinuousLoginDaysMapper
;
@Resource
private
SportUserSummaryBusinessMapper
sportUserSummaryBusinessMapper
;
...
...
@@ -29,8 +37,9 @@ public class SportUserService {
public
RespUserHomeInfo
getUserHomeInfo
(
Long
userId
)
{
RespUserHomeInfo
resp
=
new
RespUserHomeInfo
();
SportUser
sportUser
=
sportUserMapper
.
selectById
(
userId
);
SportUserSummary
sportUserSummary
=
sportUserSummaryBusinessMapper
.
selectBySportTypeAndUserId
(
userId
,
SportType
.
BICYCLE
);
if
(
sportUserSummary
==
null
){
SportUserSummary
sportUserSummary
=
sportUserSummaryBusinessMapper
.
selectBySportTypeAndUserId
(
userId
,
SportType
.
BICYCLE
);
if
(
sportUserSummary
==
null
)
{
sportUserSummary
=
new
SportUserSummary
();
sportUserSummary
.
setViews
(
0
);
sportUserSummary
.
setTotalDistance
(
BigDecimal
.
ZERO
);
...
...
@@ -56,18 +65,59 @@ public class SportUserService {
totalSummary
.
setTotalDistance
(
sportUserSummary
.
getTotalDistance
());
totalSummary
.
setTotalClimbDistance
(
sportUserSummary
.
getTotalClimbDistance
());
totalSummary
.
setTotalDuration
(
sportUserSummary
.
getTotalDuration
());
SportUserTrainingLog
longestTrainingLog
=
sportUserTrainingLogService
.
getLongestTrainingLog
(
SportType
.
BICYCLE
,
userId
);
if
(
longestTrainingLog
==
null
){
SportUserTrainingLog
longestTrainingLog
=
sportUserTrainingLogService
.
getLongestTrainingLog
(
SportType
.
BICYCLE
,
userId
);
if
(
longestTrainingLog
==
null
)
{
totalSummary
.
setLongestDistance
(
BigDecimal
.
ZERO
);
}
else
{
totalSummary
.
setLongestDistance
(
longestTrainingLog
.
getDistance
());
}
resp
.
setTotalSummary
(
totalSummary
);
//查询7天数据汇总
resp
.
setWeekSummary
(
sportUserTrainingLogService
.
getTrainingLogSummary
(
SportType
.
BICYCLE
,
userId
,
7
));
resp
.
setWeekSummary
(
sportUserTrainingLogService
.
getTrainingLogSummary
(
SportType
.
BICYCLE
,
userId
,
7
));
//查询30天数据汇总
resp
.
setMonthSummary
(
sportUserTrainingLogService
.
getTrainingLogSummary
(
SportType
.
BICYCLE
,
userId
,
30
));
resp
.
setMonthSummary
(
sportUserTrainingLogService
.
getTrainingLogSummary
(
SportType
.
BICYCLE
,
userId
,
30
));
return
resp
;
}
/**
* 用户登录日志
*/
public
void
signIn
(
Long
sportUserId
)
{
//插入登录日志
SportUserLoginLog
loginLog
=
new
SportUserLoginLog
();
loginLog
.
setSportUserId
(
sportUserId
);
loginLog
.
setCreateTime
(
LocalDateTime
.
now
());
sportUserLoginLogMapper
.
insert
(
loginLog
);
//查询连续登录时间
QueryWrapper
<
SportUserContinuousLoginDays
>
continuousLoginDaysQuery
=
new
QueryWrapper
<>();
continuousLoginDaysQuery
.
lambda
().
eq
(
SportUserContinuousLoginDays:
:
getSportUserId
,
sportUserId
);
SportUserContinuousLoginDays
continuousLoginDays
=
sportUserContinuousLoginDaysMapper
.
selectOne
(
continuousLoginDaysQuery
);
if
(
continuousLoginDays
==
null
)
{
continuousLoginDays
=
new
SportUserContinuousLoginDays
();
continuousLoginDays
.
setDays
(
1
);
continuousLoginDays
.
setSportUserId
(
sportUserId
);
continuousLoginDays
.
setLastLoginDate
(
LocalDate
.
now
());
sportUserContinuousLoginDaysMapper
.
insert
(
continuousLoginDays
);
return
;
}
//当最近连续登录时间相同时不做处理
if
(
continuousLoginDays
.
getLastLoginDate
().
isEqual
(
LocalDate
.
now
()))
{
return
;
}
//当最近连续登录时间和当天时间间隔一天时累计连续登录时间
if
(
continuousLoginDays
.
getLastLoginDate
().
isEqual
(
LocalDate
.
now
().
minusDays
(
1
)))
{
continuousLoginDays
.
setDays
(
continuousLoginDays
.
getDays
()
+
1
);
continuousLoginDays
.
setLastLoginDate
(
LocalDate
.
now
());
sportUserContinuousLoginDaysMapper
.
insert
(
continuousLoginDays
);
return
;
}
//其他情况重置连续登录天数
continuousLoginDays
.
setDays
(
1
);
continuousLoginDays
.
setLastLoginDate
(
LocalDate
.
now
());
sportUserContinuousLoginDaysMapper
.
insert
(
continuousLoginDays
);
}
}
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