commit
35aabc1e45
@ -715,13 +715,13 @@ public class WechatAppletController extends BaseController {
|
|||||||
public TableDataInfo getCommunityPunch() {
|
public TableDataInfo getCommunityPunch() {
|
||||||
startPage();
|
startPage();
|
||||||
List<CommunityPunchReponse> list = sysWxUserLogService.getCommunityPunch(new SysWxUserLog());
|
List<CommunityPunchReponse> list = sysWxUserLogService.getCommunityPunch(new SysWxUserLog());
|
||||||
if (list != null && list.size() > 0) {
|
// if (list != null && list.size() > 0) {
|
||||||
for (CommunityPunchReponse comm : list) {
|
// for (CommunityPunchReponse comm : list) {
|
||||||
comm.setId(AesUtils.encrypt(comm.getId()));
|
// comm.setId(AesUtils.encrypt(comm.getId()));
|
||||||
// comm.setCusId(AesUtils.encrypt(comm.getCusId()));
|
// comm.setCusId(AesUtils.encrypt(comm.getCusId()));
|
||||||
// comm.setThumbsupNum(comm.getThumbsupOpenid() != null ? comm.getThumbsupOpenid().size() : 0);
|
// comm.setThumbsupNum(comm.getThumbsupOpenid() != null ? comm.getThumbsupOpenid().size() : 0);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -732,25 +732,24 @@ public class WechatAppletController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/thumbsupPunch")
|
@PostMapping("/thumbsupPunch")
|
||||||
public AjaxResult getCommunityPunch(@RequestBody SysPunchThumbsup sysPunchThumbsup) {
|
public AjaxResult getCommunityPunch(@RequestBody SysPunchThumbsup sysPunchThumbsup) {
|
||||||
if (StringUtils.isEmpty(sysPunchThumbsup.getCusOpenid(), sysPunchThumbsup.getEncPunchId()) || sysPunchThumbsup.getThumbsupFlag() == null) {
|
int rows = 0;
|
||||||
return AjaxResult.error("缺少必要参数");
|
if (StringUtils.isEmpty(sysPunchThumbsup.getEncId())) {
|
||||||
|
// 点赞
|
||||||
|
sysPunchThumbsup.setPunchId(Long.parseLong(AesUtils.decrypt(sysPunchThumbsup.getEncPunchId())));
|
||||||
|
rows = sysPunchThumbsupService.insertSysPunchThumbsup(sysPunchThumbsup);
|
||||||
|
if (rows > 0) {
|
||||||
|
Map<String, Object> resultData = new HashMap<>();
|
||||||
|
resultData.put("id", AesUtils.encrypt(String.valueOf(sysPunchThumbsup.getId())));
|
||||||
|
resultData.put("openid", sysPunchThumbsup.getCusOpenid());
|
||||||
|
resultData.put("punchId", sysPunchThumbsup.getEncPunchId());
|
||||||
|
return AjaxResult.success(resultData);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 取消点赞
|
||||||
|
rows = sysPunchThumbsupService.deleteSysPunchThumbsupById(Long.parseLong(AesUtils.decrypt(sysPunchThumbsup.getEncId())));
|
||||||
}
|
}
|
||||||
sysPunchThumbsup.setPunchId(Long.parseLong(AesUtils.decrypt(sysPunchThumbsup.getEncPunchId())));
|
|
||||||
|
|
||||||
SysPunchThumbsup existPunchThumbsup = sysPunchThumbsupService.getThumbsupByPunchIdAndOpenid(sysPunchThumbsup);
|
return toAjax(rows);
|
||||||
if (existPunchThumbsup != null && sysPunchThumbsup.getThumbsupFlag()) {
|
|
||||||
return AjaxResult.error("已点过暂,无法重复点赞");
|
|
||||||
}
|
|
||||||
if (existPunchThumbsup == null && !sysPunchThumbsup.getThumbsupFlag()) {
|
|
||||||
return AjaxResult.error("还未未点赞,无法取消点赞");
|
|
||||||
}
|
|
||||||
int row = 0;
|
|
||||||
try {
|
|
||||||
row = sysPunchThumbsup.getThumbsupFlag() ? sysPunchThumbsupService.insertSysPunchThumbsup(sysPunchThumbsup) : sysPunchThumbsupService.deleteThumbsupByPunchIdAndOpenid(sysPunchThumbsup);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return toAjax(row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ public class SysPunchThumbsup extends BaseEntity
|
|||||||
/** $column.columnComment */
|
/** $column.columnComment */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
private String encId;
|
||||||
|
|
||||||
/** 打卡记录ID */
|
/** 打卡记录ID */
|
||||||
@Excel(name = "打卡记录ID")
|
@Excel(name = "打卡记录ID")
|
||||||
private Long punchId;
|
private Long punchId;
|
||||||
|
@ -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=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="punchId != null">punch_id,</if>
|
<if test="punchId != null">punch_id,</if>
|
||||||
<if test="cusOpenid != null">cus_openid,</if>
|
<if test="cusOpenid != null">cus_openid,</if>
|
||||||
<if test="createTime != null">create_time,</if>
|
<if test="true">create_time,</if>
|
||||||
<if test="updateTime != null">update_time,</if>
|
<if test="true">update_time,</if>
|
||||||
<if test="delFlag != null">del_flag,</if>
|
<if test="delFlag != null">del_flag,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="punchId != null">#{punchId},</if>
|
<if test="punchId != null">#{punchId},</if>
|
||||||
<if test="cusOpenid != null">#{cusOpenid},</if>
|
<if test="cusOpenid != null">#{cusOpenid},</if>
|
||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="true">now(),</if>
|
||||||
<if test="updateTime != null">#{updateTime},</if>
|
<if test="true">now(),</if>
|
||||||
<if test="delFlag != null">#{delFlag},</if>
|
<if test="delFlag != null">#{delFlag},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
@ -334,15 +334,15 @@
|
|||||||
|
|
||||||
|
|
||||||
<resultMap id="punchReponseMap" type="com.stdiet.custom.dto.response.CommunityPunchReponse">
|
<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="openid" column="openid"/>
|
||||||
<result property="nickName" column="nick_name"/>
|
<result property="nickName" column="nick_name"/>
|
||||||
<result property="avatarUrl" column="avatar_url"/>
|
<result property="avatarUrl" column="avatar_url"/>
|
||||||
<result property="logTime" column="log_time"/>
|
<result property="logTime" column="log_time"/>
|
||||||
<result property="weight" column="weight"/>
|
<result property="weight" column="weight"/>
|
||||||
<result property="comment" column="comment"/>
|
<result property="comment" column="comment"/>
|
||||||
<result property="thumbsupNum" column="thumbsup_num"/>
|
|
||||||
<result property="healthManifesto" column="health_manifesto"/>
|
<result property="healthManifesto" column="health_manifesto"/>
|
||||||
|
<association property="thumbsupNum" column="id" select="getPunchThumbsupCount"/>
|
||||||
<!-- 查询最近五天体重 -->
|
<!-- 查询最近五天体重 -->
|
||||||
<association property="weightData" column="{id=openid}" select="getRecentWeight"/>
|
<association property="weightData" column="{id=openid}" select="getRecentWeight"/>
|
||||||
<!-- 查询点赞的openid -->
|
<!-- 查询点赞的openid -->
|
||||||
@ -359,18 +359,31 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询打卡社区中点赞的openid -->
|
<!-- 查询打卡社区中点赞的openid -->
|
||||||
<select id="getPunchThumbsupList" parameterType="Long" resultType="Map">
|
<!-- <select id="getPunchThumbsupList" parameterType="Long" resultType="Map">-->
|
||||||
select * from
|
<!-- select * from-->
|
||||||
(select 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
|
<!-- (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
|
<!-- left join (SELECT openid, nick_name as nickName, avatar_url as avatarUrl FROM sys_wx_user_info) AS wxinfo-->
|
||||||
using(openid)
|
<!-- 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>
|
||||||
|
|
||||||
<!-- 查询所有打卡体重 -->
|
<!-- 查询所有打卡体重 -->
|
||||||
<select id="getRecentWeight" resultType="Map">
|
<select id="getRecentWeight" resultType="Map">
|
||||||
select DATE_FORMAT(log_time,'%Y-%m-%d') as name, weight as `value` from sys_wx_user_log
|
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}
|
where del_flag = 0 and openid = #{id}
|
||||||
order by log_time asc
|
order by log_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 根据客户ID查询总共打卡次数 -->
|
<!-- 根据客户ID查询总共打卡次数 -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user