Commit 5833305e authored by shiyu's avatar shiyu

签到任务

parent 5f68865b
package com.wwdz.ch.db.dao.qiandao;
import com.wwdz.ch.db.domain.qiandao.QdUserSignIn;
import com.wwdz.ch.db.dto.request.qiandao.QdUserSignInRequestDto;
import java.util.List;
public interface QdUserSignInDao {
boolean insert(QdUserSignIn qdUserSignIn);
QdUserSignIn findLastedRecord(long userId);
List<QdUserSignIn> findList(QdUserSignInRequestDto dto);
/**
* 查询昨天的签到记录
* @param userId
* @return
*/
QdUserSignIn findYesterdayRecord(long userId);
QdUserSignIn findTodayRecord(long userId);
/**
* 判断某一日期是否签到过
* @param userId
* @param date
* @return
*/
boolean isExisted(long userId, String date);
QdUserSignIn findRecord(long userId, String date, Integer consecutiveDays);
boolean update(QdUserSignIn userSignin);
boolean updateByPrimaryKey(QdUserSignIn userSignin);
boolean deleteTodayRecord(long userId);
boolean updateInvalid(QdUserSignInRequestDto dto);
}
package com.wwdz.ch.db.domain.qiandao;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
* @author shiyu
* @date 2024/12/19
*/
@Data
public class QdGiveLikeRecord implements Entity {
/**
* id
*/
private Long id;
/**
* 用户id
*/
private Long userId;
/**
* 笔记id
*/
private Long noteId;
/**
* 笔记创建人id
*/
private Long noteCreatorId;
/**
* 点赞时间
*/
private Date createTime;
/**
* 更新时间
*/
private Integer updateTime;
/**
* 是否有效
*/
private Boolean isValid;
private static final long serialVersionUID = 1L;
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", userId=").append(userId);
sb.append(", noteId=").append(noteId);
sb.append(", noteCreatorId=").append(noteCreatorId);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", isValid=").append(isValid);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
QdGiveLikeRecord other = (QdGiveLikeRecord) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getNoteId() == null ? other.getNoteId() == null : this.getNoteId().equals(other.getNoteId()))
&& (this.getNoteCreatorId() == null ? other.getNoteCreatorId() == null : this.getNoteCreatorId().equals(other.getNoteCreatorId()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getIsValid() == null ? other.getIsValid() == null : this.getIsValid().equals(other.getIsValid()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getNoteId() == null) ? 0 : getNoteId().hashCode());
result = prime * result + ((getNoteCreatorId() == null) ? 0 : getNoteCreatorId().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getIsValid() == null) ? 0 : getIsValid().hashCode());
return result;
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public enum Column {
id("id", "id", "BIGINT", false),
userId("user_id", "userId", "BIGINT", false),
noteId("note_id", "noteId", "BIGINT", false),
noteCreatorId("note_creator_id", "noteCreatorId", "BIGINT", false),
createTime("create_time", "createTime", "TIMESTAMP", false),
updateTime("update_time", "updateTime", "INTEGER", false),
isValid("is_valid", "isValid", "BIT", false);
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String BEGINNING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String ENDING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String column;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final boolean isColumnNameDelimited;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String javaProperty;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String jdbcType;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String value() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getValue() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJavaProperty() {
return this.javaProperty;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJdbcType() {
return this.jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
this.isColumnNameDelimited = isColumnNameDelimited;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String desc() {
return this.getEscapedColumnName() + " DESC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String asc() {
return this.getEscapedColumnName() + " ASC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getEscapedColumnName() {
if (this.isColumnNameDelimited) {
return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
} else {
return this.column;
}
}
}
}
\ No newline at end of file
......@@ -4,6 +4,8 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
......@@ -11,7 +13,7 @@ import lombok.Data;
* @date 2024/12/18
*/
@Data
public class QdUser implements Serializable {
public class QdUser implements Entity {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table qd_user
......
......@@ -4,6 +4,8 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
......@@ -11,7 +13,7 @@ import lombok.Data;
* @date 2024/12/18
*/
@Data
public class QdUserSignIn implements Serializable {
public class QdUserSignIn implements Entity {
/**
* id
*/
......
package com.wwdz.ch.db.domain.qiandao;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
......@@ -11,7 +11,7 @@ import lombok.Data;
* @date 2024/12/18
*/
@Data
public class QdUserSignInNote implements Serializable {
public class QdUserSignInNote implements Entity {
private Long id;
/**
......
......@@ -4,6 +4,8 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
......@@ -11,7 +13,7 @@ import lombok.Data;
* @date 2024/12/18
*/
@Data
public class QdUserSignInTask implements Serializable {
public class QdUserSignInTask implements Entity {
private Long id;
/**
......
package com.wwdz.ch.db.dto.request.qiandao;
import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.util.Date;
@Data
public class QdUserSignInNoteRequestDto implements Entity {
/**
* 用户id
*/
private Long userId;
/**
* 签到任务id
*/
private Long taskId;
/**
* 标题
*/
private String title;
/**
* 内容
*/
private String content;
/**
* 图片,分号分割
*/
private String image;
/**
* 音频
*/
private String audio;
/**
* 对应签到的日期
*/
private String signInDate;
/**
* 对应签到记录的id
*/
private Long recordId;
/**
* 是否公开
*/
private Boolean isPrivate;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 是否删除
*/
private Boolean isDeleted;
}
package com.wwdz.ch.db.dto.request.qiandao;
import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.util.Date;
@Data
public class QdUserSignInRequestDto implements Entity {
/**
* id
*/
private Long id;
/**
* 签到任务id
*/
private Long taskId;
/**
* 用户id
*/
private Long userId;
/**
* 签到时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
private Date startQueryTime;
private Date endQueryTime;
/**
* 签到日期
*/
private String signInDate;
/**
* 连续天数
*/
private Integer consecutiveDays;
/**
* 是否有奖励
*/
private Boolean isReward;
/**
* 奖励等级
*/
private Integer rewardLevel;
/**
* 是否领取奖励
*/
private Boolean isGet;
/**
* 是否有效
*/
private Boolean isValid;
}
......@@ -2,9 +2,9 @@ package com.wwdz.ch.db.dto.request.qiandao;
import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.util.Date;
@Data
public class SignInTaskRequestDto implements Entity {
......
package com.wwdz.ch.db.impl.qiandao;
import com.wwdz.ch.db.dao.qiandao.QdUserSignInDao;
import com.wwdz.ch.db.domain.qiandao.QdUserSignIn;
import com.wwdz.ch.db.domain.qiandao.QdUserSignInExample;
import com.wwdz.ch.db.dto.request.qiandao.QdUserSignInRequestDto;
import com.wwdz.ch.db.mapper.qiandao.QdUserSignInMapper;
import com.xxdxxs.db.component.JdbcHelper;
import com.xxdxxs.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.time.LocalDate;
import java.util.List;
@Repository
public class QdUserSignInDaoImpl implements QdUserSignInDao {
@Autowired
QdUserSignInMapper qdUserSignInMapper;
@Override
public boolean insert(QdUserSignIn qdQdUserSignIn) {
qdQdUserSignIn.setIsValid(true);
return qdUserSignInMapper.insert(qdQdUserSignIn) > 0;
}
@Override
public QdUserSignIn findLastedRecord(long userId) {
QdUserSignInExample example = new QdUserSignInExample();
QdUserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andIsValidEqualTo(true);
example.setOrderByClause("create_time desc");
return qdUserSignInMapper.selectOneByExample(example);
}
@Override
public List<QdUserSignIn> findList(QdUserSignInRequestDto dto) {
QdUserSignInExample example = new QdUserSignInExample();
QdUserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(dto.getUserId());
JdbcHelper.ifPresent(dto.getStartQueryTime(), criteria :: andCreateTimeGreaterThanOrEqualTo);
JdbcHelper.ifPresent(dto.getEndQueryTime(), criteria :: andCreateTimeLessThanOrEqualTo);
criteria.andIsValidEqualTo(true);
example.setOrderByClause("create_time desc");
return qdUserSignInMapper.selectByExample(example);
}
@Override
public QdUserSignIn findYesterdayRecord(long userId) {
LocalDate yesterday = LocalDate.now().minusDays(1);
String yesterdayString = DateUtils.DATE.format(yesterday);
QdUserSignInExample example = new QdUserSignInExample();
QdUserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andSignInDateEqualTo(yesterdayString);
criteria.andIsValidEqualTo(true);
return qdUserSignInMapper.selectOneByExample(example);
}
@Override
public QdUserSignIn findTodayRecord(long userId) {
LocalDate today = LocalDate.now();
String todayString = DateUtils.DATE.format(today);
QdUserSignInExample example = new QdUserSignInExample();
QdUserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andSignInDateEqualTo(todayString);
criteria.andIsValidEqualTo(true);
return qdUserSignInMapper.selectOneByExample(example);
}
@Override
public boolean isExisted(long userId, String date) {
QdUserSignInExample example = new QdUserSignInExample();
QdUserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andSignInDateEqualTo(date);
criteria.andIsValidEqualTo(true);
return qdUserSignInMapper.countByExample(example) > 0;
}
@Override
public QdUserSignIn findRecord(long userId, String date, Integer consecutiveDays) {
QdUserSignInExample example = new QdUserSignInExample();
QdUserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andSignInDateEqualTo(date);
JdbcHelper.ifPresent(consecutiveDays, criteria::andConsecutiveDaysEqualTo);
criteria.andIsValidEqualTo(true);
return qdUserSignInMapper.selectOneByExample(example);
}
@Override
public boolean update(QdUserSignIn userSignin) {
QdUserSignInExample example = new QdUserSignInExample();
QdUserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userSignin.getUserId());
criteria.andSignInDateEqualTo(userSignin.getSignInDate());
return qdUserSignInMapper.updateByExampleSelective(userSignin, example) > 0;
}
@Override
public boolean updateByPrimaryKey(QdUserSignIn userSignin) {
return qdUserSignInMapper.updateByPrimaryKeySelective(userSignin) > 0;
}
@Override
public boolean deleteTodayRecord(long userId) {
LocalDate today = LocalDate.now();
String todayString = DateUtils.DATE.format(today);
QdUserSignInExample example = new QdUserSignInExample();
QdUserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andSignInDateEqualTo(todayString);
return qdUserSignInMapper.deleteByExample(example) > 0;
}
@Override
public boolean updateInvalid(QdUserSignInRequestDto dto) {
QdUserSignInExample example = new QdUserSignInExample();
QdUserSignInExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(dto.getStartQueryTime(), criteria::andCreateTimeGreaterThan);
JdbcHelper.ifPresent(dto.getSignInDate(), criteria::andSignInDateEqualTo);
criteria.andUserIdEqualTo(dto.getUserId());
criteria.andIsValidEqualTo(true);
QdUserSignIn userSignin = new QdUserSignIn();
userSignin.setIsValid(false);
return qdUserSignInMapper.updateByExampleSelective(userSignin, example) > 0;
}
}
package com.wwdz.ch.db.mapper.qiandao;
import com.wwdz.ch.db.domain.qiandao.QdGiveLikeRecord;
import com.wwdz.ch.db.domain.qiandao.QdGiveLikeRecordExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface QdGiveLikeRecordMapper {
long countByExample(QdGiveLikeRecordExample example);
int deleteByExample(QdGiveLikeRecordExample example);
int deleteByPrimaryKey(Long id);
int insert(QdGiveLikeRecord record);
int insertSelective(QdGiveLikeRecord record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
QdGiveLikeRecord selectOneByExample(QdGiveLikeRecordExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
QdGiveLikeRecord selectOneByExampleSelective(@Param("example") QdGiveLikeRecordExample example, @Param("selective") QdGiveLikeRecord.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<QdGiveLikeRecord> selectByExampleSelective(@Param("example") QdGiveLikeRecordExample example, @Param("selective") QdGiveLikeRecord.Column ... selective);
List<QdGiveLikeRecord> selectByExample(QdGiveLikeRecordExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_give_like_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
QdGiveLikeRecord selectByPrimaryKeySelective(@Param("id") Long id, @Param("selective") QdGiveLikeRecord.Column ... selective);
QdGiveLikeRecord selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") QdGiveLikeRecord record, @Param("example") QdGiveLikeRecordExample example);
int updateByExample(@Param("record") QdGiveLikeRecord record, @Param("example") QdGiveLikeRecordExample example);
int updateByPrimaryKeySelective(QdGiveLikeRecord record);
int updateByPrimaryKey(QdGiveLikeRecord record);
}
\ No newline at end of file
......@@ -3,8 +3,11 @@ package com.wwdz.ch.db.mapper.qiandao;
import com.wwdz.ch.db.domain.qiandao.QdUserSignIn;
import com.wwdz.ch.db.domain.qiandao.QdUserSignInExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface QdUserSignInMapper {
long countByExample(QdUserSignInExample example);
......
......@@ -72,7 +72,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.qiandao"
targetProject="ch-dao/src/main/java"/>
<table tableName="qd_user_sign_in_note" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<table tableName="qd_give_like_record" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table>
......
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