Feat:原生内置时间范围搜索

This commit is contained in:
wangyu 2021-01-11 21:36:10 +08:00
parent f1fe701aff
commit c08dc11e05
4 changed files with 58 additions and 31 deletions

View File

@ -27,7 +27,6 @@
<groupId>com.flyfish.framework</groupId>
<artifactId>flyfish-web</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@ -16,6 +16,7 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
@ -44,7 +45,7 @@ public class WebSecurityConfig {
DelegatingPasswordEncoder delegatingPasswordEncoder =
(DelegatingPasswordEncoder) PasswordEncoderFactories.createDelegatingPasswordEncoder();
//设置defaultPasswordEncoderForMatches为NoOpPasswordEncoder
delegatingPasswordEncoder.setDefaultPasswordEncoderForMatches(NoOpPasswordEncoder.getInstance());
delegatingPasswordEncoder.setDefaultPasswordEncoderForMatches(new BCryptPasswordEncoder());
return delegatingPasswordEncoder;
}

View File

@ -0,0 +1,55 @@
package com.flyfish.framework.initializer;
import com.flyfish.framework.domain.UserQo;
import com.flyfish.framework.domain.po.Role;
import com.flyfish.framework.domain.po.User;
import com.flyfish.framework.enums.RoleType;
import com.flyfish.framework.enums.UserStatus;
import com.flyfish.framework.enums.UserType;
import com.flyfish.framework.service.UserService;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Arrays;
/**
* 用户初始化器可以重写
*/
@Component
public class UserInitializer {
@Resource
private UserService userService;
@Resource
private PasswordEncoder passwordEncoder;
/**
* 生成超级管理员
*/
@PostConstruct
private void init() {
UserQo qo = new UserQo();
qo.setUserType(UserType.SUPER_ADMIN.name());
if (userService.count(qo) == 0) {
User user = new User();
user.setUsername("admin");
user.setPassword(passwordEncoder.encode("admin"));
user.setUserType(UserType.SUPER_ADMIN);
user.setEnable(true);
user.setApp(false);
user.setUserStatus(UserStatus.NORMAL);
user.setRoles(Arrays.asList(Role.builder()
.type(RoleType.PC)
.admin(true)
.description("超级管理员")
.permissions(Arrays.asList())
.build()));
user.setPhone("10000000000");
user.setName("超级管理员");
user.setCode("Administrator");
userService.createSelective(user);
}
}
}

View File

@ -1,15 +1,12 @@
package com.flyfish.framework.service;
import com.flyfish.framework.domain.UserQo;
import com.flyfish.framework.domain.base.Qo;
import com.flyfish.framework.domain.po.User;
import com.flyfish.framework.enums.UserStatus;
import com.flyfish.framework.enums.UserType;
import com.flyfish.framework.repository.UserRepository;
import com.flyfish.framework.service.impl.BaseServiceImpl;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;
@ -17,31 +14,6 @@ import java.util.Optional;
@Service
public class UserService extends BaseServiceImpl<User> {
@Resource
private DepartmentService departmentService;
/**
* 生成超级管理员
*/
@PostConstruct
private void init() {
UserQo qo = new UserQo();
qo.setUserType(UserType.SUPER_ADMIN.name());
if (count(qo) == 0) {
User user = new User();
user.setUsername("admin");
user.setPassword("admin");
user.setUserType(UserType.SUPER_ADMIN);
user.setEnable(true);
user.setApp(false);
user.setUserStatus(UserStatus.NORMAL);
user.setPhone("10000000000");
user.setName("超级管理员");
user.setCode("Administrator");
createSelective(user);
}
}
/**
* 获取用户数据
*