邀请用户

飞书小程序
YXY 1 year ago
parent 8bd9136fed
commit d22be6e782

@ -22,10 +22,7 @@ import com.ruoyi.flyingbook.domain.LarkUserActiveRelatoin;
import com.ruoyi.flyingbook.domain.edi.ResponseVo; import com.ruoyi.flyingbook.domain.edi.ResponseVo;
import com.ruoyi.flyingbook.domain.lark.LarkUserRequest; import com.ruoyi.flyingbook.domain.lark.LarkUserRequest;
import com.ruoyi.flyingbook.domain.larkactive.*; import com.ruoyi.flyingbook.domain.larkactive.*;
import com.ruoyi.flyingbook.service.ILarkActiveService; import com.ruoyi.flyingbook.service.*;
import com.ruoyi.flyingbook.service.ILarkLoginLogService;
import com.ruoyi.flyingbook.service.ILarkUserActiveInviteRelatoinService;
import com.ruoyi.flyingbook.service.ILarkUserActiveRelatoinService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -49,6 +46,8 @@ public class LarkActiveController extends BaseController {
@Autowired @Autowired
private ILarkUserActiveRelatoinService larkUserActiveRelatoinService; private ILarkUserActiveRelatoinService larkUserActiveRelatoinService;
@Autowired @Autowired
private ILarkUserActiveCommentService larkUserActiveCommentService;
@Autowired
private ILarkUserActiveInviteRelatoinService larkUserActiveInviteRelatoinService; private ILarkUserActiveInviteRelatoinService larkUserActiveInviteRelatoinService;
@Autowired @Autowired
private LarkUserHelper larkUserHelper; private LarkUserHelper larkUserHelper;
@ -100,25 +99,29 @@ public class LarkActiveController extends BaseController {
return new ResponseVo(larkActive); return new ResponseVo(larkActive);
} }
/** /**
* *
*/ */
@PostMapping("/uploadActiveFile") @PostMapping("/uploadActiveFile")
public ResponseVo<LarkUserActiveRelatoin> uploadActiveFile(@RequestParam("file") MultipartFile file, @RequestParam("userName") String userName, @RequestParam("larkActiveName") String larkActiveName, @RequestParam("companyName") String companyName) { public ResponseVo<LarkUserActiveRelatoin> uploadActiveFile(@RequestBody LarkActiveUserRelationRequest request) {
LarkActiveUserRelationRequest request = new LarkActiveUserRelationRequest();
request.setFile(file);
request.setUserName(userName);
request.setLarkActiveName(larkActiveName);
request.setCompanyName(companyName);
return larkUserActiveRelatoinService.commitFile(request); return larkUserActiveRelatoinService.commitFile(request);
} }
/** /**
* *
*/ */
@PostMapping("/uploadActiveFile2") @PostMapping("/comment")
public ResponseVo<LarkUserActiveRelatoin> uploadActiveFile2(@RequestBody LarkActiveUserRelationRequest request) { public ResponseVo<LarkUserActiveRelatoin> comment(@RequestBody LarkActiveUserRelationRequest request) {
return larkUserActiveRelatoinService.commitFile(request); return larkUserActiveCommentService.comment(request);
}
/**
*
*/
@PostMapping("/queryComment")
public ResponseVo<LarkActiveCommentVo> queryComment(@RequestBody LarkActiveUserRelationRequest request) {
return larkUserActiveCommentService.queryComment(request);
} }
/** /**
@ -140,7 +143,16 @@ public class LarkActiveController extends BaseController {
} }
/** /**
* *
*/
@PostMapping("/inviteUser")
public ResponseVo<LarkInviteVo> inviteUser(@RequestBody LarkUserActiveInviteRelatoin request) {
larkUserActiveInviteRelatoinService.create(request);
return new ResponseVo();
}
/**
*
*/ */
@PostMapping("/queryInviteUserList") @PostMapping("/queryInviteUserList")
public ResponseVo<LarkInviteVo> queryInviteUserList(@RequestBody LarkUserActiveInviteRelatoin request) { public ResponseVo<LarkInviteVo> queryInviteUserList(@RequestBody LarkUserActiveInviteRelatoin request) {
@ -153,8 +165,8 @@ public class LarkActiveController extends BaseController {
* top 10 * top 10
*/ */
@PostMapping("/queryInviteTopTen") @PostMapping("/queryInviteTopTen")
public ResponseVo<LarkUserActiveInviteRelatoin> queryInviteTopTen(@RequestBody LarkUserActiveInviteRelatoin request) { public ResponseVo<LarkInviteVo> queryInviteTopTen(@RequestBody LarkUserActiveInviteRelatoin request) {
List<LarkUserActiveInviteRelatoin> larkUserActiveInviteRelatoins = larkUserActiveInviteRelatoinService.queryTopTen(request); List<LarkInviteVo> larkUserActiveInviteRelatoins = larkUserActiveInviteRelatoinService.queryTopTen(request);
return new ResponseVo(larkUserActiveInviteRelatoins); return new ResponseVo(larkUserActiveInviteRelatoins);
} }

@ -0,0 +1,29 @@
package com.ruoyi.flyingbook.domain;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
/**
* lark_user_active_comment
*
* @author ruoyi
* @date 2023-08-22
*/
@Data
public class LarkUserActiveComment extends BaseEntity
{
private static final long serialVersionUID = 1L;
private Long id;
/** 用户活动关联关系id */
private Long userActiveRelatoin;
/** 评论内容 */
private String content;
/**
* @see com.ruoyi.common.enums.FlagStatus
*/
private Long flag;
}

@ -0,0 +1,19 @@
package com.ruoyi.flyingbook.domain.larkactive;
import com.ruoyi.flyingbook.domain.LarkActive;
import com.ruoyi.flyingbook.domain.LarkUserActiveComment;
import lombok.Data;
/**
* lark_active
*
* @author ruoyi
* @date 2023-08-16
*/
@Data
public class LarkActiveCommentVo extends LarkUserActiveComment {
private String userName;
private String image;
}

@ -18,7 +18,7 @@ public class LarkActiveUserRelationRequest extends LarkActiveBaseRequestVo {
private String larkActiveName; private String larkActiveName;
private String userName; private String userName;
private String imageBase64; private String imageBase64;
private String comment;
private MultipartFile file; private MultipartFile file;

@ -2,6 +2,7 @@ package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.LarkLoginLog; import com.ruoyi.flyingbook.domain.LarkLoginLog;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -30,6 +31,7 @@ public interface LarkLoginLogMapper
public List<LarkLoginLog> selectLarkLoginLogList(LarkLoginLog larkLoginLog); public List<LarkLoginLog> selectLarkLoginLogList(LarkLoginLog larkLoginLog);
public Integer count(LarkLoginLog larkLoginLog); public Integer count(LarkLoginLog larkLoginLog);
public Integer distinctCount(LarkLoginLog larkLoginLog); public Integer distinctCount(LarkLoginLog larkLoginLog);
public List<LarkLoginLog> queryByOpenId(@Param("openIdList") List<String> openIdList);
/** /**
* *

@ -0,0 +1,65 @@
package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.LarkUserActiveComment;
import java.util.List;
/**
* Mapper
*
* @author ruoyi
* @date 2023-08-22
*/
public interface LarkUserActiveCommentMapper
{
/**
*
*
* @param id ID
* @return
*/
public LarkUserActiveComment selectLarkUserActiveCommentById(Long id);
/**
*
*
* @param larkUserActiveComment
* @return
*/
public List<LarkUserActiveComment> selectLarkUserActiveCommentList(LarkUserActiveComment larkUserActiveComment);
/**
*
*
* @param larkUserActiveComment
* @return
*/
public int insertLarkUserActiveComment(LarkUserActiveComment larkUserActiveComment);
/**
*
*
* @param larkUserActiveComment
* @return
*/
public int updateLarkUserActiveComment(LarkUserActiveComment larkUserActiveComment);
/**
*
*
* @param id ID
* @return
*/
public int deleteLarkUserActiveCommentById(Long id);
/**
*
*
* @param ids ID
* @return
*/
public int deleteLarkUserActiveCommentByIds(Long[] ids);
public List<LarkUserActiveComment> selectLarkUserActiveCommentList(LarkUserActiveComment larkUserActiveComment);
}

@ -36,6 +36,7 @@ public interface LarkUserActiveRelatoinMapper {
public int queryUserCount(LarkUserActiveRelatoin larkUserActiveRelatoin); public int queryUserCount(LarkUserActiveRelatoin larkUserActiveRelatoin);
public List<LarkActiveVo> queryUserCountGroupByActive(LarkUserActiveRelatoin larkUserActiveRelatoin); public List<LarkActiveVo> queryUserCountGroupByActive(LarkUserActiveRelatoin larkUserActiveRelatoin);
public List<LarkUserActiveRelatoin> queryByIdList(@Param("idList") List<Long> idList);
/** /**
* *

@ -2,8 +2,10 @@ package com.ruoyi.flyingbook.service;
import com.ruoyi.flyingbook.domain.LarkLoginLog; import com.ruoyi.flyingbook.domain.LarkLoginLog;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Service * Service
@ -60,4 +62,6 @@ public interface ILarkLoginLogService
* @return * @return
*/ */
public int deleteLarkLoginLogById(Long id); public int deleteLarkLoginLogById(Long id);
public Map<String,LarkLoginLog> queryByOpenId(@Param("openIdList") List<String> openIdList);
} }

@ -0,0 +1,70 @@
package com.ruoyi.flyingbook.service;
import com.ruoyi.flyingbook.domain.LarkUserActiveComment;
import com.ruoyi.flyingbook.domain.LarkUserActiveRelatoin;
import com.ruoyi.flyingbook.domain.edi.ResponseVo;
import com.ruoyi.flyingbook.domain.larkactive.LarkActiveCommentVo;
import com.ruoyi.flyingbook.domain.larkactive.LarkActiveUserRelationRequest;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-08-22
*/
public interface ILarkUserActiveCommentService
{
/**
*
*
* @param id ID
* @return
*/
public LarkUserActiveComment selectLarkUserActiveCommentById(Long id);
/**
*
*
* @param larkUserActiveComment
* @return
*/
public List<LarkUserActiveComment> selectLarkUserActiveCommentList(LarkUserActiveComment larkUserActiveComment);
/**
*
*
* @param larkUserActiveComment
* @return
*/
public int insertLarkUserActiveComment(LarkUserActiveComment larkUserActiveComment);
/**
*
*
* @param larkUserActiveComment
* @return
*/
public int updateLarkUserActiveComment(LarkUserActiveComment larkUserActiveComment);
/**
*
*
* @param ids ID
* @return
*/
public int deleteLarkUserActiveCommentByIds(Long[] ids);
/**
*
*
* @param id ID
* @return
*/
public int deleteLarkUserActiveCommentById(Long id);
public ResponseVo<LarkUserActiveRelatoin> comment(LarkActiveUserRelationRequest request);
public ResponseVo<LarkActiveCommentVo> queryComment(LarkActiveUserRelationRequest request);
}

@ -28,7 +28,7 @@ public interface ILarkUserActiveInviteRelatoinService {
*/ */
public List<LarkUserActiveInviteRelatoin> selectLarkUserActiveInviteRelatoinList(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin); public List<LarkUserActiveInviteRelatoin> selectLarkUserActiveInviteRelatoinList(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin);
public List<LarkUserActiveInviteRelatoin> queryTopTen(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin); public List<LarkInviteVo> queryTopTen(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin);
public List<LarkInviteVo> queryMyInviteList(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin); public List<LarkInviteVo> queryMyInviteList(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin);
@ -40,6 +40,7 @@ public interface ILarkUserActiveInviteRelatoinService {
* @return * @return
*/ */
public int insertLarkUserActiveInviteRelatoin(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin); public int insertLarkUserActiveInviteRelatoin(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin);
public void create(LarkUserActiveInviteRelatoin request);
/** /**
* *

@ -66,4 +66,5 @@ public interface ILarkUserActiveRelatoinService {
* @return * @return
*/ */
public int deleteLarkUserActiveRelatoinById(Long id); public int deleteLarkUserActiveRelatoinById(Long id);
} }

@ -4,10 +4,15 @@ import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.flyingbook.domain.LarkLoginLog; import com.ruoyi.flyingbook.domain.LarkLoginLog;
import com.ruoyi.flyingbook.mapper.LarkLoginLogMapper; import com.ruoyi.flyingbook.mapper.LarkLoginLogMapper;
import com.ruoyi.flyingbook.service.ILarkLoginLogService; import com.ruoyi.flyingbook.service.ILarkLoginLogService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* Service * Service
@ -94,4 +99,16 @@ public class LarkLoginLogServiceImpl implements ILarkLoginLogService
{ {
return larkLoginLogMapper.deleteLarkLoginLogById(id); return larkLoginLogMapper.deleteLarkLoginLogById(id);
} }
@Override
public Map<String, LarkLoginLog> queryByOpenId(List<String> openIdList) {
if (CollectionUtils.isEmpty(openIdList)){
return new HashMap<>();
}
return larkLoginLogMapper.queryByOpenId(openIdList)
.stream()
.collect(
Collectors.toMap(LarkLoginLog::getOpenId, Function.identity(),(k1,k2)->k1)
);
}
} }

@ -0,0 +1,210 @@
package com.ruoyi.flyingbook.service.impl;
import com.ruoyi.common.enums.FlagStatus;
import com.ruoyi.common.enums.LarkActiveStageEnum;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.flyingbook.domain.LarkActive;
import com.ruoyi.flyingbook.domain.LarkLoginLog;
import com.ruoyi.flyingbook.domain.LarkUserActiveComment;
import com.ruoyi.flyingbook.domain.LarkUserActiveRelatoin;
import com.ruoyi.flyingbook.domain.edi.ResponseVo;
import com.ruoyi.flyingbook.domain.larkactive.LarkActiveCommentVo;
import com.ruoyi.flyingbook.domain.larkactive.LarkActiveUserRelationRequest;
import com.ruoyi.flyingbook.mapper.LarkActiveMapper;
import com.ruoyi.flyingbook.mapper.LarkLoginLogMapper;
import com.ruoyi.flyingbook.mapper.LarkUserActiveCommentMapper;
import com.ruoyi.flyingbook.mapper.LarkUserActiveRelatoinMapper;
import com.ruoyi.flyingbook.service.ILarkLoginLogService;
import com.ruoyi.flyingbook.service.ILarkUserActiveCommentService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Service
*
* @author ruoyi
* @date 2023-08-22
*/
@Service
public class LarkUserActiveCommentServiceImpl implements ILarkUserActiveCommentService {
@Autowired
private LarkUserActiveCommentMapper larkUserActiveCommentMapper;
@Autowired
private LarkActiveMapper larkActiveMapper;
@Autowired
private LarkUserActiveRelatoinMapper larkUserActiveRelatoinMapper;
@Autowired
private ILarkLoginLogService larkLoginLogService;
/**
*
*
* @param id ID
* @return
*/
@Override
public LarkUserActiveComment selectLarkUserActiveCommentById(Long id) {
return larkUserActiveCommentMapper.selectLarkUserActiveCommentById(id);
}
/**
*
*
* @param larkUserActiveComment
* @return
*/
@Override
public List<LarkUserActiveComment> selectLarkUserActiveCommentList(LarkUserActiveComment larkUserActiveComment) {
return larkUserActiveCommentMapper.selectLarkUserActiveCommentList(larkUserActiveComment);
}
/**
*
*
* @param larkUserActiveComment
* @return
*/
@Override
public int insertLarkUserActiveComment(LarkUserActiveComment larkUserActiveComment) {
larkUserActiveComment.setCreateTime(DateUtils.getNowDate());
return larkUserActiveCommentMapper.insertLarkUserActiveComment(larkUserActiveComment);
}
/**
*
*
* @param larkUserActiveComment
* @return
*/
@Override
public int updateLarkUserActiveComment(LarkUserActiveComment larkUserActiveComment) {
larkUserActiveComment.setUpdateTime(DateUtils.getNowDate());
return larkUserActiveCommentMapper.updateLarkUserActiveComment(larkUserActiveComment);
}
/**
*
*
* @param ids ID
* @return
*/
@Override
public int deleteLarkUserActiveCommentByIds(Long[] ids) {
return larkUserActiveCommentMapper.deleteLarkUserActiveCommentByIds(ids);
}
/**
*
*
* @param id ID
* @return
*/
@Override
public int deleteLarkUserActiveCommentById(Long id) {
return larkUserActiveCommentMapper.deleteLarkUserActiveCommentById(id);
}
@Override
public ResponseVo<LarkUserActiveRelatoin> comment(LarkActiveUserRelationRequest request) {
List<LarkActive> larkActives = larkActiveMapper.selectLarkActiveByName(request.getLarkActiveName(), FlagStatus.OK.getCode());
if (CollectionUtils.isEmpty(larkActives)) {
return new ResponseVo();
}
LarkActive active = larkActives.get(0);
LarkUserActiveRelatoin relatoin = queryUserActiveRelation(request.getCompanyName(), request.getUserName(), active.getId());
if (relatoin == null) {
return new ResponseVo();
}
//创建评论
buildComment(request, relatoin);
relatoin.setActiveStage(LarkActiveStageEnum.ADJUST.getCode());
larkUserActiveRelatoinMapper.updateLarkUserActiveRelatoin(relatoin);
return new ResponseVo();
}
private void buildComment(LarkActiveUserRelationRequest request, LarkUserActiveRelatoin relatoin) {
LarkUserActiveComment larkUserActiveComment = new LarkUserActiveComment();
larkUserActiveComment.setCreateTime(new Date());
larkUserActiveComment.setCreateBy(request.getUserName());
larkUserActiveComment.setUserActiveRelatoin(relatoin.getId());
larkUserActiveComment.setContent(request.getComment());
larkUserActiveComment.setFlag(FlagStatus.OK.getCode());
larkUserActiveCommentMapper.insertLarkUserActiveComment(larkUserActiveComment);
}
private LarkUserActiveRelatoin queryUserActiveRelation(String companyName, String userName, Long activeId) {
LarkUserActiveRelatoin relatoin = new LarkUserActiveRelatoin();
relatoin.setUserName(userName);
relatoin.setActiveId(activeId);
relatoin.setFlag(FlagStatus.OK.getCode());
List<LarkUserActiveRelatoin> larkUserActiveRelatoins = larkUserActiveRelatoinMapper.selectLarkUserActiveRelatoinList(relatoin);
if (CollectionUtils.isNotEmpty(larkUserActiveRelatoins)) {
return larkUserActiveRelatoins.get(0);
} else {
relatoin.setCreateBy("System");
relatoin.setCreateTime(new Date());
relatoin.setActiveStage(LarkActiveStageEnum.SUBMIT.getCode());
relatoin.setCompanyName(companyName);
larkUserActiveRelatoinMapper.insertLarkUserActiveRelatoin(relatoin);
return relatoin;
}
}
@Override
public ResponseVo<LarkActiveCommentVo> queryComment(LarkActiveUserRelationRequest request) {
ResponseVo<LarkActiveCommentVo> responseVo = new ResponseVo();
LarkUserActiveComment larkUserActiveComment = new LarkUserActiveComment();
larkUserActiveComment.setFlag(FlagStatus.OK.getCode());
List<LarkUserActiveComment> larkUserActiveComments = larkUserActiveCommentMapper.selectLarkUserActiveCommentList(larkUserActiveComment);
List<Long> userLarkRelationIdList = larkUserActiveComments.stream()
.filter(r -> {
return r.getUserActiveRelatoin() != null;
})
.map(LarkUserActiveComment::getUserActiveRelatoin)
.distinct().collect(Collectors.toList());
Map<String, LarkLoginLog> userInfoMap = new HashMap<>();
Map<Long, String> relationMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(userLarkRelationIdList)) {
List<LarkUserActiveRelatoin> larkUserActiveRelatoins = larkUserActiveRelatoinMapper.queryByIdList(userLarkRelationIdList);
relationMap = larkUserActiveRelatoins.stream().collect(Collectors.toMap(LarkUserActiveRelatoin::getId, LarkUserActiveRelatoin::getUserName, (k1, k2) -> k1));
List<String> openIdList = larkUserActiveRelatoins.stream()
.filter(r -> {
return StringUtils.isNotBlank(r.getUserName());
}).map(LarkUserActiveRelatoin::getUserName)
.distinct().collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(openIdList)) {
userInfoMap = larkLoginLogService.queryByOpenId(openIdList);
}
}
Map<Long, String> finalRelationMap = relationMap;
Map<String, LarkLoginLog> finalUserInfoMap = userInfoMap;
List<LarkActiveCommentVo> activeCommentVos = larkUserActiveComments.stream().map(r -> {
LarkActiveCommentVo larkActiveCommentVo = new LarkActiveCommentVo();
BeanUtils.copyProperties(r, larkActiveCommentVo);
Long userActiveRelatoin = r.getUserActiveRelatoin();
String openId = finalRelationMap.get(userActiveRelatoin);
if (StringUtils.isNotBlank(openId)) {
LarkLoginLog userInfo = finalUserInfoMap.getOrDefault(openId, new LarkLoginLog());
larkActiveCommentVo.setUserName(userInfo.getUserName());
larkActiveCommentVo.setImage(userInfo.getImageUrl());
}
return larkActiveCommentVo;
}).collect(Collectors.toList());
responseVo.setDataList(activeCommentVos);
return responseVo;
}
}

