实现微信扫码登录PC端
parent
193e93f60a
commit
d669f04f55
|
|
@ -0,0 +1,39 @@
|
|||
package com.ruoyi.system.api.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
*
|
||||
**/
|
||||
@Getter
|
||||
public enum LoginMethodEnum {
|
||||
/**
|
||||
*
|
||||
**/
|
||||
ACCOUNT("account", "账号密码登录"),
|
||||
/**
|
||||
*
|
||||
**/
|
||||
WX_SCAN("wxScan", "微信扫码登录");
|
||||
@Getter
|
||||
@Setter
|
||||
private String desc;
|
||||
@Getter
|
||||
@Setter
|
||||
private String code;
|
||||
|
||||
LoginMethodEnum(String code,String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public static String getName(String code) {
|
||||
for (LoginMethodEnum signEnum : LoginMethodEnum.values()) {
|
||||
if (signEnum.code.equals(code)) {
|
||||
return signEnum.desc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -27,4 +27,8 @@ public class WxAppletsCodeVo {
|
|||
public String codeImgUrl;
|
||||
@ApiModelProperty(value="返回的base64",required=false)
|
||||
public byte[] bytesBase64;
|
||||
@ApiModelProperty(value="要打开的小程序版本。正式版为 release,体验版为trial,开发版为develop。默认是正式版",required=false)
|
||||
public String envVersion;
|
||||
@ApiModelProperty(value="默认是true,检查page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错);为 false 时允许小程序未发布或者 page 不存在, 但page 有数量上限(60000个)请勿滥用",required=false)
|
||||
public Boolean checkPath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.system.api.model;
|
||||
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
|
@ -48,6 +49,10 @@ public class LoginUser implements Serializable
|
|||
*/
|
||||
private String ipaddr;
|
||||
|
||||
/**
|
||||
* 登录方式:account:账号密码;wxScan:微信扫码登录;
|
||||
*/
|
||||
public String loginMethod;
|
||||
/**
|
||||
* 权限列表
|
||||
*/
|
||||
|
|
@ -110,7 +115,13 @@ public class LoginUser implements Serializable
|
|||
{
|
||||
this.loginTime = loginTime;
|
||||
}
|
||||
public String getLoginMethod() {
|
||||
return loginMethod;
|
||||
}
|
||||
|
||||
public void setLoginMethod(String loginMethod) {
|
||||
this.loginMethod = loginMethod;
|
||||
}
|
||||
public Long getExpireTime()
|
||||
{
|
||||
return expireTime;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
package com.ruoyi.auth.controller;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.auth.form.LoginBody;
|
||||
import com.ruoyi.auth.form.RegisterBody;
|
||||
|
|
@ -16,6 +23,7 @@ import com.ruoyi.common.security.auth.AuthUtil;
|
|||
import com.ruoyi.common.security.service.TokenService;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.system.api.model.LoginUser;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* token 控制
|
||||
|
|
@ -39,6 +47,14 @@ public class TokenController
|
|||
// 获取登录token
|
||||
return R.ok(tokenService.createToken(userInfo));
|
||||
}
|
||||
@ApiOperation("PC微信扫码登录-检查登录状态")
|
||||
@GetMapping("wxScanLoginCheck")
|
||||
public R<?> wxScanLoginCheck(@RequestParam("checkCode") String checkCode)
|
||||
{
|
||||
// 用户登录
|
||||
Map<String, Object> map = sysLoginService.wxScanLoginCheck(checkCode);
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
@DeleteMapping("logout")
|
||||
public R<?> logout(HttpServletRequest request)
|
||||
|
|
|
|||
|
|
@ -6,14 +6,17 @@ package com.ruoyi.auth.controller;
|
|||
* @Description
|
||||
*/
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.auth.form.WxLoginBody;
|
||||
import com.ruoyi.auth.service.SysLoginService;
|
||||
import com.ruoyi.auth.service.WxLoginService;
|
||||
import com.ruoyi.common.core.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.service.TokenService;
|
||||
import com.ruoyi.system.api.model.LoginUser;
|
||||
|
|
@ -33,6 +36,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -50,6 +54,8 @@ public class WxLoginController {
|
|||
private WxLoginService wxLoginService;
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@ApiOperation("wx用户登录")
|
||||
@PostMapping("/loginInFromWx")
|
||||
@ResponseBody
|
||||
|
|
@ -57,7 +63,14 @@ public class WxLoginController {
|
|||
LoginUser loginUser = wxLoginService.loginInFromWx(entity);
|
||||
return R.ok(tokenService.createToken(loginUser));
|
||||
}
|
||||
|
||||
@ApiOperation("wx扫码登录")
|
||||
@PostMapping("/loginInFromWxScan")
|
||||
@ResponseBody
|
||||
public R<?> loginInFromWxScan(@RequestBody LoginUser entity) {
|
||||
LoginUser loginUser = wxLoginService.loginInFromWxScan(entity);
|
||||
Map<String, Object> map = tokenService.createToken(loginUser);
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
@PostMapping("/user/register")
|
||||
@ApiOperation(value = "wx用户注册接口")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,14 @@
|
|||
package com.ruoyi.auth.service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.ruoyi.common.core.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.constant.Constants;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
|
|
@ -9,6 +16,7 @@ import com.ruoyi.common.core.domain.R;
|
|||
import com.ruoyi.common.core.enums.UserStatus;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.system.api.RemoteUserService;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
|
|
@ -30,6 +38,8 @@ public class SysLoginService
|
|||
|
||||
@Autowired
|
||||
private SysRecordLogService recordLogService;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
|
|
@ -126,4 +136,26 @@ public class SysLoginService
|
|||
}
|
||||
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
|
||||
}
|
||||
|
||||
public Map<String, Object> wxScanLoginCheck(String checkCode) {
|
||||
//直接去redis缓存中获取用户信息
|
||||
String map = redisService.getCacheObject(getCacheKey(checkCode));
|
||||
// System.out.println("扫码登录缓存信息:"+map);
|
||||
if (map == null){
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> jsonMap = JSON.parseObject(map, new TypeReference<HashMap<String, Object>>() { });
|
||||
return jsonMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码登录账状态验证缓存键名
|
||||
*
|
||||
* @param checkCode 临时变量
|
||||
* @return 缓存键key
|
||||
*/
|
||||
private String getCacheKey(String checkCode)
|
||||
{
|
||||
return CacheConstants.WX_SCAN_LOGIN_CHECK_KEY + checkCode;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
package com.ruoyi.auth.service;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.ruoyi.auth.form.WxLoginBody;
|
||||
import com.ruoyi.common.core.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import com.ruoyi.system.api.RemoteUserService;
|
||||
import com.ruoyi.system.api.model.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -17,10 +21,20 @@ import org.springframework.stereotype.Component;
|
|||
public class WxLoginService {
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
|
||||
public LoginUser loginInFromWx(LoginUser entity) {
|
||||
// 查询用户信息
|
||||
R<LoginUser> userResult = remoteUserService.getWxUserInfo(entity,SecurityConstants.INNER);
|
||||
LoginUser userInfo = userResult.getData();
|
||||
return userInfo;
|
||||
}
|
||||
public LoginUser loginInFromWxScan(LoginUser entity) {
|
||||
// 查询用户信息
|
||||
R<LoginUser> userResult = remoteUserService.getWxUserInfo(entity,SecurityConstants.INNER);
|
||||
LoginUser userInfo = userResult.getData();
|
||||
return userInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ public class CacheConstants
|
|||
*/
|
||||
public final static long PASSWORD_LOCK_TIME = 10;
|
||||
|
||||
/**
|
||||
* 微信扫码登录过期时间,默认5(分钟)
|
||||
*/
|
||||
public final static long WX_SCAN_EXPIRE_TIME = 150;
|
||||
|
||||
/**
|
||||
* 权限缓存前缀
|
||||
*/
|
||||
|
|
@ -52,6 +57,11 @@ public class CacheConstants
|
|||
*/
|
||||
public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
||||
|
||||
/**
|
||||
* 登录账户密码错误次数 redis key
|
||||
*/
|
||||
public static final String WX_SCAN_LOGIN_CHECK_KEY = "wx_scan_login_check:";
|
||||
|
||||
/**
|
||||
* 赛会推广的二维码缓存地址key
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -16,12 +16,14 @@ import com.ruoyi.common.redis.service.RedisService;
|
|||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.common.swagger.apiConstants.ApiTerminal;
|
||||
import com.ruoyi.system.api.domain.LoginMethodEnum;
|
||||
import com.ruoyi.system.api.domain.vo.WxAppletsCodeVo;
|
||||
import com.ruoyi.system.api.model.LoginUser;
|
||||
import com.ruoyi.system.domain.Competition;
|
||||
import com.ruoyi.system.domain.CompetitionSharePermissions;
|
||||
import com.ruoyi.system.domain.Sms;
|
||||
import com.ruoyi.system.domain.UserRole;
|
||||
import com.ruoyi.system.domain.WxUser;
|
||||
import com.ruoyi.system.domain.vo.CompetitionExcleVo;
|
||||
import com.ruoyi.system.domain.vo.CompetitionResponse;
|
||||
import com.ruoyi.system.domain.vo.CompetitionVo;
|
||||
|
|
@ -93,12 +95,28 @@ public class CompetitionController extends BaseController
|
|||
/**
|
||||
* 查询比赛信息列表
|
||||
*/
|
||||
@RequiresPermissions("system:competition:list")
|
||||
// @RequiresPermissions("system:competition:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Competition competition)
|
||||
public TableDataInfo list(CompetitionVo competition)
|
||||
{
|
||||
LoginUser user = SecurityUtils.getLoginUser();
|
||||
//如果是微信扫码登录进入pc系统的且是common角色,只能操作自己创建的赛事
|
||||
if(ObjectUtil.isNotNull(user.getLoginMethod()) && user.getRoles().contains("common")
|
||||
&&user.getLoginMethod().equals(LoginMethodEnum.WX_SCAN.getCode())){
|
||||
WxUser wxUser = wxUserService.selectWxUserByOpenId(user.getUsername());
|
||||
//同时可以看到分享给自己的赛事
|
||||
CompetitionSharePermissions permissions = new CompetitionSharePermissions();
|
||||
permissions.setUserId(wxUser.getId());
|
||||
permissions.setIsDeleted(0);
|
||||
List<CompetitionSharePermissions> permissionsList = competitionSharePermissionsService.selectCompetitionSharePermissionsList(permissions);
|
||||
if(ObjectUtil.isNotNull(permissionsList)&&permissionsList.size()>0){
|
||||
List<Long> competitionIds = permissionsList.stream().map(CompetitionSharePermissions::getCompetitionId).collect(Collectors.toList());
|
||||
competition.setCompetitionIds(competitionIds);
|
||||
}
|
||||
competition.setFounder(wxUser.getId());
|
||||
}
|
||||
startPage();
|
||||
List<Competition> list = competitionService.selectCompetitionList(competition);
|
||||
List<Competition> list = competitionService.getMyJoinCompetition(competition);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +136,7 @@ public class CompetitionController extends BaseController
|
|||
/**
|
||||
* 获取比赛信息详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:competition:query")
|
||||
// @RequiresPermissions("system:competition:query")
|
||||
@GetMapping(value = "/getInfo/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
|
@ -180,7 +198,7 @@ public class CompetitionController extends BaseController
|
|||
/**
|
||||
* 新增比赛信息
|
||||
*/
|
||||
@RequiresPermissions("system:competition:add")
|
||||
// @RequiresPermissions("system:competition:add")
|
||||
@Log(title = "比赛信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult addCompetition(@RequestBody Competition competition)
|
||||
|
|
@ -188,7 +206,7 @@ public class CompetitionController extends BaseController
|
|||
return toAjax(competitionService.insertCompetition(competition));
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:competition:genCompetitionCommonAqrSpread")
|
||||
// @RequiresPermissions("system:competition:genCompetitionCommonAqrSpread")
|
||||
@Log(title = "生成赛会普通微信推广码", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/genCompetitionCommonAqrSpread")
|
||||
public AjaxResult genCompetitionCommonAqrSpread(@RequestBody WxAppletsCodeVo wxAppletsCodeVo)
|
||||
|
|
@ -199,7 +217,7 @@ public class CompetitionController extends BaseController
|
|||
/**
|
||||
* 修改比赛信息
|
||||
*/
|
||||
@RequiresPermissions("system:competition:edit")
|
||||
// @RequiresPermissions("system:competition:edit")
|
||||
@Log(title = "比赛信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult editCompetition(@RequestBody Competition competition)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class CompetitionMembersController extends BaseController
|
|||
/**
|
||||
* 查询比赛参与人员列表
|
||||
*/
|
||||
@RequiresPermissions("system:competitionMembers:list")
|
||||
// @RequiresPermissions("system:competitionMembers:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CompetitionMembers competitionMembers)
|
||||
{
|
||||
|
|
@ -61,7 +61,7 @@ public class CompetitionMembersController extends BaseController
|
|||
/**
|
||||
* 获取比赛参与人员详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:competitionMembers:query")
|
||||
// @RequiresPermissions("system:competitionMembers:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
|
@ -76,7 +76,7 @@ public class CompetitionMembersController extends BaseController
|
|||
/**
|
||||
* 新增比赛参与人员
|
||||
*/
|
||||
@RequiresPermissions("system:competitionMembers:add")
|
||||
// @RequiresPermissions("system:competitionMembers:add")
|
||||
@Log(title = "比赛参与人员", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CompetitionMembers competitionMembers)
|
||||
|
|
@ -87,7 +87,7 @@ public class CompetitionMembersController extends BaseController
|
|||
/**
|
||||
* 修改比赛参与人员
|
||||
*/
|
||||
@RequiresPermissions("system:competitionMembers:edit")
|
||||
// @RequiresPermissions("system:competitionMembers:edit")
|
||||
@Log(title = "比赛参与人员", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CompetitionMembers competitionMembers)
|
||||
|
|
@ -98,7 +98,7 @@ public class CompetitionMembersController extends BaseController
|
|||
/**
|
||||
* 删除比赛参与人员
|
||||
*/
|
||||
@RequiresPermissions("system:competitionMembers:remove")
|
||||
// @RequiresPermissions("system:competitionMembers:remove")
|
||||
@Log(title = "比赛参与人员", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class CompetitionMembersScoreController extends BaseController
|
|||
/**
|
||||
* 查询赛会中-赛程-人员得分列表
|
||||
*/
|
||||
@RequiresPermissions("system:competitionMemberScore:list")
|
||||
// @RequiresPermissions("system:competitionMemberScore:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CompetitionMembersScore competitionMembersScore)
|
||||
{
|
||||
|
|
@ -50,7 +50,7 @@ public class CompetitionMembersScoreController extends BaseController
|
|||
/**
|
||||
* 导出赛会中-赛程-人员得分列表
|
||||
*/
|
||||
@RequiresPermissions("system:competitionMemberScore:export")
|
||||
// @RequiresPermissions("system:competitionMemberScore:export")
|
||||
@Log(title = "赛会中-赛程-人员得分", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CompetitionMembersScore competitionMembersScore)
|
||||
|
|
@ -63,7 +63,7 @@ public class CompetitionMembersScoreController extends BaseController
|
|||
/**
|
||||
* 获取赛会中-赛程-人员得分详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:competitionMemberScore:query")
|
||||
// @RequiresPermissions("system:competitionMemberScore:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
|
@ -73,7 +73,7 @@ public class CompetitionMembersScoreController extends BaseController
|
|||
/**
|
||||
* 新增赛会中-赛程-人员得分
|
||||
*/
|
||||
@RequiresPermissions("system:competitionMemberScore:add")
|
||||
// @RequiresPermissions("system:competitionMemberScore:add")
|
||||
@Log(title = "赛会中-赛程-人员得分", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CompetitionMembersScore competitionMembersScore)
|
||||
|
|
@ -84,7 +84,7 @@ public class CompetitionMembersScoreController extends BaseController
|
|||
/**
|
||||
* 修改赛会中-赛程-人员得分
|
||||
*/
|
||||
@RequiresPermissions("system:competitionMemberScore:edit")
|
||||
// @RequiresPermissions("system:competitionMemberScore:edit")
|
||||
@Log(title = "赛会中-赛程-人员得分", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CompetitionMembersScore competitionMembersScore)
|
||||
|
|
@ -95,7 +95,7 @@ public class CompetitionMembersScoreController extends BaseController
|
|||
/**
|
||||
* 删除赛会中-赛程-人员得分
|
||||
*/
|
||||
@RequiresPermissions("system:competitionMemberScore:remove")
|
||||
// @RequiresPermissions("system:competitionMemberScore:remove")
|
||||
@Log(title = "赛会中-赛程-人员得分", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class CompetitionOfTeamController extends BaseController
|
|||
/**
|
||||
* 查询赛会中-参赛队伍列表
|
||||
*/
|
||||
@RequiresPermissions("system:competitionOfTeam:list")
|
||||
// @RequiresPermissions("system:competitionOfTeam:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CompetitionOfTeamVo competitionOfTeam)
|
||||
{
|
||||
|
|
@ -94,7 +94,7 @@ public class CompetitionOfTeamController extends BaseController
|
|||
/**
|
||||
* 获取赛会中-参赛队伍详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:competitionOfTeam:query")
|
||||
// @RequiresPermissions("system:competitionOfTeam:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
|
@ -104,7 +104,7 @@ public class CompetitionOfTeamController extends BaseController
|
|||
/**
|
||||
* 新增赛会中-参赛队伍
|
||||
*/
|
||||
@RequiresPermissions("system:competitionOfTeam:add")
|
||||
// @RequiresPermissions("system:competitionOfTeam:add")
|
||||
@Log(title = "赛会中-参赛队伍", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CompetitionOfTeam competitionOfTeam)
|
||||
|
|
@ -115,14 +115,14 @@ public class CompetitionOfTeamController extends BaseController
|
|||
/**
|
||||
* 修改赛会中-参赛队伍
|
||||
*/
|
||||
@RequiresPermissions("system:competitionOfTeam:edit")
|
||||
// @RequiresPermissions("system:competitionOfTeam:edit")
|
||||
@Log(title = "赛会中-参赛队伍", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CompetitionOfTeam competitionOfTeam)
|
||||
{
|
||||
return toAjax(competitionOfTeamService.updateCompetitionOfTeam(competitionOfTeam));
|
||||
}
|
||||
@RequiresPermissions("system:competitionOfTeam:batchEditById")
|
||||
// @RequiresPermissions("system:competitionOfTeam:batchEditById")
|
||||
@Log(title = "赛会中-参赛队伍批量修改", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/batchEditById")
|
||||
public AjaxResult batchEditById(@RequestBody List<CompetitionOfTeam> list)
|
||||
|
|
@ -130,7 +130,7 @@ public class CompetitionOfTeamController extends BaseController
|
|||
return toAjax(competitionOfTeamService.batchUpdateCompetitionOfTeam(list));
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:competitionOfTeam:removeTeamGroup")
|
||||
// @RequiresPermissions("system:competitionOfTeam:removeTeamGroup")
|
||||
@Log(title = "赛会中-参赛队伍移除分组", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/removeTeamGroup/{ids}")
|
||||
public AjaxResult removeTeamGroup(@PathVariable Long[] ids)
|
||||
|
|
@ -138,7 +138,7 @@ public class CompetitionOfTeamController extends BaseController
|
|||
return toAjax(competitionOfTeamService.removeTeamGroup(ids));
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:competitionOfTeam:intoTeamGroup")
|
||||
// @RequiresPermissions("system:competitionOfTeam:intoTeamGroup")
|
||||
@Log(title = "赛会中-参赛队伍移入分组", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/intoTeamGroup/{competitionGroup}")
|
||||
public AjaxResult intoTeamGroup(@PathVariable String competitionGroup,@RequestBody List<Long> ids)
|
||||
|
|
@ -148,7 +148,7 @@ public class CompetitionOfTeamController extends BaseController
|
|||
/**
|
||||
* 删除赛会中-参赛队伍
|
||||
*/
|
||||
@RequiresPermissions("system:competitionOfTeam:remove")
|
||||
// @RequiresPermissions("system:competitionOfTeam:remove")
|
||||
@Log(title = "赛会中-参赛队伍", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class CompetitionResultController extends BaseController
|
|||
/**
|
||||
* 查询赛会中-赛程结果记录列表
|
||||
*/
|
||||
@RequiresPermissions("system:competitionResult:list")
|
||||
// @RequiresPermissions("system:competitionResult:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CompetitionResult competitionResult)
|
||||
{
|
||||
|
|
@ -62,7 +62,7 @@ public class CompetitionResultController extends BaseController
|
|||
/**
|
||||
* 导出赛会中-赛程结果记录列表
|
||||
*/
|
||||
@RequiresPermissions("system:competitionResult:export")
|
||||
// @RequiresPermissions("system:competitionResult:export")
|
||||
@Log(title = "赛会中赛程结果记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CompetitionResult competitionResult)
|
||||
|
|
@ -75,7 +75,7 @@ public class CompetitionResultController extends BaseController
|
|||
/**
|
||||
* 获取赛会中-赛程结果记录详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:competitionResult:query")
|
||||
// @RequiresPermissions("system:competitionResult:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
|
@ -85,7 +85,7 @@ public class CompetitionResultController extends BaseController
|
|||
/**
|
||||
* 新增赛会中-赛程结果记录
|
||||
*/
|
||||
@RequiresPermissions("system:competitionResult:add")
|
||||
// @RequiresPermissions("system:competitionResult:add")
|
||||
@Log(title = "赛会中赛程结果记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CompetitionResult competitionResult)
|
||||
|
|
@ -96,21 +96,21 @@ public class CompetitionResultController extends BaseController
|
|||
/**
|
||||
* 修改赛会中-赛程结果记录
|
||||
*/
|
||||
@RequiresPermissions("system:competitionResult:edit")
|
||||
// @RequiresPermissions("system:competitionResult:edit")
|
||||
@Log(title = "赛会中赛程结果记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CompetitionResult competitionResult)
|
||||
{
|
||||
return toAjax(competitionResultService.updateCompetitionResult(competitionResult));
|
||||
}
|
||||
@RequiresPermissions("system:competitionResult:batchEdit")
|
||||
// @RequiresPermissions("system:competitionResult:batchEdit")
|
||||
@Log(title = "赛会中批量保存赛程结果记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/batchEdit")
|
||||
public AjaxResult batchEdit(@RequestBody List<CompetitionResult> list)
|
||||
{
|
||||
return toAjax(competitionResultService.batchUpdateCompetitionResult(list));
|
||||
}
|
||||
@RequiresPermissions("system:competitionResult:editData")
|
||||
// @RequiresPermissions("system:competitionResult:editData")
|
||||
@Log(title = "赛会中保存赛程结果记录2", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/editData")
|
||||
public AjaxResult editData(@RequestBody CompetitionVsRecordVo obj)
|
||||
|
|
@ -121,7 +121,7 @@ public class CompetitionResultController extends BaseController
|
|||
/**
|
||||
* 删除赛会中-赛程结果记录
|
||||
*/
|
||||
@RequiresPermissions("system:competitionResult:remove")
|
||||
// @RequiresPermissions("system:competitionResult:remove")
|
||||
@Log(title = "赛会中赛程结果记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class CompetitionTeamGroupController extends BaseController
|
|||
/**
|
||||
* 查询赛会中-分组列表
|
||||
*/
|
||||
@RequiresPermissions("system:competitionTeamGroup:list")
|
||||
// @RequiresPermissions("system:competitionTeamGroup:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CompetitionTeamGroup competitionTeamGroup)
|
||||
{
|
||||
|
|
@ -75,7 +75,7 @@ public class CompetitionTeamGroupController extends BaseController
|
|||
/**
|
||||
* 获取赛会中-分组详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:competitionTeamGroup:query")
|
||||
// @RequiresPermissions("system:competitionTeamGroup:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
|
@ -85,7 +85,7 @@ public class CompetitionTeamGroupController extends BaseController
|
|||
/**
|
||||
* 新增赛会中-分组
|
||||
*/
|
||||
@RequiresPermissions("system:competitionTeamGroup:add")
|
||||
// @RequiresPermissions("system:competitionTeamGroup:add")
|
||||
@Log(title = "赛会中-分组", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CompetitionTeamGroup competitionTeamGroup)
|
||||
|
|
@ -96,7 +96,7 @@ public class CompetitionTeamGroupController extends BaseController
|
|||
/**
|
||||
* 修改赛会中-分组
|
||||
*/
|
||||
@RequiresPermissions("system:competitionTeamGroup:edit")
|
||||
// @RequiresPermissions("system:competitionTeamGroup:edit")
|
||||
@Log(title = "赛会中-分组", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CompetitionTeamGroup competitionTeamGroup)
|
||||
|
|
@ -113,7 +113,7 @@ public class CompetitionTeamGroupController extends BaseController
|
|||
/**
|
||||
* 删除赛会中-分组
|
||||
*/
|
||||
@RequiresPermissions("system:competitionTeamGroup:remove")
|
||||
// @RequiresPermissions("system:competitionTeamGroup:remove")
|
||||
@Log(title = "赛会中-分组", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class CompetitionTeamVsTeamController extends BaseController
|
|||
/**
|
||||
* 查询赛会中-球队VS球队关系列表
|
||||
*/
|
||||
@RequiresPermissions("system:competitionTeamVsTeam:list")
|
||||
// @RequiresPermissions("system:competitionTeamVsTeam:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CompetitionTeamVsTeam competitionTeamVsTeam)
|
||||
{
|
||||
|
|
@ -67,7 +67,7 @@ public class CompetitionTeamVsTeamController extends BaseController
|
|||
/**
|
||||
* 获取赛会中-球队VS球队关系详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:competitionTeamVsTeam:query")
|
||||
// @RequiresPermissions("system:competitionTeamVsTeam:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
|
@ -77,7 +77,7 @@ public class CompetitionTeamVsTeamController extends BaseController
|
|||
/**
|
||||
* 新增赛会中-球队VS球队关系
|
||||
*/
|
||||
@RequiresPermissions("system:competitionTeamVsTeam:add")
|
||||
// @RequiresPermissions("system:competitionTeamVsTeam:add")
|
||||
@Log(title = "赛会中球队VS球队关系", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CompetitionTeamVsTeam competitionTeamVsTeam)
|
||||
|
|
@ -88,7 +88,7 @@ public class CompetitionTeamVsTeamController extends BaseController
|
|||
/**
|
||||
* 修改赛会中-球队VS球队关系
|
||||
*/
|
||||
@RequiresPermissions("system:competitionTeamVsTeam:edit")
|
||||
// @RequiresPermissions("system:competitionTeamVsTeam:edit")
|
||||
@Log(title = "赛会中球队VS球队关系", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CompetitionTeamVsTeam competitionTeamVsTeam)
|
||||
|
|
@ -99,7 +99,7 @@ public class CompetitionTeamVsTeamController extends BaseController
|
|||
/**
|
||||
* 删除赛会中-球队VS球队关系
|
||||
*/
|
||||
@RequiresPermissions("system:competitionTeamVsTeam:remove")
|
||||
// @RequiresPermissions("system:competitionTeamVsTeam:remove")
|
||||
@Log(title = "赛会中球队VS球队关系", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class CompetitionVsController extends BaseController {
|
|||
/**
|
||||
* 查询约战列表
|
||||
*/
|
||||
@RequiresPermissions("system:vs:list")
|
||||
// @RequiresPermissions("system:vs:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Competition competition)
|
||||
{
|
||||
|
|
@ -58,7 +58,7 @@ public class CompetitionVsController extends BaseController {
|
|||
/**
|
||||
* 获取约战详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:vs:query")
|
||||
// @RequiresPermissions("system:vs:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
|
@ -68,7 +68,7 @@ public class CompetitionVsController extends BaseController {
|
|||
/**
|
||||
* 新增约战
|
||||
*/
|
||||
@RequiresPermissions("system:vs:add")
|
||||
// @RequiresPermissions("system:vs:add")
|
||||
@Log(title = "约战", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Competition competition)
|
||||
|
|
@ -79,7 +79,7 @@ public class CompetitionVsController extends BaseController {
|
|||
/**
|
||||
* 修改约战
|
||||
*/
|
||||
@RequiresPermissions("system:vs:edit")
|
||||
// @RequiresPermissions("system:vs:edit")
|
||||
@Log(title = "约战", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Competition competition)
|
||||
|
|
@ -90,7 +90,7 @@ public class CompetitionVsController extends BaseController {
|
|||
/**
|
||||
* 删除约战
|
||||
*/
|
||||
@RequiresPermissions("system:vs:remove")
|
||||
// @RequiresPermissions("system:vs:remove")
|
||||
@Log(title = "约战", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.system.api.domain.LoginMethodEnum;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -15,6 +18,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
|
|
@ -158,9 +162,41 @@ public class SysUserController extends BaseController
|
|||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("getInfo")
|
||||
public AjaxResult getInfo()
|
||||
public AjaxResult getInfo(@RequestParam(value = "userId", required = false) Long userId)
|
||||
{
|
||||
SysUser user = userService.selectUserById(SecurityUtils.getUserId());
|
||||
String permission = null;
|
||||
if(userId == null){
|
||||
userId = SecurityUtils.getUserId();
|
||||
}else {
|
||||
LoginUser user = SecurityUtils.getLoginUser();
|
||||
if(ObjectUtil.isNotNull(user.getLoginMethod()) && user.getRoles().contains("common")
|
||||
&&user.getLoginMethod().equals(LoginMethodEnum.WX_SCAN.getCode())){
|
||||
permission = "*:*:*";
|
||||
}
|
||||
}
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(user);
|
||||
// 权限集合
|
||||
Set<String> permissions = permissionService.getMenuPermission(user);
|
||||
if(ObjectUtil.isNotNull(permission)){
|
||||
permissions.add(permission);
|
||||
}
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", roles);
|
||||
ajax.put("permissions", permissions);
|
||||
return ajax;
|
||||
}
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("getWxScanInfo")
|
||||
public AjaxResult getWxScanInfo(@RequestParam("userId") Long userId)
|
||||
{
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(user);
|
||||
// 权限集合
|
||||
|
|
@ -171,13 +207,12 @@ public class SysUserController extends BaseController
|
|||
ajax.put("permissions", permissions);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户编号获取详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:user:query")
|
||||
@GetMapping(value = { "/", "/{userId}" })
|
||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
||||
public AjaxResult getUserInfo(@PathVariable(value = "userId", required = false) Long userId)
|
||||
{
|
||||
userService.checkUserDataScope(userId);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
|
|||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.swagger.apiConstants.ApiTerminal;
|
||||
import com.ruoyi.system.api.domain.vo.WxAppletsCodeVo;
|
||||
import com.ruoyi.system.service.WxApplesCodeService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
|
@ -27,6 +30,7 @@ public class WxApplesCodeController extends BaseController {
|
|||
{
|
||||
return AjaxResult.success(wxApplesCodeService.getWxApplesAccessToken());
|
||||
}
|
||||
@ApiOperation(ApiTerminal.wxMiniProgram+"生成微信小程序二维码")
|
||||
@RequiresPermissions("system:wxApplesCode:genWxApplesAqrCode")
|
||||
@Log(title = "生成微信小程序二维码", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/genWxApplesAqrCode")
|
||||
|
|
@ -34,4 +38,12 @@ public class WxApplesCodeController extends BaseController {
|
|||
{
|
||||
return AjaxResult.success(wxApplesCodeService.genWxApplesAqrCode(wxAppletsCodeVo));
|
||||
}
|
||||
|
||||
@ApiOperation(ApiTerminal.pc+"生成微信扫码登录二维码")
|
||||
@Log(title = ApiTerminal.pc+"生成微信扫码登录二维码", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/genWxApplesAqrCodeForPc")
|
||||
public AjaxResult genWxApplesAqrCodeForPc(@RequestBody WxAppletsCodeVo wxAppletsCodeVo)
|
||||
{
|
||||
return AjaxResult.success(wxApplesCodeService.genWxApplesAqrCodeForPc(wxAppletsCodeVo));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class WxBuildingInfoController extends BaseController
|
|||
/**
|
||||
* 查询球场管理列表
|
||||
*/
|
||||
@RequiresPermissions("system:WxBuilding:list")
|
||||
// @RequiresPermissions("system:WxBuilding:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(WxBuildingInfo wxBuildingInfo)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,6 +38,17 @@ public class WxLoginController {
|
|||
return AjaxResult.success(loginUser);
|
||||
}
|
||||
|
||||
@ApiOperation(ApiTerminal.wxMiniProgram+"微信扫码登录")
|
||||
@PostMapping("/wxScanLogin")
|
||||
@ResponseBody
|
||||
public AjaxResult wxScanLogin(@RequestBody WxLoginRequest entity) throws Exception {
|
||||
// WxLoginUser loginUser = wxLoginService.loginInFromWx(entity);
|
||||
WxLoginUser loginUser = new WxLoginUser();
|
||||
loginUser.setUserId(1L);
|
||||
loginUser.setLoginName("test");
|
||||
loginUser.setAccessToken("sfsdfsdf");
|
||||
return AjaxResult.success(loginUser);
|
||||
}
|
||||
|
||||
@PostMapping("/user/register")
|
||||
@ApiOperation(value = ApiTerminal.wxMiniProgram+"用户注册接口")
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ public class CompetitionSharePermissions extends BaseEntity
|
|||
/** 赛事id(competition的ID) */
|
||||
@Excel(name = "赛事id(competition的ID)")
|
||||
private Long competitionId;
|
||||
@Excel(name = "赛会创建人ID")
|
||||
private Long competitionOwnId;
|
||||
|
||||
/** 用户ID */
|
||||
@Excel(name = "用户ID")
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.ruoyi.system.service;
|
|||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import com.ruoyi.system.api.model.LoginUser;
|
||||
import com.ruoyi.system.domain.WxUser;
|
||||
|
||||
/**
|
||||
* 用户 业务层
|
||||
|
|
@ -203,4 +205,6 @@ public interface ISysUserService
|
|||
* @return 结果
|
||||
*/
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
SysUser wxScanUserAdd(WxUser wxUser);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,4 +62,6 @@ public interface IWxUserService extends IService<WxUser>
|
|||
public int deleteWxUserById(Long id);
|
||||
|
||||
WxUser getUserInfoBy(WxUser wxUser);
|
||||
|
||||
WxUser selectWxUserByOpenId(String username);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,4 +17,6 @@ public interface WxApplesCodeService {
|
|||
String getWxApplesAccessToken();
|
||||
|
||||
WxAppletsCodeVo genWxApplesAqrCode(WxAppletsCodeVo wxAppletsCodeVo);
|
||||
|
||||
WxAppletsCodeVo genWxApplesAqrCodeForPc(WxAppletsCodeVo wxAppletsCodeVo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl;
|
|||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -36,7 +37,7 @@ public class SysPermissionServiceImpl implements ISysPermissionService
|
|||
{
|
||||
Set<String> roles = new HashSet<String>();
|
||||
// 管理员拥有所有权限
|
||||
if (user.isAdmin())
|
||||
if (Objects.nonNull(user.isAdmin())&&user.isAdmin())
|
||||
{
|
||||
roles.add("admin");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.validation.Validator;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.system.api.model.LoginUser;
|
||||
import com.ruoyi.system.domain.WxUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -538,4 +543,31 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
return successMsg.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser wxScanUserAdd(WxUser wxUser) {
|
||||
log.info("wxScanUserAdd wxUser: {}", JSON.toJSONString(wxUser));
|
||||
String openid = wxUser.getOpenid();
|
||||
SysUser sysUser = userMapper.selectUserByUserName(openid);
|
||||
if (StringUtils.isNull(sysUser))
|
||||
{
|
||||
Date date = new Date();
|
||||
sysUser = new SysUser();
|
||||
sysUser.setNickName("微信用户");
|
||||
sysUser.setUserName(openid);
|
||||
sysUser.setStatus("0");
|
||||
sysUser.setDelFlag("0");
|
||||
sysUser.setLoginDate(date);
|
||||
sysUser.setCreateBy("system");
|
||||
sysUser.setCreateTime(date);
|
||||
sysUser.setRemark("微信扫码登录用户");
|
||||
//设置刚刚
|
||||
Long[] postIds = {4L};
|
||||
sysUser.setPostIds(postIds);
|
||||
Long[] roleIds = {2L};
|
||||
sysUser.setRoleIds(roleIds);
|
||||
this.insertUser(sysUser);
|
||||
}
|
||||
return sysUser;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.ruoyi.common.redis.service.RedisService;
|
|||
import com.ruoyi.system.api.domain.vo.WxAppletsCodeVo;
|
||||
import com.ruoyi.system.service.WxApplesCodeService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
|
@ -28,6 +29,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
|
@ -130,6 +132,7 @@ public class WxApplesCodeServiceImpl implements WxApplesCodeService {
|
|||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
outputStream.flush();
|
||||
wxAppletsCodeVo.setBytesBase64(result);
|
||||
wxAppletsCodeVo.setCodeImgUrl(domainName+xdpath);
|
||||
return wxAppletsCodeVo;
|
||||
|
||||
|
|
@ -151,7 +154,89 @@ public class WxApplesCodeServiceImpl implements WxApplesCodeService {
|
|||
}
|
||||
}
|
||||
}
|
||||
System.out.println("获取二维码");
|
||||
return wxAppletsCodeVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxAppletsCodeVo genWxApplesAqrCodeForPc(WxAppletsCodeVo wxAppletsCodeVo) {
|
||||
if(restTemplate==null){
|
||||
restTemplate = new RestTemplate();
|
||||
}
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
//根据APPid和密钥获取存取令牌
|
||||
try {
|
||||
String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + this.getWxApplesAccessToken();
|
||||
//定义生产二维码所需的参数、样式
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("scene", wxAppletsCodeVo.getScene());
|
||||
param.put("page", wxAppletsCodeVo.getPage());
|
||||
param.put("check_path",wxAppletsCodeVo.getCheckPath()==null?Boolean.FALSE:wxAppletsCodeVo.getCheckPath());
|
||||
if(wxAppletsCodeVo.getEnvVersion()!=null&&!StringUtils.isEmpty(wxAppletsCodeVo.getEnvVersion())){
|
||||
param.put("env_version",wxAppletsCodeVo.getEnvVersion());
|
||||
}
|
||||
param.put("width", org.apache.commons.lang3.StringUtils.isEmpty(wxAppletsCodeVo.getPage())?10:wxAppletsCodeVo.getPage());
|
||||
param.put("auto_color", wxAppletsCodeVo.getAutoColor()==null?false:wxAppletsCodeVo.getAutoColor());
|
||||
param.put("is_hyaline",wxAppletsCodeVo.getIsHyaline()==null?false:wxAppletsCodeVo.getIsHyaline());
|
||||
Map<String, Object> line_color = new HashMap<>();
|
||||
line_color.put("r", 0);
|
||||
line_color.put("g", 0);
|
||||
line_color.put("b", 0);
|
||||
param.put("line_color", line_color);
|
||||
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
||||
HttpEntity requestEntity = new HttpEntity(param, headers);
|
||||
// System.out.println("协议请求头"+headers+""+requestEntity);
|
||||
ResponseEntity<byte[]> entity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, byte[].class, new Object[0]);
|
||||
// LOG.info("调用小程序生成微信永久小程序码URL接口返回结果:" + entity.getBody());
|
||||
// System.out.println("返回结果"+entity.getBody()+".."+entity);
|
||||
byte[] result = entity.getBody();
|
||||
// inputStream = new ByteArrayInputStream(result);
|
||||
//// 生成随机数命名图片
|
||||
// String filename = UUID.randomUUID().toString();
|
||||
// // System.out.println(filename);
|
||||
// Date date = new Date();
|
||||
// String time = new SimpleDateFormat("yyyy-MM-dd").format(date);
|
||||
// String[] str = time.split("-");//根据‘-’进行拆分字符串 拆分出来的日期有,年,日,月,根据年日月创建文件夹
|
||||
// String datePath="/"+str[0]+"/"+str[1]+"/"+str[2]+"/";
|
||||
// //创建文件夹
|
||||
// String xdpath = datePath+filename+".png";
|
||||
// String filePath = linuxLocation+datePath+filename+".png";
|
||||
//// 服务器存放位置
|
||||
// File file = new File(filePath);
|
||||
// //文件目录不存在需要先创建
|
||||
// if(!file.getParentFile().exists()){
|
||||
// file.getParentFile().mkdirs();
|
||||
// }
|
||||
// outputStream = new FileOutputStream(file);
|
||||
// int len = 0;
|
||||
// byte[] buf = new byte[1024];
|
||||
// while ((len = inputStream.read(buf, 0, 1024)) != -1) {
|
||||
// outputStream.write(buf, 0, len);
|
||||
// }
|
||||
// outputStream.flush();
|
||||
|
||||
wxAppletsCodeVo.setBytesBase64(result);
|
||||
// wxAppletsCodeVo.setCodeImgUrl(domainName+xdpath);
|
||||
wxAppletsCodeVo.setBase64(new String(Objects.requireNonNull(Base64.encodeBase64(result))));
|
||||
return wxAppletsCodeVo;
|
||||
} catch (Exception e) {
|
||||
log.error("调用小程序生成微信永久小程序码URL接口异常", e);
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return wxAppletsCodeVo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.core.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.constant.Constants;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import com.ruoyi.common.security.service.TokenService;
|
||||
import com.ruoyi.system.api.domain.LoginMethodEnum;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import com.ruoyi.system.api.model.LoginUser;
|
||||
import com.ruoyi.system.api.model.WxLoginUser;
|
||||
|
|
@ -13,6 +18,8 @@ import com.ruoyi.system.domain.enums.UserRoles;
|
|||
import com.ruoyi.system.domain.vo.WxLoginRequest;
|
||||
import com.ruoyi.system.mapper.UserRoleMapper;
|
||||
import com.ruoyi.system.mapper.WxUserMapper;
|
||||
import com.ruoyi.system.service.ISysPermissionService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.system.service.WxLoginService;
|
||||
import com.ruoyi.system.utils.jwt.JwtUtil;
|
||||
import org.apache.http.HttpEntity;
|
||||
|
|
@ -32,6 +39,7 @@ import java.io.IOException;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -45,6 +53,15 @@ public class WxLoginServiceImpl implements WxLoginService {
|
|||
private WxUserMapper wxUserMapper;
|
||||
@Autowired
|
||||
private UserRoleMapper userRoleMapper;
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@Autowired
|
||||
private ISysPermissionService permissionService;
|
||||
private Long wxScanExpireTime= CacheConstants.WX_SCAN_EXPIRE_TIME;
|
||||
@Override
|
||||
public WxLoginUser loginInFromWx(WxLoginRequest entity) {
|
||||
//获取openId
|
||||
|
|
@ -350,6 +367,34 @@ public class WxLoginServiceImpl implements WxLoginService {
|
|||
loginUser.setUsername(login.getOpenid());
|
||||
loginUser.setRoles(codes);
|
||||
loginUser.setSysUser(sysUser);
|
||||
//判断是否是微信扫码登录;如果是需要判断是否存在账号在system_user表中,如果不存在则创建账号,权限
|
||||
if(!StringUtils.isEmpty(entity.getLoginMethod()) &&LoginMethodEnum.WX_SCAN.getCode().equals(entity.getLoginMethod())){
|
||||
SysUser sysUser1 = sysUserService.wxScanUserAdd(login);
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(sysUser1);
|
||||
// 权限集合
|
||||
Set<String> permissions = permissionService.getMenuPermission(sysUser1);
|
||||
LoginUser sysUserVo = new LoginUser();
|
||||
sysUserVo.setSysUser(sysUser1);
|
||||
sysUserVo.setRoles(roles);
|
||||
sysUserVo.setUserid(sysUser1.getUserId());
|
||||
sysUserVo.setUsername(sysUser1.getUserName());
|
||||
sysUserVo.setPermissions(permissions);
|
||||
sysUserVo.setLoginMethod(entity.getLoginMethod());
|
||||
Map<String, Object> map = tokenService.createToken(sysUserVo);
|
||||
//设置到缓存里面
|
||||
redisService.setCacheObject(getCacheKey(entity.getToken()), JSON.toJSONString(map), wxScanExpireTime, TimeUnit.MINUTES);
|
||||
}
|
||||
return loginUser;
|
||||
}
|
||||
/**
|
||||
* 扫码登录账状态验证缓存键名
|
||||
*
|
||||
* @param checkCode 临时变量
|
||||
* @return 缓存键key
|
||||
*/
|
||||
private String getCacheKey(String checkCode)
|
||||
{
|
||||
return CacheConstants.WX_SCAN_LOGIN_CHECK_KEY + checkCode;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,4 +97,9 @@ public class WxUserServiceImpl extends ServiceImpl<WxUserMapper, WxUser> impleme
|
|||
public WxUser getUserInfoBy(WxUser wxUser) {
|
||||
return wxUserMapper.getUserInfoBy(wxUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxUser selectWxUserByOpenId(String username) {
|
||||
return wxUserMapper.selectByOpenId(username);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,17 +17,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="updateBy" column="update_by" />
|
||||
<result property="isDeleted" column="is_deleted" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="competitionOwnId" column="competition_own_id" />
|
||||
<result property="canSetType" column="can_set_type" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCompetitionSharePermissionsVo">
|
||||
select id, create_time, competition_id, user_id, user_tel, user_name, status, update_time, create_by, update_by, is_deleted, remark, can_set_type from competition_share_permissions
|
||||
select id, create_time, competition_id,competition_own_id, user_id, user_tel, user_name, status, update_time, create_by, update_by, is_deleted, remark, can_set_type from competition_share_permissions
|
||||
</sql>
|
||||
|
||||
<select id="selectCompetitionSharePermissionsList" parameterType="com.ruoyi.system.domain.CompetitionSharePermissions" resultMap="CompetitionSharePermissionsResult">
|
||||
<include refid="selectCompetitionSharePermissionsVo"/>
|
||||
<where>
|
||||
<if test="competitionId != null "> and competition_id = #{competitionId}</if>
|
||||
<if test="competitionOwnId != null "> and competition_own_id = #{competitionOwnId}</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="userTel != null and userTel != ''"> and user_tel = #{userTel}</if>
|
||||
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
|
||||
|
|
@ -57,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="isDeleted != null">is_deleted,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="canSetType != null">can_set_type,</if>
|
||||
<if test="competitionOwnId != null">competition_own_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
|
|
@ -71,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="isDeleted != null">#{isDeleted},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="canSetType != null">#{canSetType},</if>
|
||||
<if test="competitionOwnId != null">#{competitionOwnId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
|
@ -89,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="isDeleted != null">is_deleted = #{isDeleted},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="canSetType != null">can_set_type = #{canSetType},</if>
|
||||
<if test="competitionOwnId != null">competition_own_id = #{competitionOwnId},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
|
@ -114,6 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="isDeleted != null "> and is_deleted = #{isDeleted}</if>
|
||||
<if test="canSetType != null and canSetType != ''"> and can_set_type = #{canSetType}</if>
|
||||
<if test="competitionOwnId != null "> and competition_own_id = #{competitionOwnId}</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -104,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertWxUser" parameterType="com.ruoyi.system.domain.WxUser" useGeneratedKeys="true" keyProperty="id">
|
||||
<insert id="insertWxUser" parameterType="com.ruoyi.system.domain.WxUser" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into user_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="isDeleted != null">IS_DELETED,</if>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,17 @@ export function login(username, password, code, uuid) {
|
|||
})
|
||||
}
|
||||
|
||||
// 微信扫码登录状态检查方法
|
||||
export function wxScanLoginCheck(query) {
|
||||
return request({
|
||||
url: '/auth/wxScanLoginCheck',
|
||||
headers: {
|
||||
isToken: false
|
||||
},
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
// 注册方法
|
||||
export function register(data) {
|
||||
return request({
|
||||
|
|
@ -33,12 +44,22 @@ export function refreshToken() {
|
|||
}
|
||||
|
||||
// 获取用户详细信息
|
||||
export function getInfo() {
|
||||
export function getInfo(params) {
|
||||
return request({
|
||||
url: '/system/user/getInfo',
|
||||
method: 'get'
|
||||
method: 'get',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
// 获取微信扫码用户详细信息
|
||||
export function getWxScanInfo(params) {
|
||||
return request({
|
||||
url: '/system/user/getWxScanInfo',
|
||||
method: 'get',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 退出方法
|
||||
export function logout() {
|
||||
|
|
@ -58,4 +79,4 @@ export function getCodeImg() {
|
|||
method: 'get',
|
||||
timeout: 20000
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,22 @@ export function getWxApplesAccessToken(query) {
|
|||
})
|
||||
}
|
||||
|
||||
// 查询约战详细
|
||||
// 获取微信小程序码
|
||||
export function genWxApplesAqrCode(data) {
|
||||
return request({
|
||||
url: '/system/wxApplesCode/genWxApplesAqrCode',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
//获取微信小程序码二进制数据
|
||||
export function genWxApplesAqrCodeForPc(data) {
|
||||
return request({
|
||||
url: '/system/wxApplesCode/genWxApplesAqrCodeForPc',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import store from './store'
|
|||
import { Message } from 'element-ui'
|
||||
import NProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import {getToken, getWxScanUserId} from '@/utils/auth'
|
||||
import { isRelogin } from '@/utils/request'
|
||||
|
||||
NProgress.configure({ showSpinner: false })
|
||||
|
|
@ -22,7 +22,10 @@ router.beforeEach((to, from, next) => {
|
|||
if (store.getters.roles.length === 0) {
|
||||
isRelogin.show = true
|
||||
// 判断当前用户是否已拉取完user_info信息
|
||||
store.dispatch('GetInfo').then(() => {
|
||||
let params ={
|
||||
userId: getWxScanUserId()
|
||||
}
|
||||
store.dispatch('GetInfo',params).then(() => {
|
||||
isRelogin.show = false
|
||||
store.dispatch('GenerateRoutes').then(accessRoutes => {
|
||||
// 根据roles权限生成可访问的路由表
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { login, logout, getInfo, refreshToken } from '@/api/login'
|
||||
import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth'
|
||||
import { login, logout, getInfo, refreshToken,getWxScanInfo } from '@/api/login'
|
||||
import {getToken, setToken, setExpiresIn, removeToken, setWxScanUserId, removeWxScanUserId} from '@/utils/auth'
|
||||
|
||||
const user = {
|
||||
state: {
|
||||
|
|
@ -7,7 +7,8 @@ const user = {
|
|||
name: '',
|
||||
avatar: '',
|
||||
roles: [],
|
||||
permissions: []
|
||||
permissions: [],
|
||||
wxScanUserId: null
|
||||
},
|
||||
|
||||
mutations: {
|
||||
|
|
@ -17,6 +18,9 @@ const user = {
|
|||
SET_EXPIRES_IN: (state, time) => {
|
||||
state.expires_in = time
|
||||
},
|
||||
SET_WX_SCAN_USER_ID_IN: (state, wxScanUserId) => {
|
||||
state.wxScanUserId = wxScanUserId
|
||||
},
|
||||
SET_NAME: (state, name) => {
|
||||
state.name = name
|
||||
},
|
||||
|
|
@ -51,11 +55,42 @@ const user = {
|
|||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 获取用户信息
|
||||
GetInfo({ commit, state }) {
|
||||
// 微信扫码登录
|
||||
WxScanLogin({ commit }, data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getInfo().then(res => {
|
||||
setToken(data.access_token)
|
||||
commit('SET_TOKEN', data.access_token)
|
||||
setExpiresIn(data.expires_in)
|
||||
commit('SET_EXPIRES_IN', data.expires_in)
|
||||
setWxScanUserId(data.user.userid)
|
||||
commit('SET_WX_SCAN_USER_ID_IN', data.user.userid)
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
// 获取微信扫码用户信息
|
||||
GetWxScanInfo({ commit, state },params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getWxScanInfo(params).then(res => {
|
||||
const user = res.user
|
||||
const avatar = (user.avatar == "" || user.avatar == null) ? require("@/assets/images/profile.jpg") : user.avatar;
|
||||
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
||||
commit('SET_ROLES', res.roles)
|
||||
commit('SET_PERMISSIONS', res.permissions)
|
||||
} else {
|
||||
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
||||
}
|
||||
commit('SET_NAME', user.userName)
|
||||
commit('SET_AVATAR', avatar)
|
||||
resolve(res)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取用户信息
|
||||
GetInfo({ commit, state },params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getInfo(params).then(res => {
|
||||
const user = res.user
|
||||
const avatar = (user.avatar == "" || user.avatar == null) ? require("@/assets/images/profile.jpg") : user.avatar;
|
||||
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
||||
|
|
@ -85,7 +120,7 @@ const user = {
|
|||
})
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
// 退出系统
|
||||
LogOut({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
@ -93,7 +128,9 @@ const user = {
|
|||
commit('SET_TOKEN', '')
|
||||
commit('SET_ROLES', [])
|
||||
commit('SET_PERMISSIONS', [])
|
||||
commit('SET_WX_SCAN_USER_ID_IN', null)
|
||||
removeToken()
|
||||
removeWxScanUserId()
|
||||
resolve()
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
|
|
@ -105,7 +142,9 @@ const user = {
|
|||
FedLogOut({ commit }) {
|
||||
return new Promise(resolve => {
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_WX_SCAN_USER_ID_IN', null)
|
||||
removeToken()
|
||||
removeWxScanUserId()
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,16 @@ const TokenKey = 'Admin-Token'
|
|||
|
||||
const ExpiresInKey = 'Admin-Expires-In'
|
||||
|
||||
const WxScanUserIdKey = 'Admin-Wx-UserId-In'
|
||||
export function getWxScanUserId() {
|
||||
return Cookies.get(WxScanUserIdKey)
|
||||
}
|
||||
export function setWxScanUserId(userId) {
|
||||
return Cookies.set(WxScanUserIdKey, userId)
|
||||
}
|
||||
export function removeWxScanUserId() {
|
||||
return Cookies.remove(WxScanUserIdKey)
|
||||
}
|
||||
export function getToken() {
|
||||
return Cookies.get(TokenKey)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,68 +1,80 @@
|
|||
<template>
|
||||
<div class="login">
|
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
|
||||
<h3 class="title">篮球Zone后台管理系统</h3>
|
||||
<el-form-item prop="username">
|
||||
<el-input
|
||||
v-model="loginForm.username"
|
||||
type="text"
|
||||
auto-complete="off"
|
||||
placeholder="账号"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
<el-input
|
||||
v-model="loginForm.password"
|
||||
type="password"
|
||||
auto-complete="off"
|
||||
placeholder="密码"
|
||||
@keyup.enter.native="handleLogin"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="code" v-if="captchaEnabled">
|
||||
<el-input
|
||||
v-model="loginForm.code"
|
||||
auto-complete="off"
|
||||
placeholder="验证码"
|
||||
style="width: 63%"
|
||||
@keyup.enter.native="handleLogin"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
|
||||
</el-input>
|
||||
<div class="login-code">
|
||||
<img :src="codeUrl" @click="getCode" class="login-code-img"/>
|
||||
<el-tabs v-model="activeName" @tab-click="handleTagClick" class="login-form">
|
||||
<el-tab-pane name="first" label="账号登录">
|
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" >
|
||||
<h3 class="title">篮球Zone后台管理系统</h3>
|
||||
<el-form-item prop="username">
|
||||
<el-input
|
||||
v-model="loginForm.username"
|
||||
type="text"
|
||||
auto-complete="off"
|
||||
placeholder="账号"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
<el-input
|
||||
v-model="loginForm.password"
|
||||
type="password"
|
||||
auto-complete="off"
|
||||
placeholder="密码"
|
||||
@keyup.enter.native="handleLogin"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="code" v-if="captchaEnabled">
|
||||
<el-input
|
||||
v-model="loginForm.code"
|
||||
auto-complete="off"
|
||||
placeholder="验证码"
|
||||
style="width: 63%"
|
||||
@keyup.enter.native="handleLogin"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
|
||||
</el-input>
|
||||
<div class="login-code">
|
||||
<img :src="codeUrl" @click="getCode" class="login-code-img"/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
|
||||
<el-form-item style="width:100%;">
|
||||
<el-button
|
||||
:loading="loading"
|
||||
size="medium"
|
||||
type="primary"
|
||||
style="width:100%;"
|
||||
@click.native.prevent="handleLogin"
|
||||
>
|
||||
<span v-if="!loading">登 录</span>
|
||||
<span v-else>登 录 中...</span>
|
||||
</el-button>
|
||||
<div style="float: right;" v-if="register">
|
||||
<router-link class="link-type" :to="'/register'">立即注册</router-link>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="second" label="微信扫码登录">
|
||||
<div class="wx-qrcode" >
|
||||
<el-image v-if="imageLoaded" :src="qrCodeUrl" class="wx-qrcode-login-img" @load="handleImageLoad" @error="handleImageError" @click="getWxScanQrCode"/>
|
||||
<div class="el-icon-loading" v-else></div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
|
||||
<el-form-item style="width:100%;">
|
||||
<el-button
|
||||
:loading="loading"
|
||||
size="medium"
|
||||
type="primary"
|
||||
style="width:100%;"
|
||||
@click.native.prevent="handleLogin"
|
||||
>
|
||||
<span v-if="!loading">登 录</span>
|
||||
<span v-else>登 录 中...</span>
|
||||
</el-button>
|
||||
<div style="float: right;" v-if="register">
|
||||
<router-link class="link-type" :to="'/register'">立即注册</router-link>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<!-- 底部 -->
|
||||
<div class="el-login-footer">
|
||||
<span>Copyright © 2018-2022 future.basket All Rights Reserved.</span>
|
||||
<span>Copyright © 2020-2024 lzsport.com All Rights Reserved.</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getCodeImg } from "@/api/login";
|
||||
import { getCodeImg, wxScanLoginCheck } from "@/api/login";
|
||||
import {genWxApplesAqrCodeForPc, genWxApplesAqrCode} from "@/api/system/wxApplesCode";
|
||||
import Cookies from "js-cookie";
|
||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
|
||||
|
|
@ -92,7 +104,11 @@ export default {
|
|||
captchaEnabled: true,
|
||||
// 注册开关
|
||||
register: false,
|
||||
redirect: undefined
|
||||
redirect: undefined,
|
||||
qrCodeUrl: "",
|
||||
activeName: 'first',
|
||||
showexpire: false,
|
||||
imageLoaded: false,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
|
|
@ -107,6 +123,11 @@ export default {
|
|||
this.getCode();
|
||||
this.getCookie();
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.timer) {
|
||||
clearInterval(this.timer); // 销毁组件前清除定时器
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getCode() {
|
||||
getCodeImg().then(res => {
|
||||
|
|
@ -117,6 +138,50 @@ export default {
|
|||
}
|
||||
});
|
||||
},
|
||||
handleImageLoad(){
|
||||
console.log('图片加载完成');
|
||||
this.imageLoaded = true;
|
||||
},
|
||||
handleImageError(){
|
||||
console.log('图片加载失败');
|
||||
this.$modal.msgWarning("二维码加载失败");
|
||||
},
|
||||
getWxScanQrCode() {
|
||||
const timestamp = Date.now();
|
||||
let checkCode = 'wxScanLogin'+timestamp;
|
||||
let params ={
|
||||
// envVersion: 'develop',
|
||||
checkPath: false,
|
||||
scene: checkCode,
|
||||
page: 'pages/wxScanLogin/wxScanLogin'
|
||||
};
|
||||
console.log(params)
|
||||
genWxApplesAqrCodeForPc(params).then(res => {
|
||||
this.qrCodeUrl = "data:image/png;base64," + res.data.base64;
|
||||
this.imageLoaded = true;
|
||||
this.timer = setInterval(() => {
|
||||
let param1 = {
|
||||
checkCode: checkCode
|
||||
}
|
||||
wxScanLoginCheck(param1).then(res1 => {
|
||||
console.log(res1)
|
||||
if(res1.data){
|
||||
console.log("登录成功")
|
||||
// 登录成功清除定时器
|
||||
clearInterval(this.timer);
|
||||
this.$store.dispatch("WxScanLogin", res1.data).then(() => {
|
||||
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
|
||||
}).catch(() => {
|
||||
console.log("登录失败")
|
||||
});
|
||||
}else{
|
||||
console.log("登录失败")
|
||||
}
|
||||
});
|
||||
// 执行需要定时重复执行的任务
|
||||
}, 2000); // 每2秒钟执行一次
|
||||
});
|
||||
},
|
||||
getCookie() {
|
||||
const username = Cookies.get("username");
|
||||
const password = Cookies.get("password");
|
||||
|
|
@ -150,12 +215,24 @@ export default {
|
|||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 切换登录方式
|
||||
handleTagClick(tab, event) {
|
||||
if (tab.name === 'first') {
|
||||
this.getCode();
|
||||
this.getCookie();
|
||||
} else {
|
||||
this.getWxScanQrCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss">
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
.login {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
|
@ -216,4 +293,13 @@ export default {
|
|||
.login-code-img {
|
||||
height: 38px;
|
||||
}
|
||||
.wx-qrcode{
|
||||
width: 100%;
|
||||
height: 320px;
|
||||
text-align: center;
|
||||
}
|
||||
.wx-qrcode-login-img{
|
||||
height: 300px;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -207,9 +207,7 @@
|
|||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-setting"
|
||||
@click="handleCompetitionSet(scope.row)"
|
||||
v-hasPermi="['system:competition:edit']"
|
||||
>设置</el-button>
|
||||
@click="handleCompetitionSet(scope.row)">设置</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
|
|
|||
|
|
@ -94,16 +94,16 @@
|
|||
<el-table-column label="领队人电话" align="center" prop="contactsTel" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleEditOfTeam(scope.row)" v-hasPermi="['system:competitionOfTeam:edit']">编辑</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleEditOfTeam(scope.row)" >编辑</el-button>
|
||||
<el-popconfirm v-if="scope.row.status===0" @confirm="bindConfirm(scope.row.id,1)" title="你确定同意此球队加入赛会吗?">
|
||||
<el-button slot="reference" size="mini" type="text" icon="el-icon-success" v-hasPermi="['system:competitionOfTeam:edit']">同意</el-button>
|
||||
<el-button slot="reference" size="mini" type="text" icon="el-icon-success" >同意</el-button>
|
||||
</el-popconfirm>
|
||||
<el-popconfirm v-if="scope.row.status===0" @confirm="bindConfirm(scope.row.id,-1)" title="你确定不同意此球队加入赛会吗?">
|
||||
<el-button slot="reference" size="mini" type="text" icon="el-icon-info" v-hasPermi="['system:competitionOfTeam:remove']">驳回</el-button>
|
||||
<el-button slot="reference" size="mini" type="text" icon="el-icon-info" >驳回</el-button>
|
||||
</el-popconfirm>
|
||||
<el-button size="mini" type="text" icon="el-icon-s-custom" @click="handleTeamUser(scope.row)" v-hasPermi="['system:competitionOfTeam:list']">球队成员</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-s-custom" @click="handleTeamUser(scope.row)" >球队成员</el-button>
|
||||
<el-popconfirm v-if="scope.row.status===0" @confirm="bindDelOfTeamConfirm(scope.row.id,1)" title="你确定要删除此球队吗?">
|
||||
<el-button slot="reference" size="mini" type="text" icon="el-icon-delete" v-hasPermi="['system:competitionOfTeam:remove']">删除</el-button>
|
||||
<el-button slot="reference" size="mini" type="text" icon="el-icon-delete" >删除</el-button>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
|
@ -120,7 +120,6 @@
|
|||
plain
|
||||
icon="el-icon-plus"
|
||||
@click="handleAddGroup"
|
||||
v-hasPermi="['system:competition:add']"
|
||||
>新增分组</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
|
@ -179,7 +178,6 @@
|
|||
plain
|
||||
icon="el-icon-time"
|
||||
@click="handleTeamVsTeamAdd"
|
||||
v-hasPermi="['system:competitionTeamVsTeam:add']"
|
||||
>手动设置赛程</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
|
|
@ -188,7 +186,6 @@
|
|||
plain
|
||||
icon="el-icon-bangzhu"
|
||||
@click="handleMindTeamVsTeam"
|
||||
v-hasPermi="['system:competitionTeamVsTeam:add']"
|
||||
>系统智能设置小组循环赛赛程</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
|
@ -237,10 +234,10 @@
|
|||
<el-table-column label="球场名称" align="center" prop="buildingName" width="250"/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit-outline" @click="handleTeamVsTeamRecord(scope.row)" v-hasPermi="['system:competitionOfTeam:edit']">比赛记录</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleTeamVsTeamEdit(scope.row)" v-hasPermi="['system:competitionTeamVsTeam:edit']">编辑赛程</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleTeamVsTeamDel(scope.row)" v-hasPermi="['system:competitionOfTeam:del']">删除赛程</el-button>
|
||||
<!-- <el-button v-if="new Date(scope.row.competitionDate).getTime() > new Date().getTime()" size="mini" type="text" icon="el-icon-delete" @click="handleTeamVsTeamDel(scope.row)" v-hasPermi="['system:competitionOfTeam:del']">删除赛程</el-button>-->
|
||||
<el-button size="mini" type="text" icon="el-icon-edit-outline" @click="handleTeamVsTeamRecord(scope.row)" >比赛记录</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleTeamVsTeamEdit(scope.row)">编辑赛程</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleTeamVsTeamDel(scope.row)">删除赛程</el-button>
|
||||
<!-- <el-button v-if="new Date(scope.row.competitionDate).getTime() > new Date().getTime()" size="mini" type="text" icon="el-icon-delete" @click="handleTeamVsTeamDel(scope.row)" ">删除赛程</el-button>-->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
|
@ -642,7 +639,6 @@
|
|||
type="primary"
|
||||
icon="el-icon-check"
|
||||
@click="handleTeamVsTeamRecordSave"
|
||||
v-hasPermi="['system:competitionOfTeam:save']"
|
||||
>数据保存</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
|
|
@ -688,7 +684,6 @@
|
|||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdateMemberScore(scope.row)"
|
||||
v-hasPermi="['system:competitionMemberScore:edit']"
|
||||
>计分</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
|
@ -1595,6 +1590,7 @@ export default {
|
|||
genCompetitionCommonAqrSpread(data).then(response => {
|
||||
this.$modal.msgSuccess("生成普通推广二维码成功");
|
||||
this.spreadImgurl = response.data.codeImgUrl;
|
||||
// this.spreadImgurl = "data:image/png;base64," + response.data.bytesBase64;
|
||||
});
|
||||
},
|
||||
clickCarousel(data){
|
||||
|
|
|
|||
Loading…
Reference in New Issue