Commit 77f72600 authored by hanfeng's avatar hanfeng

Merge branch 'base-modify' of http://10.5.52.3/youjj/cloud-platform into base-modify

parents 413f9d1b e720509a
......@@ -170,6 +170,24 @@
<optional>true</optional>
</dependency>
<!-- mongodb -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>2.1.5.RELEASE</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>mongo-java-driver</artifactId>
<groupId>org.mongodb</groupId>
</exclusion>
<exclusion>
<artifactId>jcl-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
......
package com.github.wxiaoqi.security.common.log;
import com.github.wxiaoqi.security.common.log.entity.LogEntity;
import com.github.wxiaoqi.security.common.log.entity.XxLogEntity;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.aspectj.lang.ProceedingJoinPoint;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
public interface CommonLogService {
/**
* 记录日志
* @param logEntity
*/
void log(LogEntity logEntity);
/**
* 记录日志
* @param xxLogEntity
*/
void commonLog(XxLogEntity xxLogEntity);
/**
* 初始化日志前半部分
* @param xxLogEntity
* @param request
*/
void initCommonLogPrePart(XxLogEntity xxLogEntity, HttpServletRequest request, ProceedingJoinPoint pjp);
/**
* 初始化日志后半部分
* @param xxLogEntity
* @param result
*/
void initCommonLogLastPart(XxLogEntity xxLogEntity, Object result);
/**
* 初始化日志后半部分(String)
* @param xxLogEntity
* @param result
*/
void initCommonLogLastPart(XxLogEntity xxLogEntity, String result);
/**
* 初始化FeignClient日志前半部分
* @param xxLogEntity
* @param targetMethod
*/
void initFeignClientLogPrePart(XxLogEntity xxLogEntity, Method targetMethod);
/**
* 初始化mq消息日志前半部分
* @param xxLogEntity
* @param targetMethod
*/
void initMqLogPrePart(XxLogEntity xxLogEntity, Method targetMethod);
}
package com.github.wxiaoqi.security.common.log.Impl;
import com.alibaba.fastjson.JSON;
import com.github.wxiaoqi.security.common.log.CommonLogService;
import com.github.wxiaoqi.security.common.log.entity.LogEntity;
import com.github.wxiaoqi.security.common.log.entity.XxLogEntity;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@Service
public class CommonLogServiceImpl implements CommonLogService {
@Value("${spring.application.name}")
private String applicationName;
// 获取当前cpu个数
private static int corePoolSize = Runtime.getRuntime().availableProcessors();
// 设置任务队列,长度无限制
private static BlockingQueue blockingQueue=new LinkedBlockingQueue<>();
// 定义线程池,初始化线程数为cpu个数,最大线程数为cpu个数*2, 档队列类型为LinkedBlockingQueue,maximumPoolSize 参数无效
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(corePoolSize, corePoolSize*2, 60L, TimeUnit.SECONDS, blockingQueue);
@Autowired
private MongoTemplate mongoTemplate;
@Override
public void log(LogEntity logEntity){
threadPoolExecutor.execute(
new SycnLog(logEntity)
);
}
class SycnLog implements Runnable {
private LogEntity logEntity;
public SycnLog() {
super();
}
public SycnLog(LogEntity logEntity) {
super();
this.logEntity = logEntity;
}
@Override
public void run() {
mongoTemplate.insert(logEntity);
}
}
@Override
public void commonLog(XxLogEntity xxLogEntity){
threadPoolExecutor.execute(
new SycnCommonLog(xxLogEntity)
);
}
class SycnCommonLog implements Runnable {
private XxLogEntity xxLogEntity;
public SycnCommonLog() {
super();
}
public SycnCommonLog(XxLogEntity xxLogEntity) {
super();
this.xxLogEntity = xxLogEntity;
}
@Override
public void run() {
mongoTemplate.insert(xxLogEntity, xxLogEntity.getMongoKey());
}
}
@Override
public void initCommonLogPrePart(XxLogEntity xxLogEntity, HttpServletRequest request, ProceedingJoinPoint pjp) {
//request 获得头部
xxLogEntity.setApp(request.getHeader("app"));
LocalDateTime startTime= LocalDateTime.now();//开始时间
xxLogEntity.setCreateDate(startTime.toString());
xxLogEntity.setServletPath(request.getServletPath());
MethodSignature signature = (MethodSignature) pjp.getSignature();
xxLogEntity.setMethod(signature.getMethod().toString());
xxLogEntity.setMongoKey(applicationName + ":" + request.getServletPath());
}
@Override
public void initCommonLogLastPart(XxLogEntity xxLogEntity, Object result) {
initCommonLogLastPart(xxLogEntity, JSON.toJSONString(result));
}
@Override
public void initCommonLogLastPart(XxLogEntity xxLogEntity, String result) {
LocalDateTime endTime = LocalDateTime.now();//结束时间
xxLogEntity.setEndDate(endTime.toString());
xxLogEntity.setResponseData(result);
}
@Override
public void initFeignClientLogPrePart(XxLogEntity xxLogEntity, Method targetMethod) {
PostMapping postMapping = targetMethod.getAnnotation(PostMapping.class);
String header = postMapping.headers()[0];
xxLogEntity.setApp(header.substring(header.lastIndexOf("app=") + 4, header.length()));
LocalDateTime startTime= LocalDateTime.now();//开始时间
xxLogEntity.setCreateDate(startTime.toString());
xxLogEntity.setServletPath(postMapping.value()[0]);
xxLogEntity.setMongoKey(applicationName + ":" + "feignClient");
}
@Override
public void initMqLogPrePart(XxLogEntity xxLogEntity, Method targetMethod) {
PostMapping postMapping = targetMethod.getAnnotation(PostMapping.class);
String header = postMapping.headers()[0];
LocalDateTime startTime= LocalDateTime.now();//开始时间
xxLogEntity.setCreateDate(startTime.toString());
xxLogEntity.setServletPath(postMapping.value()[0]);
xxLogEntity.setMongoKey(applicationName + ":" + "mqSender");
}
}
package com.github.wxiaoqi.security.common.log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.log.CommonLogService;
import com.github.wxiaoqi.security.common.log.entity.XxLogEntity;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Created by zhoujianwei
* cas 项目注解相关拦截器
* Date : 2018/6/6.
* Time : 18:13
*/
@Aspect
@Component
@Slf4j
public class XxLogInterceptor{
@Autowired
CommonLogService commonLogService;
//触发条件为:com.xxfc.platform包下面所有controller
@Around("within(com.xxfc.platform.*.rest..* || com.xxfc.platform.*.controller..*)")
public Object doAroundXxControllerLog(ProceedingJoinPoint pjp) throws Throwable {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();//获取request
HttpServletResponse response = servletRequestAttributes.getResponse();//获取response
//request 获得头部
XxLogEntity xxLogEntity = new XxLogEntity();
commonLogService.initCommonLogPrePart(xxLogEntity, request, pjp);
Object[] params = pjp.getArgs();//获取请求参数
MethodSignature signature = (MethodSignature) pjp.getSignature();
if(params != null && params.length > 0) {
try{
xxLogEntity.setRequestData(JSON.toJSONString(params[0]));
}catch (Exception e) {
log.error(e.getMessage(), e);
}
}
Object result = new Object();
try{
//###################上面代码为方法执行前#####################
result = pjp.proceed();//执行方法,获取返回参数
//###################下面代码为方法执行后#####################
if(result instanceof JSONObject) {
commonLogService.initCommonLogLastPart(xxLogEntity, ((JSONObject) result).toJSONString());
}else{
commonLogService.initCommonLogLastPart(xxLogEntity, result);
}
}catch (BaseException e){
commonLogService.initCommonLogLastPart(xxLogEntity, ObjectRestResponse.createFailedResult(e.getStatus(), e.getMessage()));
throw e;
}catch (Exception e){
commonLogService.initCommonLogLastPart(xxLogEntity, ObjectRestResponse.createFailedResult(500, e.getMessage()));
throw e;
}finally {
commonLogService.commonLog(xxLogEntity);
}
return result;
}
// @Around("within(com.github.wxiaoqi.security.security.gate.filter..*)")
// public Object doAroundXxControllerLog(ProceedingJoinPoint pjp) throws Throwable {
//
// }
// //casEipMsgErrDeal:外联报错消息处理
// @AfterReturning(value = "within(com.ht.cas.*.*.*.*) && @annotation(casEipMsgErrDeal)", returning = "result")
// public Result doAfterCasEipMsgErrDeal(JoinPoint jp, Result result, CasEipMsgErrDeal casEipMsgErrDeal) {
// String msg = result.getMsg();
// if(StringUtils.isBlank(msg)) {
// msg = result.getCodeDesc();
// }
// //returnCode不为EIP_SUCCESS_CODE 并且 msg 没有信息
// if(!CommonConstant.EIP_SUCCESS_CODE.equals(result.getReturnCode())) {
// result.setData(null);
// if(StringUtils.isBlank(msg)) {
// Map map = ((List<Map>)result.getData()).get(0);
// msg = map.get("field").toString() + " " + map.get("defaultMessage");
// }
// }
// result.setMsg(msg);
// return result;
// }
//
// //casMqSenderLog:mq发送消息
// @Around(value = "within(com.ht.cas..*) && @annotation(casMqSenderLog)")
// public void doAfterCasMqSenderLog(ProceedingJoinPoint pjp, CasMqSenderLog casMqSenderLog) {
//
// }
//
// //casMqSenderLog:mq接收消息
// @Around(value = "within(com.ht.cas..*) && @annotation(casMqReceiverLog)")
// public void doAfterCasMqLog(ProceedingJoinPoint pjp, CasMqReceiverLog casMqReceiverLog) {
//
// }
//
//
// // defined aop pointcut
// @Pointcut("execution(* com.ht.cas.common.feignClient.*.*(..))")
// public void casFeignClientLog() {
// }
//
//
// //@Around("casFeignClientLog()")
// public Object doAroundCasFeignClientLog(ProceedingJoinPoint pjp) throws Throwable {
// //request 获得头部
// Signature signature = pjp.getSignature();
// MethodSignature methodSignature = (MethodSignature)signature;
// Method targetMethod = methodSignature.getMethod();
//
// XxLogEntity xxLogEntity = new XxLogEntity();
// commonLogService.initFeignClientLogPrePart(xxLogEntity, targetMethod);
//
// Object[] params = pjp.getArgs();//获取请求参数
//
// if(params != null && params.length > 0) {
// xxLogEntity.setRequestData(JSON.toJSONString(params[0]));
// }
// Object result = new Object();
// try{
// //###################上面代码为方法执行前#####################
// result = pjp.proceed();//执行方法,获取返回参数
// //###################下面代码为方法执行后#####################
// commonLogService.initCommonLogLastPart(xxLogEntity, (Result) result);
// }catch (Exception e){
// commonLogService.initCommonLogLastPart(xxLogEntity, (Result) result);
// xxLogEntity.setResponseData(JSON.toJSONString(ResultHelper.buildFail(e.getMessage())));
// throw e;
// }finally {
// commonLogService.commonLog(xxLogEntity);
// }
//
// return result;
// }
}
package com.github.wxiaoqi.security.common.log.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
/**
* 日誌信息
*/
@Data
public class LogEntity implements Serializable{
public LogEntity(){
super();
}
public LogEntity(String businessCode, String url, String app, String appName, String requestData, String responseData,Date createDate,Date endDate) {
super();
this.businessCode = businessCode;
this.url = url;
this.app = app;
this.appName = appName;
this.requestData = requestData;
this.responseData = responseData;
this.createDate = createDate;
this.endDate = endDate;
}
private String businessCode;
private String url;
private String app;
private String appName;
private String requestData;
private String responseData;
private Date createDate;
private Date endDate;
}
package com.github.wxiaoqi.security.common.log.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* Created by zhoujianwei
* Date : 2018/6/6.
* Time : 16:59
*/
@Data
public class XxLogEntity implements Serializable {
private String app;
private String servletPath;
private String requestData;
private String responseData;
private String createDate;
private String endDate;
private String requestPath;
private String method;
private String mongoKey;
public XxLogEntity() {
super();
}
public XxLogEntity(String app, String servletPath, String requestData, String responseData, String createDate, String endDate, String requestPath, String mongoKey) {
this.app = app;
this.servletPath = servletPath;
this.requestData = requestData;
this.responseData = responseData;
this.createDate = createDate;
this.endDate = endDate;
this.requestPath = requestPath;
this.mongoKey = mongoKey;
}
}
......@@ -39,6 +39,14 @@ public interface UserFeign {
@RequestMapping(value = "/public/userinfo-by-uid")
public ObjectRestResponse<UserDTO> userinfoByUid(@RequestParam("uid") Integer uid);
/**
* id获取用户信息
* @param id
* @return
*/
@RequestMapping(value = "/public/app/userinfo-by-id")
public ObjectRestResponse<AppUserDTO> userDetailById(@RequestParam("id") Integer id);
/**
*status:0-判断是否认证过,1-认证成功后修改用户认证状态
......
package com.github.wxiaoqi.security.admin.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/15 9:55
*/
@Data
public class WalletCathDetailVo {
/**
* 订单状态:0-未提现,待审核,1-已审核
*/
@ApiModelProperty(value = "订单状态:0-未提现,待审核,1-已审核")
private Integer stauts;
/**
* 提现日期
*/
@ApiModelProperty(value = "提现日期", hidden = true )
private Long crtTime;
/**
* 审核日期
*/
@ApiModelProperty(value = "审核日期")
private Long finishTime;
}
......@@ -14,6 +14,7 @@ import java.math.BigDecimal;
@Data
public class WalletCathVo {
private Long id;
/**
* 用户iD
*/
......
package com.github.wxiaoqi.security.admin.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/15 9:22
*/
@Data
public class WalletDetailPageVo {
@ApiModelProperty("主键ID")
private Integer id;
/**
* 来源:0-活动,1-佣金,2-会员充值,10-提现,11-转账,12-购买
*/
@ApiModelProperty(value = "来源:0-活动,1-佣金,2-会员充值,10-提现,11-转账,12-购买")
private Integer source;
/**
* 收入/支出:0-收入,1-支出
*/
@ApiModelProperty(value = "收入/支出:0-收入,1-支出")
private Integer itype;
/**
* 收入/支出的金额(分)
*/
@ApiModelProperty(value = "收入/支出的金额(分)")
private BigDecimal amount;
/**
* 操作时间
*/
@ApiModelProperty(value = "操作时间", hidden = true )
private Long crtTime;
}
......@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.entity.MyWalletCath;
import com.github.wxiaoqi.security.admin.mapper.MyWalletCathMapper;
import com.github.wxiaoqi.security.admin.vo.WalletCathDetailVo;
import com.github.wxiaoqi.security.admin.vo.WalletCathPageVo;
import com.github.wxiaoqi.security.admin.vo.WalletCathVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
......@@ -15,6 +16,7 @@ import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* @author libin
......@@ -59,4 +61,14 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> {
return walletCathPageVo;
}
public WalletCathDetailVo getWalletCathDetailById(Long id) {
WalletCathDetailVo walletCathDetailVo = new WalletCathDetailVo();
MyWalletCath myWalletCath = new MyWalletCath();
myWalletCath.setId(id);
MyWalletCath walletCath = mapper.selectByPrimaryKey(myWalletCath);
Optional.ofNullable(walletCath).ifPresent(wc->{
BeanUtils.copyProperties(wc,walletCathDetailVo);
});
return walletCathDetailVo;
}
}
......@@ -2,9 +2,17 @@ package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.entity.MyWalletDetail;
import com.github.wxiaoqi.security.admin.mapper.MyWalletDetailMapper;
import com.github.wxiaoqi.security.admin.vo.WalletDetailPageVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -18,4 +26,31 @@ import org.springframework.transaction.annotation.Transactional;
public class MyWalletDetailBiz extends BaseBiz<MyWalletDetailMapper, MyWalletDetail> {
public PageDataVO<WalletDetailPageVo> findWalletDetailPage(Integer userId,Integer pageNo,Integer pageSize){
PageDataVO<WalletDetailPageVo> walletDetailPageVo = new PageDataVO<>();
Example example = new Example(MyWalletDetail.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("userId",userId);
PageDataVO<WalletDetailPageVo> walletDetailPageVoPageDataVO = PageDataVO.pageInfo(pageNo, pageSize, () -> mapper.selectByExample(example));
List<WalletDetailPageVo> walletDetails = walletDetailPageVoPageDataVO.getData();
if (CollectionUtils.isEmpty(walletDetails)){
return walletDetailPageVo;
}
List<WalletDetailPageVo> walletDetailPageVoList = new ArrayList<>();
WalletDetailPageVo walletDetail;
for (WalletDetailPageVo walletDetailPage : walletDetails) {
walletDetail = new WalletDetailPageVo();
BeanUtils.copyProperties(walletDetailPage,walletDetail);
walletDetailPageVoList.add(walletDetail);
}
walletDetailPageVo.setTotalPage(walletDetailPageVoPageDataVO.getTotalPage());
walletDetailPageVo.setTotalCount(walletDetailPageVoPageDataVO.getTotalCount());
walletDetailPageVo.setPageSize(walletDetailPageVoPageDataVO.getPageSize());
walletDetailPageVo.setPageNum(walletDetailPageVoPageDataVO.getPageNum());
walletDetailPageVo.setData(walletDetailPageVoList);
return walletDetailPageVo;
}
}
package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.MyWalletDetailBiz;
import com.github.wxiaoqi.security.admin.vo.WalletDetailPageVo;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/15 9:45
*/
@RestController
@RequestMapping("/walletDetail")
public class MyWalletDetailController {
@Autowired
private MyWalletDetailBiz myWalletDetailBiz;
@Autowired
private UserAuthUtil userAuthUtil;
@Autowired
private UserAuthConfig userAuthConfig;
@GetMapping("/page")
public ObjectRestResponse<PageDataVO<WalletDetailPageVo>> findWalletDetailPage(@RequestParam("pageNo") Integer pageNo,@RequestParam("pageSize") Integer pageSize, HttpServletRequest request) {
try {
IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request));
PageDataVO<WalletDetailPageVo> walletDetailPage = myWalletDetailBiz.findWalletDetailPage(Integer.valueOf(infoFromToken.getId()), pageNo, pageSize);
return ObjectRestResponse.succ(walletDetailPage);
} catch (Exception e) {
throw new BaseException(e);
}
}
}
......@@ -22,10 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
/**
* ${DESCRIPTION}
......@@ -70,14 +68,30 @@ public class PublicController {
ObjectRestResponse userDetailByToken(String token) throws Exception {
String username = userAuthUtil.getInfoFromToken(token).getId();
if (username == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE);
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
}
AppUserDTO userDTO=new AppUserDTO();
Integer userid = Integer.parseInt(username);
return ObjectRestResponse.succ(getAppUserInfoById(userid));
}
@RequestMapping(value = "/app/userinfo-by-id", method = RequestMethod.GET)
public @ResponseBody
ObjectRestResponse<AppUserDTO> userDetailById(Integer id) throws Exception {
if (id == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
}
return ObjectRestResponse.succ(getAppUserInfoById(id));
}
private AppUserDTO getAppUserInfoById(Integer userid) throws IllegalAccessException, InvocationTargetException {
AppUserDTO userDTO=new AppUserDTO();
//获取用户基础信息
AppUserVo userVo = detailBiz.getUserInfoById(userid);
if (userVo == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE);
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户不存在!");}});
}
Integer id= userVo.getId();
Integer positionId=userVo.getPositionId();
......@@ -94,7 +108,7 @@ public class PublicController {
userDTO.setPositionName(userPosition.getName());
}
userDTO.setId(id);
return new ObjectRestResponse<AppUserDetail>().rel(true).data(userDTO);
return userDTO;
}
@RequestMapping(value = "/userinfo-by-uid", method = RequestMethod.GET)
......
package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.MyWalletCathBiz;
import com.github.wxiaoqi.security.admin.vo.WalletCathDetailVo;
import com.github.wxiaoqi.security.admin.vo.WalletCathPageVo;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
......@@ -34,7 +33,8 @@ public class WalletCathController {
@Autowired
private UserAuthConfig userAuthConfig;
@GetMapping
@ApiOperation("提现记录列表")
@GetMapping("/page")
public ObjectRestResponse<WalletCathPageVo> findWatchCatchByWithdrawalState(@RequestParam("state") Integer state,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize,
......@@ -47,4 +47,11 @@ public class WalletCathController {
throw new BaseException(e);
}
}
@ApiOperation("提现详情")
@GetMapping("/detail/{id}")
public ObjectRestResponse<WalletCathDetailVo> getWalletCathDetailById(@PathVariable(value = "id") Long id) {
WalletCathDetailVo walletCathDetailVo = myWalletCathBiz.getWalletCathDetailById(id);
return ObjectRestResponse.succ(walletCathDetailVo);
}
}
......@@ -28,34 +28,35 @@ public class IntegralMQHandler {
@RabbitListener(queues = "integral_queue")
public void integralHandler(Message message, @Headers Map<String, Object> headers, Channel channel) {
try{
String messageId = message.getMessageProperties().getMessageId();
String msg = new String(message.getBody(), "UTF-8");
log.info("接收到的消息:msg = {}, 消息ID是:messageId = {} ", msg, messageId);
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(new Runnable() {
@Override
public void run() {
if(StringUtils.isNotBlank(msg)) {
IntegralUserRecordDto integralUserRecordDto = JSONObject.parseObject(msg, IntegralUserRecordDto.class);
integralUserRecordBiz.add(integralUserRecordDto);
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(new Runnable() {
@Override
public void run() {
try{
String messageId = message.getMessageProperties().getMessageId();
String msg = new String(message.getBody(), "UTF-8");
log.info("接收到的消息:msg = {}, 消息ID是:messageId = {} ", msg, messageId);
if(StringUtils.isNotBlank(msg)) {
IntegralUserRecordDto integralUserRecordDto = JSONObject.parseObject(msg, IntegralUserRecordDto.class);
integralUserRecordBiz.add(integralUserRecordDto);
}
executorService.shutdown();
Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
// 手动签收
channel.basicAck(deliveryTag, false);
}catch (Exception e){
log.info("接收到的消息失败");
try{
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
}catch (IOException i){
i.printStackTrace();
}
e.printStackTrace();
}
});
executorService.shutdown();
Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
// 手动签收
channel.basicAck(deliveryTag, false);
}catch (Exception e){
log.info("接收到的消息失败");
try{
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
}catch (IOException i){
i.printStackTrace();
}
e.printStackTrace();
}
});
}
......
......@@ -24,7 +24,8 @@ spring:
nacos:
config:
server-addr: 127.0.0.1:8848
#共用配置,暂定一个
shared-dataids: common-dev.yaml,mongodb-log-dev.yaml
---
spring:
profiles: pro
......
......@@ -100,4 +100,9 @@ public class Banner {
@Column(name = "type")
@ApiModelProperty(value = "banner类型")
private Integer type;
/**
* 位置 banner位置0 所有 1:推荐 2:拍拍 3:短视频 4:问答
*/
private Integer location;
}
......@@ -11,7 +11,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(scanBasePackages = {
"com.xxfc.platform",
"com.github.wxiaoqi.*"
"com.github.wxiaoqi.security.common.handler",
"com.github.wxiaoqi.security.common.log"
})
@EnableDiscoveryClient
@EnableScheduling
......
......@@ -32,9 +32,9 @@ public class BannerBiz extends BaseBiz<BannerMapper,Banner> {
this.deleteById(id);
}*/
public List<BannerVo> findBannerList(Integer type) {
public List<BannerVo> findBannerList(Integer type,Integer location) {
List<BannerVo> bannerVos = new ArrayList<>();
List<Banner> banners = mapper.findBannerListByType(type);
List<Banner> banners = mapper.findBannerListByType(type,location);
banners.forEach(banner -> {
BannerVo bannerVo = new BannerVo();
bannerVo.setCover(banner.getCover());
......
package com.xxfc.platform.app.mapper;
import com.xxfc.platform.app.entity.Banner;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
......@@ -22,6 +23,6 @@ public interface BannerMapper extends Mapper<Banner> {
List<Banner> findBannerListByisDelOrderByRank(Banner banner);
@Select("select * from `banner` where `is_del`=0 and `type`=#{type} order by rank asc ")
List<Banner> findBannerListByType(Integer type);
List<Banner> findBannerListByType(@Param("type") Integer type,@Param("location") Integer location);
}
......@@ -29,11 +29,11 @@ public class BannerController {
* @return
*/
@GetMapping("/app/unauth/findBannerlist")
public ObjectRestResponse findBannerlist(@RequestParam("type") Integer type){
public ObjectRestResponse findBannerlist(@RequestParam("type") Integer type,@RequestParam(required = false,value = "location") Integer location){
if (type==null) {
return ObjectRestResponse.createDefaultFail();
}
List<BannerVo> bannerList = bannerBiz.findBannerList(type);
List<BannerVo> bannerList = bannerBiz.findBannerList(type,location);
return ObjectRestResponse.succ(bannerList);
}
}
......@@ -24,7 +24,8 @@ spring:
nacos:
config:
server-addr: 127.0.0.1:8848
#共用配置,暂定一个
shared-dataids: common-dev.yaml,mongodb-log-dev.yaml
---
spring:
profiles: pro
......
<?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.xxfc.platform.tour.mapper.TourBannerMapper">
<mapper namespace="com.xxfc.platform.app.mapper.BannerMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.app.entity.Banner" id="bannerMap">
......@@ -14,6 +14,14 @@
<result property="updTime" column="upd_time"/>
<result property="url" column="url"/>
<result property="isDel" column="is_del"/>
<result property="location" column="location"/>
</resultMap>
<select id="findBannerListByType">
select * from `banner` where `is_del`=0 and `type`=#{type}
<if test="location != null">
and `location`=#{location}
</if>
order by rank asc
</select>
</mapper>
\ No newline at end of file
......@@ -19,7 +19,8 @@ import tk.mybatis.spring.annotation.MapperScan;
*/
@SpringBootApplication(scanBasePackages = {
"com.xxfc.platform",
"com.github.wxiaoqi.*"
"com.github.wxiaoqi.security.common.handler",
"com.github.wxiaoqi.security.common.log"
})
@EnableDiscoveryClient
@EnableAceAuthClient
......
......@@ -12,6 +12,7 @@ import com.xxfc.platform.campsite.mapper.CampsiteShopTagMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.time.Instant;
import java.util.List;
......@@ -76,4 +77,12 @@ public class CampsiteShopTagBiz extends BaseBiz<CampsiteShopTagMapper,CampsiteSh
}
return effectRows;
}
public boolean checkTagHashBindByTagId(Integer tagId){
Example example = new Example(CampsiteShopTag.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("",tagId);
List<CampsiteShopTag> shopTags = mapper.selectByExample(example);
return shopTags==null?false:shopTags.size()>0?true:false;
}
}
\ No newline at end of file
......@@ -2,12 +2,13 @@ package com.xxfc.platform.campsite.biz;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.sun.org.apache.regexp.internal.RE;
import com.xxfc.platform.campsite.dto.CampsiteTagListDTO;
import com.xxfc.platform.campsite.vo.CampsiteTagListVo;
import com.xxfc.platform.campsite.vo.CampsiteTagVo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xxfc.platform.campsite.entity.CampsiteTag;
......@@ -26,6 +27,9 @@ import java.util.List;
*/
@Service
public class CampsiteTagBiz extends BaseBiz<CampsiteTagMapper,CampsiteTag> {
@Autowired
private CampsiteShopTagBiz campsiteShopTagBiz;
/**
* 查询营地列表
......@@ -46,7 +50,11 @@ public class CampsiteTagBiz extends BaseBiz<CampsiteTagMapper,CampsiteTag> {
* @return
*/
public int updateCampsiteTagStatus(Integer tagId) {
return mapper.updateCampsiteTagStatusById(tagId,1);
boolean isBinding = campsiteShopTagBiz.checkTagHashBindByTagId(tagId);
if (isBinding){
throw new BaseException("该类型标签已经被占用",400);
}
return mapper.updateCampsiteTagStatusById(tagId,1);
}
/**
......@@ -74,6 +82,7 @@ public class CampsiteTagBiz extends BaseBiz<CampsiteTagMapper,CampsiteTag> {
* @return
*/
public int updateCampsiteTagIsSearchStatus(Integer id, Integer status) {
return mapper.updateCampsiteTagIsearchStatusById(id,status);
}
......
......@@ -14,6 +14,8 @@ spring:
nacos:
config:
server-addr: 127.0.0.1:8848
#共用配置,暂定一个
shared-dataids: common-dev.yaml,mongodb-log-dev.yaml
---
spring:
......
......@@ -120,6 +120,13 @@
<artifactId>swagger-spring-boot-starter</artifactId>
<version>1.8.0.RELEASE</version>
</dependency>
<!-- mongodb -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -49,10 +49,6 @@
</dependency>
<!--mongodb-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb.morphia</groupId>
<artifactId>morphia</artifactId>
......
......@@ -13,7 +13,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(scanBasePackages = {
"com.xxfc.platform",
"com.github.wxiaoqi.*"
"com.github.wxiaoqi.security.common.handler",
"com.github.wxiaoqi.security.common.log"
},exclude = DataSourceAutoConfiguration.class)
@EnableDiscoveryClient
@EnableScheduling
......
......@@ -17,7 +17,14 @@ public enum OrderTypeEnum {
*/
private String desc;
private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>();
public static Map<Integer, OrderTypeEnum> codeAndDesc = new HashMap<Integer, OrderTypeEnum>();
//Maps.newHashMap();
static{
for(OrderTypeEnum enumE : OrderTypeEnum.values()){
codeAndDesc.put(enumE.getCode(), enumE);
}
}
OrderTypeEnum(Integer code, String desc){
this.code=code;
......
......@@ -19,11 +19,11 @@ public enum RefundTypeEnum {
private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>();
//Maps.newHashMap();
// static{
// for(VehicleBookRecordStatus constantType : VehicleBookRecordStatus.values()){
// codeAndDesc.put(constantType.getCode(),constantType.getDesc());
// }
// }
static{
for(RefundTypeEnum enumE : RefundTypeEnum.values()){
codeAndDesc.put(enumE.getCode(),enumE.getDesc());
}
}
RefundTypeEnum(Integer code, String desc){
this.code=code;
......
......@@ -13,7 +13,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(scanBasePackages = {
"com.xxfc.platform",
"com.github.wxiaoqi.*"
"com.github.wxiaoqi.security.common.handler",
"com.github.wxiaoqi.security.common.log"
})
@EnableDiscoveryClient
@EnableScheduling
......
package com.xxfc.platform.order.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
......@@ -19,6 +21,7 @@ import com.xxfc.platform.order.pojo.order.OrderListVo;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto;
import com.xxfc.platform.tour.feign.TourFeign;
import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.vo.OrderRefundVo;
import com.xxfc.platform.vehicle.common.RestResponse;
......@@ -387,7 +390,10 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
* @param orderNo
* @param tradeNo
*/
@Transactional
public void payNotifyHandle(String orderNo, String tradeNo, Integer type) {
OrderRentVehicleDetail orvd = new OrderRentVehicleDetail();
OrderMemberDetail omd = new OrderMemberDetail();
BaseOrder baseOrder = this.selectOne(new BaseOrder() {{
setNo(orderNo);
}});
......@@ -406,23 +412,25 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
if(OrderTypeEnum.MEMBER.getCode().equals(baseOrder.getType())) {
//直接设置订单完成
updateOrder.setStatus(OrderStatusEnum.ORDER_FINISH.getCode());
OrderMemberDetail omd = orderMemberDetailBiz.selectOne(new OrderMemberDetail(){{
omd = orderMemberDetailBiz.selectOne(new OrderMemberDetail(){{
setOrderId(baseOrder.getId());
}});
//触发会员效益
ObjectRestResponse orr = userFeign.buyMember(new UserMemberDTO() {{
UserMemberDTO userMemberDTO = new UserMemberDTO() {{
setUserId(baseOrder.getUserId());
setDiscount(omd.getRebate());
setIsBind(ISBIND_BIND);
setMemberLevel(omd.getMemberLevel());
setRentFreeDays(omd.getRentFreeNum());
setTotalNumber(omd.getRentFreeNum());
}});
}};
userMemberDTO.setMemberLevel(omd.getMemberLevel());
userMemberDTO.setRentFreeDays(omd.getRentFreeNum());
userMemberDTO.setTotalNumber(omd.getRentFreeNum());
userMemberDTO.setDiscount(omd.getRebate());
ObjectRestResponse orr = userFeign.buyMember(userMemberDTO);
log.info("orr.getStatus() : " + orr.getStatus() );
}else if(OrderTypeEnum.RENT_VEHICLE.getCode().equals(baseOrder.getType())) {
updateOrder.setStatus(OrderStatusEnum.ORDER_TOSTART.getCode());
OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{
orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{
setOrderId(baseOrder.getId());
}});
//车辆预定审核通过
......@@ -441,7 +449,49 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
//站点总人数添加
tourFeign.updateTourGoodPersonNum(otd.getVerificationId(), TourFeign.TOTAL_PERSON, otd.getTotalNumber());
}
this.updateSelectiveByIdRe(updateOrder);
try {
this.updateSelectiveByIdRe(updateOrder);
}finally {
OrderTypeEnum orderTypeEnum = OrderTypeEnum.codeAndDesc.get(baseOrder.getType());
AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData();
Integer smstype;
List<String> smsParams = new ArrayList<String>();
smsParams.add(baseOrder.getRealAmount().toString());
switch (orderTypeEnum) {
case RENT_VEHICLE:
if(orvd.getFreeDays() > 0) {
smstype = SmsTemplateDTO.RENT_MEMENT;
smsParams.add(orvd.getFreeDays().toString());
smsParams.add(appUserDTO.getRentFreeDays().toString());
}else {
smstype = SmsTemplateDTO.RENT_NORMAL;
}
thirdFeign.sendTemplate(new SmsTemplateDTO(){{
setPhoneNumbers(appUserDTO.getUsername());
setType(smstype);
setParams(smsParams.toArray(new String[smsParams.size()]));
}});
break;
case TOUR:
thirdFeign.sendTemplate(new SmsTemplateDTO(){{
setPhoneNumbers(appUserDTO.getUsername());
setType(SmsTemplateDTO.TOUR);
setParams(smsParams.toArray(new String[smsParams.size()]));
}});
break;
case MEMBER:
smsParams.add(omd.getRentFreeNum().toString());
smsParams.add(appUserDTO.getRentFreeDays().toString());
thirdFeign.sendTemplate(new SmsTemplateDTO(){{
setPhoneNumbers(appUserDTO.getUsername());
setType(SmsTemplateDTO.MEMENT);
setParams(smsParams.toArray(new String[smsParams.size()]));
}});
break;
default:
break;
}
}
} else {
log.error(" order has payed , orderNo:{}, tradeNo:{} ", orderNo, tradeNo);
}
......
......@@ -207,7 +207,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
}
//商品价格
goodsAmount = goodsAmount.add(vehicleAmount).add(driverAmount);
goodsAmount = goodsAmount.add(vehicleAmount).add(driverAmount).add(damageSafeAmount);
//总价格(包含押金)
orderAmount = orderAmount.add(goodsAmount).add(vehicleModel.getDeposit());
......
......@@ -14,8 +14,8 @@ spring:
nacos:
config:
server-addr: 127.0.0.1:8848
#共用配置,暂定一个
shared-dataids: commonaaa-dev.yaml
#共用配置,+ mongodb日志配置
shared-dataids: common-dev.yaml,mongodb-log-dev.yaml
#---
#spring:
......
#spring:
# application:
# name: vehicle
# cloud:
# nacos:
# config:
# server-addr: 127.0.0.1:8848
# file-extension: yaml
# profiles:
# active: dev
spring:
profiles:
active: dev
application:
name: xx-tour
cloud:
nacos:
config:
file-extension: yaml
debug: true
feign:
compression:
response:
enabled: true
request:
enabled: true
logging:
level:
com.github.wxiaoqi: debug
com.xxfc: debug
---
spring:
profiles: dev
cloud:
nacos:
config:
server-addr: 127.0.0.1:8848
---
spring:
profiles: pro
cloud:
nacos:
config:
#spring:
# application:
# name: vehicle
# cloud:
# nacos:
# config:
# server-addr: 127.0.0.1:8848
# file-extension: yaml
# profiles:
# active: dev
spring:
profiles:
active: dev
application:
name: xx-tour
cloud:
nacos:
config:
file-extension: yaml
debug: true
feign:
compression:
response:
enabled: true
request:
enabled: true
logging:
level:
com.github.wxiaoqi: debug
com.xxfc: debug
---
spring:
profiles: dev
cloud:
nacos:
config:
server-addr: 127.0.0.1:8848
#共用配置,暂定一个
shared-dataids: common-dev.yaml,mongodb-log-dev.yaml
---
spring:
profiles: pro
cloud:
nacos:
config:
server-addr: 10.5.52.2:8848
\ No newline at end of file
......@@ -88,7 +88,7 @@
from tour_good g
LEFT JOIN tour_good_tag tag ON g.id=tag.good_id
LEFT JOIN tour_tag t ON tag.tag_id=t.id
where g.recommend=1 and g.status=1 and g.is_del=0
where g.recommend=1 and g.status=1 and g.is_del=0 and t.is_del=0
GROUP BY g.id
ORDER BY g.rank DESC ,g.id DESC
limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER}
......@@ -104,7 +104,7 @@
LEFT JOIN tour_good_tag tag ON g.id=tag.good_id
LEFT JOIN tour_tag t ON tag.tag_id=t.id
<where>
g.is_del=0
g.is_del=0 and t.is_del=0
<if test="params.name != null and params.name != ''">
and (g.`name` like CONCAT('%',#{params.name},'%') or g.introduce like CONCAT('%',#{params.name},'%'))
</if>
......
......@@ -39,12 +39,27 @@
<artifactId>jdom</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>5.2</version>
</dependency>
<!-- httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
<!-- 短信机-->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>
......
package com.xxfc.platform.universal.dto;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/3 17:51
*/
@Data
public class SmsTemplateDTO {
public static final int RENT_NORMAL = 1;
public static final int RENT_MEMENT = 2;
public static final int TOUR = 3;
public static final int MEMENT = 4;
//类型:1-租车订单通知(普通用户),2-租车订单短信(会员权益),3-旅游订单短信,4-加入会员通知
private Integer type;
//手机号码(多个短信逗号隔开)
private String phoneNumbers;
//参数
private String[] params;
}
......@@ -3,6 +3,7 @@ package com.xxfc.platform.universal.feign;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.dto.RegionDTO;
import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.OrderRefund;
import com.xxfc.platform.universal.vo.*;
......@@ -29,6 +30,9 @@ public interface ThirdFeign {
@RequestMapping(value = "/sms/app/unauth/sendCode", method = RequestMethod.GET)
//发送短信模板消息
public JSONObject sendCode(@RequestParam("phone") String phone, @RequestParam("code")String code, @RequestParam("templateCode")String templateCode );
//云通讯短信机
@RequestMapping(value = "/sms/app/unauth/sendTemplate", method = RequestMethod.POST)
public ObjectRestResponse sendTemplate(SmsTemplateDTO smsTemplateDTO);
@RequestMapping(value = "/file/app/unauth/uploadFiles", method = RequestMethod.POST)
public JSONObject uploadFiles(@RequestParam(value = "files") MultipartFile[] files);
@RequestMapping(value = "/pay/app/wx", method = RequestMethod.POST)
......
package com.xxfc.platform.universal.filter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
public class AcceptFilter extends Filter<ILoggingEvent> {
@Override
public FilterReply decide(ILoggingEvent event) {
return event.getLoggerName().startsWith("com.xxfc.platform") ? FilterReply.ACCEPT : FilterReply.DENY;
}
}
\ No newline at end of file
package com.xxfc.platform.universal.filter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
public class DenyFilter extends Filter<ILoggingEvent> {
@Override
public FilterReply decide(ILoggingEvent event) {
return event.getLoggerName().startsWith("com.xxfc.platform") ? FilterReply.DENY : FilterReply.ACCEPT;
}
}
\ No newline at end of file
......@@ -3,10 +3,8 @@ package com.xxfc.platform.universal.mq;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.transaction.RabbitTransactionManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
......@@ -54,12 +52,4 @@ public class MQAutoConfiguration {
factory.setMaxConcurrentConsumers(10);
return factory;
}
/**
* 配置启用rabbitmq事务
*/
@Bean
public RabbitTransactionManager rabbitTransactionManager(CachingConnectionFactory connectionFactory) {
return new RabbitTransactionManager(connectionFactory);
}
}
package com.xxfc.platform.universal.utils;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class CCPRestSmsUtils {
public static CCPRestSDK restAPI;
static {
restAPI = new CCPRestSDK();
restAPI.init("app.cloopen.com", "8883");
restAPI.setAccount("8aaf070865e6b6eb0165ecd776700559",
"3fe5e2f053674f23b029a9a9fc9503f0");
restAPI.setAppId("8a216da86812593601684bec10581ab5");
}
public static Map<String, Object> sendTemplateSMS(String phoneNumbers, String[] params, String templateId) {
HashMap<String, Object> result = null;
result = restAPI.sendTemplateSMS(phoneNumbers, templateId, params);
System.out.println("SDKTestGetSubAccounts result=" + result);
if ("000000".equals(result.get("statusCode"))) {
// 正常返回输出data包体信息(map)
HashMap<String, Object> data = (HashMap<String, Object>) result.get("data");
Set<String> keySet = data.keySet();
for (String key : keySet) {
Object object = data.get(key);
System.out.println(key + " = " + object);
}
} else {
// 异常返回输出错误码和错误信息
System.out.println("错误码=" + result.get("statusCode") + " 错误信息= " + result.get("statusMsg"));
}
return result;
}
}
\ No newline at end of file
package com.xxfc.platform.universal.utils;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.Principal;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
public class CcopHttpClient
{
public DefaultHttpClient registerSSL(String hostname, String protocol, int port, String scheme)
throws NoSuchAlgorithmException, KeyManagementException
{
DefaultHttpClient httpclient = new DefaultHttpClient();
SSLContext ctx = SSLContext.getInstance(protocol);
X509TrustManager tm = new X509TrustManager()
{
public void checkClientTrusted(X509Certificate[] chain,String authType)
throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] chain,String authType)
throws CertificateException {
if ((chain == null) || (chain.length == 0))
throw new IllegalArgumentException("null or zero-length certificate chain");
if ((authType == null) || (authType.length() == 0))
throw new IllegalArgumentException("null or zero-length authentication type");
boolean br = false;
Principal principal = null;
for (X509Certificate x509Certificate : chain) {
principal = x509Certificate.getSubjectX500Principal();
if (principal != null) {
br = true;
return;
}
}
if (!(br))
throw new CertificateException("服务端证书验证失败!");
}
public X509Certificate[] getAcceptedIssuers()
{
return new X509Certificate[0];
}
};
ctx.init(null, new TrustManager[] { tm }, new SecureRandom());
SSLSocketFactory socketFactory = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
Scheme sch = new Scheme(scheme, port, socketFactory);
httpclient.getConnectionManager().getSchemeRegistry().register(sch);
return httpclient;
}
}
\ No newline at end of file
......@@ -48,7 +48,6 @@ public class CertifHttpUtils {
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpGet request = new HttpGet(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
......
/*
* Copyright (c) 2014 The CCP project authors. All Rights Reserved.
*
* Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
* that can be found in the LICENSE file in the root of the web site.
*
* http://www.yuntongxun.com
*
* An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package com.xxfc.platform.universal.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateUtil
{
public static final int DEFAULT = 0;
public static final int YM = 1;
public static final int YMR_SLASH = 11;
public static final int NO_SLASH = 2;
public static final int YM_NO_SLASH = 3;
public static final int DATE_TIME = 4;
public static final int DATE_TIME_NO_SLASH = 5;
public static final int DATE_HM = 6;
public static final int TIME = 7;
public static final int HM = 8;
public static final int LONG_TIME = 9;
public static final int SHORT_TIME = 10;
public static final int DATE_TIME_LINE = 12;
public static String dateToStr(Date date, String pattern)
{
if ((date == null) || (date.equals("")))
return null;
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
return formatter.format(date);
}
public static String dateToStr(Date date) {
return dateToStr(date, "yyyy/MM/dd");
}
public static String dateToStr(Date date, int type) {
switch (type)
{
case 0:
return dateToStr(date);
case 1:
return dateToStr(date, "yyyy/MM");
case 2:
return dateToStr(date, "yyyyMMdd");
case 11:
return dateToStr(date, "yyyy-MM-dd");
case 3:
return dateToStr(date, "yyyyMM");
case 4:
return dateToStr(date, "yyyy/MM/dd HH:mm:ss");
case 5:
return dateToStr(date, "yyyyMMddHHmmss");
case 6:
return dateToStr(date, "yyyy/MM/dd HH:mm");
case 7:
return dateToStr(date, "HH:mm:ss");
case 8:
return dateToStr(date, "HH:mm");
case 9:
return dateToStr(date, "HHmmss");
case 10:
return dateToStr(date, "HHmm");
case 12:
return dateToStr(date, "yyyy-MM-dd HH:mm:ss");
}
throw new IllegalArgumentException("Type undefined : " + type);
}
}
\ No newline at end of file
/*
* Copyright (c) 2014 The CCP project authors. All Rights Reserved.
*
* Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
* that can be found in the LICENSE file in the root of the web site.
*
* http://www.yuntongxun.com
*
* An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package com.xxfc.platform.universal.utils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import cn.hutool.core.codec.Base64;
public class EncryptUtil
{
private static final String UTF8 = "utf-8";
public String md5Digest(String src) throws NoSuchAlgorithmException, UnsupportedEncodingException
{
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] b = md.digest(src.getBytes("utf-8"));
return byte2HexStr(b);
}
public String base64Encoder(String src) throws UnsupportedEncodingException
{
// BASE64Encoder encoder = new BASE64Encoder();
return Base64.encode(src.getBytes("utf-8"));
}
public String base64Decoder(String dest)
throws NoSuchAlgorithmException, IOException
{
// BASE64Decoder decoder = new BASE64Decoder();
return new String(Base64.decode(dest), "utf-8");
}
private String byte2HexStr(byte[] b)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < b.length; ++i) {
String s = Integer.toHexString(b[i] & 0xFF);
if (s.length() == 1) {
sb.append("0");
}
sb.append(s.toUpperCase());
}
return sb.toString();
}
}
\ No newline at end of file
package com.xxfc.platform.universal.utils;
public class PublicMsg {
public final static String UEDITOR_CONFIG = "{\n" +
" \"imageActionName\": \"uploadimage\",\n" +
" \"imageFieldName\": \"upfile\",\n" +
" \"imageMaxSize\": 2048000,\n" +
" \"imageAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"],\n" +
" \"imageCompressEnable\": true,\n" +
" \"imageCompressBorder\": 1600,\n" +
" \"imageInsertAlign\": \"none\",\n" +
" \"imageUrlPrefix\": \"\",\n" +
" \"imagePathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
"\n" +
" \"scrawlActionName\": \"uploadscrawl\",\n" +
" \"scrawlFieldName\": \"upfile\",\n" +
" \"scrawlPathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
" \"scrawlMaxSize\": 2048000,\n" +
" \"scrawlUrlPrefix\": \"\",\n" +
" \"scrawlInsertAlign\": \"none\",\n" +
"\n" +
" \"snapscreenActionName\": \"uploadimage\",\n" +
" \"snapscreenPathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
" \"snapscreenUrlPrefix\": \"\",\n" +
" \"snapscreenInsertAlign\": \"none\",\n" +
"\n" +
" \"catcherLocalDomain\": [\"127.0.0.1\", \"localhost\", \"img.baidu.com\"],\n" +
" \"catcherActionName\": \"catchimage\",\n" +
" \"catcherFieldName\": \"source\",\n" +
" \"catcherPathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
" \"catcherUrlPrefix\": \"\",\n" +
" \"catcherMaxSize\": 2048000,\n" +
" \"catcherAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"],\n" +
"\n" +
" \"videoActionName\": \"uploadvideo\",\n" +
" \"videoFieldName\": \"upfile\",\n" +
" \"videoPathFormat\": \"/ueditor/jsp/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
" \"videoUrlPrefix\": \"\",\n" +
" \"videoMaxSize\": 102400000,\n" +
" \"videoAllowFiles\": [\n" +
" \".flv\", \".swf\", \".mkv\", \".avi\", \".rm\", \".rmvb\", \".mpeg\", \".mpg\",\n" +
" \".ogg\", \".ogv\", \".mov\", \".wmv\", \".mp4\", \".webm\", \".mp3\", \".wav\", \".mid\"],\n" +
"\n" +
" \"fileActionName\": \"uploadfile\",\n" +
" \"fileFieldName\": \"upfile\",\n" +
" \"filePathFormat\": \"/ueditor/jsp/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
" \"fileUrlPrefix\": \"\",\n" +
" \"fileMaxSize\": 51200000,\n" +
" \"fileAllowFiles\": [\n" +
" \".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\",\n" +
" \".flv\", \".swf\", \".mkv\", \".avi\", \".rm\", \".rmvb\", \".mpeg\", \".mpg\",\n" +
" \".ogg\", \".ogv\", \".mov\", \".wmv\", \".mp4\", \".webm\", \".mp3\", \".wav\", \".mid\",\n" +
" \".rar\", \".zip\", \".tar\", \".gz\", \".7z\", \".bz2\", \".cab\", \".iso\",\n" +
" \".doc\", \".docx\", \".xls\", \".xlsx\", \".ppt\", \".pptx\", \".pdf\", \".txt\", \".md\", \".xml\"\n" +
" ],\n" +
"\n" +
" \"imageManagerActionName\": \"listimage\",\n" +
" \"imageManagerListPath\": \"/ueditor/jsp/upload/image/\",\n" +
" \"imageManagerListSize\": 20,\n" +
" \"imageManagerUrlPrefix\": \"\",\n" +
" \"imageManagerInsertAlign\": \"none\",\n" +
" \"imageManagerAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"],\n" +
"\n" +
" \"fileManagerActionName\": \"listfile\",\n" +
" \"fileManagerListPath\": \"/ueditor/jsp/upload/file/\",\n" +
" \"fileManagerUrlPrefix\": \"\",\n" +
" \"fileManagerListSize\": 20,\n" +
" \"fileManagerAllowFiles\": [\n" +
" \".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\",\n" +
" \".flv\", \".swf\", \".mkv\", \".avi\", \".rm\", \".rmvb\", \".mpeg\", \".mpg\",\n" +
" \".ogg\", \".ogv\", \".mov\", \".wmv\", \".mp4\", \".webm\", \".mp3\", \".wav\", \".mid\",\n" +
" \".rar\", \".zip\", \".tar\", \".gz\", \".7z\", \".bz2\", \".cab\", \".iso\",\n" +
" \".doc\", \".docx\", \".xls\", \".xlsx\", \".ppt\", \".pptx\", \".pdf\", \".txt\", \".md\", \".xml\"\n" +
" ] \n" +
"\n" +
"}";
/**
* Ueditor的返回状态类型
*/
public enum UeditorMsg{
SUCCESS("SUCCESS"),ERROR("上传失败");
private String v;
UeditorMsg(String v){
this.v =v;
}
public String get(){
return this.v;
}
}
}
\ No newline at end of file
package com.xxfc.platform.universal.vo;
import lombok.Data;
@Data
public class Ueditor {
private String url;
private String original;
private String state;
private String title;
}
......@@ -27,6 +27,12 @@
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
</exclusions>
<version>4.4.2</version>
</dependency>
<dependency>
......
......@@ -13,7 +13,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication(scanBasePackages = {
"com.xxfc.platform",
"com.github.wxiaoqi.*"
"com.github.wxiaoqi.security.common.handler",
"com.github.wxiaoqi.security.common.log"
})
@EnableDiscoveryClient
@EnableAceAuthClient
......
package com.xxfc.platform.universal.biz;
import com.xxfc.platform.universal.utils.CCPRestSmsUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class CCPRestSmsBiz{
//租车订单通知(普通用户)1
public static final String TEMPLATE_ID_ORDER = "457270";
//租车订单短信(会员权益)2
public static final String TEMPLATE_ID_ORDER_MEMBER = "457271";
//旅游订单短信3
public static final String TEMPLATE_ID_ORDER_TOUR = "457272";
//加入会员通知4
public static final String TEMPLATE_ID_MEMBER = "457273";
//发送模板消息
public void sendTemplateSMS(Integer type,String phoneNumbers,String[]params){
switch (type){
case 1 :
CCPRestSmsUtils.sendTemplateSMS(phoneNumbers,params,TEMPLATE_ID_ORDER);
break;
case 2 :
CCPRestSmsUtils.sendTemplateSMS(phoneNumbers,params,TEMPLATE_ID_ORDER_MEMBER);
break;
case 3 :
CCPRestSmsUtils.sendTemplateSMS(phoneNumbers,params,TEMPLATE_ID_ORDER_TOUR);
break;
case 4 :
CCPRestSmsUtils.sendTemplateSMS(phoneNumbers,params,TEMPLATE_ID_MEMBER);
break;
}
}
}
......@@ -7,6 +7,7 @@ import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.UUID;
......@@ -16,6 +17,7 @@ public class MQServiceBiZ {
private RabbitTemplate rabbitTemplate;
@Transactional(rollbackFor = Exception.class)
public ObjectRestResponse sendMessage(String exchange, String routKey, String json) {
Message message = MessageBuilder.withBody(json.getBytes())
.setContentType(MessageProperties.CONTENT_TYPE_JSON).setContentEncoding("utf-8")
......
......@@ -3,15 +3,15 @@ package com.xxfc.platform.universal.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.universal.biz.CCPRestSmsBiz;
import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.service.SmsService;
import com.xxfc.platform.universal.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
......@@ -29,6 +29,9 @@ public class SmsController {
@Autowired
SmsService smsService;
@Autowired
CCPRestSmsBiz smsBiz;
@RequestMapping(value = "/app/unauth/send", method = RequestMethod.GET) //匹配的是href中的download请求
public JSONObject sendSms(@RequestParam("phone") String phone) throws Exception {
return smsService.smsCode(phone);
......@@ -40,5 +43,17 @@ public class SmsController {
@RequestParam("templateCode")String templateCode ) throws Exception {
return smsService.smsByCode(phone,code,templateCode);
}
@RequestMapping(value = "/app/unauth/sendTemplate", method = RequestMethod.POST)
public ObjectRestResponse sendTemplate(@RequestBody SmsTemplateDTO smsTemplateDTO) throws Exception {
if(smsTemplateDTO==null){
return ObjectRestResponse.createDefaultFail();
}
Integer type=smsTemplateDTO.getType();
String[] params=smsTemplateDTO.getParams();
String phoneNumbers=smsTemplateDTO.getPhoneNumbers();
smsBiz.sendTemplateSMS(type,phoneNumbers,params);
return ObjectRestResponse.succ();
}
}
......@@ -4,16 +4,17 @@ import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.universal.service.UploadService;
import com.xxfc.platform.universal.utils.PublicMsg;
import com.xxfc.platform.universal.vo.Ueditor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
/**
* 图片上传
......@@ -96,5 +97,24 @@ public class UploadController{
return JsonResultUtil.createDefaultFail();
}
//以下是图片上传的方法
@RequestMapping(value="/app/unauth/ueditor")
@ResponseBody
public String ueditor(HttpServletRequest request) {
return PublicMsg.UEDITOR_CONFIG;
}
@RequestMapping(value="/app/unauth/ueditor", method = RequestMethod.POST)
public Ueditor imgUpload(MultipartFile upfile) throws Exception {
Ueditor ueditor = new Ueditor();
ueditor.setUrl(uploadService.uploadFile(upfile,"admin"));
ueditor.setOriginal(upfile.getOriginalFilename());
ueditor.setState("SUCCESS");
ueditor.setTitle(upfile.getOriginalFilename());
return ueditor;
}
}
......@@ -46,4 +46,4 @@ certif.expirationDateName=expiryDate
#\u63A5\u53E3appcode
ALIYUN.CODE=acea1c8811f748b3a65815f11db357c4
#\u8FD4\u56DE\u53C2\u6570\u7C7B\u578B(HTML/JSON/JSONP/XML)
RETURN.TYPE=JSON
\ No newline at end of file
RETURN.TYPE=JSON
logging:
config: classpath:logback.xml
level:
com.xxfc.platform.universal:
debug
com.xxfc.platform.common:
debug
\ No newline at end of file
......@@ -17,6 +17,7 @@ spring:
nacos:
config:
file-extension: yaml
---
spring:
profiles: dev
......@@ -24,7 +25,8 @@ spring:
nacos:
config:
server-addr: 127.0.0.1:8848
#共用配置,暂定一个
shared-dataids: common-dev.yaml,mongodb-log-dev.yaml
---
spring:
profiles: pro
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径 -->
<property name="LOG_HOME" value="${system.log.path:-logs}"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <!--1. 输出到控制台-->
<encoder>
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
<charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder>
</appender>
<appender name="SYSTEM_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"><!-- 按照每天生成日志文件 -->
<filter class="com.xxfc.platform.universal.filter.DenyFilter"></filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${LOG_HOME}/sys.%d{yyyy-MM-dd}.log</FileNamePattern><!--日志文件输出的文件名 -->
<MaxHistory>30</MaxHistory><!--日志文件保留天数 -->
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n</pattern><!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
</encoder>
</appender>
<appender name="WEB_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"><!-- 按照每天生成日志文件 -->
<filter class="com.xxfc.platform.universal.filter.AcceptFilter"></filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${LOG_HOME}/log.%d{yyyy-MM-dd}.log</FileNamePattern><!--日志文件输出的文件名 -->
<MaxHistory>30</MaxHistory><!--日志文件保留天数 -->
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n</pattern><!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
</encoder>
</appender>
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>192.168.0.181:5044</destination>
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder" >
<!--"appname":"springboot21-log-elk" 的作用是指定创建索引的名字时用,并且在生成的文档中会多了这个字段
在logstashindex中引入 index => "%{[appname]}-%{+YYYY.MM.dd}"-->
<customFields>{"appName":"elk-log-service-operate-dev"}</customFields>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
......@@ -11,7 +11,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(scanBasePackages = {
"com.xxfc.platform",
"com.github.wxiaoqi.*"
"com.github.wxiaoqi.security.common.handler",
"com.github.wxiaoqi.security.common.log"
})
@EnableDiscoveryClient
@EnableScheduling
......
......@@ -4,6 +4,7 @@ import com.github.wxiaoqi.security.auth.client.interceptor.ServiceAuthRestInterc
import com.github.wxiaoqi.security.auth.client.interceptor.UserAuthRestInterceptor;
import com.github.wxiaoqi.security.common.handler.GlobalExceptionHandler;
import com.github.wxiaoqi.security.common.interceptor.CorsInterceptor;
import com.github.wxiaoqi.security.common.log.XxLogInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
......@@ -33,7 +34,6 @@ public class WebConfiguration implements WebMvcConfigurer {
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(getCorsInterceptor()).addPathPatterns("/**");
registry.addInterceptor(getServiceAuthRestInterceptor()).
addPathPatterns(getIncludePathPatterns());
......@@ -41,6 +41,13 @@ public class WebConfiguration implements WebMvcConfigurer {
addPathPatterns(getIncludePathPatterns());
}
// @Bean
// XxLogInterceptor getXxLogInterceptor() {
// return new XxLogInterceptor();
// }
@Bean
ServiceAuthRestInterceptor getServiceAuthRestInterceptor() {
return new ServiceAuthRestInterceptor();
......
......@@ -25,7 +25,7 @@ spring:
config:
server-addr: 127.0.0.1:8848
#共用配置,暂定一个
shared-dataids: common-dev.yaml
shared-dataids: common-dev.yaml,mongodb-log-dev.yaml
---
spring:
......
......@@ -365,7 +365,7 @@
</if>
<!-- yearNo4Where 标识时间参数不用于where条件,用于select部分 -->
<if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true">
,(
,max(
<foreach collection="yearMonthAndParam" index="yearMonth" item="andOperation" separator="and">
<include refid="yearMonthAndParamSql"></include>
</foreach>
......@@ -380,7 +380,7 @@
and bc.id is not null
GROUP BY model_id, company_id
<if test="lon != null and lat != null">, distance</if>
<if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true">, hasVehicle</if>
<!--<if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true">, hasVehicle</if>-->
<!-- 循环 相同父级 数据做并集, 不同父级做或集 -->
<if test=" catas != null ">
......
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