新增学霸业务、掌门少儿新增设备字段

master
queyounan 4 years ago
parent cbff138796
commit 81c8fd7ae5

@ -396,4 +396,33 @@ public class ABClient {
return abClientService.recordSongshuClientMsg(atoCvt)?
CommonResponse.createBySuccess() : CommonResponse.createByErrorMessage("调用失败请重试");
}
/**
*
*
* @return
*/
@PostMapping("/api/req/forminput/xueba")
@ResponseBody
public CommonResponse getFormData(@RequestBody ABClientXuebaMessageVO vo){
//记录日志
log.info("====== [ one request comming, request content is {} ] ======", vo.toString());
// 验证参数,并进行解密
String callLog = vo.getCalllog();
if (StringUtils.isEmpty(callLog)){
return CommonResponse.createByErrorMessage(ResponseCode.EMPTY_ARGUMENT.getDesc());
}
// 获取的是解密且解码后的Json字符串
String jsonResult = SecurityOperationUtil.decCallLogSecurityInfo(callLog);
// Json转成对应的实体类
if (StringUtils.isEmpty(jsonResult)){
return CommonResponse.createByErrorMessage(ResponseCode.DECRYPT_ERROR.getDesc());
}
// vo赋值到DTO
XuebaMessageDTO xuebaMessageDTO = JSONUtil.toBean(jsonResult, XuebaMessageDTO.class);
XuebaMessageDTO atoCvt = XuebaMessageConverter.convertXuebaMessageDTOFromVO(xuebaMessageDTO, vo);
// 处理具体逻辑,返回校验成功的结果
return abClientService.recordXuebaClientMsg(atoCvt)?
CommonResponse.createBySuccess() : CommonResponse.createByErrorMessage("调用失败请重试");
}
}

@ -0,0 +1,21 @@
package com.yuyou.openapi.openapi.dao;
import com.yuyou.openapi.openapi.model.dataobject.SongshuMessageDO;
import com.yuyou.openapi.openapi.model.dataobject.XuebaMessageDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface XuebaMessageRepository extends JpaRepository<XuebaMessageDO, Long> {
/**
* RecId
*
* @param recId Id
* @return
*/
List<XuebaMessageDO> findByRecId(Long recId);
}

@ -0,0 +1,94 @@
package com.yuyou.openapi.openapi.model.convert;
import cn.hutool.core.codec.Base64;
import com.yuyou.openapi.openapi.common.enums.ConstantEnum;
import com.yuyou.openapi.openapi.common.enums.GradeEnum;
import com.yuyou.openapi.openapi.common.enums.SubjectEnum;
import com.yuyou.openapi.openapi.common.security.SecurityConstants;
import com.yuyou.openapi.openapi.common.security.SecurityService;
import com.yuyou.openapi.openapi.model.dataobject.SongshuMessageDO;
import com.yuyou.openapi.openapi.model.dataobject.XuebaMessageDO;
import com.yuyou.openapi.openapi.model.dto.SongshuMessageDTO;
import com.yuyou.openapi.openapi.model.dto.XuebaMessageDTO;
import com.yuyou.openapi.openapi.model.vo.ABClientSongshuMessageVO;
import com.yuyou.openapi.openapi.model.vo.ABClientXuebaMessageVO;
import com.yuyou.openapi.openapi.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @version 1.0
* @date 2020/8/10
*/
@Slf4j
public class XuebaMessageConverter {
/**
* VODTO
* @param abClientXuebaMessageVO
* @return
*/
public static XuebaMessageDTO convertXuebaMessageDTOFromVO(XuebaMessageDTO xuebaMessageDTO, ABClientXuebaMessageVO abClientXuebaMessageVO) {
BeanUtils.copyProperties(abClientXuebaMessageVO, xuebaMessageDTO);
return xuebaMessageDTO;
}
/**
* DTODO
* @param list
* @return
*/
public static List<XuebaMessageDO> convertXuebaMessageDOFromDTO(List<XuebaMessageDTO> list) {
if (CollectionUtils.isEmpty(list)) {
return null;
}
List<XuebaMessageDO> xuebaMessageDOs = new ArrayList<>();
list.forEach(each -> {
XuebaMessageDO xuebaMessageDO = convertXuebaMessageDOFromDTO(each);
if (xuebaMessageDO != null) {
xuebaMessageDOs.add(xuebaMessageDO);
}
});
return xuebaMessageDOs;
}
/**
* DTODO
* @param xuebaMessageDTO
* @return
*/
public static XuebaMessageDO convertXuebaMessageDOFromDTO(XuebaMessageDTO xuebaMessageDTO) {
if (xuebaMessageDTO == null || xuebaMessageDTO.getTag() == null || xuebaMessageDTO.getData() == null) {
return null;
}
XuebaMessageDO xuebaMessageDO = new XuebaMessageDO();
BeanUtils.copyProperties(xuebaMessageDTO.getData(), xuebaMessageDO);
try {
xuebaMessageDTO.getData().setMobile(Base64.encode(xuebaMessageDTO.getData().getMobile()));
String encryptedMobile = SecurityService.encrypt(xuebaMessageDTO.getData().getMobile(), SecurityConstants.PHONE);
String encryptedName = SecurityService.encrypt(xuebaMessageDTO.getData().getName(), SecurityConstants.SIMPLE);
xuebaMessageDO.setPnum(encryptedMobile);
xuebaMessageDO.setStuName(encryptedName);
} catch (Exception e) {
log.error("Encrypt data raise Error, recId = {}, error is :", xuebaMessageDTO.getTag().getTag_key_id(), e);
xuebaMessageDO.setPnum(xuebaMessageDTO.getData().getMobile());
xuebaMessageDO.setStuName(xuebaMessageDTO.getData().getName());
}
xuebaMessageDO.setAppId(xuebaMessageDTO.getAppId());
xuebaMessageDO.setPushTime(DateUtils.date(xuebaMessageDTO.getTimestamp()));
xuebaMessageDO.setStuGrade(GradeEnum.codeOf(xuebaMessageDTO.getData().getGrade()));
xuebaMessageDO.setStuSub(SubjectEnum.codeOf(xuebaMessageDTO.getData().getCourse()));
xuebaMessageDO.setDevice(ConstantEnum.YesOrNo.codeOf(xuebaMessageDTO.getData().getDevice()));
xuebaMessageDO.setRecId(xuebaMessageDTO.getTag().getTag_key_id());
return xuebaMessageDO;
}
}

