From 4ddc978edf5d75e08772f7bebe8233c1a74633a7 Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Mon, 9 Sep 2024 11:29:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=94=A8=E6=88=B7=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E4=BA=A4=E6=98=93=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hfkj/config/AuthConfig.java | 3 +- .../main/java/com/hfkj/config/AuthConfig.java | 3 +- .../com/hfkj/controller/ClientController.java | 3 +- .../controller/UserAccountController.java | 86 +++++++++++++++++++ .../com/hfkj/controller/UserController.java | 5 +- .../hfkj/common/security/SecUserCenter.java | 3 +- .../com/hfkj/common/security/UserCenter.java | 2 +- .../service/sec/impl/SecUserServiceImpl.java | 4 +- .../impl/BsUserAccountRecordServiceImpl.java | 2 + .../service/user/impl/BsUserServiceImpl.java | 3 +- 10 files changed, 104 insertions(+), 10 deletions(-) create mode 100644 cweb/src/main/java/com/hfkj/controller/UserAccountController.java diff --git a/bweb/src/main/java/com/hfkj/config/AuthConfig.java b/bweb/src/main/java/com/hfkj/config/AuthConfig.java index e2e7c82..0b7a013 100644 --- a/bweb/src/main/java/com/hfkj/config/AuthConfig.java +++ b/bweb/src/main/java/com/hfkj/config/AuthConfig.java @@ -8,6 +8,7 @@ import com.hfkj.common.security.UserCenter; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.HttpMessageConverter; @@ -27,7 +28,7 @@ public class AuthConfig implements WebMvcConfigurer { private static Logger log = LoggerFactory.getLogger(AuthConfig.class); - @Resource + @Autowired private SecUserCenter userCenter; /** diff --git a/cweb/src/main/java/com/hfkj/config/AuthConfig.java b/cweb/src/main/java/com/hfkj/config/AuthConfig.java index 9843536..f9a5311 100644 --- a/cweb/src/main/java/com/hfkj/config/AuthConfig.java +++ b/cweb/src/main/java/com/hfkj/config/AuthConfig.java @@ -7,6 +7,7 @@ import com.hfkj.common.security.UserCenter; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.HttpMessageConverter; @@ -26,7 +27,7 @@ public class AuthConfig implements WebMvcConfigurer { private static Logger log = LoggerFactory.getLogger(AuthConfig.class); - @Resource + @Autowired private UserCenter userCenter; /** diff --git a/cweb/src/main/java/com/hfkj/controller/ClientController.java b/cweb/src/main/java/com/hfkj/controller/ClientController.java index aa26a45..b605fa3 100644 --- a/cweb/src/main/java/com/hfkj/controller/ClientController.java +++ b/cweb/src/main/java/com/hfkj/controller/ClientController.java @@ -15,6 +15,7 @@ import com.hfkj.sysenum.user.UserLoginType; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,7 +39,7 @@ public class ClientController { private BsUserService userService; @Resource private RedisUtil redisUtil; - @Resource + @Autowired private UserCenter userCenter; @RequestMapping(value = "/smsLogin", method = RequestMethod.POST) diff --git a/cweb/src/main/java/com/hfkj/controller/UserAccountController.java b/cweb/src/main/java/com/hfkj/controller/UserAccountController.java new file mode 100644 index 0000000..c401987 --- /dev/null +++ b/cweb/src/main/java/com/hfkj/controller/UserAccountController.java @@ -0,0 +1,86 @@ +package com.hfkj.controller; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.RedisUtil; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.model.ResponseData; +import com.hfkj.model.UserSessionObject; +import com.hfkj.service.user.BsUserAccountRecordService; +import com.hfkj.service.user.BsUserAccountService; +import com.hfkj.service.user.BsUserService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +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.ResponseBody; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; + +/** + * @className: ClientController + * @author: HuRui + * @date: 2024/9/6 + **/ +@Controller +@RequestMapping(value="/userAccount") +@Api(value="客户端业务") +public class UserAccountController { + @Resource + private BsUserAccountService userAccountService; + @Resource + private BsUserAccountRecordService userAccountRecordService; + @Autowired + private UserCenter userCenter; + + @RequestMapping(value = "/getAccount", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询用户账户信息") + public ResponseData getAccount() { + try { + // 用户session + UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class); + + Map param = new HashMap<>(); + // 用户信息 + param.put("account", userAccountService.getAccount(session.getUser().getId())); + + return ResponseMsgUtil.success(param); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/getRecordList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询账户记录") + public ResponseData getRecordList(@RequestParam(value = "type" , required = false) Integer type, + @RequestParam(value = "sourceType" , required = false) Integer sourceType, + @RequestParam(value = "pageNum" , required = true) Integer pageNum, + @RequestParam(value = "pageSize" , required = true) Integer pageSize) { + try { + // 用户session + UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class); + + Map param = new HashMap<>(); + param.put("useId", session.getUser().getId()); + param.put("type", type); + param.put("sourceType", sourceType); + + PageHelper.startPage(pageNum,pageSize); + return ResponseMsgUtil.success(new PageInfo<>(userAccountRecordService.getList(param))); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/cweb/src/main/java/com/hfkj/controller/UserController.java b/cweb/src/main/java/com/hfkj/controller/UserController.java index 2baa7cd..e71e973 100644 --- a/cweb/src/main/java/com/hfkj/controller/UserController.java +++ b/cweb/src/main/java/com/hfkj/controller/UserController.java @@ -17,6 +17,7 @@ import com.hfkj.sysenum.user.UserLoginType; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -41,10 +42,10 @@ public class UserController { private BsUserService userService; @Resource private RedisUtil redisUtil; - @Resource + @Autowired private UserCenter userCenter; - @RequestMapping(value = "/getUser", method = RequestMethod.POST) + @RequestMapping(value = "/getUser", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询用户信息") public ResponseData getUser() { diff --git a/service/src/main/java/com/hfkj/common/security/SecUserCenter.java b/service/src/main/java/com/hfkj/common/security/SecUserCenter.java index d0b6b27..6e06a08 100644 --- a/service/src/main/java/com/hfkj/common/security/SecUserCenter.java +++ b/service/src/main/java/com/hfkj/common/security/SecUserCenter.java @@ -9,12 +9,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; -@Component +@Component() public class SecUserCenter { private static Logger log = LoggerFactory.getLogger(SecUserCenter.class); diff --git a/service/src/main/java/com/hfkj/common/security/UserCenter.java b/service/src/main/java/com/hfkj/common/security/UserCenter.java index 01295d9..303eb64 100644 --- a/service/src/main/java/com/hfkj/common/security/UserCenter.java +++ b/service/src/main/java/com/hfkj/common/security/UserCenter.java @@ -14,7 +14,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; -@Component +@Component() public class UserCenter { private static Logger log = LoggerFactory.getLogger(UserCenter.class); diff --git a/service/src/main/java/com/hfkj/service/sec/impl/SecUserServiceImpl.java b/service/src/main/java/com/hfkj/service/sec/impl/SecUserServiceImpl.java index fb81cd2..34509ff 100644 --- a/service/src/main/java/com/hfkj/service/sec/impl/SecUserServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/sec/impl/SecUserServiceImpl.java @@ -6,7 +6,6 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.AESEncodeUtil; import com.hfkj.common.security.SecUserCenter; import com.hfkj.common.security.SessionObject; -import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.MD5Util; import com.hfkj.dao.SecUserMapper; import com.hfkj.entity.*; @@ -21,6 +20,7 @@ import com.hfkj.sysenum.sec.SecUserObjectTypeEnum; import com.hfkj.sysenum.sec.SecUserStatusEnum; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; @@ -41,7 +41,7 @@ public class SecUserServiceImpl implements SecUserService { @Resource private SecUserMapper secUserMapper; - @Resource + @Autowired private SecUserCenter userCenter; @Resource private SecUserLoginLogService secUserLoginLogService; diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserAccountRecordServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserAccountRecordServiceImpl.java index 625f062..ee95cf9 100644 --- a/service/src/main/java/com/hfkj/service/user/impl/BsUserAccountRecordServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserAccountRecordServiceImpl.java @@ -5,6 +5,7 @@ import com.hfkj.entity.BsUserAccountRecord; import com.hfkj.entity.BsUserAccountRecordExample; import com.hfkj.service.user.BsUserAccountRecordService; import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; @@ -16,6 +17,7 @@ import java.util.Map; * @author: HuRui * @date: 2024/9/8 **/ +@Service("userAccountRecordService") public class BsUserAccountRecordServiceImpl implements BsUserAccountRecordService { @Resource private BsUserAccountRecordMapper userAccountRecordMapper; diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java index 8ad4df2..2e1b19d 100644 --- a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java @@ -19,6 +19,7 @@ import com.hfkj.sysenum.user.UserLoginType; import com.hfkj.sysenum.user.UserStatusEnum; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -42,7 +43,7 @@ public class BsUserServiceImpl implements BsUserService { private BsUserMapper userMapper; @Resource private RedisUtil redisUtil; - @Resource + @Autowired private UserCenter userCenter; @Resource private BsUserLoginLogService userLoginLogService;