Forráskód Böngészése

完善操作日志

fushengqian 1 éve
szülő
commit
ff4db2e570

+ 6 - 1
fuint-application/src/main/java/com/fuint/common/aspect/TActionLogAop.java

@@ -117,6 +117,8 @@ public class TActionLogAop {
             logger.info("AOP切入点获取参数异常", e);
         } catch (NotFoundException e) {
             logger.info("AOP切入点获取参数异常", e);
+        } catch (Exception e) {
+            logger.info("AOP切入点获取参数异常", e.getMessage());
         }
     }
 
@@ -172,7 +174,10 @@ public class TActionLogAop {
         hal.setUserAgent(userAgent);
         hal.setMerchantId(merchantId);
         hal.setStoreId(storeId);
-        hal.setParam(param);
+        if (param.length() > 10000) {
+            param = param.substring(0, 10000);
+        }
+        hal.setParam(param.equals("{}") ? "" : param);
         if (StringUtils.isNotEmpty(module) && userName != null && StringUtils.isNotEmpty(userName)) {
             this.tActionLogService.saveActionLog(hal);
         }

+ 11 - 0
fuint-application/src/main/java/com/fuint/common/service/AccountService.java

@@ -6,6 +6,8 @@ import com.fuint.common.dto.AccountInfo;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
+import com.fuint.module.backendApi.request.LoginRequest;
+import com.fuint.module.backendApi.response.LoginResponse;
 import com.fuint.repository.model.TAccount;
 import com.fuint.repository.model.TDuty;
 import java.util.List;
@@ -108,4 +110,13 @@ public interface AccountService extends IService<TAccount> {
      * @return
      * */
     String getEntryptPassword(String password, String salt);
+
+    /**
+     * 登录后台系统
+     *
+     * @param loginRequest 登录参数
+     * @param userAgent 登录浏览器
+     * @return
+     * */
+    LoginResponse doLogin(LoginRequest loginRequest, String userAgent) throws BusinessCheckException;
 }

+ 58 - 0
fuint-application/src/main/java/com/fuint/common/service/impl/AccountServiceImpl.java

@@ -6,17 +6,22 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fuint.common.dto.AccountDto;
 import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.service.AccountService;
+import com.fuint.common.service.CaptchaService;
 import com.fuint.common.service.StaffService;
 import com.fuint.common.service.StoreService;
+import com.fuint.common.util.TokenUtil;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.exception.BusinessRuntimeException;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
+import com.fuint.module.backendApi.request.LoginRequest;
+import com.fuint.module.backendApi.response.LoginResponse;
 import com.fuint.repository.mapper.*;
 import com.fuint.repository.model.*;
 import com.fuint.utils.Digests;
 import com.fuint.utils.Encodes;
+import com.fuint.utils.StringUtil;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import lombok.AllArgsConstructor;
@@ -58,6 +63,11 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
      * */
     private StoreService storeService;
 
+    /**
+     * 验证码服务接口
+     * */
+    private CaptchaService captchaService;
+
     /**
      * 分页查询账号列表
      *
@@ -335,4 +345,52 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
         byte[] hashPassword = Digests.sha1(password.getBytes(), salt1, 1024);
         return Encodes.encodeHex(hashPassword);
     }
+
+    /**
+     * 登录后台系统
+     *
+     * @param loginRequest 登录参数
+     * @param userAgent 登录浏览器
+     * @return
+     * */
+    @Override
+    @OperationServiceLog(description = "登录后台系统")
+    public LoginResponse doLogin(LoginRequest loginRequest, String userAgent) throws BusinessCheckException {
+        String accountName = loginRequest.getUsername();
+        String password = loginRequest.getPassword();
+        String captchaCode = loginRequest.getCaptchaCode();
+        String uuid = loginRequest.getUuid();
+
+        Boolean captchaVerify = captchaService.checkCodeByUuid(captchaCode, uuid);
+        if (!captchaVerify) {
+            throw new BusinessCheckException("图形验证码有误");
+        }
+
+        if (StringUtil.isEmpty(accountName)|| StringUtil.isEmpty(password) || StringUtil.isEmpty(captchaCode)) {
+            throw new BusinessCheckException("登录参数有误");
+        } else {
+            AccountInfo accountInfo = getAccountByName(loginRequest.getUsername());
+            if (accountInfo == null) {
+                throw new BusinessCheckException("登录账号或密码有误");
+            }
+
+            TAccount tAccount = getAccountInfoById(accountInfo.getId());
+            String myPassword = tAccount.getPassword();
+            String inputPassword = getEntryptPassword(password, tAccount.getSalt());
+            if (!myPassword.equals(inputPassword) || !tAccount.getAccountStatus().toString().equals("1")) {
+                throw new BusinessCheckException("登录账号或密码有误");
+            }
+
+            String token = TokenUtil.generateToken(userAgent, accountInfo.getId());
+            accountInfo.setToken(token);
+            TokenUtil.saveAccountToken(accountInfo);
+
+            LoginResponse response = new LoginResponse();
+            response.setLogin(true);
+            response.setToken(token);
+            response.setTokenCreatedTime(new Date());
+
+            return response;
+        }
+    }
 }

+ 7 - 0
fuint-application/src/main/java/com/fuint/common/service/impl/OrderServiceImpl.java

@@ -34,6 +34,8 @@ import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import weixin.popular.util.JsonUtil;
+
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
 import java.util.*;
