mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 20:54:26 +08:00
feat:整合sentinel
This commit is contained in:
parent
29c1a06ec2
commit
48ecde6caa
@ -28,9 +28,10 @@ public class AddressController {
|
||||
|
||||
private final Integer ADDRESS_DEFAULTED = 1;
|
||||
|
||||
@ApiOperation(value = "获取会员的地址列表")
|
||||
@ApiOperation(value = "获取登录会员的地址列表")
|
||||
@GetMapping
|
||||
public Result list(@RequestParam(required = false) Long memberId) {
|
||||
public Result list() {
|
||||
Long memberId = RequestUtils.getUserId();
|
||||
List<UmsAddress> addressList = iUmsAddressService.list(new LambdaQueryWrapper<UmsAddress>()
|
||||
.eq(UmsAddress::getMemberId, memberId)
|
||||
.orderByDesc(UmsAddress::getDefaulted));
|
||||
@ -42,11 +43,11 @@ public class AddressController {
|
||||
@ApiImplicitParam(name = "address", value = "实体JSON对象", required = true, paramType = "body", dataType = "UmsAddress")
|
||||
@PostMapping
|
||||
public Result add(@RequestBody UmsAddress address) {
|
||||
Long userId = RequestUtils.getUserId();
|
||||
address.setMemberId(userId);
|
||||
Long memberId = RequestUtils.getUserId();
|
||||
address.setMemberId(memberId);
|
||||
if (ADDRESS_DEFAULTED.equals(address.getDefaulted())) { // 修改其他默认地址为非默认
|
||||
iUmsAddressService.update(new LambdaUpdateWrapper<UmsAddress>()
|
||||
.eq(UmsAddress::getMemberId, userId)
|
||||
.eq(UmsAddress::getMemberId, memberId)
|
||||
.eq(UmsAddress::getDefaulted, 1)
|
||||
.set(UmsAddress::getDefaulted, 0)
|
||||
);
|
||||
@ -65,10 +66,10 @@ public class AddressController {
|
||||
public Result update(
|
||||
@PathVariable Long id,
|
||||
@RequestBody UmsAddress address) {
|
||||
Long userId = RequestUtils.getUserId();
|
||||
Long memberId = RequestUtils.getUserId();
|
||||
if (address.getDefaulted().equals(1)) { // 修改其他默认地址为非默认
|
||||
iUmsAddressService.update(new LambdaUpdateWrapper<UmsAddress>()
|
||||
.eq(UmsAddress::getMemberId, userId)
|
||||
.eq(UmsAddress::getMemberId, memberId)
|
||||
.eq(UmsAddress::getDefaulted, 1)
|
||||
.set(UmsAddress::getDefaulted, 0)
|
||||
);
|
||||
|
@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author haoxr
|
||||
* @description TODO
|
||||
* @description 自定义流控异常
|
||||
* @createTime 2021/4/12 22:57
|
||||
*/
|
||||
@Component
|
||||
@ -26,8 +26,11 @@ public class CustomBlockExceptionHandler implements BlockExceptionHandler {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
if(e instanceof FlowException){
|
||||
new ObjectMapper().writeValue(response.getWriter(), Result.failed(ResultCode.FLOW_LIMITING));
|
||||
// objectMapper.writeValue 用于将java对象转位JSON格式返回调用方
|
||||
objectMapper.writeValue(response.getWriter(), Result.failed(ResultCode.FLOW_LIMITING));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
" left join sys_dept d on u.dept_id= d.id " +
|
||||
" left join sys_user_role ur on u.id=ur.user_id " +
|
||||
" left join sys_role r on ur.role_id=r.id " +
|
||||
" where 1=1 " +
|
||||
" where deleted != 1 " +
|
||||
" <if test ='user.username!=null and user.username.trim() neq \"\"'>" +
|
||||
" and u.username like concat('%',#{user.username},'%')" +
|
||||
" </if>" +
|
||||
|
@ -1,15 +1,15 @@
|
||||
package com.youlai.auth.service;
|
||||
|
||||
import com.youlai.admin.pojo.dto.UserDTO;
|
||||
import com.youlai.admin.api.UserFeignService;
|
||||
import com.youlai.admin.pojo.dto.UserDTO;
|
||||
import com.youlai.auth.domain.User;
|
||||
import com.youlai.common.constant.AuthConstants;
|
||||
import com.youlai.common.result.Result;
|
||||
import com.youlai.common.result.ResultCode;
|
||||
import com.youlai.common.web.exception.BizException;
|
||||
import com.youlai.common.web.util.RequestUtils;
|
||||
import com.youlai.mall.ums.pojo.dto.AuthMemberDTO;
|
||||
import com.youlai.mall.ums.api.UmsMemberFeignService;
|
||||
import com.youlai.mall.ums.pojo.dto.AuthMemberDTO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.security.authentication.AccountExpiredException;
|
||||
import org.springframework.security.authentication.DisabledException;
|
||||
@ -43,7 +43,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
UserDTO userDTO = (UserDTO) result.getData();
|
||||
user = new User(userDTO);
|
||||
} else {
|
||||
throw new BizException(ResultCode.getValue(result.getCode()));
|
||||
throw new BizException(result.getMsg());
|
||||
}
|
||||
break;
|
||||
case AuthConstants.WEAPP_CLIENT_ID: // 小程序会员
|
||||
@ -51,8 +51,8 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
if (ResultCode.SUCCESS.getCode().equals(result.getCode())) {
|
||||
AuthMemberDTO authMemberDTO = (AuthMemberDTO) result.getData();
|
||||
user = new User(authMemberDTO);
|
||||
} else {
|
||||
throw new BizException(ResultCode.getValue(result.getCode()));
|
||||
} else {
|
||||
throw new BizException(result.getMsg());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ spring:
|
||||
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
||||
file-extension: yaml
|
||||
sentinel:
|
||||
enabled: false
|
||||
enabled: false # 网关流控开关
|
||||
eager: true # 取消控制台懒加载,项目启动即连接Sentinel
|
||||
transport:
|
||||
client-ip: localhost
|
||||
|
Loading…
Reference in New Issue
Block a user