@ -87,7 +87,6 @@ public class ZhangmenKidMessageConverter {
zhangmenKidMessageDO.setStuGrade(GradeEnum.codeOf(zhangmenKidMessageDTO.getData().getGrade()));
zhangmenKidMessageDO.setStuSub(SubjectEnum.codeOf(zhangmenKidMessageDTO.getData().getCourse()));
zhangmenKidMessageDO.setDevice(ConstantEnum.YesOrNo.codeOf(zhangmenKidMessageDTO.getData().getDevice()));
zhangmenKidMessageDO.setRecId(zhangmenKidMessageDTO.getTag().getTag_key_id());
return zhangmenKidMessageDO;

@ -1,6 +1,7 @@
package com.yuyou.openapi.openapi.model.convert;
import cn.hutool.core.codec.Base64;
import com.yuyou.openapi.openapi.common.enums.ConstantEnum;
import com.yuyou.openapi.openapi.common.enums.GradeEnum;
import com.yuyou.openapi.openapi.common.enums.SubjectEnum;
import com.yuyou.openapi.openapi.common.security.SecurityConstants;
@ -82,7 +83,7 @@ public class ZhangmenMessageConverter {
zhangmenMessageDO.setStuGrade(GradeEnum.codeOf(abzmMessageDTO.getData().getGrade()));
zhangmenMessageDO.setStuSub(SubjectEnum.codeOf(abzmMessageDTO.getData().getCourse()));
zhangmenMessageDO.setDevice(ConstantEnum.YesOrNo.codeOf(abzmMessageDTO.getData().getDevice()));
zhangmenMessageDO.setRecId(abzmMessageDTO.getTag().getTag_key_id());
return zhangmenMessageDO;

@ -0,0 +1,83 @@
package com.yuyou.openapi.openapi.model.dataobject;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.Date;
/**
*
* @version 1.0
* @date 2020/8/10
*/
@Data
@Table(name = "xueba_message")
@Entity
@EntityListeners(AuditingEntityListener.class)
public class XuebaMessageDO {
/**
* id
*/
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Long id;
@Column(name = "gmt_create")
@CreatedDate
private Date gmtCreate;
@Column(name = "gmt_modified")
@LastModifiedDate
private Date gmtModified;
/**
* id
*/
@Column(name = "rec_id")
private Long recId;
/**
*
*/
@Column(name = "stu_name")
private String stuName;
/**
*
*/
private String pnum;
/**
*
*/
@Column(name = "stu_grade")
private Integer stuGrade;
/**
*
*/
@Column(name = "stu_sub")
private Integer stuSub;
@Column(name = "device")
private Integer device;
/**
* id
*/
@Column(name = "app_id")
private String appId;
/**
*
*/
@Column(name = "push_time")
private Date pushTime;
@Column(name = "submit_status")
private Integer submitStatus = 0;
}

@ -63,6 +63,9 @@ public class ZhangmenMessageDO {
@Column(name = "stu_sub")
private Integer stuSub;
@Column(name = "device")
private Integer device;
/**
* id
*/

@ -99,7 +99,7 @@ public class ABZMMessageDTO {
/**
*
*/
private Integer device;
private String device;
/**
*

@ -0,0 +1,101 @@
package com.yuyou.openapi.openapi.model.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class XuebaMessageDTO {
/**
* ID
*/
private String appId;
/**
*
*/
private Long timestamp;
/**
*
*/
private Tag tag;
/**
*
*/
private Datas data;
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Tag {
/**
* id
*/
private Long tag_key_id;
/**
*
*/
private String tag_key_name;
/**
*
*/
private String tag_key_mobile;
/**
*
*/
private String tag_key_grade;
/**
*
*/
private String tag_key_course;
/**
*
*/
private String tag_key_device;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Datas {
/**
*
*/
private String name;
/**
*
*/
private String mobile;
/**
*
*/
private String grade;
/**
*
*/
private String course;
/**
*
*/
private String device;
}
}

@ -0,0 +1,27 @@
package com.yuyou.openapi.openapi.model.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* Copyright (C), 2012 - 2018, qyx
* FileName: ABClientMessageVO
* Author: x
* Date: 2020/8/4 6:59 PM
* Description: ABClient
* History:
* <author> <time> <version> <desc>
* x 2020/8/4 v1.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class ABClientXuebaMessageVO extends ABClientBaseVO implements Serializable {
/**
*
*/
private String calllog;
}

@ -99,4 +99,11 @@ public interface ABClientService {
* @param dto Bean
*/
boolean recordSongshuClientMsg(SongshuMessageDTO dto);
/**
* ,
*
* @param dto Bean
*/
boolean recordXuebaClientMsg(XuebaMessageDTO dto);
}

@ -68,6 +68,9 @@ public class ABClientServiceImpl implements ABClientService {
@Autowired
private SongshuMessageRepository songshuMessageRepository;
@Autowired
private XuebaMessageRepository xuebaMessageRepository;
@Override
public boolean recordAndSendABClientMsg(List<ABMessageDTO> dtos) {
if (CollectionUtils.isEmpty(dtos)) {
@ -431,4 +434,33 @@ public class ABClientServiceImpl implements ABClientService {
}
return Boolean.TRUE;
}
@Override
public boolean recordXuebaClientMsg(XuebaMessageDTO dto) {
if (dto == null) {
log.error("Param dtos is empty");
return Boolean.FALSE;
}
XuebaMessageDO xuebaMessageDO = XuebaMessageConverter.convertXuebaMessageDOFromDTO(dto);
Long recId = xuebaMessageDO.getRecId();
if (recId <= 0){
log.error("========== [recId is null,please check this data , error msg is {} ] ==========", dto.toString());
return Boolean.FALSE;
}
// 增加前先进行校验在数据库中是否存在
List<XuebaMessageDO> xuebaMessageDOList = xuebaMessageRepository.findByRecId(recId);
if (CollectionUtils.isEmpty(xuebaMessageDOList)){
XuebaMessageDO result = xuebaMessageRepository.save(xuebaMessageDO);
if (result == null) {
log.error("========== [insert xueba data error , please check . ] ==========");
return Boolean.FALSE;
}
}else{
log.error("========== [insert xueba data error , recId is exist , recId is {} ] ==========", recId);
return Boolean.TRUE;
}
return Boolean.TRUE;
}
}

@ -113,6 +113,11 @@ public class ABClientServiceProxy implements ABClientService {
return abClientService.recordSongshuClientMsg(dto);
}
@Override
public boolean recordXuebaClientMsg(XuebaMessageDTO dto) {
return abClientService.recordXuebaClientMsg(dto);
}
/**
*
* @param base64Value

Loading…
Cancel
Save