微服务项目:尚融宝(60)(核心业务流程:个人中心)

认清现实,放弃幻想,准备斗争

一、资金列表接口

1、Controller

TransFlowController

@Api(tags = "资金记录")
@RestController
@RequestMapping("/api/core/transFlow")
@Slf4j
public class TransFlowController {

    @Resource
    private TransFlowService transFlowService;

    @ApiOperation("获取列表")
    @GetMapping("/list")
    public R list(HttpServletRequest request) {
        String token = request.getHeader("token");
        Long userId = JwtUtils.getUserId(token);
        List<TransFlow> list = transFlowService.selectByUserId(userId);
        return R.ok().data("list", list);
    }
}

2、Service

接口:TransFlowService

List<TransFlow> selectByUserId(Long userId);

实现:TransFlowServiceImpl 

@Override
public List<TransFlow> selectByUserId(Long userId) {

    QueryWrapper<TransFlow> queryWrapper = new QueryWrapper<>();
    queryWrapper
        .eq("user_id", userId)
        .orderByDesc("id");
    return baseMapper.selectList(queryWrapper);
}

二、前端整合

脚本

pages/user/fund.vue

fetchTransFlowList() {
  this.$axios.$get('/api/core/transFlow/list').then((response) => {
    this.transFlowList = response.data.list
  })
},

一、后端接口

1、创建VO

@Data
@ApiModel(description = "首页用户信息")
public class UserIndexVO {

    @ApiModelProperty(value = "用户id")
    private Long userId;

    @ApiModelProperty(value = "用户姓名")
    private String name;

    @ApiModelProperty(value = "用户昵称")
    private String nickName;

    @ApiModelProperty(value = "1:出借人 2:借款人")
    private Integer userType;

    @ApiModelProperty(value = "用户头像")
    private String headImg;

    @ApiModelProperty(value = "绑定状态(0:未绑定,1:绑定成功 -1:绑定失败)")
    private Integer bindStatus;

    @ApiModelProperty(value = "帐户可用余额")
    private BigDecimal amount;

    @ApiModelProperty(value = "冻结金额")
    private BigDecimal freezeAmount;

    @ApiModelProperty(value = "上次登录时间")
    private LocalDateTime lastLoginTime;

}

2、Controller

UserInfoController

@ApiOperation("获取个人空间用户信息")
@GetMapping("/auth/getIndexUserInfo")
public R getIndexUserInfo(HttpServletRequest request) {
    String token = request.getHeader("token");
    Long userId = JwtUtils.getUserId(token);
    UserIndexVO userIndexVO = userInfoService.getIndexUserInfo(userId);
    return R.ok().data("userIndexVO", userIndexVO);
}

3、Service

接口:UserInfoService

UserIndexVO getIndexUserInfo(Long userId);

实现:UserInfoServiceImpl 

 

@Override
public UserIndexVO getIndexUserInfo(Long userId) {
    
    //用户信息
    UserInfo userInfo = baseMapper.selectById(userId);

    //账户信息
    QueryWrapper<UserAccount> userAccountQueryWrapper = new QueryWrapper<>();
    userAccountQueryWrapper.eq("user_id", userId);
    UserAccount userAccount = userAccountMapper.selectOne(userAccountQueryWrapper);

    //登录信息
    QueryWrapper<UserLoginRecord> userLoginRecordQueryWrapper = new QueryWrapper<>();
    userLoginRecordQueryWrapper
        .eq("user_id", userId)
        .orderByDesc("id")
        .last("limit 1");
    UserLoginRecord userLoginRecord = userLoginRecordMapper.selectOne(userLoginRecordQueryWrapper);
    result.put("userLoginRecord", userLoginRecord);

    //组装结果数据
    UserIndexVO userIndexVO = new UserIndexVO();
    userIndexVO.setUserId(userInfo.getId());
    userIndexVO.setUserType(userInfo.getUserType());
    userIndexVO.setName(userInfo.getName());
    userIndexVO.setNickName(userInfo.getNickName());
    userIndexVO.setHeadImg(userInfo.getHeadImg());
    userIndexVO.setBindStatus(userInfo.getBindStatus());
    userIndexVO.setAmount(userAccount.getAmount());
    userIndexVO.setFreezeAmount(userAccount.getFreezeAmount());
    userIndexVO.setLastLoginTime(userLoginRecord.getCreateTime());

    return userIndexVO;
}

二、前端整合

脚本

pages/user/index.vue

fetchUserData() {
  this.$axios
    .$get('/api/core/userInfo/auth/getIndexUserInfo')
    .then((response) => {
      this.userIndexVO = response.data.userIndexVO
    })
},

今日分享

计算机网络是指将地理位置不同的具有独立功能的多台计算机icon-default.png?t=M85Bhttps://baike.baidu.com/item/%E8%AE%A1%E7%AE%97%E6%9C%BA/140338及其外部设备,通过通信线路连接起来,在网络操作系统网络管理软件icon-default.png?t=M85Bhttps://baike.baidu.com/item/%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86%E8%BD%AF%E4%BB%B6/6579078网络通信协议的管理和协调下,实现资源共享和信息传递的计算机系统。 [1] 

计算机网络主要是由一些通用的、可编程的硬件互连而成的,而这些硬件并非专门用来实现某一特定目的(例如,传送数据或视频信号)。这些可编程的硬件能够用来传送多种不同类型的数据,并能支持广泛的和日益增长的应用。

猜你喜欢

转载自blog.csdn.net/m0_62436868/article/details/127043702