Search in sources :

Example 1 with BaseResponse

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;
}
Also used : BaseResponse(com.tony.billing.response.BaseResponse)

Example 2 with BaseResponse

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("日志保存失败");
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) BaseResponse(com.tony.billing.response.BaseResponse) LoginLog(com.tony.billing.entity.LoginLog) AdminLoginRequest(com.tony.billing.request.admin.AdminLoginRequest) AfterReturning(org.aspectj.lang.annotation.AfterReturning)

Example 3 with BaseResponse

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;
}
Also used : BaseResponse(com.tony.billing.response.BaseResponse) CostRecord(com.tony.billing.entity.CostRecord) TagInfo(com.tony.billing.entity.TagInfo) TagCostRef(com.tony.billing.entity.TagCostRef) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with BaseResponse

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;
}
Also used : BaseResponse(com.tony.billing.response.BaseResponse) TagInfo(com.tony.billing.entity.TagInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with BaseResponse

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;
}
Also used : BaseResponse(com.tony.billing.response.BaseResponse) CostRecord(com.tony.billing.entity.CostRecord) ParseException(java.text.ParseException) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

BaseResponse (com.tony.billing.response.BaseResponse)15 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 CostRecord (com.tony.billing.entity.CostRecord)4 ModifyAdmin (com.tony.billing.entity.ModifyAdmin)3 TagInfo (com.tony.billing.entity.TagInfo)3 IOException (java.io.IOException)3 Admin (com.tony.billing.entity.Admin)2 ParseException (java.text.ParseException)2 Budget (com.tony.billing.entity.Budget)1 LoginLog (com.tony.billing.entity.LoginLog)1 TagCostRef (com.tony.billing.entity.TagCostRef)1 BaseBusinessException (com.tony.billing.exceptions.BaseBusinessException)1 AdminLoginRequest (com.tony.billing.request.admin.AdminLoginRequest)1 HashMap (java.util.HashMap)1 List (java.util.List)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 AfterReturning (org.aspectj.lang.annotation.AfterReturning)1 BindException (org.springframework.validation.BindException)1 FieldError (org.springframework.validation.FieldError)1 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)1