ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteShopService.java
@@ -4,9 +4,11 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.system.api.domain.poji.activity.ActivityGoods; import com.ruoyi.system.api.domain.poji.shop.Shop; import com.ruoyi.system.api.domain.vo.ShopRelUserVo; import com.ruoyi.system.api.factory.RemoteShopFallbackFactory; import com.ruoyi.system.api.factory.RemoteUserFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -15,4 +17,7 @@ @PostMapping("/shop/getShop") public R<Shop> getShop(@RequestBody Long shopId); @GetMapping("/shop/getShopByUserId") public R<ShopRelUserVo> getShopByUserId(Long userId); } ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/vo/ShopRelUserVo.java
New file @@ -0,0 +1,14 @@ package com.ruoyi.system.api.domain.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class ShopRelUserVo { @ApiModelProperty("商户id") private Long shopId; @ApiModelProperty("用户姓名") private String userName; } ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteShopFallbackFactory.java
@@ -4,6 +4,7 @@ import com.ruoyi.system.api.RemoteMemberService; import com.ruoyi.system.api.RemoteShopService; import com.ruoyi.system.api.domain.poji.shop.Shop; import com.ruoyi.system.api.domain.vo.ShopRelUserVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; @@ -11,7 +12,7 @@ /** * 商户服务 * * * @author jqs */ @Component @@ -29,6 +30,11 @@ public R<Shop> getShop(Long shopId) { return R.fail("获取商户失败:" + throwable.getMessage()); } @Override public R<ShopRelUserVo> getShopByUserId(Long userId) { return R.fail("获取商户失败:" + throwable.getMessage()); } }; } } ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/QwH5LoginVo.java
@@ -10,6 +10,9 @@ @ApiModelProperty("成员UserID") private String userid; @ApiModelProperty("商户id") private Long shopId; @ApiModelProperty("手机") private String mobile; ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
@@ -1,6 +1,8 @@ package com.ruoyi.auth.service; import com.ruoyi.system.api.RemoteMemberService; import com.ruoyi.system.api.RemoteShopService; import com.ruoyi.system.api.domain.vo.ShopRelUserVo; import com.ruoyi.system.api.model.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -32,6 +34,9 @@ @Autowired private RemoteMemberService remoteMemberService; @Autowired private RemoteShopService remoteShopService; @Autowired private SysPasswordService passwordService; @@ -172,7 +177,16 @@ recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); throw new ServiceException("对不起,您的账号:" + username + " 已停用"); } // 查询用户商户 R<ShopRelUserVo> shopResult = remoteShopService.getShopByUserId(user.getUserId()); if (R.FAIL == userResult.getCode()) { throw new ServiceException(userResult.getMsg()); } ShopRelUserVo shopInfo = shopResult.getData(); userInfo.setShopId(shopInfo.getShopId()); recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); return userInfo; } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/console/ShopController.java
@@ -1,17 +1,19 @@ package com.ruoyi.shop.controller.console; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.security.annotation.InnerAuth; import com.ruoyi.shop.domain.pojo.shop.ShopRelUser; import com.ruoyi.shop.service.shop.ShopRelUserService; import com.ruoyi.shop.service.shop.ShopService; import com.ruoyi.system.api.domain.poji.activity.ActivityGoods; import com.ruoyi.system.api.domain.poji.shop.Shop; import com.ruoyi.system.api.domain.vo.ShopRelUserVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.Optional; /** * @author jqs34 @@ -27,6 +29,9 @@ @Resource private ShopService shopService; @Resource private ShopRelUserService shopRelUserService; @PostMapping("/getShop") public R<Shop> getShop(@RequestBody Long shopId) @@ -36,4 +41,16 @@ } @GetMapping("/getShopByUserId") public R<ShopRelUserVo> getShopByUserId(Long userId) { ShopRelUser shopRelUser = shopRelUserService.getByUserId(userId); Optional.ofNullable(shopRelUser).orElseThrow(() -> new ServiceException("未查询到商户信息")); ShopRelUserVo shopRelUserVo = new ShopRelUserVo(); shopRelUserVo.setShopId(shopRelUser.getShopId()); shopRelUserVo.setUserName(shopRelUser.getUserName()); return R.ok(shopRelUserVo); } } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/shop/ShopService.java
@@ -75,6 +75,7 @@ Shop getByShopId(Long shopId); /** * 获取商户端首页统计 * @param userId ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/sys/SysUserController.java
@@ -64,8 +64,6 @@ @Autowired private ISysConfigService configService; /** * 获取用户列表 */