@@ -289,6 +291,7 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
     @Transactional(rollbackFor = Exception.class)
     @OperationServiceLog(description = "提交订单信息")
     public MtOrder saveOrder(OrderDto orderDto) throws BusinessCheckException {
+        logger.info("orderService.saveOrder orderDto = {}", JsonUtil.toJSONString(orderDto));
         MtOrder mtOrder;
         if (null != orderDto.getId() && orderDto.getId() > 0) {
             mtOrder = mtOrderMapper.selectById(orderDto.getId());
@@ -1042,6 +1045,7 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
     @OperationServiceLog(description = "取消订单")
     public MtOrder cancelOrder(Integer orderId, String remark) throws BusinessCheckException {
         MtOrder mtOrder = mtOrderMapper.selectById(orderId);
+        logger.info("orderService.cancelOrder orderId = {}, remark = {}", orderId, remark);
 
         if (mtOrder != null && mtOrder.getStatus().equals(OrderStatusEnum.CREATED.getKey()) && mtOrder.getPayStatus().equals(PayStatusEnum.WAIT.getKey())) {
             if (StringUtil.isNotEmpty(remark)) {
@@ -1131,6 +1135,7 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
     @Override
     @OperationServiceLog(description = "删除订单信息")
     public void deleteOrder(Integer orderId, String operator) {
+        logger.info("orderService.deleteOrder orderId = {}, operator = {}", orderId, operator);
         MtOrder mtOrder = mtOrderMapper.selectById(orderId);
         if (mtOrder == null) {
             return;
@@ -1170,6 +1175,7 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
     @Transactional(rollbackFor = Exception.class)
     @OperationServiceLog(description = "更新订单信息")
     public MtOrder updateOrder(OrderDto orderDto) throws BusinessCheckException {
+        logger.info("orderService.updateOrder orderDto = {}", JsonUtil.toJSONString(orderDto));
         MtOrder mtOrder = mtOrderMapper.selectById(orderDto.getId());
         if (null == mtOrder || OrderStatusEnum.DELETED.getKey().equals(mtOrder.getStatus())) {
             throw new BusinessCheckException("该订单状态异常");
@@ -1256,6 +1262,7 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
         if (id > 0) {
             mtOrder = mtOrderMapper.selectById(mtOrder.getId());
         }
+        logger.info("orderService.updateOrder orderInfo = {}", JsonUtil.toJSONString(mtOrder));
         return mtOrder;
     }
 

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/service/impl/SourceServiceImpl.java

@@ -240,7 +240,7 @@ public class SourceServiceImpl extends ServiceImpl<TSourceMapper, TSource> imple
     /**
      * 菜单去重
      *
-     * @param sources
+     * @param sources 菜单列表
      * @return
      */
     private List<TSource> delRepeated(List<TSource> sources) {

+ 3 - 43
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendLoginController.java

@@ -52,55 +52,15 @@ public class BackendLoginController extends BaseController {
      * */
     private DutyService dutyService;
 
-    /**
-     * 验证码服务接口
-     * */
-    private CaptchaService captchaService;
-
     /**
      * 后台登录
      * */
     @ApiOperation(value = "后台登录")
     @RequestMapping(value="/doLogin", method = RequestMethod.POST)
-    @OperationServiceLog(description = "登录后台系统")
-    public ResponseObject doLogin(HttpServletRequest request, @RequestBody LoginRequest loginRequest) {
+    public ResponseObject doLogin(HttpServletRequest request, @RequestBody LoginRequest loginRequest) throws BusinessCheckException {
         String userAgent = request.getHeader("user-agent");
-        String accountName = loginRequest.getUsername();
-        String password = loginRequest.getPassword();
-        String captchaCode = loginRequest.getCaptchaCode();
-        String uuid = loginRequest.getUuid();
-
-        Boolean captchaVerify = captchaService.checkCodeByUuid(captchaCode, uuid);
-        if (!captchaVerify) {
-            return getFailureResult(201,"图形验证码有误");
-        }
-
-        if (StringUtil.isEmpty(accountName)|| StringUtil.isEmpty(password) || StringUtil.isEmpty(captchaCode)) {
-            return getFailureResult(Constants.HTTP_RESPONSE_CODE_PARAM_ERROR);
-        } else {
-            AccountInfo accountInfo = accountService.getAccountByName(loginRequest.getUsername());
-            if (accountInfo == null) {
-                return getFailureResult(Constants.HTTP_RESPONSE_CODE_USER_LOGIN_ERROR);
-            }
-
-            TAccount tAccount = accountService.getAccountInfoById(accountInfo.getId());
-            String myPassword = tAccount.getPassword();
-            String inputPassword = accountService.getEntryptPassword(password, tAccount.getSalt());
-            if (!myPassword.equals(inputPassword) || !tAccount.getAccountStatus().toString().equals("1")) {
-                return getFailureResult(201, "账号或密码有误");
-            }
-
-            String token = TokenUtil.generateToken(userAgent, accountInfo.getId());
-            accountInfo.setToken(token);
-            TokenUtil.saveAccountToken(accountInfo);
-
-            LoginResponse response = new LoginResponse();
-            response.setLogin(true);
-            response.setToken(token);
-            response.setTokenCreatedTime(new Date());
-
-            return getSuccessResult(response);
-        }
+        LoginResponse response = accountService.doLogin(loginRequest, userAgent);
+        return getSuccessResult(response);
     }
 
     /**