@ -3,14 +3,19 @@ package com.ruoyi.flyingbook.service.impl;
import com.ruoyi.common.enums.FlagStatus; import com.ruoyi.common.enums.FlagStatus;
import com.ruoyi.common.enums.LarkActiveInviteStageEnum; import com.ruoyi.common.enums.LarkActiveInviteStageEnum;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.flyingbook.domain.LarkLoginLog;
import com.ruoyi.flyingbook.domain.LarkUserActiveInviteRelatoin; import com.ruoyi.flyingbook.domain.LarkUserActiveInviteRelatoin;
import com.ruoyi.flyingbook.domain.larkactive.LarkInviteVo; import com.ruoyi.flyingbook.domain.larkactive.LarkInviteVo;
import com.ruoyi.flyingbook.mapper.LarkLoginLogMapper;
import com.ruoyi.flyingbook.mapper.LarkUserActiveInviteRelatoinMapper; import com.ruoyi.flyingbook.mapper.LarkUserActiveInviteRelatoinMapper;
import com.ruoyi.flyingbook.service.ILarkLoginLogService;
import com.ruoyi.flyingbook.service.ILarkUserActiveInviteRelatoinService; import com.ruoyi.flyingbook.service.ILarkUserActiveInviteRelatoinService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -23,6 +28,8 @@ import java.util.stream.Collectors;
public class LarkUserActiveInviteRelatoinServiceImpl implements ILarkUserActiveInviteRelatoinService { public class LarkUserActiveInviteRelatoinServiceImpl implements ILarkUserActiveInviteRelatoinService {
@Autowired @Autowired
private LarkUserActiveInviteRelatoinMapper larkUserActiveInviteRelatoinMapper; private LarkUserActiveInviteRelatoinMapper larkUserActiveInviteRelatoinMapper;
@Autowired
private ILarkLoginLogService larkLoginLogService;
/** /**
* *
@ -47,28 +54,61 @@ public class LarkUserActiveInviteRelatoinServiceImpl implements ILarkUserActiveI
} }
@Override @Override
public List<LarkUserActiveInviteRelatoin> queryTopTen(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin) { public List<LarkInviteVo> queryTopTen(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin) {
larkUserActiveInviteRelatoin.setFlag(FlagStatus.OK.getCode()); larkUserActiveInviteRelatoin.setFlag(FlagStatus.OK.getCode());
larkUserActiveInviteRelatoin.setInviteStage(LarkActiveInviteStageEnum.ACTIVE.getCode()); larkUserActiveInviteRelatoin.setInviteStage(LarkActiveInviteStageEnum.ACTIVE.getCode());
return larkUserActiveInviteRelatoinMapper.queryTopTen(larkUserActiveInviteRelatoin); List<LarkUserActiveInviteRelatoin> larkUserActiveInviteRelatoins = larkUserActiveInviteRelatoinMapper.queryTopTen(larkUserActiveInviteRelatoin);
Map<String, LarkLoginLog> userInfoMap = queryUserInfoMap(larkUserActiveInviteRelatoins);
List<LarkInviteVo> result = larkUserActiveInviteRelatoins.stream()
.filter(r -> {
return userInfoMap.containsKey(r.getUserName());
})
.map(r -> {
LarkInviteVo larkInviteVo = new LarkInviteVo();
String userName = r.getUserName();
LarkLoginLog larkLoginLog = userInfoMap.get(userName);
larkInviteVo.setUrl(larkLoginLog.getImageUrl());
larkInviteVo.setText(larkLoginLog.getUserName());
return larkInviteVo;
}).collect(Collectors.toList());
return result;
} }
@Override @Override
public List<LarkInviteVo> queryMyInviteList(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin) { public List<LarkInviteVo> queryMyInviteList(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin) {
larkUserActiveInviteRelatoin.setFlag(FlagStatus.OK.getCode()); larkUserActiveInviteRelatoin.setFlag(FlagStatus.OK.getCode());
List<LarkUserActiveInviteRelatoin> larkUserActiveInviteRelatoins = larkUserActiveInviteRelatoinMapper.selectLarkUserActiveInviteRelatoinList(larkUserActiveInviteRelatoin); List<LarkUserActiveInviteRelatoin> larkUserActiveInviteRelatoins = larkUserActiveInviteRelatoinMapper.selectLarkUserActiveInviteRelatoinList(larkUserActiveInviteRelatoin);
Map<String, LarkLoginLog> userInfoMap = queryUserInfoMap(larkUserActiveInviteRelatoins);
List<LarkInviteVo> result = larkUserActiveInviteRelatoins.stream().map(r -> { List<LarkInviteVo> result = larkUserActiveInviteRelatoins.stream().map(r -> {
LarkInviteVo larkInviteVo = new LarkInviteVo(); LarkInviteVo larkInviteVo = new LarkInviteVo();
larkInviteVo.setUrl(r.getInviteUserName()); String inviteUserName = r.getInviteUserName();
larkInviteVo.setText(r.getUserName()); LarkLoginLog larkLoginLog = userInfoMap.get(inviteUserName);
if (larkLoginLog != null) {
larkInviteVo.setUrl(larkLoginLog.getImageUrl());
larkInviteVo.setText(larkLoginLog.getUserName());
} else {
larkInviteVo.setText(r.getRemark());
}
LarkActiveInviteStageEnum inviteStageEnum = LarkActiveInviteStageEnum.getByCode(r.getInviteStage()); LarkActiveInviteStageEnum inviteStageEnum = LarkActiveInviteStageEnum.getByCode(r.getInviteStage());
larkInviteVo.setType(inviteStageEnum != null ? inviteStageEnum.getType() : "primary"); larkInviteVo.setType(inviteStageEnum != null ? inviteStageEnum.getType() : "primary");
return larkInviteVo; return larkInviteVo;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return result; return result;
} }
private Map<String, LarkLoginLog> queryUserInfoMap(List<LarkUserActiveInviteRelatoin> larkUserActiveInviteRelatoins) {
if (CollectionUtils.isEmpty(larkUserActiveInviteRelatoins)) {
return new HashMap<>();
}
List<String> openIdList = larkUserActiveInviteRelatoins.stream()
.filter(r -> {
return StringUtils.isNotBlank(r.getInviteUserName());
})
.map(LarkUserActiveInviteRelatoin::getInviteUserName)
.distinct().collect(Collectors.toList());
return larkLoginLogService.queryByOpenId(openIdList);
}
/** /**
* *
* *
@ -81,6 +121,42 @@ public class LarkUserActiveInviteRelatoinServiceImpl implements ILarkUserActiveI
return larkUserActiveInviteRelatoinMapper.insertLarkUserActiveInviteRelatoin(larkUserActiveInviteRelatoin); return larkUserActiveInviteRelatoinMapper.insertLarkUserActiveInviteRelatoin(larkUserActiveInviteRelatoin);
} }
@Override
public void create(LarkUserActiveInviteRelatoin request) {
Boolean exist = queryExist(request.getUserName(), request.getInviteUserName(), request.getCompanyName());
if (exist) {
return;
}
LarkUserActiveInviteRelatoin relation = new LarkUserActiveInviteRelatoin();
relation.setUserName(request.getUserName());
relation.setInviteUserName(request.getInviteUserName());
relation.setCreateTime(new Date());
relation.setCreateBy(request.getUserName());
relation.setInviteStage(LarkActiveInviteStageEnum.INVITE.getCode());
relation.setCompanyName(request.getCompanyName());
relation.setFlag(FlagStatus.OK.getCode());
larkUserActiveInviteRelatoinMapper.insertLarkUserActiveInviteRelatoin(relation);
}
private Boolean queryExist(String userName, String inviteUserName, String companyName) {
LarkUserActiveInviteRelatoin relation = new LarkUserActiveInviteRelatoin();
relation.setUserName(userName);
relation.setInviteUserName(inviteUserName);
relation.setCompanyName(companyName);
List<LarkUserActiveInviteRelatoin> larkUserActiveInviteRelatoins = larkUserActiveInviteRelatoinMapper.selectLarkUserActiveInviteRelatoinList(relation);
if (CollectionUtils.isNotEmpty(larkUserActiveInviteRelatoins)) {
return Boolean.TRUE;
}
relation.setUserName(inviteUserName);
relation.setInviteUserName(userName);
larkUserActiveInviteRelatoins = larkUserActiveInviteRelatoinMapper.selectLarkUserActiveInviteRelatoinList(relation);
if (CollectionUtils.isNotEmpty(larkUserActiveInviteRelatoins)) {
return Boolean.TRUE;
} else {
return Boolean.FALSE;
}
}
/** /**
* *
* *

@ -50,6 +50,16 @@
</where> </where>
</select> </select>
<select id="queryByOpenId" parameterType="com.ruoyi.flyingbook.domain.LarkLoginLog"
resultMap="LarkLoginLogResult">
<include refid="selectLarkLoginLogVo"/>
where open_id in
<foreach collection="openIdList" open="(" separator="," close=")" item="item">
#{item}
</foreach>
group by open_id
</select>
<select id="count" parameterType="com.ruoyi.flyingbook.domain.LarkLoginLog" resultType="java.lang.Integer"> <select id="count" parameterType="com.ruoyi.flyingbook.domain.LarkLoginLog" resultType="java.lang.Integer">
select count(id) from lark_login_log select count(id) from lark_login_log
<where> <where>

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.LarkUserActiveCommentMapper">
<resultMap type="com.ruoyi.flyingbook.domain.LarkUserActiveComment" id="LarkUserActiveCommentResult">
<result property="id" column="id" />
<result property="userActiveRelatoin" column="user_active_relatoin" />
<result property="content" column="content" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="flag" column="flag" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectLarkUserActiveCommentVo">
select id, user_active_relatoin, content, create_by, create_time, update_by, update_time, flag, remark from lark_user_active_comment
</sql>
<select id="selectLarkUserActiveCommentList" parameterType="com.ruoyi.flyingbook.domain.LarkUserActiveComment" resultMap="LarkUserActiveCommentResult">
<include refid="selectLarkUserActiveCommentVo"/>
<where>
<if test="userActiveRelatoin != null "> and user_active_relatoin = #{userActiveRelatoin}</if>
<if test="content != null and content != ''"> and content = #{content}</if>
<if test="flag != null "> and flag = #{flag}</if>
</where>
</select>
<select id="selectLarkUserActiveCommentById" parameterType="Long" resultMap="LarkUserActiveCommentResult">
<include refid="selectLarkUserActiveCommentVo"/>
where id = #{id}
</select>
<insert id="insertLarkUserActiveComment" parameterType="com.ruoyi.flyingbook.domain.LarkUserActiveComment" useGeneratedKeys="true" keyProperty="id">
insert into lark_user_active_comment
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userActiveRelatoin != null">user_active_relatoin,</if>
<if test="content != null">content,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="flag != null">flag,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userActiveRelatoin != null">#{userActiveRelatoin},</if>
<if test="content != null">#{content},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="flag != null">#{flag},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateLarkUserActiveComment" parameterType="com.ruoyi.flyingbook.domain.LarkUserActiveComment">
update lark_user_active_comment
<trim prefix="SET" suffixOverrides=",">
<if test="userActiveRelatoin != null">user_active_relatoin = #{userActiveRelatoin},</if>
<if test="content != null">content = #{content},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="flag != null">flag = #{flag},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteLarkUserActiveCommentById" parameterType="Long">
delete from lark_user_active_comment where id = #{id}
</delete>
<delete id="deleteLarkUserActiveCommentByIds" parameterType="String">
delete from lark_user_active_comment where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

@ -50,6 +50,15 @@
</where> </where>
</select> </select>
<select id="queryByIdList"
resultMap="LarkUserActiveRelatoinResult">
<include refid="selectLarkUserActiveRelatoinVo"/>
where id in
<foreach collection="idList" open="(" separator="," close=")" item="item">
#{item}
</foreach>
</select>
<select id="queryPage" parameterType="com.ruoyi.flyingbook.domain.larkactive.LarkActiveUserRelationRequest" <select id="queryPage" parameterType="com.ruoyi.flyingbook.domain.larkactive.LarkActiveUserRelationRequest"
resultMap="LarkUserActiveRelatoinResult"> resultMap="LarkUserActiveRelatoinResult">
<include refid="selectLarkUserActiveRelatoinVo"/> <include refid="selectLarkUserActiveRelatoinVo"/>

Loading…
Cancel
Save