Skip to content

Commit

Permalink
Merge branch 'master' of github.com:huankai/hk-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
huankai committed Sep 11, 2019
2 parents c45c9e4 + 2cef6d5 commit 88567f5
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Version;
import org.springframework.data.elasticsearch.annotations.*;
import org.springframework.data.elasticsearch.core.completion.Completion;

Expand Down Expand Up @@ -346,6 +347,18 @@ public static class CommoditySKUStore implements Serializable {
//
// }

/**
* 指定版本,类型为 Long
*/
@Version
private Long version;

/**
* parent
*/
@Parent(type = "")
private String parent;

/**
* 商品服务信息
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected void configure(HttpSecurity http) throws Exception {
.authorizeRequests().anyRequest().authenticated();
}

private UserDetailsService userDetailsService = username -> new SecurityUserPrincipal(1L, null, null, null, null, username, false,
private UserDetailsService userDetailsService = username -> new SecurityUserPrincipal(1L, null, null, null, null, username,
username, ByteConstants.ONE, username,
username, ByteConstants.ONE, null, username, ByteConstants.TWO, null, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected void configure(HttpSecurity http) throws Exception {
.authorizeRequests().anyRequest().authenticated();
}

private UserDetailsService userDetailsService = username -> new SecurityUserPrincipal(1L, null, null, null, null, username, false,
private UserDetailsService userDetailsService = username -> new SecurityUserPrincipal(1L, null, null, null, null, username,
username, ByteConstants.ONE, username,
username, ByteConstants.ONE, null, username, ByteConstants.TWO, null, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class TokenUserPrincipal extends SecurityUserPrincipal implements Seriali

public TokenUserPrincipal(String token, LocalDateTime expire, SecurityUserPrincipal principal) {
super(principal.getUserId(), principal.getOrgId(), principal.getOrgName(),
principal.getDeptId(), principal.getDeptName(), principal.getAccount(), principal.isProtectUser(),
principal.getDeptId(), principal.getDeptName(), principal.getAccount(),
principal.getRealName(), principal.getUserType(), principal.getPhone(),
principal.getEmail(), principal.getSex(), principal.getIconPath(), principal.getPassword(), principal.getUserType(),
principal.getRoles(), principal.getPermissions());
Expand All @@ -45,11 +45,11 @@ public TokenUserPrincipal(String token, LocalDateTime expire, SecurityUserPrinci

public TokenUserPrincipal(String token, LocalDateTime expire, Long userId, Long orgId, String orgName,
Long deptId, String deptName,
String account, boolean protectUser,
String account,
String realName, Byte userType, String phone,
String email, Byte sex, String iconPath, String password,
Byte userStatus, Set<String> roles, Set<String> permissions) {
super(userId, orgId, orgName, deptId, deptName, account, protectUser, realName, userType, phone, email, sex, iconPath, password, userStatus,
super(userId, orgId, orgName, deptId, deptName, account, realName, userType, phone, email, sex, iconPath, password, userStatus,
roles, permissions);
this.token = token;
this.expire = expire;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
package com.hk.weixin.example;

import com.hk.commons.util.ByteConstants;
import com.hk.core.authentication.api.ClientAppInfo;
import com.hk.core.authentication.security.SecurityUserPrincipal;
import com.hk.core.authentication.security.UserDetailClientService;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.security.core.userdetails.UserDetailsService;

/**
* @author kevin
* @date 2017年12月19日上午10:57:48
*/
@SpringBootApplication
public class WxMpDemoApplication {

public static void main(String[] args) {
SpringApplication application = new SpringApplication(WxMpDemoApplication.class);
application.setBannerMode(Banner.Mode.OFF);
application.run(args);
}

@Bean
public UserDetailsService userDetailsService() {
return new UserDetailClientService() {
@Override
public SecurityUserPrincipal loadUserByLoginUsername(String username) {
return new SecurityUserPrincipal(1L, null, null, null, null, username, false,
username, ByteConstants.ONE, username,
username, ByteConstants.ONE, null, "$2a$10$KgOArE6QpbY2iTQC0WGGS.hP72PQsHpToqbNVEEmUrd5LcEqrbzAG", ByteConstants.TWO, null, null);
}

@Override
public ClientAppInfo getClientInfoById(Long clientId) {
return null;
}
};
}

}
package com.hk.weixin.example;

import com.hk.commons.util.ByteConstants;
import com.hk.core.authentication.api.ClientAppInfo;
import com.hk.core.authentication.security.SecurityUserPrincipal;
import com.hk.core.authentication.security.UserDetailClientService;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.security.core.userdetails.UserDetailsService;

/**
* @author kevin
* @date 2017年12月19日上午10:57:48
*/
@SpringBootApplication
public class WxMpDemoApplication {

public static void main(String[] args) {
SpringApplication application = new SpringApplication(WxMpDemoApplication.class);
application.setBannerMode(Banner.Mode.OFF);
application.run(args);
}

@Bean
public UserDetailsService userDetailsService() {
return new UserDetailClientService() {
@Override
public SecurityUserPrincipal loadUserByLoginUsername(String username) {
return new SecurityUserPrincipal(1L, null, null, null, null, username,
username, ByteConstants.ONE, username,
username, ByteConstants.ONE, null, "$2a$10$KgOArE6QpbY2iTQC0WGGS.hP72PQsHpToqbNVEEmUrd5LcEqrbzAG", ByteConstants.TWO, null, null);
}

@Override
public ClientAppInfo getClientInfoById(Long clientId) {
return null;
}
};
}

}
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
/**
*
*/
package com.hk.weixin.example.config;

import com.hk.commons.util.ByteConstants;
import com.hk.core.authentication.api.ClientAppInfo;
import com.hk.core.authentication.security.SecurityUserPrincipal;
import com.hk.core.authentication.security.UserDetailClientService;
import com.hk.weixin.example.domain.User;
import com.hk.weixin.example.repository.jpa.UserRepository;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import java.util.Optional;

/**
* @author kevin
* @date 2018年2月5日下午3:03:07
*/
public class UserDetailServcieImpl implements UserDetailClientService {

private UserRepository userRepository;

@Override
public SecurityUserPrincipal loadUserByLoginUsername(String username) {
Optional<User> optional = userRepository.findUniqueByLoginName(username);
if (!optional.isPresent()) {
throw new UsernameNotFoundException("不存在的用户:" + username);
}
User user = optional.get();
return new SecurityUserPrincipal(user.getId(), null, null, null, null, user.getPhone(), false,
user.getNickName(), ByteConstants.ONE, user.getPhone(),
user.getEmail(), ByteConstants.ONE, user.getIconPath(), user.getPassWord(), ByteConstants.TWO, null, null);
}

@Override
public ClientAppInfo getClientInfoById(Long clientId) {
return null;
}

public void setUserRepository(UserRepository userRepository) {
this.userRepository = userRepository;
}

}
/**
*
*/
package com.hk.weixin.example.config;

import com.hk.commons.util.ByteConstants;
import com.hk.core.authentication.api.ClientAppInfo;
import com.hk.core.authentication.security.SecurityUserPrincipal;
import com.hk.core.authentication.security.UserDetailClientService;
import com.hk.weixin.example.domain.User;
import com.hk.weixin.example.repository.jpa.UserRepository;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import java.util.Optional;

/**
* @author kevin
* @date 2018年2月5日下午3:03:07
*/
public class UserDetailServcieImpl implements UserDetailClientService {

private UserRepository userRepository;

@Override
public SecurityUserPrincipal loadUserByLoginUsername(String username) {
Optional<User> optional = userRepository.findUniqueByLoginName(username);
if (!optional.isPresent()) {
throw new UsernameNotFoundException("不存在的用户:" + username);
}
User user = optional.get();
return new SecurityUserPrincipal(user.getId(), null, null, null, null, user.getPhone(),
user.getNickName(), ByteConstants.ONE, user.getPhone(),
user.getEmail(), ByteConstants.ONE, user.getIconPath(), user.getPassWord(), ByteConstants.TWO, null, null);
}

@Override
public ClientAppInfo getClientInfoById(Long clientId) {
return null;
}

public void setUserRepository(UserRepository userRepository) {
this.userRepository = userRepository;
}

}

0 comments on commit 88567f5

Please sign in to comment.