提交代码

master
胡锐 6 months ago committed by yuanye
parent 7776cea718
commit 592d4521b3
  1. 7
      service/src/main/java/com/hfkj/service/user/BsUserService.java
  2. 11
      service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java
  3. 55
      user/src/main/java/com/user/controller/UserIntegralController.java

@ -78,4 +78,11 @@ public interface BsUserService {
*/ */
SessionObject updateSession(String token); SessionObject updateSession(String token);
/**
* 获取积分数量
* @param userId
* @return
*/
Long getIntegral(Long userId);
} }

@ -155,4 +155,15 @@ public class BsUserServiceImpl implements BsUserService {
return newSession; return newSession;
} }
@Override
public Long getIntegral(Long userId) {
BsUserExample example = new BsUserExample();
example.createCriteria().andIdEqualTo(userId).andStatusNotEqualTo(UserStatusEnum.status0.getCode());
List<BsUser> list = userMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0).getIntegral();
}
return null;
}
} }

@ -0,0 +1,55 @@
package com.user.controller;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.user.BsUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @className: UserIntegralController
* @author: HuRui
* @date: 2024/5/20
**/
@Controller
@RequestMapping(value="/userIntegral")
@Api(value="用户积分业务")
public class UserIntegralController {
Logger log = LoggerFactory.getLogger(UserIntegralController.class);
@Resource
private BsUserService userService;
@Resource
private UserCenter userCenter;
@RequestMapping(value="/queryIntegral",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取积分数量")
public ResponseData queryIntegral() {
try {
// 用户
UserSessionObject userSessionObject = userCenter.getSessionModel(UserSessionObject.class);
if (userSessionObject == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, "");
}
return ResponseMsgUtil.success(userService.getIntegral(userSessionObject.getUser().getId()));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}
Loading…
Cancel
Save