Merge branch 'master' of https://git.njzscloud.com/lzq/njzscloud-dispose
commit
633467ab9e
|
|
@ -38,7 +38,6 @@ public enum ClientCode implements DictInt {
|
|||
}
|
||||
|
||||
public static boolean valid(int clientCode) {
|
||||
|
||||
Optional<Integer> max = Arrays.stream(ClientCode.class.getEnumConstants())
|
||||
.map(ClientCode::getVal)
|
||||
.reduce((a, b) -> a | b);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.njzscloud.common.security.contant;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.njzscloud.common.core.utils.Key;
|
||||
import com.njzscloud.common.security.support.AnonymousUser;
|
||||
import com.njzscloud.common.security.support.UserDetail;
|
||||
|
||||
/**
|
||||
|
|
@ -28,5 +30,5 @@ public final class Constants {
|
|||
/**
|
||||
* 匿名用户
|
||||
*/
|
||||
public static final UserDetail ANONYMOUS_USER = UserDetail.anonymousUser();
|
||||
public static final UserDetail ANONYMOUS_USER = SpringUtil.getBean(AnonymousUser.class).anonymousUser();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package com.njzscloud.common.security.support;
|
||||
|
||||
public interface AnonymousUser {
|
||||
UserDetail anonymousUser();
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package com.njzscloud.common.security.support;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
|
@ -15,8 +14,6 @@ import org.springframework.security.core.CredentialsContainer;
|
|||
import java.security.Principal;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.njzscloud.common.security.contant.Constants.ROLE_ANONYMOUS;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
|
|
@ -69,14 +66,6 @@ public class UserDetail implements CredentialsContainer, Principal {
|
|||
*/
|
||||
private Boolean disabled;
|
||||
|
||||
public static UserDetail anonymousUser() {
|
||||
return new UserDetail()
|
||||
.setUserId(0L)
|
||||
.setAccountId(0L)
|
||||
.setRoles(CollUtil.newHashSet(ROLE_ANONYMOUS))
|
||||
.setToken(Token.anonymousToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* 账号是否过期
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@ import cn.hutool.core.lang.Assert;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.njzscloud.common.core.ex.Exceptions;
|
||||
import com.njzscloud.common.security.contant.ClientCode;
|
||||
import com.njzscloud.common.security.module.password.PasswordLoginForm;
|
||||
import com.njzscloud.common.security.module.wechat.mini.WechatMiniLoginForm;
|
||||
import com.njzscloud.common.security.support.AnonymousUser;
|
||||
import com.njzscloud.common.security.support.IAuthService;
|
||||
import com.njzscloud.common.security.support.Token;
|
||||
import com.njzscloud.common.security.support.UserDetail;
|
||||
import com.njzscloud.dispose.finance.mapper.MoneyAccountMapper;
|
||||
import com.njzscloud.dispose.finance.pojo.entity.MoneyAccountEntity;
|
||||
|
|
@ -23,6 +26,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -35,7 +39,7 @@ import static com.njzscloud.common.security.contant.Constants.ROLE_AUTHENTICATED
|
|||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AuthService implements IAuthService {
|
||||
public class AuthService implements IAuthService, AnonymousUser {
|
||||
private final AuthMapper authMapper;
|
||||
private final MoneyAccountMapper moneyAccountMapper;
|
||||
|
||||
|
|
@ -71,13 +75,15 @@ public class AuthService implements IAuthService {
|
|||
@Override
|
||||
public UserDetail my(Long userId, Integer client) {
|
||||
UserDetail userDetail = authMapper.selectUser(Wrappers.query().eq("b.id", userId).eq("a.deleted", 0));
|
||||
Assert.notNull(userDetail, () -> Exceptions.exception("未查询到用户信息"));
|
||||
// Assert.notNull(userDetail, () -> Exceptions.exception("未查询到用户信息"));
|
||||
if (userDetail == null) return null;
|
||||
return my(userDetail, client);
|
||||
}
|
||||
|
||||
public UserDetail my(Long userId, Integer client, Long currentCustomerId) {
|
||||
UserDetail userDetail = authMapper.selectUser(Wrappers.query().eq("b.id", userId).eq("a.deleted", 0));
|
||||
Assert.notNull(userDetail, () -> Exceptions.exception("未查询到用户信息"));
|
||||
if (userDetail == null) return null;
|
||||
// Assert.notNull(userDetail, () -> Exceptions.exception("未查询到用户信息"));
|
||||
return my(userDetail, client, currentCustomerId);
|
||||
}
|
||||
|
||||
|
|
@ -118,4 +124,13 @@ public class AuthService implements IAuthService {
|
|||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetail anonymousUser() {
|
||||
return new MyResult()
|
||||
.setClient(Arrays.stream(ClientCode.values()).map(ClientCode::getVal).reduce(Integer::sum).orElse(0))
|
||||
.setUserId(0L)
|
||||
.setAccountId(0L)
|
||||
.setRoles(CollUtil.newHashSet(ROLE_ANONYMOUS))
|
||||
.setToken(Token.anonymousToken());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,26 +29,6 @@ public class DistrictEntity {
|
|||
*/
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 省
|
||||
*/
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 市
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 区县
|
||||
*/
|
||||
private String area;
|
||||
|
||||
/**
|
||||
* 乡镇街道
|
||||
*/
|
||||
private String town;
|
||||
|
||||
/**
|
||||
* 层级; >= 1
|
||||
*/
|
||||
|
|
@ -58,10 +38,9 @@ public class DistrictEntity {
|
|||
* 地区名称
|
||||
*/
|
||||
private String districtName;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
private String initial;
|
||||
private String pinyin;
|
||||
private Double lng;
|
||||
private Double lat;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,26 +21,6 @@ public class DistrictTreeResult {
|
|||
*/
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 省
|
||||
*/
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 市
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 区县
|
||||
*/
|
||||
private String area;
|
||||
|
||||
/**
|
||||
* 乡镇街道
|
||||
*/
|
||||
private String town;
|
||||
|
||||
/**
|
||||
* 层级; >= 1
|
||||
*/
|
||||
|
|
@ -50,12 +30,10 @@ public class DistrictTreeResult {
|
|||
* 地区名称
|
||||
*/
|
||||
private String districtName;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
|
||||
private Integer sort;
|
||||
private String initial;
|
||||
private String pinyin;
|
||||
private Double lng;
|
||||
private Double lat;
|
||||
|
||||
private List<DistrictTreeResult> children;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import lombok.Setter;
|
|||
@Setter
|
||||
@Constraint
|
||||
public class MenuAddParam implements Constrained {
|
||||
@NotNull
|
||||
@NotNull(message = "未指定客户端")
|
||||
private ClientCode clientCode;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -69,7 +70,7 @@ public class MenuService extends ServiceImpl<MenuMapper, MenuEntity> implements
|
|||
|
||||
Integer sort = menuEntity.getSort();
|
||||
if (sort == null || sort == 0) {
|
||||
Integer maxSort = this.getOne(Wrappers.<MenuEntity>query().eq("pid", pid).orderByDesc("sort").select("IFNULL(MAX(sort),0) sort")).getSort();
|
||||
Integer maxSort = this.getOne(Wrappers.<MenuEntity>query().eq("pid", pid).select("IFNULL(MAX(sort),0) sort")).getSort();
|
||||
menuEntity.setSort(maxSort + 1);
|
||||
} else {
|
||||
this.update(Wrappers.<MenuEntity>lambdaUpdate().eq(MenuEntity::getPid, pid).ge(MenuEntity::getSort, sort).setIncrBy(MenuEntity::getSort, 1));
|
||||
|
|
@ -108,29 +109,27 @@ public class MenuService extends ServiceImpl<MenuMapper, MenuEntity> implements
|
|||
}
|
||||
Long oldPid = oldMenuEntity.getPid();
|
||||
if (pid != null && !pid.equals(oldPid)) {
|
||||
MenuEntity parent = this.getById(pid);
|
||||
MenuEntity parent;
|
||||
if (pid == 0) {
|
||||
parent = new MenuEntity()
|
||||
.setTier(0)
|
||||
.setBreadcrumb(new LinkedList<>())
|
||||
.setId(0L);
|
||||
} else {
|
||||
parent = this.getById(pid);
|
||||
}
|
||||
Assert.notNull(parent, () -> Exceptions.exception("上级菜单不存在"));
|
||||
String title = menuEntity.getTitle();
|
||||
List<String> breadcrumb = parent.getBreadcrumb();
|
||||
breadcrumb.add(StrUtil.isBlank(title) ? oldMenuEntity.getTitle() : title);
|
||||
menuEntity.setBreadcrumb(breadcrumb)
|
||||
.setTier(parent.getTier() + 1);
|
||||
|
||||
this.modifyChild(menuEntity);
|
||||
}
|
||||
|
||||
Integer sort = menuEntity.getSort();
|
||||
if (sort != null && sort != 0) {
|
||||
List<MenuEntity> list = this.list(Wrappers.<MenuEntity>lambdaQuery()
|
||||
.eq(MenuEntity::getPid, pid == null ? oldPid : pid)
|
||||
.ge(MenuEntity::getSort, sort)
|
||||
.ne(MenuEntity::getId, id)
|
||||
.select(MenuEntity::getSort, MenuEntity::getId)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
list.forEach(item -> item.setSort(sort + 1));
|
||||
this.updateBatchById(list);
|
||||
}
|
||||
this.update(Wrappers.<MenuEntity>lambdaUpdate().eq(MenuEntity::getPid, pid).ge(MenuEntity::getSort, sort).setIncrBy(MenuEntity::getSort, 1));
|
||||
}
|
||||
|
||||
this.updateById(menuEntity);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ spring:
|
|||
- /endpoint/reload
|
||||
- /permission/refresh_cache
|
||||
- /static/**
|
||||
- /**
|
||||
|
||||
oss:
|
||||
type: ali
|
||||
|
|
|
|||
Loading…
Reference in New Issue