You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.0 KiB
60 lines
2.0 KiB
package com.hfkj.controller;
|
|
|
|
import com.hfkj.common.security.UserCenter;
|
|
import com.hfkj.common.utils.ResponseMsgUtil;
|
|
import com.hfkj.entity.BsUserInviteCode;
|
|
import com.hfkj.model.ResponseData;
|
|
import com.hfkj.model.UserSessionObject;
|
|
import com.hfkj.service.user.BsUserInviteCodeService;
|
|
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.ResponseBody;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* @className: ClientController
|
|
* @author: HuRui
|
|
* @date: 2024/9/6
|
|
**/
|
|
@Controller
|
|
@RequestMapping(value="/userInviteCode")
|
|
@Api(value="用户邀请码")
|
|
public class UserInviteCodeController {
|
|
@Resource
|
|
private BsUserInviteCodeService userInviteCodeService;
|
|
@Autowired
|
|
private UserCenter userCenter;
|
|
|
|
@RequestMapping(value = "/query", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "获取邀请码")
|
|
public ResponseData query() {
|
|
try {
|
|
// 获取用户session
|
|
UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class);
|
|
// 查询用户邀请码
|
|
BsUserInviteCode userInviteCode = userInviteCodeService.getDetail(session.getUser().getId());
|
|
if (userInviteCode == null) {
|
|
// 没有就创建
|
|
userInviteCode = userInviteCodeService.create(session.getUser().getId());
|
|
}
|
|
Map<String,Object> param = new HashMap<>();
|
|
// 邀请码
|
|
param.put("inviteCode", userInviteCode.getInviteCode());
|
|
// 二维码
|
|
param.put("qrCode", userInviteCode.getQrCodeImg());
|
|
return ResponseMsgUtil.success(param);
|
|
|
|
} catch (Exception e) {
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
}
|
|
|