Commit 922cf26f authored by shiyu's avatar shiyu

排行榜

parent 61fe456c
......@@ -9,4 +9,6 @@ public class QdUserSignInRecord implements Entity {
private Long totalDays;
private Long ranking;
}
package com.wwdz.ch.db.dao.qiandao;
import com.wwdz.ch.db.bean.QdUserSignInRecord;
import com.wwdz.ch.db.domain.qiandao.QdSignInRanking;
import com.wwdz.ch.db.domain.qiandao.QdUserSignIn;
public interface QdSignInRankingDao {
Long insert(QdSignInRanking qdSignInRanking);
QdSignInRanking findByIndex(long userId, Long taskId);
void update(QdSignInRanking qdSignInRanking);
/**
* 是否存在
* @param userId
* @param taskId
* @return
*/
boolean isExisted(long userId, Long taskId);
/**
* 查询排名
* @param userId
* @param taskId
* @return
*/
QdUserSignInRecord findRanking(long userId, Long taskId);
}
......@@ -11,6 +11,9 @@ public interface QdUserSignInTaskDao {
boolean update(QdUserSignInTask qdUserSignInTask);
QdUserSignInTask findByIndex(long userId, long taskId);
List<QdUserSignInTask> findByPage(QdUserSignInTaskRequestDto dto);
/**
......
......@@ -10,7 +10,7 @@ import lombok.Data;
/**
* @author shiyu
* @date 2024/12/18
* @date 2025/02/10
*/
@Data
public class QdUserSignIn implements Entity {
......@@ -44,6 +44,11 @@ public class QdUserSignIn implements Entity {
*/
private String signInDate;
/**
* 参加任务时间
*/
private Date addTaskTime;
/**
* 连续天数
*/
......@@ -83,6 +88,7 @@ public class QdUserSignIn implements Entity {
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", signInDate=").append(signInDate);
sb.append(", addTaskTime=").append(addTaskTime);
sb.append(", consecutiveDays=").append(consecutiveDays);
sb.append(", isReward=").append(isReward);
sb.append(", rewardLevel=").append(rewardLevel);
......@@ -111,6 +117,7 @@ public class QdUserSignIn implements Entity {
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getSignInDate() == null ? other.getSignInDate() == null : this.getSignInDate().equals(other.getSignInDate()))
&& (this.getAddTaskTime() == null ? other.getAddTaskTime() == null : this.getAddTaskTime().equals(other.getAddTaskTime()))
&& (this.getConsecutiveDays() == null ? other.getConsecutiveDays() == null : this.getConsecutiveDays().equals(other.getConsecutiveDays()))
&& (this.getIsReward() == null ? other.getIsReward() == null : this.getIsReward().equals(other.getIsReward()))
&& (this.getRewardLevel() == null ? other.getRewardLevel() == null : this.getRewardLevel().equals(other.getRewardLevel()))
......@@ -128,6 +135,7 @@ public class QdUserSignIn implements Entity {
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getSignInDate() == null) ? 0 : getSignInDate().hashCode());
result = prime * result + ((getAddTaskTime() == null) ? 0 : getAddTaskTime().hashCode());
result = prime * result + ((getConsecutiveDays() == null) ? 0 : getConsecutiveDays().hashCode());
result = prime * result + ((getIsReward() == null) ? 0 : getIsReward().hashCode());
result = prime * result + ((getRewardLevel() == null) ? 0 : getRewardLevel().hashCode());
......@@ -150,6 +158,7 @@ public class QdUserSignIn implements Entity {
createTime("create_time", "createTime", "TIMESTAMP", false),
updateTime("update_time", "updateTime", "TIMESTAMP", false),
signInDate("sign_in_date", "signInDate", "VARCHAR", false),
addTaskTime("add_task_time", "addTaskTime", "TIMESTAMP", false),
consecutiveDays("consecutive_days", "consecutiveDays", "INTEGER", false),
isReward("is_reward", "isReward", "BIT", false),
rewardLevel("reward_level", "rewardLevel", "INTEGER", false),
......
......@@ -950,6 +950,138 @@ public class QdUserSignInExample {
return (Criteria) this;
}
public Criteria andAddTaskTimeIsNull() {
addCriterion("add_task_time is null");
return (Criteria) this;
}
public Criteria andAddTaskTimeIsNotNull() {
addCriterion("add_task_time is not null");
return (Criteria) this;
}
public Criteria andAddTaskTimeEqualTo(Date value) {
addCriterion("add_task_time =", value, "addTaskTime");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andAddTaskTimeEqualToColumn(QdUserSignIn.Column column) {
addCriterion(new StringBuilder("add_task_time = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAddTaskTimeNotEqualTo(Date value) {
addCriterion("add_task_time <>", value, "addTaskTime");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andAddTaskTimeNotEqualToColumn(QdUserSignIn.Column column) {
addCriterion(new StringBuilder("add_task_time <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAddTaskTimeGreaterThan(Date value) {
addCriterion("add_task_time >", value, "addTaskTime");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andAddTaskTimeGreaterThanColumn(QdUserSignIn.Column column) {
addCriterion(new StringBuilder("add_task_time > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAddTaskTimeGreaterThanOrEqualTo(Date value) {
addCriterion("add_task_time >=", value, "addTaskTime");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andAddTaskTimeGreaterThanOrEqualToColumn(QdUserSignIn.Column column) {
addCriterion(new StringBuilder("add_task_time >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAddTaskTimeLessThan(Date value) {
addCriterion("add_task_time <", value, "addTaskTime");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andAddTaskTimeLessThanColumn(QdUserSignIn.Column column) {
addCriterion(new StringBuilder("add_task_time < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAddTaskTimeLessThanOrEqualTo(Date value) {
addCriterion("add_task_time <=", value, "addTaskTime");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andAddTaskTimeLessThanOrEqualToColumn(QdUserSignIn.Column column) {
addCriterion(new StringBuilder("add_task_time <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAddTaskTimeIn(List<Date> values) {
addCriterion("add_task_time in", values, "addTaskTime");
return (Criteria) this;
}
public Criteria andAddTaskTimeNotIn(List<Date> values) {
addCriterion("add_task_time not in", values, "addTaskTime");
return (Criteria) this;
}
public Criteria andAddTaskTimeBetween(Date value1, Date value2) {
addCriterion("add_task_time between", value1, value2, "addTaskTime");
return (Criteria) this;
}
public Criteria andAddTaskTimeNotBetween(Date value1, Date value2) {
addCriterion("add_task_time not between", value1, value2, "addTaskTime");
return (Criteria) this;
}
public Criteria andConsecutiveDaysIsNull() {
addCriterion("consecutive_days is null");
return (Criteria) this;
......
......@@ -60,6 +60,13 @@ public class QdUserSignInRequestDto extends BaseRequestDto implements Entity {
*/
private Integer rewardLevel;
/**
* 参加任务时间
*/
private Date addTaskTime;
/**
* 是否领取奖励
*/
......
package com.wwdz.ch.db.impl.qiandao;
import com.wwdz.ch.db.bean.QdUserSignInRecord;
import com.wwdz.ch.db.dao.qiandao.QdSignInRankingDao;
import com.wwdz.ch.db.domain.qiandao.QdSignInRanking;
import com.wwdz.ch.db.domain.qiandao.QdSignInRankingExample;
import com.wwdz.ch.db.mapper.qiandao.QdSignInRankingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository
public class QdSignInRankingDaoImpl implements QdSignInRankingDao {
@Autowired
QdSignInRankingMapper qdSignInRankingMapper;
@Override
public Long insert(QdSignInRanking qdSignInRanking) {
qdSignInRankingMapper.insert(qdSignInRanking);
return qdSignInRanking.getId();
}
@Override
public QdSignInRanking findByIndex(long userId, Long taskId) {
QdSignInRankingExample example = new QdSignInRankingExample();
QdSignInRankingExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andTaskIdEqualTo(taskId);
criteria.andIsValidEqualTo(true);
return qdSignInRankingMapper.selectOneByExample(example);
}
@Override
public void update(QdSignInRanking qdSignInRanking) {
qdSignInRankingMapper.updateByPrimaryKeySelective(qdSignInRanking);
}
@Override
public boolean isExisted(long userId, Long taskId) {
QdSignInRankingExample example = new QdSignInRankingExample();
QdSignInRankingExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andTaskIdEqualTo(taskId);
criteria.andIsValidEqualTo(true);
return qdSignInRankingMapper.countByExample(example) > 0;
}
@Override
public QdUserSignInRecord findRanking(long userId, Long taskId) {
return qdSignInRankingMapper.findRanking(userId, taskId);
}
}
......@@ -37,6 +37,16 @@ public class QdUserSignInTaskDaoImpl implements QdUserSignInTaskDao {
}
@Override
public QdUserSignInTask findByIndex(long userId, long taskId) {
QdUserSignInTaskExample example = new QdUserSignInTaskExample();
QdUserSignInTaskExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andTaskIdEqualTo(taskId);
criteria.andIsValidEqualTo(true);
return qdUserSignInTaskMapper.selectOneByExample(example);
}
@Override
public boolean update(QdUserSignInTask qdUserSignInTask) {
QdUserSignInTaskExample example = new QdUserSignInTaskExample();
......
package com.wwdz.ch.db.mapper.qiandao;
import com.wwdz.ch.db.bean.QdUserSignInRecord;
import com.wwdz.ch.db.domain.qiandao.QdSignInRanking;
import com.wwdz.ch.db.domain.qiandao.QdSignInRankingExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface QdSignInRankingMapper {
long countByExample(QdSignInRankingExample example);
int deleteByExample(QdSignInRankingExample example);
int deleteByPrimaryKey(Long id);
int insert(QdSignInRanking record);
int insertSelective(QdSignInRanking record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_sign_in_ranking
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
QdSignInRanking selectOneByExample(QdSignInRankingExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_sign_in_ranking
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
QdSignInRanking selectOneByExampleSelective(@Param("example") QdSignInRankingExample example, @Param("selective") QdSignInRanking.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_sign_in_ranking
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<QdSignInRanking> selectByExampleSelective(@Param("example") QdSignInRankingExample example, @Param("selective") QdSignInRanking.Column ... selective);
List<QdSignInRanking> selectByExample(QdSignInRankingExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_sign_in_ranking
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
QdSignInRanking selectByPrimaryKeySelective(@Param("id") Long id, @Param("selective") QdSignInRanking.Column ... selective);
QdSignInRanking selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") QdSignInRanking record, @Param("example") QdSignInRankingExample example);
int updateByExample(@Param("record") QdSignInRanking record, @Param("example") QdSignInRankingExample example);
int updateByPrimaryKeySelective(QdSignInRanking record);
int updateByPrimaryKey(QdSignInRanking record);
QdUserSignInRecord findRanking(@Param("userId")Long userId, @Param("taskId")Long taskId);
}
\ No newline at end of file
......@@ -4,7 +4,6 @@ import com.wwdz.ch.db.bean.QdUserSignInRecord;
import com.wwdz.ch.db.domain.qiandao.QdUserSignIn;
import com.wwdz.ch.db.domain.qiandao.QdUserSignInExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......
......@@ -8,6 +8,7 @@
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="sign_in_date" jdbcType="VARCHAR" property="signInDate" />
<result column="add_task_time" jdbcType="TIMESTAMP" property="addTaskTime" />
<result column="consecutive_days" jdbcType="INTEGER" property="consecutiveDays" />
<result column="is_reward" jdbcType="BIT" property="isReward" />
<result column="reward_level" jdbcType="INTEGER" property="rewardLevel" />
......@@ -73,8 +74,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, task_id, user_id, create_time, update_time, sign_in_date, consecutive_days, is_reward,
reward_level, is_get, is_valid
id, task_id, user_id, create_time, update_time, sign_in_date, add_task_time, consecutive_days,
is_reward, reward_level, is_get, is_valid
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.qiandao.QdUserSignInExample" resultMap="BaseResultMap">
select
......@@ -103,14 +104,14 @@
distinct
</if>
<choose>
<when test="selective != null and selective.length > 0">
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, task_id, user_id, create_time, update_time, sign_in_date, consecutive_days, is_reward,
reward_level, is_get, is_valid
id, task_id, user_id, create_time, update_time, sign_in_date, add_task_time, consecutive_days,
is_reward, reward_level, is_get, is_valid
</otherwise>
</choose>
from qd_user_sign_in
......@@ -135,14 +136,14 @@
-->
select
<choose>
<when test="selective != null and selective.length > 0">
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, task_id, user_id, create_time, update_time, sign_in_date, consecutive_days, is_reward,
reward_level, is_get, is_valid
id, task_id, user_id, create_time, update_time, sign_in_date, add_task_time, consecutive_days,
is_reward, reward_level, is_get, is_valid
</otherwise>
</choose>
from qd_user_sign_in
......@@ -163,13 +164,13 @@
SELECT LAST_INSERT_ID()
</selectKey>
insert into qd_user_sign_in (task_id, user_id, create_time,
update_time, sign_in_date, consecutive_days,
is_reward, reward_level, is_get,
is_valid)
update_time, sign_in_date, add_task_time,
consecutive_days, is_reward, reward_level,
is_get, is_valid)
values (#{taskId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{signInDate,jdbcType=VARCHAR}, #{consecutiveDays,jdbcType=INTEGER},
#{isReward,jdbcType=BIT}, #{rewardLevel,jdbcType=INTEGER}, #{isGet,jdbcType=BIT},
#{isValid,jdbcType=BIT})
#{updateTime,jdbcType=TIMESTAMP}, #{signInDate,jdbcType=VARCHAR}, #{addTaskTime,jdbcType=TIMESTAMP},
#{consecutiveDays,jdbcType=INTEGER}, #{isReward,jdbcType=BIT}, #{rewardLevel,jdbcType=INTEGER},
#{isGet,jdbcType=BIT}, #{isValid,jdbcType=BIT})
</insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.qiandao.QdUserSignIn">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
......@@ -192,6 +193,9 @@
<if test="signInDate != null">
sign_in_date,
</if>
<if test="addTaskTime != null">
add_task_time,
</if>
<if test="consecutiveDays != null">
consecutive_days,
</if>
......@@ -224,6 +228,9 @@
<if test="signInDate != null">
#{signInDate,jdbcType=VARCHAR},
</if>
<if test="addTaskTime != null">
#{addTaskTime,jdbcType=TIMESTAMP},
</if>
<if test="consecutiveDays != null">
#{consecutiveDays,jdbcType=INTEGER},
</if>
......@@ -268,6 +275,9 @@
<if test="record.signInDate != null">
sign_in_date = #{record.signInDate,jdbcType=VARCHAR},
</if>
<if test="record.addTaskTime != null">
add_task_time = #{record.addTaskTime,jdbcType=TIMESTAMP},
</if>
<if test="record.consecutiveDays != null">
consecutive_days = #{record.consecutiveDays,jdbcType=INTEGER},
</if>
......@@ -296,6 +306,7 @@
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
sign_in_date = #{record.signInDate,jdbcType=VARCHAR},
add_task_time = #{record.addTaskTime,jdbcType=TIMESTAMP},
consecutive_days = #{record.consecutiveDays,jdbcType=INTEGER},
is_reward = #{record.isReward,jdbcType=BIT},
reward_level = #{record.rewardLevel,jdbcType=INTEGER},
......@@ -323,6 +334,9 @@
<if test="signInDate != null">
sign_in_date = #{signInDate,jdbcType=VARCHAR},
</if>
<if test="addTaskTime != null">
add_task_time = #{addTaskTime,jdbcType=TIMESTAMP},
</if>
<if test="consecutiveDays != null">
consecutive_days = #{consecutiveDays,jdbcType=INTEGER},
</if>
......@@ -348,6 +362,7 @@
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
sign_in_date = #{signInDate,jdbcType=VARCHAR},
add_task_time = #{addTaskTime,jdbcType=TIMESTAMP},
consecutive_days = #{consecutiveDays,jdbcType=INTEGER},
is_reward = #{isReward,jdbcType=BIT},
reward_level = #{rewardLevel,jdbcType=INTEGER},
......@@ -382,14 +397,14 @@
select
'true' as QUERYID,
<choose>
<when test="selective != null and selective.length > 0">
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, task_id, user_id, create_time, update_time, sign_in_date, consecutive_days, is_reward,
reward_level, is_get, is_valid
id, task_id, user_id, create_time, update_time, sign_in_date, add_task_time, consecutive_days,
is_reward, reward_level, is_get, is_valid
</otherwise>
</choose>
from qd_user_sign_in
......@@ -401,14 +416,13 @@
</if>
limit 1
</select>
<select id="countGroupByUser" parameterType="com.wwdz.ch.db.domain.qiandao.QdUserSignInExample" resultType="com.wwdz.ch.db.bean.QdUserSignInRecord">
select `user_id` as userId, count(1) as totalDays from qd_user_sign_in
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
group by `user_id` order by totalDays desc
group by `user_id` order by totalDays, `add_task_time` desc
</select>
</mapper>
\ No newline at end of file
......@@ -72,7 +72,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.qiandao"
targetProject="ch-dao/src/main/java"/>
<table tableName="qd_disposable_subscribe_record" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<table tableName="qd_sign_in_ranking" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table>
......
......@@ -73,6 +73,9 @@ public class QdUserSignInServiceImpl implements QdUserSignInService {
@Autowired
WxCheckRecordDao wxCheckRecordDao;
@Autowired
QdSignInRankingDao qdSignInRankingDao;
@Override
public Result check(QdUserSignInRequestDto dto) {
try {
......@@ -240,7 +243,24 @@ public class QdUserSignInServiceImpl implements QdUserSignInService {
}
logger.info("=========== 微信音频内容安全识别接口调用成功 ===========");
}
//保存签到排名记录
QdSignInRanking qdSignInRanking = qdSignInRankingDao.findByIndex(userId, taskId);
if (qdSignInRanking == null) {
qdSignInRanking.setIsValid(true);
qdSignInRanking.setTotalSignInDays(1);
qdSignInRanking.setUserId(userId);
qdSignInRanking.setTaskId(taskId);
//查询用户加入任务的时间
QdUserSignInTask qdUserSignInTask = qdUserSignInTaskDao.findByIndex(userId, taskId);
qdSignInRanking.setAddTaskTime(qdUserSignInTask.getCreateTime());
qdSignInRanking.setCreateTime(new Date());
qdSignInRanking.setUpdateTime(new Date());
qdSignInRankingDao.insert(qdSignInRanking);
} else {
qdSignInRanking.setTotalSignInDays(qdSignInRanking.getTotalSignInDays() + 1);
qdSignInRanking.setUpdateTime(new Date());
qdSignInRankingDao.update(qdSignInRanking);
}
return Result.success();
} catch (Exception e) {
logger.error("乾岛签到失败 error:{}", e);
......
......@@ -5,10 +5,7 @@ import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.bean.QdUserSignInRecord;
import com.wwdz.ch.db.dao.qiandao.*;
import com.wwdz.ch.db.domain.User;
import com.wwdz.ch.db.domain.qiandao.QdUser;
import com.wwdz.ch.db.domain.qiandao.QdUserSignIn;
import com.wwdz.ch.db.domain.qiandao.QdUserSignInTask;
import com.wwdz.ch.db.domain.qiandao.SignInTask;
import com.wwdz.ch.db.domain.qiandao.*;
import com.wwdz.ch.db.dto.request.qiandao.QdUserSignInRequestDto;
import com.wwdz.ch.db.dto.request.qiandao.QdUserSignInTaskRequestDto;
import com.wwdz.ch.db.dto.request.qiandao.SignInTaskRequestDto;
......@@ -50,6 +47,9 @@ public class QdUserSignInTaskServiceImpl implements QdUserSignInTaskService {
@Autowired
QdUserDao qdUserDao;
@Autowired
QdSignInRankingDao qdSignInRankingDao;
@Override
public Result join(QdUserSignInTaskRequestDto dto) {
try {
......@@ -253,8 +253,13 @@ public class QdUserSignInTaskServiceImpl implements QdUserSignInTaskService {
@Override
public Result findCharts(QdUserSignInTaskRequestDto dto) {
try {
Map<String, Object> resultMap = new HashMap<>();
long taskId = dto.getTaskId();
long userId = dto.getUserId();
//查询参加任务的人数
long joinNum = qdUserSignInTaskDao.countByTaskId(taskId);
resultMap.put("joinNum", joinNum);
QdUser cUser = qdUserDao.queryById(userId);
//当前用户总打卡数
long currentUserTotalDays = qdUserSignInDao.countTotalRecord(userId, taskId);
......@@ -262,6 +267,7 @@ public class QdUserSignInTaskServiceImpl implements QdUserSignInTaskService {
int currentUserRanking = 0;
List<QdUserSignInRecord> list = qdUserSignInDao.countGroupByUser(taskId);
List<Map<String, Object>> dataList = new ArrayList<>();
//为了并列排序
for (int i =0; i < list.size(); i++) {
Map<String, Object> chartsListInfo = new HashMap<>();
int ranking = i + 1;
......@@ -275,12 +281,18 @@ public class QdUserSignInTaskServiceImpl implements QdUserSignInTaskService {
}
dataList.add(chartsListInfo);
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("currentUserName", cUser.getNickName());
resultMap.put("currentAvatar", cUser.getAvatar());
resultMap.put("currentAvatar", cUser.getAvatar());
if (currentUserRanking == 0) {
resultMap.put("currentUserRanking", "未上榜");
if (currentUserTotalDays == 0) {
resultMap.put("currentUserRanking", "未打卡");
} else {
QdUserSignInRecord qdUserSignInRecord = qdSignInRankingDao.findRanking(userId, taskId);
if (qdUserSignInRecord != null) {
resultMap.put("currentUserRanking", qdUserSignInRecord.getRanking());
}
}
} else {
resultMap.put("currentUserRanking", currentUserRanking);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment