Commit d4ea2053 authored by yuwenwen's avatar yuwenwen
parents dcd315f0 b8553733
package com.tangguo.web.controller.system;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.tangguo.common.constant.Constants;
import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.domain.entity.SysMenu;
import com.tangguo.common.core.domain.entity.SysUser;
import com.tangguo.common.core.domain.model.LoginBody;
import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.common.core.domain.model.LoginUser;
import com.tangguo.common.core.domain.model.WxcpCodeLogin;
import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.framework.config.ServerConfig;
import com.tangguo.framework.web.service.SysLoginService;
import com.tangguo.framework.web.service.SysPermissionService;
import com.tangguo.framework.web.service.TokenService;
import com.tangguo.framework.web.service.UserDetailsServiceImpl;
import com.tangguo.system.service.ISysMenuService;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.cp.api.WxCpOAuth2Service;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/**
......@@ -25,6 +37,7 @@ import java.util.Set;
*
* @author ruoyi
*/
@Slf4j
@RestController
public class SysLoginController {
@Autowired
......@@ -36,6 +49,19 @@ public class SysLoginController {
@Autowired
private SysPermissionService permissionService;
@Autowired
private UserDetailsServiceImpl userDetailsServiceImpl;
@Autowired
private TokenService tokenService;
@Autowired
private WxCpService wxCpService;
@Autowired
private ServerConfig serverConfig;
/**
* 登录方法
*
......@@ -94,8 +120,32 @@ public class SysLoginController {
*/
@PostMapping("/bbs/mobile/user/code/login")
public AjaxResult codeLogin(@RequestBody WxcpCodeLogin bo) {
Map<String, Object> tokenMap = this.loginService.codeLogin(bo);
return AjaxResult.success(tokenMap);
LoginUser loginUser = SecurityUtils.getLoginUserNotEx();
// 企微登录认证链接
String authCode = bo.getCode();
String baseUrl = this.serverConfig.getUrl();
String redirectUrl = "http://test.tangguo.ren" + "/bbs/h5/pages/login/login/";
WxCpOAuth2Service oauth2Service = this.wxCpService.getOauth2Service();
if (Objects.isNull(loginUser) && StrUtil.isBlank(authCode)) {
String oauth2Url = oauth2Service.buildAuthorizationUrl(redirectUrl, null);
return AjaxResult.error(401, "身份认证失败", oauth2Url);
}
// 查询企微用户信息
String token = null;
if (Objects.isNull(loginUser) && StrUtil.isNotBlank(authCode)) {
try {
WxCpOauth2UserInfo userInfo = oauth2Service.getUserInfo(authCode);
log.info("=> 查询企微用户信息,返回结果:{},{}", authCode, JSON.toJSONString(userInfo));
UserDetails userDetails = this.userDetailsServiceImpl.loadUserByUsername2(userInfo.getUserId());
token = this.tokenService.createToken((LoginUser) userDetails);
} catch (Exception e) {
log.error("=> 查询用户信息失败:", e);
throw new ServiceException("登录失败,查询用户信息失败。");
}
}
return AjaxResult.success("登录成功", token);
}
......
......@@ -97,5 +97,5 @@ wx:
cp:
corp-id: ww63ca87d5f8647514
app-config:
agent-id: 1000044
secret: GqApjJ2aDuntiU5iQ9yqx8JKQwYDMrg1tTHdeeF0BWA
agent-id: 1000072
secret: O2KXf2b9oGG2GBrpzDgf4EFdhGwl2KaS9BWtJQT1I64
# 项目相关配置
ruoyi:
profile: /home/application/safe-campus-bbs/server/resources
profile: /home/applications/safe-campus-bbs/server/resources
# 数据源配置
spring:
......
package com.tangguo;
import com.tangguo.common.constant.ActiveMQConstant;
import com.tangguo.common.domain.PointsDetail;
import me.chanjar.weixin.cp.api.WxCpOAuth2Service;
import me.chanjar.weixin.cp.api.WxCpService;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.jms.core.MessagePostProcessor;
import org.springframework.test.context.ActiveProfiles;
import javax.annotation.Resource;
import javax.jms.*;
/**
*
......@@ -33,59 +28,10 @@ public class ApplicationTest {
@Test
public void test() {
PointsDetail detail = new PointsDetail();
detail.setUserName("TanXiao");
detail.setDetailPoints(10);
detail.setDetailName("外部系统");
detail.setDescription("外部系统");
this.jmsTemplate.convertAndSend(ActiveMQConstant.Points.DECR_USER_POINTS_QUEUE, detail, message -> {
message.setStringProperty("userName", detail.getUserName());
return message;
});
}
public static void main(String[] args) {
// 连接到ActiveMQ
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
connectionFactory.setUserName("admin");
connectionFactory.setPassword("admin");
Connection connection = null;
try {
connection = connectionFactory.createConnection();
connection.start();
// 创建会话
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// 创建目标队列
Queue queue = session.createQueue(ActiveMQConstant.Points.INCR_USER_POINTS_QUEUE);
// 创建消息生产者
MessageProducer producer = session.createProducer(queue);
WxCpOAuth2Service oauth2Service = this.wxCpService.getOauth2Service();
System.out.println(oauth2Service.buildAuthorizationUrl("https://test.tangguo.ren/bbs/h5/pages/login/login/", ""));
// 创建文本消息
TextMessage message = session.createTextMessage("Hello ActiveMQ!");
// 设置有效期为5秒(5000毫秒)
long timeToLive = 5000; // 5000毫秒
producer.send(message, DeliveryMode.PERSISTENT, Message.DEFAULT_PRIORITY, timeToLive);
System.out.println("消息发送成功,消息ID: " + message.getJMSMessageID());
} catch (JMSException e) {
e.printStackTrace();
} finally {
// 关闭连接
try {
if (connection != null) {
connection.close();
}
} catch (JMSException e) {
e.printStackTrace();
}
}
}
}
......@@ -158,6 +158,17 @@ public class AjaxResult extends HashMap<String, Object> {
return new AjaxResult(code, msg, null);
}
/**
* 返回错误消息
*
* @param code 状态码
* @param msg 返回内容
* @return 错误消息
*/
public static AjaxResult error(int code, String msg, Object data) {
return new AjaxResult(code, msg, data);
}
/**
* 方便链式调用
*
......
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.tangguo.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
......@@ -37,6 +38,7 @@ public class BaseEntity implements Serializable {
/**
* 创建时间
*/
@Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
@TableField(fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("创建时间")
......
......@@ -57,6 +57,18 @@ public class SecurityUtils {
}
}
/**
* 获取用户
* 不会抛出异常 用于可登录可不登录时使用获取信息
**/
public static LoginUser getLoginUserNotEx() {
try {
return (LoginUser) getAuthentication().getPrincipal();
} catch (Exception e) {
return null;
}
}
/**
* 获取Authentication
*/
......
package com.tangguo.framework.web.service;
import cn.hutool.core.util.StrUtil;
import com.tangguo.common.constant.CacheConstants;
import com.tangguo.common.constant.Constants;
import com.tangguo.common.constant.UserConstants;
......@@ -11,6 +12,7 @@ import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.exception.user.*;
import com.tangguo.common.utils.DateUtils;
import com.tangguo.common.utils.MessageUtils;
import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.common.utils.StringUtils;
import com.tangguo.common.utils.ip.IpUtils;
import com.tangguo.framework.manager.AsyncManager;
......@@ -20,6 +22,7 @@ import com.tangguo.system.service.ISysConfigService;
import com.tangguo.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpOAuth2Service;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -174,34 +177,4 @@ public class SysLoginService {
userService.updateUserProfile(sysUser);
}
/**
* 企微用户Code登录
*
* @param bo 登录参数
* @return 登录结果
*/
public Map<String, Object> codeLogin(WxcpCodeLogin bo) {
String userName;
try {
log.info("=> 移动端用户登录:{}", bo);
WxCpOauth2UserInfo authUserInfo = this.wxCpService.getOauth2Service().getAuthUserInfo(bo.getCode());
userName = authUserInfo.getUserId();
} catch (WxErrorException e) {
log.error("=> 移动端用户登录失败,查询当前企微用户数据失败:", e);
throw new ServiceException("登录失败,查询当前企微用户数据失败。");
}
try {
UserDetails userDetails = this.userDetailsServiceImpl.loadUserByUsername2(userName);
String token = this.tokenService.createToken((LoginUser) userDetails);
Map<String, Object> resultMap = new LinkedHashMap<>(2);
resultMap.put("token", token);
return resultMap;
} catch (Exception e) {
log.error("=> 移动端用户登录失败,生成用户Token失败:", e);
throw new ServiceException("登录失败:" + e.getMessage());
}
}
}
......@@ -196,9 +196,11 @@ public class MBbsMomentController {
*/
@DeleteMapping("/comment/delete/{commentId}")
public AjaxResult deleteComment(@PathVariable Long commentId) {
synchronized (String.valueOf(commentId).intern()) {
this.momentService.userDeleteComment(commentId);
return AjaxResult.success();
}
}
/**
......
......@@ -5,6 +5,7 @@ import com.tangguo.common.core.controller.BaseController;
import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.enums.BusinessType;
import com.tangguo.common.utils.poi.ExcelUtil;
import com.tangguo.domain.BbsMoment;
import com.tangguo.domain.vo.BbsMomentListVO;
import com.tangguo.service.IBbsMomentService;
......@@ -14,6 +15,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
......@@ -44,6 +46,20 @@ public class BbsMomentController extends BaseController {
}
/**
* 导出动态列表
*/
@ApiOperation("导出动态列表")
@PreAuthorize("@ss.hasPermi('points:points:export')")
@Log(title = "导出动态列表", businessType = BusinessType.EXPORT)
@PostMapping("/list/export")
public void export(HttpServletResponse response, BbsMoment bbsMoment) {
List<BbsMoment> list = bbsMomentService.selectBbsMomentList(bbsMoment);
ExcelUtil<BbsMoment> util = new ExcelUtil<>(BbsMoment.class);
util.exportExcel(response, list, "动态数据");
}
/**
* 获取动态详细信息
*/
......
......@@ -15,6 +15,7 @@ import lombok.ToString;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
/**
* 动态对象 bbs_moment
......@@ -37,94 +38,88 @@ public class BbsMoment extends BaseEntity {
private Long id;
/** 发布人用户名 */
@Excel(name = "发布人用户名")
@ApiModelProperty("发布人用户名")
@Excel(name = "用户名", sort = 2)
private String userName;
/** 动态内容 */
@Excel(name = "动态内容")
@Excel(name = "动态内容", sort = 4)
@ApiModelProperty("动态内容")
private String content;
/** 动态类型:IMAGE 图片动态、VIDEO 视频动态、URL 链接动态 */
@Excel(name = "动态类型:IMAGE 图片动态、VIDEO 视频动态、URL 链接动态")
@ApiModelProperty("动态类型:IMAGE 图片动态、VIDEO 视频动态、URL 链接动态")
private String type;
/** 话题名称(逗号分割) */
@Excel(name = "话题名称", readConverterExp = "逗号分割")
@Excel(name = "话题名称", sort = 5)
@ApiModelProperty("话题名称(逗号分割)")
private String topicNames;
/** 话题Ids(逗号分割) */
@Excel(name = "话题Ids", readConverterExp = "逗号分割")
@ApiModelProperty("话题Ids(逗号分割)")
private String topicIds;
/** 外部链接地址 */
@Excel(name = "外部链接地址")
@ApiModelProperty("外部链接地址")
private String linkUrl;
/** 是否开启评论:0 否、1 是 */
@Excel(name = "是否开启评论:0 否、1 是")
@ApiModelProperty("是否开启评论:0 否、1 是")
private Integer isEnableComment;
/** 是否精选评论:0 否、1 是 */
@Excel(name = "是否精选评论:0 否、1 是")
@ApiModelProperty("是否精选评论:0 否、1 是")
private Integer isEnableFeaturedComment;
/** 是否开启投票:0 否、1 是 */
@Excel(name = "是否开启投票:0 否、1 是")
@ApiModelProperty("是否开启投票:0 否、1 是")
private Integer isEnableVote;
/** 投票标题 */
@Excel(name = "投票标题")
@ApiModelProperty("投票标题")
private String voteTitle;
/** 投票选项类型:TEXT 文字、IMAGE 图片 */
@Excel(name = "投票选项类型:TEXT 文字、IMAGE 图片")
@ApiModelProperty("投票选项类型:TEXT 文字、IMAGE 图片")
private String voteOptionType;
/** 投票开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "投票开始时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("投票开始时间")
private Date voteStartTime;
/** 投票结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "投票结束时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("投票结束时间")
private Date voteEndTime;
/** 动态点赞人数 */
@Excel(name = "动态点赞人数")
@Excel(name = "点赞人数", sort = 6)
@ApiModelProperty("动态点赞人数")
private Integer likeCount;
/** 动态评论人数 */
@Excel(name = "动态评论人数")
@Excel(name = "评论人数", sort = 7)
@ApiModelProperty("动态评论人数")
private Integer commentCount;
/** 动态投票人数 */
@Excel(name = "动态投票人数")
@ApiModelProperty("动态投票人数")
private Integer voteCount;
/** 用户姓名 */
@Excel(name = "姓名", sort = 1)
@TableField(exist = false)
private String nickName;
/** 用户部门 */
@Excel(name = "所在部门", sort = 3)
@TableField(exist = false)
private String deptName;
/** 动态附件 */
@TableField(exist = false)
private List<BbsMomentAttachment> attachments;
}
......@@ -31,4 +31,22 @@ public interface BbsMomentMapper extends BaseMapper<BbsMoment> {
BbsMomentListVO selectMomentDetail(@Param("momentId") Long momentId, @Param("userName") String userName);
int incrMomentLikeCount(@Param("momentId") Long momentId, @Param("count") int count);
int decrMomentLikeCount(@Param("momentId") Long momentId, @Param("count") int count);
int incrMomentCommentCount(@Param("momentId") Long momentId, @Param("count") int count);
int decrMomentCommentCount(@Param("momentId") Long momentId, @Param("count") int count);
int incrMomentVoteCount(@Param("momentId") Long momentId, @Param("count") int count);
int decrMomentVoteCount(@Param("momentId") Long momentId, @Param("count") int count);
}
......@@ -11,7 +11,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
......
......@@ -43,9 +43,6 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
@Resource
private ApplicationEventPublisher eventPublisher;
@Resource
private BbsMomentMapper bbsMomentMapper;
@Resource
private IBbsMomentAttachmentService attachmentsService;
......@@ -70,7 +67,18 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
*/
@Override
public List<BbsMoment> selectBbsMomentList(BbsMoment moment) {
return this.baseMapper.selectBbsMomentList(moment);
List<BbsMoment> dbMoments = this.baseMapper.selectBbsMomentList(moment);
List<Long> momentIds = dbMoments.stream().map(BbsMoment::getId).collect(Collectors.toList());
List<BbsMomentAttachment> dbAtts = this.attachmentsService.getAttachments(momentIds);
for (BbsMoment dbMoment : dbMoments) {
List<BbsMomentAttachment> atts = dbAtts.stream()
.filter(a -> dbMoment.getId().equals(a.getMomentId()))
.collect(Collectors.toList());
dbMoment.setAttachments(atts);
}
return dbMoments;
}
......@@ -245,32 +253,27 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw new ServiceException("点赞失败,未查询到当前动态数据。");
}
Long dbMomentId = dbMoment.getId();
String username = SecurityUtils.getUsername();
long likeStatus = this.likeService.getUserMomentLikeCount(dbMoment.getId(), username);
int likeCount = dbMoment.getLikeCount();
long likeStatus = this.likeService.getUserMomentLikeCount(dbMomentId, username);
if (LikeStatus.LIKE.getStatus() == bo.getLikeStatus()) {
if (likeStatus > 0) {
throw new ServiceException("点赞失败,已对当前动态点赞。");
} else {
this.likeService.addMomentLike(dbMoment.getId(), username);
likeCount++;
this.likeService.addMomentLike(dbMomentId, username);
this.baseMapper.incrMomentLikeCount(dbMomentId, 1);
}
} else {
}
else {
if (likeStatus < 1) {
throw new ServiceException("取消失败,没有对当前动态点赞。");
} else {
this.likeService.deleteMomentLike(dbMoment.getId(), username);
likeCount--;
this.likeService.deleteMomentLike(dbMomentId, username);
this.baseMapper.decrMomentLikeCount(dbMomentId, 1);
}
}
// 更新动态点赞人数
BbsMoment updMoment = new BbsMoment();
updMoment.setId(dbMoment.getId());
updMoment.setLikeCount(likeCount);
this.updateById(updMoment);
// 发布用户操作事件
OperateEvent operateEvent = new OperateEvent(username, OperateType.DZDT);
this.eventPublisher.publishEvent(operateEvent);
......@@ -293,20 +296,21 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw new ServiceException("投票失败,当前动态未开启投票。");
}
Long dbMomentId = dbMoment.getId();
String username = SecurityUtils.getUsername();
long voteCount = this.voteService.getUserMomentVoteCount(dbMoment.getId(), username);
long voteCount = this.voteService.getUserMomentVoteCount(dbMomentId, username);
if (voteCount > 0) {
throw new ServiceException("投票失败,已对当前动态投票。");
}
String optionCode = bo.getOptionCode();
BbsMomentVoteOption dbOption = this.voteOptionService.getVoteOption(dbMoment.getId(), optionCode);
BbsMomentVoteOption dbOption = this.voteOptionService.getVoteOption(dbMomentId, optionCode);
if (Objects.isNull(dbOption)) {
throw new ServiceException("投票失败,未查询到当前投票选项数据。");
}
// 添加投票记录
this.voteService.addMomentVoteCount(dbMoment.getId(), username, optionCode);
this.voteService.addMomentVoteCount(dbMomentId, username, optionCode);
// 更新投票选项投票人数
BbsMomentVoteOption updOption = new BbsMomentVoteOption();
......@@ -315,10 +319,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
this.voteOptionService.updateById(updOption);
// 更新动态投票人数
BbsMoment updMoment = new BbsMoment();
updMoment.setId(dbMoment.getId());
updMoment.setVoteCount(dbMoment.getVoteCount() + 1);
this.updateById(updMoment);
this.baseMapper.incrMomentVoteCount(dbMomentId, 1);
// 发布用户操作事件
OperateEvent operateEvent = new OperateEvent(username, OperateType.TPDT);
......@@ -360,9 +361,10 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
}
// 添加动态评论
Long dbMomentId = dbMoment.getId();
SysUser dbUser = SecurityUtils.getLoginUser().getUser();
BbsMomentComment newComment = new BbsMomentComment();
newComment.setMomentId(dbMoment.getId());
newComment.setMomentId(dbMomentId);
newComment.setUserName(dbUser.getUserName());
newComment.setNickName(dbUser.getNickName());
newComment.setContent(content);
......@@ -383,10 +385,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
this.commentService.updateById(updComment);
// 更新动态评论人数
BbsMoment updMoment = new BbsMoment();
updMoment.setId(dbMoment.getId());
updMoment.setCommentCount(dbMoment.getCommentCount() + 1);
this.updateById(updMoment);
this.baseMapper.incrMomentCommentCount(dbMomentId, 1);
// 发布用户操作事件
OperateEvent operateEvent = new OperateEvent(dbUser.getUserName(), OperateType.TPDT);
......@@ -412,10 +411,10 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw new ServiceException("删除失败,没有对当前动态评论的操作权限。");
}
BbsMomentComment updComment = new BbsMomentComment();
updComment.setId(dbComment.getId());
updComment.setStatus(CommentStatus.SC.getStatus());
this.commentService.updateById(updComment);
this.commentService.removeById(dbComment.getId());
// 更新动态评论人数
this.baseMapper.incrMomentCommentCount(dbComment.getMomentId(), 1);
}
......
......@@ -22,7 +22,6 @@ import com.tangguo.service.IBbsTopicService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
......
......@@ -19,6 +19,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="moment.content != null and moment.content != ''">
m.content LIKE CONCAT('%', #{moment.content}, '%')
</if>
<if test="moment.topicNames != null and moment.topicNames != ''">
AND m.topic_names LIKE CONCAT('%', #{moment.topicNames}, '%')
</if>
<if test="moment.params.startTime != null and moment.params.startTime != ''">
AND DATE_FORMAT(m.create_time, '%Y-%m-%d') >= #{moment.params.startTime}
</if>
......@@ -157,4 +160,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
m.create_time DESC
</select>
<update id="incrMomentLikeCount">
UPDATE bbs_moment SET like_count = like_count + #{count} WHERE id = #{momentId}
</update>
<update id="decrMomentLikeCount">
UPDATE bbs_moment SET like_count = like_count - #{count} WHERE id = #{momentId}
</update>
<update id="incrMomentCommentCount">
UPDATE bbs_moment SET comment_count = comment_count + #{count} WHERE id = #{momentId}
</update>
<update id="decrMomentCommentCount">
UPDATE bbs_moment SET comment_count = comment_count - #{count} WHERE id = #{momentId}
</update>
<update id="incrMomentVoteCount">
UPDATE bbs_moment SET vote_count = vote_count + #{count} WHERE id = #{momentId}
</update>
<update id="decrMomentVoteCount">
UPDATE bbs_moment SET vote_count = vote_count - #{count} WHERE id = #{momentId}
</update>
</mapper>
package com.tangguo.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tangguo.common.annotation.Log;
import com.tangguo.common.core.controller.BaseController;
import com.tangguo.common.core.domain.AjaxResult;
......
......@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.common.domain.PointsDetail;
import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.utils.SecurityUtils;
import com.tangguo.domain.BbsGrade;
import com.tangguo.domain.BbsUserPoints;
import com.tangguo.domain.BbsUserPointsDetail;
......
......@@ -196,7 +196,7 @@
SELECT
q.id, q.parent_id, q.ancestors, q.dept_name, q.order_num, q.create_time
FROM
qwmh_sys_dept q
ods_sys_dept_view q
LEFT JOIN
sys_dept d ON d.dept_id = q.id
WHERE
......
......@@ -272,7 +272,7 @@
SELECT
q.dept_id, q.user_name, q.real_name, q.phonenumber, q.email, q.avatar, q.create_time
FROM
qwmh_sys_user q
ods_sys_user_view q
LEFT JOIN
sys_user u ON u.user_name = q.user_name
WHERE
......
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