use of com.tony.billing.response.BaseResponse in project BillingDubbo by TonyJiangWJ.
the class ResponseUtil method error.
public static BaseResponse error(String message) {
BaseResponse response = error();
response.setMsg(message);
return response;
}
use of com.tony.billing.response.BaseResponse in project BillingDubbo by TonyJiangWJ.
the class LoginResultInterceptor method getResult.
@AfterReturning(returning = "returnValue", pointcut = "execution(* com.tony.billing.controller.AdminController.login(..))")
public void getResult(JoinPoint point, Object returnValue) {
Object[] args = point.getArgs();
AdminLoginRequest loginRequest = (AdminLoginRequest) args[0];
HttpServletRequest httpServletRequest = (HttpServletRequest) args[1];
BaseResponse response = (BaseResponse) returnValue;
LoginLog loginLog = new LoginLog();
loginLog.setLoginIp(getLoginIp(httpServletRequest));
if (loginRequest.getUserName() != null) {
loginLog.setUserName(loginRequest.getUserName());
} else {
loginLog.setUserName("未知");
}
loginLog.setLoginResult(JSON.toJSONString(response));
loginLog.setCode(response.getCode());
loginLog.setMsg(response.getMsg());
Long id = loginLogService.addLog(loginLog);
logger.info("{} 请求登录, 结果:{}", loginLog.getUserName(), loginLog.getLoginResult());
logger.info("ip地址:{}", loginLog.getLoginIp());
if (id != null) {
logger.info("日志保存成功,id:{}", id);
} else {
logger.error("日志保存失败");
}
}
use of com.tony.billing.response.BaseResponse in project BillingDubbo by TonyJiangWJ.
the class TagInfoController method putCostTag.
/**
* 添加账单标签
*
* @param request
* @return
*/
@RequestMapping(value = "/cost/tag/put")
public BaseResponse putCostTag(@ModelAttribute("request") @Validated CostTagPutRequest request) {
BaseResponse response = new BaseResponse();
try {
CostRecord costRecord = costRecordService.findByTradeNo(request.getTradeNo(), request.getUserId());
TagInfo tagInfo = tagInfoService.getTagInfoById(request.getTagId());
if (costRecord != null && tagInfo != null) {
TagCostRef ref = new TagCostRef();
ref.setCostId(costRecord.getId());
ref.setTagId(tagInfo.getId());
if (tagInfoService.insertTagCostRef(ref) > 0) {
ResponseUtil.success(response);
} else {
ResponseUtil.error(response);
}
} else {
ResponseUtil.paramError(response);
}
} catch (Exception e) {
logger.error("/cost/tag/put error", e);
ResponseUtil.sysError(response);
}
return response;
}
use of com.tony.billing.response.BaseResponse in project BillingDubbo by TonyJiangWJ.
the class TagInfoController method putTag.
/**
* 添加标签
*
* @param request
* @return
*/
@RequestMapping(value = "/tag/put")
public BaseResponse putTag(@ModelAttribute("request") @Validated TagInfoPutRequest request) {
BaseResponse response = new BaseResponse();
try {
TagInfo tagInfo = new TagInfo();
tagInfo.setTagName(request.getTagName());
tagInfo.setUserId(request.getUserId());
if (tagInfoService.putTagInfo(tagInfo) > 0) {
ResponseUtil.success(response);
} else {
ResponseUtil.error(response);
}
} catch (Exception e) {
logger.error("/tag/put error", e);
ResponseUtil.sysError(response);
}
return response;
}
use of com.tony.billing.response.BaseResponse in project BillingDubbo by TonyJiangWJ.
the class CostRecordController method putDetail.
/**
* 添加消费记录
*
* @param request
* @return
*/
@RequestMapping(value = "/record/put")
public BaseResponse putDetail(@ModelAttribute("request") @Validated CostRecordPutRequest request) {
BaseResponse response = new BaseResponse();
try {
CostRecord record = new CostRecord();
record.setTradeStatus(TradeStatus.TRADE_SUCCESS);
record.setTradeNo(generateTradeNo(request.getCreateTime()));
record.setTarget(request.getTarget());
record.setPaidTime(request.getCreateTime());
record.setOrderType(request.getOrderType());
record.setMoney(MoneyUtil.yuan2fen(request.getMoney()));
record.setCostCreateTime(request.getCreateTime());
record.setIsDeleted(0);
record.setOrderStatus(TradeStatus.TRADE_SUCCESS);
record.setInOutType(request.getInOutType());
record.setMemo(request.getMemo());
record.setGoodsName(request.getMemo());
record.setLocation(request.getLocation());
record.setUserId(request.getUserId());
if (costRecordService.orderPut(record) > 0) {
ResponseUtil.success(response);
} else {
ResponseUtil.error(response);
}
} catch (Exception e) {
logger.error("/record/put error", e);
ResponseUtil.sysError(response);
}
return response;
}
Aggregations