联调
continuous-integration/drone/push Build is passing Details

飞书小程序
YXY 1 year ago
parent 6a014a19d0
commit a22ea3bcf7

@ -158,6 +158,12 @@
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel-core</artifactId>
<version>3.1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

@ -0,0 +1,44 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum LarkActiveEnum {
/**
*
*/
MOOC("MOOC", "MOOC"),
FUN_KNOWLEDGE("FunKnowledge", "知识竞赛"),
NITPICK("Nitpick", "信息安全找茬活动"),
VIDEO("Video", "看信息安全通识视频"),
AI("AI", "AI应用创意畅想"),
INFORMATION_SECURITY("InformationSecurity", "信息安全风险提报");
private final String code;
private final String info;
LarkActiveEnum(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode() {
return code;
}
public String getInfo() {
return info;
}
public static LarkActiveEnum getByCode(String code){
for (LarkActiveEnum value : LarkActiveEnum.values()) {
if (value.getCode().equals(code)){
return value;
}
}
return null;
}
}

@ -10,7 +10,7 @@ public enum LarkActiveTypeEnum {
/**
*
*/
DEFAULT("DEFAULT", "正常");
LARK_APP_TYPE("LARK_APP_TYPE", "默认飞书小程序");
private final String code;
private final String info;

@ -0,0 +1,30 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum LarkUserTypeEnum {
/**
*
*/
LARK_APP("LARK_APP", "飞书小程序");
private final String code;
private final String info;
LarkUserTypeEnum(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode() {
return code;
}
public String getInfo() {
return info;
}
}

@ -0,0 +1,22 @@
package com.ruoyi.common.utils;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
@Slf4j
public class ExportUtils {
@SneakyThrows(UnsupportedEncodingException.class)
public static void writeFile(HttpServletResponse response, String fileName) {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8' '" + fileName + ".xlsx");
}
}

@ -0,0 +1,25 @@
package com.ruoyi.common.utils.excelStrategy;
import java.lang.annotation.*;
/**
*
* @author yuxiangyong
* @create 2022-10-08 13:49
*/
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface CustomMerge {
/**
*
*/
boolean needMerge() default false;
/**
*
*/
boolean isPk() default false;
}

@ -0,0 +1,135 @@
package com.ruoyi.common.utils.excelStrategy;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.write.handler.RowWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
/**
* excel-
* @see com.commons.annotation.CustomMerge
* @author yuxiangyong
* @create 2022-10-09 13:41
*/
public class CustomMergeStrategy implements RowWriteHandler {
/**
*
*/
private Integer pkIndex;
/**
*
*/
private List<Integer> needMergeColumnIndex = new ArrayList<>();
/**
* DTO
*/
private Class<?> elementType;
public CustomMergeStrategy(Class<?> elementType) {
this.elementType = elementType;
}
@Override
public void afterRowDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Integer relativeRowIndex, Boolean isHead) {
// 如果是标题,则直接返回
if (isHead) {
return;
}
// 获取当前sheet
Sheet sheet = writeSheetHolder.getSheet();
// 获取标题行
Row titleRow = sheet.getRow(0);
if (null == pkIndex) {
this.lazyInit(writeSheetHolder);
}
// 判断是否需要和上一行进行合并
// 不能和标题合并,只能数据行之间合并
if (row.getRowNum() <= 1) {
return;
}
// 获取上一行数据
Row lastRow = sheet.getRow(row.getRowNum() - 1);
// 将本行和上一行是同一类型的数据(通过主键字段进行判断),则需要合并
if (lastRow.getCell(pkIndex).getStringCellValue().equalsIgnoreCase(row.getCell(pkIndex).getStringCellValue())) {
for (Integer needMerIndex : needMergeColumnIndex) {
CellRangeAddress cellRangeAddress = new CellRangeAddress(row.getRowNum() - 1, row.getRowNum(),
needMerIndex, needMerIndex);
sheet.addMergedRegionUnsafe(cellRangeAddress);
}
}
}
/**
*
*/
private void lazyInit(WriteSheetHolder writeSheetHolder) {
// 获取当前sheet
Sheet sheet = writeSheetHolder.getSheet();
// 获取标题行
Row titleRow = sheet.getRow(0);
// 获取DTO的类型
Class<?> eleType = this.elementType;
// 获取DTO所有的属性
Field[] fields = eleType.getDeclaredFields();
// 遍历所有的字段因为是基于DTO的字段来构建excel所以字段数 >= excel的列数
for (Field theField : fields) {
// 获取@ExcelProperty注解用于获取该字段对应在excel中的列的下标
ExcelProperty easyExcelAnno = theField.getAnnotation(ExcelProperty.class);
// 为空,则表示该字段不需要导入到excel,直接处理下一个字段
if (null == easyExcelAnno) {
continue;
}
// 获取自定义的注解,用于合并单元格
CustomMerge customMerge = theField.getAnnotation(CustomMerge.class);
// 没有@CustomMerge注解的默认不合并
if (null == customMerge) {
continue;
}
for (int index = 0; index < fields.length; index++) {
Cell theCell = titleRow.getCell(index);
// 当配置为不需要导出时返回的为null这里作一下判断防止NPE
if (null == theCell) {
continue;
}
// 将字段和excel的表头匹配上
if (easyExcelAnno.value()[0].equalsIgnoreCase(theCell.getStringCellValue())) {
if (customMerge.isPk()) {
pkIndex = index;
}
if (customMerge.needMerge()) {
needMergeColumnIndex.add(index);
}
}
}
}
// 没有指定主键,则异常
if (null == this.pkIndex) {
throw new IllegalStateException("使用@CustomMerge注解必须指定主键");
}
}
}

@ -76,6 +76,12 @@
<artifactId>cos_api</artifactId>
<version>5.6.155</version>
</dependency>
<!-- EasyExcel -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>

@ -1,6 +1,13 @@
package com.ruoyi.flyingbook.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.lark.oapi.service.authen.v1.model.CreateAccessTokenRespBody;
import com.lark.oapi.service.contact.v3.model.GetUserRespBody;
import com.lark.oapi.service.contact.v3.model.User;
import com.ruoyi.common.enums.LarkUserTypeEnum;
import com.ruoyi.common.utils.ExportUtils;
import com.ruoyi.common.utils.excelStrategy.CustomMergeStrategy;
import com.ruoyi.flyingbook.CosHelper.CosHelper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.FlagStatus;
@ -9,12 +16,14 @@ import com.ruoyi.common.enums.LarkActiveStageEnum;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.flyingbook.LarkHelper.LarkUserHelper;
import com.ruoyi.flyingbook.domain.LarkActive;
import com.ruoyi.flyingbook.domain.LarkLoginLog;
import com.ruoyi.flyingbook.domain.LarkUserActiveInviteRelatoin;
import com.ruoyi.flyingbook.domain.LarkUserActiveRelatoin;
import com.ruoyi.flyingbook.domain.edi.ResponseVo;
import com.ruoyi.flyingbook.domain.lark.LarkUserRequest;
import com.ruoyi.flyingbook.domain.larkactive.*;
import com.ruoyi.flyingbook.service.ILarkActiveService;
import com.ruoyi.flyingbook.service.ILarkLoginLogService;
import com.ruoyi.flyingbook.service.ILarkUserActiveInviteRelatoinService;
import com.ruoyi.flyingbook.service.ILarkUserActiveRelatoinService;
import lombok.extern.slf4j.Slf4j;
@ -23,7 +32,9 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.Arrays;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
@ -42,19 +53,34 @@ public class LarkActiveController extends BaseController {
@Autowired
private LarkUserHelper larkUserHelper;
@Autowired
private ILarkLoginLogService larkLoginLogService;
@Autowired
private CosHelper cosHelper;
private static final String APP_ID = "cli_a482a8572cbc9013";
private static final String APP_SECRET = "lZNXbCLlOslWbwBIVc4qvgxOdnfA8Mos";
private static final String APP_ID = "cli_a4504c9fe9f95013";
private static final String APP_SECRET = "oWiLzl2Tkt68tvZHjQIfOb27rPQkTUhu";
/**
*
*/
@PostMapping("/getSession")
public ResponseVo<CreateAccessTokenRespBody> getSession(@RequestBody LarkSessionRequest request) {
public ResponseVo<User> getSession(@RequestBody LarkSessionRequest request) {
LarkSessionResponse larkSessionResponse = larkUserHelper.tokenLoginValidate(new LarkUserRequest(APP_ID, APP_SECRET, null, request.getCode()));
CreateAccessTokenRespBody userToken = larkUserHelper.getUserToken(new LarkUserRequest(APP_ID, APP_SECRET, larkSessionResponse.getData().getOpen_id()));
return new ResponseVo<>(userToken);
String openId = larkSessionResponse.getData().getOpen_id();
GetUserRespBody userInfoDetail = larkUserHelper.getUserInfoDetail(new LarkUserRequest(APP_ID, APP_SECRET, openId));
User user = userInfoDetail.getUser();
LarkLoginLog larkLoginLog = new LarkLoginLog();
larkLoginLog.setFlag(FlagStatus.OK.getCode());
larkLoginLog.setCompanyName(request.getCompanyName());
larkLoginLog.setImageUrl(user.getAvatar().getAvatarOrigin());
larkLoginLog.setCreateTime(new Date());
larkLoginLog.setUserName(user.getName());
larkLoginLog.setOpenId(openId);
larkLoginLog.setType(LarkUserTypeEnum.LARK_APP.getCode());
larkLoginLog.setCreateBy(user.getName());
larkLoginLog.setCreateTime(new Date());
larkLoginLogService.insertLarkLoginLog(larkLoginLog);
return new ResponseVo<>(user);
}
/**
@ -78,11 +104,12 @@ public class LarkActiveController extends BaseController {
*
*/
@PostMapping("/uploadActiveFile")
public ResponseVo<LarkUserActiveRelatoin> uploadActiveFile(@RequestParam("file") MultipartFile file,@RequestParam("userName")String userName,@RequestParam("larkActiveName") String larkActiveName) {
public ResponseVo<LarkUserActiveRelatoin> uploadActiveFile(@RequestParam("file") MultipartFile file,@RequestParam("userName")String userName,@RequestParam("larkActiveName") String larkActiveName,@RequestParam("companyName") String companyName) {
LarkActiveUserRelationRequest request = new LarkActiveUserRelationRequest();
request.setFile(file);
request.setUserName(userName);
request.setLarkActiveName(larkActiveName);
request.setCompanyName(companyName);
return larkUserActiveRelatoinService.commitFile(request);
}
@ -126,10 +153,23 @@ public class LarkActiveController extends BaseController {
/**
*
*/
@PostMapping("/queryCount")
public ResponseVo<LarkActiveCountVo> queryCount(@RequestBody LarkUserActiveRelatoin request) {
LarkActiveCountVo larkActiveCountVo = larkUserActiveRelatoinService.queryCount(request);
return new ResponseVo(larkActiveCountVo);
@ResponseBody
@GetMapping("/export")
public void export(HttpServletResponse response) {
try {
LarkActiveCountVo larkActiveCountVo = larkUserActiveRelatoinService.queryCount();
ExportUtils.writeFile(response, "fileName");
EasyExcel.write(response.getOutputStream())
.head(LarkActiveCountVo.class)
.registerWriteHandler(new CustomMergeStrategy(LarkActiveCountVo.class))
.excelType(ExcelTypeEnum.XLSX)
.password("123456")
.autoCloseStream(Boolean.TRUE)
.sheet("sheetName")
.doWrite(Arrays.asList(larkActiveCountVo));
}catch (Exception e){
log.info("导出信息错误",e);
}
}
}

@ -0,0 +1,43 @@
package com.ruoyi.flyingbook.domain;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* lark_login_log
*
* @author ruoyi
* @date 2023-08-20
*/
@Data
public class LarkLoginLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
private Long id;
/** 用户唯一id */
private String openId;
/** 公司名称 */
private String companyName;
/** 用户名称 */
private String userName;
/** 用户头像 */
private String imageUrl;
/**
*
* @see com.ruoyi.common.enums.LarkUserTypeEnum
*/
private String type;
/**
* @see com.ruoyi.common.enums.FlagStatus
*/
private Long flag;
}

@ -1,9 +1,10 @@
package com.ruoyi.flyingbook.domain.larkactive;
import com.ruoyi.flyingbook.domain.LarkActive;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.ruoyi.common.utils.excelStrategy.CustomMerge;
import lombok.Data;
import java.util.List;
/**
* lark_active
@ -14,17 +15,31 @@ import java.util.List;
@Data
public class LarkActiveCountVo {
/**
*
*/
private Integer totalClickQty;
/**
*
*/
private Integer totalUserQty;
/**
*
*/
private List<LarkActiveVo> activeUserQtyList;
@ColumnWidth(20)
@ExcelProperty("总点击量")
@CustomMerge(isPk = true)
private Integer totalClickQty = 0;
@ColumnWidth(20)
@ExcelProperty("总用户量")
private Integer totalUserQty = 0;
@ColumnWidth(20)
@ExcelProperty("MOOC 课程")
private Integer moccQty = 0;
@ColumnWidth(20)
@ExcelProperty("知识竞赛")
private Integer funKnowledgeQty = 0;
@ColumnWidth(20)
@ExcelProperty("信息安全找茬活动")
private Integer nitpickQty = 0;
@ColumnWidth(20)
@ExcelProperty("看信息安全通识视频")
private Integer videoQty = 0;
@ColumnWidth(20)
@ExcelProperty("AI应用创意畅想")
private Integer aiQty = 0;
@ColumnWidth(20)
@ExcelProperty("信息安全风险提报")
private Integer informationSecurityQty = 0;
}

@ -9,6 +9,7 @@ import lombok.Data;
@Data
public class LarkSessionRequest {
private String companyName;
private String code;
}

@ -2,6 +2,7 @@ package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.LarkActive;
import com.ruoyi.flyingbook.domain.larkactive.LarkActiveRequest;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@ -20,7 +21,7 @@ public interface LarkActiveMapper {
* @return
*/
public LarkActive selectLarkActiveById(Long id);
public List<LarkActive> selectLarkActiveByName(@RequestParam("activeName") String activeName,@RequestParam("flag") Long flag);
public List<LarkActive> selectLarkActiveByName(@Param("activeName") String activeName, @Param("flag") Long flag);
/**
*
@ -31,7 +32,7 @@ public interface LarkActiveMapper {
public List<LarkActive> selectLarkActiveList(LarkActive larkActive);
public Integer count(LarkActive larkActive);
public List<LarkActive> queryPage(LarkActiveRequest request);
public List<LarkActive> queryActive(LarkActiveRequest larkActive);
public List<LarkActive> queryActive(LarkActive larkActive);
public List<LarkActive> queryCompleteActive(LarkActiveRequest larkActive);
/**
*

@ -0,0 +1,64 @@
package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.LarkLoginLog;
import java.util.List;
/**
* Mapper
*
* @author ruoyi
* @date 2023-08-20
*/
public interface LarkLoginLogMapper
{
/**
*
*
* @param id ID
* @return
*/
public LarkLoginLog selectLarkLoginLogById(Long id);
/**
*
*
* @param larkLoginLog
* @return
*/
public List<LarkLoginLog> selectLarkLoginLogList(LarkLoginLog larkLoginLog);
public Integer count(LarkLoginLog larkLoginLog);
/**
*
*
* @param larkLoginLog
* @return
*/
public int insertLarkLoginLog(LarkLoginLog larkLoginLog);
/**
*
*
* @param larkLoginLog
* @return
*/
public int updateLarkLoginLog(LarkLoginLog larkLoginLog);
/**
*
*
* @param id ID
* @return
*/
public int deleteLarkLoginLogById(Long id);
/**
*
*
* @param ids ID
* @return
*/
public int deleteLarkLoginLogByIds(Long[] ids);
}

@ -0,0 +1,63 @@
package com.ruoyi.flyingbook.service;
import com.ruoyi.flyingbook.domain.LarkLoginLog;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-08-20
*/
public interface ILarkLoginLogService
{
/**
*
*
* @param id ID
* @return
*/
public LarkLoginLog selectLarkLoginLogById(Long id);
/**
*
*
* @param larkLoginLog
* @return
*/
public List<LarkLoginLog> selectLarkLoginLogList(LarkLoginLog larkLoginLog);
/**
*
*
* @param larkLoginLog
* @return
*/
public int insertLarkLoginLog(LarkLoginLog larkLoginLog);
/**
*
*
* @param larkLoginLog
* @return
*/
public int updateLarkLoginLog(LarkLoginLog larkLoginLog);
/**
*
*
* @param ids ID
* @return
*/
public int deleteLarkLoginLogByIds(Long[] ids);
/**
*
*
* @param id ID
* @return
*/
public int deleteLarkLoginLogById(Long id);
}

@ -22,7 +22,7 @@ public interface ILarkUserActiveRelatoinService {
*/
public LarkUserActiveRelatoin selectLarkUserActiveRelatoinById(Long id);
public LarkActiveCountVo queryCount(LarkUserActiveRelatoin request);
public LarkActiveCountVo queryCount();
/**
*

@ -0,0 +1,97 @@
package com.ruoyi.flyingbook.service.impl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.flyingbook.domain.LarkLoginLog;
import com.ruoyi.flyingbook.mapper.LarkLoginLogMapper;
import com.ruoyi.flyingbook.service.ILarkLoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-08-20
*/
@Service
public class LarkLoginLogServiceImpl implements ILarkLoginLogService
{
@Autowired
private LarkLoginLogMapper larkLoginLogMapper;
/**
*
*
* @param id ID
* @return
*/
@Override
public LarkLoginLog selectLarkLoginLogById(Long id)
{
return larkLoginLogMapper.selectLarkLoginLogById(id);
}
/**
*
*
* @param larkLoginLog
* @return
*/
@Override
public List<LarkLoginLog> selectLarkLoginLogList(LarkLoginLog larkLoginLog)
{
return larkLoginLogMapper.selectLarkLoginLogList(larkLoginLog);
}
/**
*
*
* @param larkLoginLog
* @return
*/
@Override
public int insertLarkLoginLog(LarkLoginLog larkLoginLog)
{
larkLoginLog.setCreateTime(DateUtils.getNowDate());
return larkLoginLogMapper.insertLarkLoginLog(larkLoginLog);
}
/**
*
*
* @param larkLoginLog
* @return
*/
@Override
public int updateLarkLoginLog(LarkLoginLog larkLoginLog)
{
larkLoginLog.setUpdateTime(DateUtils.getNowDate());
return larkLoginLogMapper.updateLarkLoginLog(larkLoginLog);
}
/**
*
*
* @param ids ID
* @return
*/
@Override
public int deleteLarkLoginLogByIds(Long[] ids)
{
return larkLoginLogMapper.deleteLarkLoginLogByIds(ids);
}
/**
*
*
* @param id ID
* @return
*/
@Override
public int deleteLarkLoginLogById(Long id)
{
return larkLoginLogMapper.deleteLarkLoginLogById(id);
}
}

@ -2,11 +2,14 @@ package com.ruoyi.flyingbook.service.impl;
import com.qcloud.cos.model.PutObjectResult;
import com.ruoyi.common.enums.FlagStatus;
import com.ruoyi.common.enums.LarkActiveEnum;
import com.ruoyi.common.enums.LarkActiveStageEnum;
import com.ruoyi.common.enums.LarkUserTypeEnum;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.flyingbook.CosHelper.CosHelper;
import com.ruoyi.flyingbook.domain.LarkActive;
import com.ruoyi.flyingbook.domain.LarkLoginLog;
import com.ruoyi.flyingbook.domain.LarkUserActiveImage;
import com.ruoyi.flyingbook.domain.LarkUserActiveRelatoin;
import com.ruoyi.flyingbook.domain.edi.ResponseVo;
@ -15,6 +18,7 @@ import com.ruoyi.flyingbook.domain.larkactive.LarkActiveRequest;
import com.ruoyi.flyingbook.domain.larkactive.LarkActiveUserRelationRequest;
import com.ruoyi.flyingbook.domain.larkactive.LarkActiveVo;
import com.ruoyi.flyingbook.mapper.LarkActiveMapper;
import com.ruoyi.flyingbook.mapper.LarkLoginLogMapper;
import com.ruoyi.flyingbook.mapper.LarkUserActiveImageMapper;
import com.ruoyi.flyingbook.mapper.LarkUserActiveRelatoinMapper;
import com.ruoyi.flyingbook.service.ILarkUserActiveRelatoinService;
@ -48,6 +52,8 @@ public class LarkUserActiveRelatoinServiceImpl implements ILarkUserActiveRelatoi
private CosHelper cosHelper;
@Autowired
private LarkUserActiveImageMapper larkUserActiveImageMapper;
@Autowired
private LarkLoginLogMapper larkLoginLogMapper;
private static final String BUCKET_NAME = "ruoyi-1308275795";
@ -64,32 +70,57 @@ public class LarkUserActiveRelatoinServiceImpl implements ILarkUserActiveRelatoi
}
@Override
public LarkActiveCountVo queryCount(LarkUserActiveRelatoin request) {
public LarkActiveCountVo queryCount() {
LarkActiveCountVo larkActiveCountVo = new LarkActiveCountVo();
//总点击量
LarkLoginLog larkLoginLog = new LarkLoginLog();
larkLoginLog.setType(LarkUserTypeEnum.LARK_APP.getCode());
larkLoginLog.setFlag(FlagStatus.OK.getCode());
Integer totalClickQty = larkLoginLogMapper.count(larkLoginLog);
larkActiveCountVo.setTotalClickQty(totalClickQty);
//总用户量
LarkUserActiveRelatoin larkUserActiveRelatoin = new LarkUserActiveRelatoin();
larkUserActiveRelatoin.setActiveStage(LarkActiveStageEnum.ADJUST.getCode());
larkUserActiveRelatoin.setFlag(FlagStatus.OK.getCode());
larkUserActiveRelatoin.setUserName(request.getUserName());
int userCount = larkUserActiveRelatoinMapper.queryUserCount(larkUserActiveRelatoin);
larkActiveCountVo.setTotalUserQty(userCount);
List<LarkActiveVo> larkActiveCountVos = larkUserActiveRelatoinMapper.queryUserCountGroupByActive(larkUserActiveRelatoin);
if (CollectionUtils.isNotEmpty(larkActiveCountVos)) {
List<Long> activeIdList = larkActiveCountVos.stream().map(LarkActiveVo::getId).distinct().collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(activeIdList)) {
LarkActiveRequest query = new LarkActiveRequest();
//每个活动的数量
LarkActive query = new LarkActive();
query.setFlag(FlagStatus.OK.getCode());
query.setLarkActiveIdList(activeIdList);
Map<Long, LarkActive> activeMap = larkActiveMapper.queryActive(query).stream().collect(Collectors.toMap(LarkActive::getId, Function.identity(), (k1, k2) -> k1));
for (LarkActiveVo activeCountVo : larkActiveCountVos) {
LarkActive larkActive = activeMap.get(activeCountVo.getId());
if (larkActive != null) {
BeanUtils.copyProperties(larkActive, activeCountVo);
List<LarkActive> larkActives = larkActiveMapper.queryActive(query);
if (CollectionUtils.isNotEmpty(larkActives)) {
Map<Long, Integer> activeCountMap = larkUserActiveRelatoinMapper.queryUserCountGroupByActive(larkUserActiveRelatoin).stream().collect(Collectors.toMap(LarkActiveVo::getId, LarkActiveVo::getQty, (k1, k2) -> k1));
for (LarkActive active : larkActives) {
Integer qty = activeCountMap.getOrDefault(active.getId(), 0);
fillCount(larkActiveCountVo,qty,active.getActiveDesc());
}
}
return larkActiveCountVo;
}
private void fillCount(LarkActiveCountVo larkActiveCountVo,Integer qty,String activeCode){
qty = qty == null ? 0 : qty;
LarkActiveEnum activeEnum = LarkActiveEnum.getByCode(activeCode);
switch (activeEnum){
case MOOC:
larkActiveCountVo.setMoccQty(qty);
break;
case FUN_KNOWLEDGE:
larkActiveCountVo.setFunKnowledgeQty(qty);
break;
case NITPICK:
larkActiveCountVo.setNitpickQty(qty);
break;
case VIDEO:
larkActiveCountVo.setVideoQty(qty);
break;
case AI:
larkActiveCountVo.setAiQty(qty);
break;
case INFORMATION_SECURITY:
larkActiveCountVo.setInformationSecurityQty(qty);
break;
}
larkActiveCountVo.setActiveUserQtyList(larkActiveCountVos);
return larkActiveCountVo;
}
/**
@ -133,7 +164,7 @@ public class LarkUserActiveRelatoinServiceImpl implements ILarkUserActiveRelatoi
return new ResponseVo();
}
LarkActive active = larkActives.get(0);
LarkUserActiveRelatoin relatoin = queryUserActiveRelation(request.getUserName(), active.getId());
LarkUserActiveRelatoin relatoin = queryUserActiveRelation(request.getCompanyName(),request.getUserName(), active.getId());
if (relatoin == null) {
return new ResponseVo();
}
@ -143,6 +174,7 @@ public class LarkUserActiveRelatoinServiceImpl implements ILarkUserActiveRelatoi
buildUserActiveImage(relatoin, key);
if (totalCount >= larkActive.getActiveImageCount()) {
relatoin.setActiveStage(LarkActiveStageEnum.ADJUST.getCode());
larkUserActiveRelatoinMapper.updateLarkUserActiveRelatoin(relatoin);
}
return new ResponseVo();
}
@ -165,7 +197,7 @@ public class LarkUserActiveRelatoinServiceImpl implements ILarkUserActiveRelatoi
return larkUserActiveImageMapper.selectLarkUserActiveImageList(larkUserActiveImage).size();
}
private LarkUserActiveRelatoin queryUserActiveRelation(String userName, Long activeId) {
private LarkUserActiveRelatoin queryUserActiveRelation(String companyName,String userName, Long activeId) {
LarkUserActiveRelatoin relatoin = new LarkUserActiveRelatoin();
relatoin.setUserName(userName);
relatoin.setActiveId(activeId);
@ -173,8 +205,14 @@ public class LarkUserActiveRelatoinServiceImpl implements ILarkUserActiveRelatoi
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;
}
return null;
}
/**

@ -103,7 +103,7 @@
limit #{offset},{pageSize}
</select>
<select id="queryActive" parameterType="com.ruoyi.flyingbook.domain.larkactive.LarkActiveRequest"
<select id="queryActive" parameterType="com.ruoyi.flyingbook.domain.LarkActive"
resultMap="LarkActiveResult">
<include refid="selectLarkActiveVo"/>
<where>
@ -120,12 +120,6 @@
<if test="activeScore != null and activeScore != ''">and active_score = #{activeScore}</if>
<if test="activeImageCount != null ">and active_image_count = #{activeImageCount}</if>
<if test="flag != null ">and flag = #{flag}</if>
<if test="larkActiveIdList != null ">
and id in
<foreach collection="larkActiveIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
@ -147,7 +141,7 @@
<select id="selectLarkActiveByName" resultMap="LarkActiveResult">
<include refid="selectLarkActiveVo"/>
where activeName = #{activeName} and flag = #{flag}
where active_name = #{activeName} and flag = #{flag}
</select>
<insert id="insertLarkActive" parameterType="com.ruoyi.flyingbook.domain.LarkActive" useGeneratedKeys="true"

@ -0,0 +1,113 @@
<?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.LarkLoginLogMapper">
<resultMap type="com.ruoyi.flyingbook.domain.LarkLoginLog" id="LarkLoginLogResult">
<result property="id" column="id" />
<result property="openId" column="open_id" />
<result property="companyName" column="company_name" />
<result property="userName" column="user_name" />
<result property="imageUrl" column="image_url" />
<result property="type" column="type" />
<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="selectLarkLoginLogVo">
select id, open_id, company_name, user_name, image_url, type, create_by, create_time, update_by, update_time, flag, remark from lark_login_log
</sql>
<select id="selectLarkLoginLogList" parameterType="com.ruoyi.flyingbook.domain.LarkLoginLog" resultMap="LarkLoginLogResult">
<include refid="selectLarkLoginLogVo"/>
<where>
<if test="openId != null "> and open_id = #{openId}</if>
<if test="companyName != null and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="imageUrl != null and imageUrl != ''"> and image_url = #{imageUrl}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="flag != null "> and flag = #{flag}</if>
</where>
</select>
<select id="count" parameterType="com.ruoyi.flyingbook.domain.LarkLoginLog" resultType="java.lang.Integer">
select count(id) from lark_login_log
<where>
<if test="openId != null "> and open_id = #{openId}</if>
<if test="companyName != null and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="imageUrl != null and imageUrl != ''"> and image_url = #{imageUrl}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="flag != null "> and flag = #{flag}</if>
</where>
</select>
<select id="selectLarkLoginLogById" parameterType="Long" resultMap="LarkLoginLogResult">
<include refid="selectLarkLoginLogVo"/>
where id = #{id}
</select>
<insert id="insertLarkLoginLog" parameterType="com.ruoyi.flyingbook.domain.LarkLoginLog" useGeneratedKeys="true" keyProperty="id">
insert into lark_login_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="openId != null">open_id,</if>
<if test="companyName != null">company_name,</if>
<if test="userName != null">user_name,</if>
<if test="imageUrl != null">image_url,</if>
<if test="type != null">type,</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="openId != null">#{openId},</if>
<if test="companyName != null">#{companyName},</if>
<if test="userName != null">#{userName},</if>
<if test="imageUrl != null">#{imageUrl},</if>
<if test="type != null">#{type},</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="updateLarkLoginLog" parameterType="com.ruoyi.flyingbook.domain.LarkLoginLog">
update lark_login_log
<trim prefix="SET" suffixOverrides=",">
<if test="openId != null">open_id = #{openId},</if>
<if test="companyName != null">company_name = #{companyName},</if>
<if test="userName != null">user_name = #{userName},</if>
<if test="imageUrl != null">image_url = #{imageUrl},</if>
<if test="type != null">type = #{type},</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="deleteLarkLoginLogById" parameterType="Long">
delete from lark_login_log where id = #{id}
</delete>
<delete id="deleteLarkLoginLogByIds" parameterType="String">
delete from lark_login_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

@ -94,7 +94,6 @@
<if test="activeStage != null and activeStage != ''">and active_stage = #{activeStage}</if>
<if test="flag != null ">and flag = #{flag}</if>
</where>
group by user_name
</select>
<resultMap type="com.ruoyi.flyingbook.domain.larkactive.LarkActiveCountVo" id="CountGroupResult">

Loading…
Cancel
Save