Merge branch 'master' of https://gitee.com/darlk/ShengTangManage into xzj
This commit is contained in:
@ -18,6 +18,8 @@ public class SysPunchThumbsup extends BaseEntity
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
private String encId;
|
||||
|
||||
/** 打卡记录ID */
|
||||
@Excel(name = "打卡记录ID")
|
||||
private Long punchId;
|
||||
|
@ -22,11 +22,6 @@ public class CommunityPunchReponse {
|
||||
*/
|
||||
private String openid;
|
||||
|
||||
/**
|
||||
* 客户ID
|
||||
*/
|
||||
private String cusId;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
@ -43,11 +38,6 @@ public class CommunityPunchReponse {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date logTime;
|
||||
|
||||
/**
|
||||
* 当天打卡体重
|
||||
*/
|
||||
private BigDecimal weight;
|
||||
|
||||
/**
|
||||
* 营养师评论
|
||||
*/
|
||||
@ -66,10 +56,10 @@ public class CommunityPunchReponse {
|
||||
/**
|
||||
* 近期打卡体重信息 logTime: 打卡日期 weight: 体重
|
||||
*/
|
||||
private List<Map<String,Object>> recentWeight;
|
||||
private List<Map<String,Object>> weightData;
|
||||
|
||||
/**
|
||||
* 点赞的openid
|
||||
*/
|
||||
private List<Map<String,Object>> thumbsupOpenid;
|
||||
private List<Map<String,Object>> thumbsupUser;
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.stdiet.custom.typehandler;
|
||||
|
||||
import com.stdiet.common.utils.sign.AesUtils;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@MappedTypes({String.class})
|
||||
@MappedJdbcTypes({JdbcType.BIGINT})
|
||||
public class EncryptedIdHandler extends BaseTypeHandler<String> {
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement preparedStatement, int i, String encrypedId, JdbcType jdbcType) throws SQLException {
|
||||
preparedStatement.setLong(i, Long.parseLong(AesUtils.decrypt(encrypedId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNullableResult(ResultSet resultSet, String s) throws SQLException {
|
||||
return this.encryptedString(resultSet.getLong(s));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNullableResult(ResultSet resultSet, int i) throws SQLException {
|
||||
return this.encryptedString(resultSet.getLong(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNullableResult(CallableStatement callableStatement, int i) throws SQLException {
|
||||
return this.encryptedString(callableStatement.getLong(i));
|
||||
}
|
||||
|
||||
private String encryptedString(Long id) {
|
||||
return AesUtils.encrypt(String.valueOf(id));
|
||||
}
|
||||
}
|
@ -31,15 +31,15 @@
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="punchId != null">punch_id,</if>
|
||||
<if test="cusOpenid != null">cus_openid,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="true">create_time,</if>
|
||||
<if test="true">update_time,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="punchId != null">#{punchId},</if>
|
||||
<if test="cusOpenid != null">#{cusOpenid},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="true">now(),</if>
|
||||
<if test="true">now(),</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
@ -334,42 +334,56 @@
|
||||
|
||||
|
||||
<resultMap id="punchReponseMap" type="com.stdiet.custom.dto.response.CommunityPunchReponse">
|
||||
<result property="id" column="id"/>
|
||||
<result property="id" column="id" typeHandler="com.stdiet.custom.typehandler.EncryptedIdHandler"/>
|
||||
<result property="openid" column="openid"/>
|
||||
<result property="cusId" column="cus_id"/>
|
||||
<result property="nickName" column="nick_name"/>
|
||||
<result property="avatarUrl" column="avatar_url"/>
|
||||
<result property="logTime" column="log_time"/>
|
||||
<result property="weight" column="weight"/>
|
||||
<result property="comment" column="comment"/>
|
||||
<result property="thumbsupNum" column="thumbsup_num"/>
|
||||
<result property="healthManifesto" column="health_manifesto"/>
|
||||
<association property="thumbsupNum" column="id" select="getPunchThumbsupCount"/>
|
||||
<!-- 查询最近五天体重 -->
|
||||
<association property="recentWeight" column="{cusId=cus_id,logTime=log_time}" select="getRecentWeight"/>
|
||||
<association property="weightData" column="{id=openid}" select="getRecentWeight"/>
|
||||
<!-- 查询点赞的openid -->
|
||||
<association property="thumbsupOpenid" column="id" select="getPunchThumbsupList"/>
|
||||
<association property="thumbsupUser" column="id" select="getPunchThumbsupList"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 查询打卡社区内容 -->
|
||||
<select id="getCommunityPunch" resultMap="punchReponseMap" parameterType="SysWxUserLog">
|
||||
select wxlog.id,wxinfo.openid,wxinfo.cus_id,wxinfo.nick_name,wxinfo.avatar_url,wxlog.log_time,wxlog.weight,wxlog.comment,wxlog.thumbsup_num,wxlog.health_manifesto from sys_wx_user_log wxlog
|
||||
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
|
||||
where wxlog.del_flag = 0
|
||||
order by wxlog.log_time desc
|
||||
SELECT * FROM
|
||||
(SELECT id, openid, `comment`, health_manifesto, log_time FROM sys_wx_user_log WHERE TO_DAYS(log_time) = TO_DAYS(NOW()) AND del_flag = 0) AS wxlog
|
||||
LEFT JOIN (SELECT openid, nick_name, avatar_url FROM sys_wx_user_info) AS wxinfo
|
||||
USING(openid)
|
||||
ORDER BY log_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询打卡社区中点赞的openid -->
|
||||
<select id="getPunchThumbsupList" parameterType="Long" resultType="Map">
|
||||
select cus_openid as openid from sys_punch_thumbsup
|
||||
where punch_id = #{id} and del_flag = 0
|
||||
<!-- <select id="getPunchThumbsupList" parameterType="Long" resultType="Map">-->
|
||||
<!-- select * from-->
|
||||
<!-- (select id, cus_openid as openid, DATE_FORMAT(create_time,'%Y-%m-%d %H:%i') as `time` from sys_punch_thumbsup where punch_id = #{id} and del_flag = 0 order by create_time asc) as tu-->
|
||||
<!-- left join (SELECT openid, nick_name as nickName, avatar_url as avatarUrl FROM sys_wx_user_info) AS wxinfo-->
|
||||
<!-- using(openid)-->
|
||||
<!-- </select>-->
|
||||
|
||||
<resultMap id="thumbupUserResultMap" type="Map">
|
||||
<result property="id" column="id" typeHandler="com.stdiet.custom.typehandler.EncryptedIdHandler"/>
|
||||
<result property="openid" column="cus_openid"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getPunchThumbsupList" parameterType="Long" resultMap="thumbupUserResultMap">
|
||||
select id, cus_openid from sys_punch_thumbsup where punch_id = #{id} and del_flag = 0
|
||||
</select>
|
||||
|
||||
<!-- 查询最近一周的打卡体重 -->
|
||||
<select id="getPunchThumbsupCount" parameterType="Long" resultType="Integer">
|
||||
select count(*) from sys_punch_thumbsup where punch_id = #{id} and del_flag = 0
|
||||
</select>
|
||||
|
||||
<!-- 查询所有打卡体重 -->
|
||||
<select id="getRecentWeight" resultType="Map">
|
||||
select DATE_FORMAT(wxlog.log_time,'%Y-%m-%d') as logTime,wxlog.weight as weight from sys_wx_user_log wxlog
|
||||
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
|
||||
where wxlog.del_flag = 0 and wxinfo.cus_id = #{cusId} and #{logTime} >= wxlog.log_time
|
||||
order by wxlog.log_time desc limit 7
|
||||
select DATE_FORMAT(log_time,'%Y-%m-%d') as name, weight as `value` from sys_wx_user_log
|
||||
where del_flag = 0 and openid = #{id}
|
||||
order by log_time desc
|
||||
</select>
|
||||
|
||||
<!-- 根据客户ID查询总共打卡次数 -->
|
||||
|
Reference in New Issue
Block a user