diff --git a/auth-center/pom.xml b/auth-center/pom.xml index b2b96dcd..cb427d23 100644 --- a/auth-center/pom.xml +++ b/auth-center/pom.xml @@ -233,5 +233,13 @@ ${poi.version} provided + + + + io.minio + minio + ${minio.version} + provided + diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/permission/entity/persistence/Permission.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/permission/entity/persistence/Permission.java index 0bb7187a..52f4462d 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/permission/entity/persistence/Permission.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/permission/entity/persistence/Permission.java @@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; -import java.util.Date; +import java.time.LocalDateTime; import static com.baomidou.mybatisplus.annotation.FieldFill.INSERT; import static com.baomidou.mybatisplus.annotation.FieldFill.UPDATE; @@ -21,109 +21,83 @@ @Data @TableName(value = Permission.TABLE_NAME) public class Permission { + public static final String TABLE_NAME = "permission"; + public static final String COL_ID = "id"; + public static final String COL_URL = "url"; + public static final String COL_DESCRIPTION = "description"; + public static final String COL_TYPE = "type"; + public static final String COL_PERMISSION_EXPRESSION = "permission_expression"; + public static final String COL_METHOD = "method"; + public static final String COL_SORT = "sort"; + public static final String COL_PARENT_ID = "parent_id"; + public static final String COL_CREATED_BY = "created_by"; + public static final String COL_CREATED_TIME = "created_time"; + public static final String COL_MODIFIED_BY = "modified_by"; + public static final String COL_MODIFIED_TIME = "modified_time"; + public static final String COL_DELETED = "deleted"; /** * Primary key */ @TableId(value = COL_ID, type = IdType.AUTO) private Long id; - /** * URL. If type of record is page (1), URL stands for route; if type of record is button (2), URL stands for API */ @TableField(value = COL_URL) private String url; - /** * Permission description */ @TableField(value = COL_DESCRIPTION) private String description; - /** * Permission type. 1 - page; 2 - button */ @TableField(value = COL_TYPE) private Byte type; - /** * Permission expression */ @TableField(value = COL_PERMISSION_EXPRESSION) private String permissionExpression; - /** * HTTP method of API */ @TableField(value = COL_METHOD) private Object method; - /** * Sort number */ @TableField(value = COL_SORT) private Integer sort; - /** * Primary key of parent */ @TableField(value = COL_PARENT_ID) private Long parentId; - /** * Created by */ @TableField(value = COL_CREATED_BY, fill = INSERT) private Long createdBy; - /** * Created time */ @TableField(value = COL_CREATED_TIME, fill = INSERT) - private Date createdTime; - + private LocalDateTime createdTime; /** * Modified by */ @TableField(value = COL_MODIFIED_BY, fill = UPDATE) private Long modifiedBy; - /** * Modified time */ @TableField(value = COL_MODIFIED_TIME, fill = UPDATE) - private Date modifiedTime; - + private LocalDateTime modifiedTime; /** * Deleted flag */ @TableField(value = COL_DELETED, fill = INSERT) private Byte deleted; - - public static final String TABLE_NAME = "permission"; - - public static final String COL_ID = "id"; - - public static final String COL_URL = "url"; - - public static final String COL_DESCRIPTION = "description"; - - public static final String COL_TYPE = "type"; - - public static final String COL_PERMISSION_EXPRESSION = "permission_expression"; - - public static final String COL_METHOD = "method"; - - public static final String COL_SORT = "sort"; - - public static final String COL_PARENT_ID = "parent_id"; - - public static final String COL_CREATED_BY = "created_by"; - - public static final String COL_CREATED_TIME = "created_time"; - - public static final String COL_MODIFIED_BY = "modified_by"; - - public static final String COL_MODIFIED_TIME = "modified_time"; - - public static final String COL_DELETED = "deleted"; } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/controller/RoleController.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/controller/RoleController.java index bd17d9d3..ebe315de 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/controller/RoleController.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/controller/RoleController.java @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; +import java.time.Instant; import java.util.List; /** @@ -33,15 +34,22 @@ public ResponseEntity downloadRoleStat() { @Override public void onExceptionOccurred() { log.error("Exception occurred when uploading excel for role."); + this.fileName.set("role-stat" + Instant.now() + ".xlsx"); } @Override - protected void executeDatabaseOperation(List beanList) throws Exception { + protected void beforeDatabaseOperation(List beanList) { + log.info("BeforeDatabaseOperation: {}", beanList); + } + @Override + protected void executeDatabaseOperation(List beanList) throws Exception { + log.info("ExecuteDatabaseOperation: {}", beanList); + this.roleService.save(beanList); } @Override protected boolean validateBeforeAddToBeanList(List beanList, RoleExcelImport bean, int index) throws IllegalArgumentException { - return false; + return this.roleService.validateBeforeAddToBeanList(beanList, bean, index); } } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/entity/RoleExcelImport.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/entity/RoleExcelImport.java index 1c0ca9d6..d9c3743c 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/entity/RoleExcelImport.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/entity/RoleExcelImport.java @@ -39,4 +39,17 @@ public static RoleExcelImport transformBy(Role role) { roleExcelImport.setDescription(role.getDescription()); return roleExcelImport; } + + /** + * Transform by role. + * + * @param roleExcelImport the role excel import + * @return the role excel import + */ + public static Role transformTo(RoleExcelImport roleExcelImport) { + val role = new Role(); + role.setName(roleExcelImport.getName()); + role.setDescription(roleExcelImport.getDescription()); + return role; + } } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/entity/persistence/Role.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/entity/persistence/Role.java index c388c01b..3699ad2a 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/entity/persistence/Role.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/entity/persistence/Role.java @@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; -import java.util.Date; +import java.time.LocalDateTime; import static com.baomidou.mybatisplus.annotation.FieldFill.INSERT; import static com.baomidou.mybatisplus.annotation.FieldFill.UPDATE; @@ -21,69 +21,53 @@ @Data @TableName(value = Role.TABLE_NAME) public class Role { + public static final String TABLE_NAME = "role"; + public static final String COL_ID = "id"; + public static final String COL_NAME = "name"; + public static final String COL_DESCRIPTION = "description"; + public static final String COL_CREATED_BY = "created_by"; + public static final String COL_CREATED_TIME = "created_time"; + public static final String COL_MODIFIED_BY = "modified_by"; + public static final String COL_MODIFIED_TIME = "modified_time"; + public static final String COL_DELETED = "deleted"; /** * Primary key */ @TableId(value = COL_ID, type = IdType.AUTO) private Long id; - /** * Role name */ @TableField(value = COL_NAME) private String name; - /** * Role description */ @TableField(value = COL_DESCRIPTION) private String description; - /** * Created by */ @TableField(value = COL_CREATED_BY, fill = INSERT) private Long createdBy; - /** * Created time */ @TableField(value = COL_CREATED_TIME, fill = INSERT) - private Date createdTime; - + private LocalDateTime createdTime; /** * Modified by */ @TableField(value = COL_MODIFIED_BY, fill = UPDATE) private Long modifiedBy; - /** * Modified time */ @TableField(value = COL_MODIFIED_TIME, fill = UPDATE) - private Date modifiedTime; - + private LocalDateTime modifiedTime; /** * Deleted flag. */ @TableField(value = COL_DELETED, fill = INSERT) private Byte deleted; - - public static final String TABLE_NAME = "role"; - - public static final String COL_ID = "id"; - - public static final String COL_NAME = "name"; - - public static final String COL_DESCRIPTION = "description"; - - public static final String COL_CREATED_BY = "created_by"; - - public static final String COL_CREATED_TIME = "created_time"; - - public static final String COL_MODIFIED_BY = "modified_by"; - - public static final String COL_MODIFIED_TIME = "modified_time"; - - public static final String COL_DELETED = "deleted"; } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/service/RoleService.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/service/RoleService.java index b0c06d34..250247dc 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/service/RoleService.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/service/RoleService.java @@ -1,6 +1,7 @@ package com.jmsoftware.maf.authcenter.role.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.jmsoftware.maf.authcenter.role.entity.RoleExcelImport; import com.jmsoftware.maf.authcenter.role.entity.persistence.Role; import com.jmsoftware.maf.common.domain.authcenter.role.GetRoleListByUserIdResponse; import com.jmsoftware.maf.common.domain.authcenter.role.GetRoleListByUserIdSingleResponse; @@ -9,6 +10,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; +import javax.validation.Valid; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.util.List; @@ -23,6 +25,8 @@ */ @Validated public interface RoleService extends IService { + String ROLE_TEMPLATE_EXCEL = "role-stat.xlsx"; + /** * Gets role list by user id. * @@ -53,4 +57,21 @@ public interface RoleService extends IService { * @return the response entity */ ResponseEntity downloadRoleStat(); + + /** + * Validate before add to bean list boolean. + * + * @param beanList the bean list + * @param bean the bean + * @param index the index + * @return the boolean + */ + boolean validateBeforeAddToBeanList(List beanList, RoleExcelImport bean, int index); + + /** + * Save. + * + * @param beanList the bean list + */ + void save(@NotEmpty List<@Valid RoleExcelImport> beanList); } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/service/impl/RoleServiceImpl.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/service/impl/RoleServiceImpl.java index 8b5c34fc..9ed9ecf9 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/service/impl/RoleServiceImpl.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/service/impl/RoleServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.BooleanUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.validation.ValidationUtil; import cn.hutool.poi.excel.ExcelWriter; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -23,6 +24,7 @@ import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; import lombok.val; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.http.ContentDisposition; @@ -31,6 +33,7 @@ import org.springframework.stereotype.Service; import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; +import javax.validation.Valid; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.lang.reflect.Field; @@ -46,10 +49,10 @@ * @author Johnny Miller (锺俊) * @date 2020-05-10 22:39:50 */ +@Slf4j @Service @RequiredArgsConstructor public class RoleServiceImpl extends ServiceImpl implements RoleService { - private static final String ROLE_TEMPLATE_EXCEL = "role-stat.xlsx"; private final MafProjectProperty mafProjectProperty; private final MafConfiguration mafConfiguration; private final RedisTemplate redisTemplate; @@ -116,4 +119,25 @@ public ResponseEntity downloadRoleStat() { ContentDisposition.builder("attachment").filename(ROLE_TEMPLATE_EXCEL).build().toString()) .body(outputStream -> excelWriter.flush(outputStream, true)); } + + @Override + public boolean validateBeforeAddToBeanList(List beanList, RoleExcelImport bean, int index) { + val beanValidationResult = ValidationUtil.warpValidate(bean); + if (!beanValidationResult.isSuccess()) { + log.warn("Validation failed! beanList: {}, bean: {}, index: {}", beanList, bean, index); + val firstErrorMessage = CollUtil.getFirst(beanValidationResult.getErrorMessages()); + throw new IllegalArgumentException( + String.format("%s %s", firstErrorMessage.getPropertyName(), firstErrorMessage.getMessage())); + } + return true; + } + + @Override + public void save(@NotEmpty List<@Valid RoleExcelImport> beanList) { + val roleList = beanList.stream().map(RoleExcelImport::transformTo).collect(Collectors.toList()); + val saved = this.saveBatch(roleList); + if (!saved) { + log.error("Cannot save batch role list. {}", roleList); + } + } } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/security/controller/JwtRemoteApiController.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/security/controller/JwtRemoteApiController.java index f08559aa..c59c0d46 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/security/controller/JwtRemoteApiController.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/security/controller/JwtRemoteApiController.java @@ -3,7 +3,6 @@ import com.jmsoftware.maf.authcenter.security.service.JwtService; import com.jmsoftware.maf.common.bean.ResponseBodyBean; import com.jmsoftware.maf.common.domain.authcenter.security.ParseJwtResponse; -import com.jmsoftware.maf.common.exception.SecurityException; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -36,8 +35,7 @@ public class JwtRemoteApiController { */ @GetMapping("/parse") @ApiOperation(value = "Parse JWT", notes = "Parse JWT (Remote API)") - public ResponseBodyBean parse(HttpServletRequest request) throws SecurityException { - return ResponseBodyBean.ofSuccess( - new ParseJwtResponse().setUsername(jwtService.getUsernameFromRequest(request))); + public ResponseBodyBean parse(HttpServletRequest request) { + return ResponseBodyBean.ofSuccess(this.jwtService.parse(request)); } } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/security/service/JwtService.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/security/service/JwtService.java index ddc5d5fe..ed8dd38d 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/security/service/JwtService.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/security/service/JwtService.java @@ -1,5 +1,6 @@ package com.jmsoftware.maf.authcenter.security.service; +import com.jmsoftware.maf.common.domain.authcenter.security.ParseJwtResponse; import com.jmsoftware.maf.common.exception.SecurityException; import io.jsonwebtoken.Claims; import org.springframework.security.core.Authentication; @@ -83,4 +84,12 @@ String createJwt(Boolean rememberMe, Long id, String subject, List roles * @return the jwt from request */ String getJwtFromRequest(HttpServletRequest request); + + /** + * Parse parse jwt response. + * + * @param request the request + * @return the parse jwt response + */ + ParseJwtResponse parse(HttpServletRequest request); } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/security/service/impl/JwtServiceImpl.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/security/service/impl/JwtServiceImpl.java index e72259de..5697e3ce 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/security/service/impl/JwtServiceImpl.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/security/service/impl/JwtServiceImpl.java @@ -4,12 +4,14 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.jmsoftware.maf.authcenter.security.service.JwtService; +import com.jmsoftware.maf.common.domain.authcenter.security.ParseJwtResponse; import com.jmsoftware.maf.common.domain.authcenter.security.UserPrincipal; import com.jmsoftware.maf.common.exception.SecurityException; import com.jmsoftware.maf.springcloudstarter.configuration.JwtConfiguration; import io.jsonwebtoken.*; import io.jsonwebtoken.security.Keys; import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import lombok.val; import org.springframework.data.redis.core.RedisTemplate; @@ -49,16 +51,16 @@ public class JwtServiceImpl implements JwtService { @PostConstruct private void init() { log.info("Start to init class members of {}.", this.getClass().getSimpleName()); - secretKey = Keys.hmacShaKeyFor(jwtConfiguration.getSigningKey().getBytes(StandardCharsets.UTF_8)); - log.warn("Secret key for JWT was generated. Algorithm: {}", secretKey.getAlgorithm()); - jwtParser = Jwts.parserBuilder().setSigningKey(secretKey).build(); + this.secretKey = Keys.hmacShaKeyFor(this.jwtConfiguration.getSigningKey().getBytes(StandardCharsets.UTF_8)); + log.warn("Secret key for JWT was generated. Algorithm: {}", this.secretKey.getAlgorithm()); + this.jwtParser = Jwts.parserBuilder().setSigningKey(this.secretKey).build(); } @Override public String createJwt(Authentication authentication, Boolean rememberMe) { val userPrincipal = (UserPrincipal) authentication.getPrincipal(); - return createJwt(rememberMe, userPrincipal.getId(), userPrincipal.getUsername(), userPrincipal.getRoles(), - userPrincipal.getAuthorities()); + return this.createJwt(rememberMe, userPrincipal.getId(), userPrincipal.getUsername(), userPrincipal.getRoles(), + userPrincipal.getAuthorities()); } @Override @@ -69,19 +71,20 @@ public String createJwt(Boolean rememberMe, Long id, String subject, List 0) { builder.setExpiration(DateUtil.offsetMillisecond(now, ttl.intValue())); } val jwt = builder.compact(); // Store new JWT in Redis - String redisKeyOfJwt = String.format("%s%s", jwtConfiguration.getJwtRedisKeyPrefix(), subject); - redisTemplate.opsForValue().set(redisKeyOfJwt, jwt, ttl, TimeUnit.MILLISECONDS); + String redisKeyOfJwt = String.format("%s%s", this.jwtConfiguration.getJwtRedisKeyPrefix(), subject); + this.redisTemplate.opsForValue().set(redisKeyOfJwt, jwt, ttl, TimeUnit.MILLISECONDS); log.info("Storing JWT in Redis. Key: {}, Value: {}", redisKeyOfJwt, jwt); return jwt; } @@ -90,7 +93,7 @@ public String createJwt(Boolean rememberMe, Long id, String subject, List new SecurityException(HttpStatus.INTERNAL_SERVER_ERROR, "The JWT Claims Set is null", null)); } catch (ExpiredJwtException e) { @@ -107,16 +110,16 @@ public Claims parseJwt(String jwt) throws SecurityException { throw new SecurityException(HttpStatus.UNAUTHORIZED, "The parameter of JWT is invalid"); } val username = claims.getSubject(); - val redisKeyOfJwt = jwtConfiguration.getJwtRedisKeyPrefix() + username; + val redisKeyOfJwt = this.jwtConfiguration.getJwtRedisKeyPrefix() + username; // Check if JWT exists - val expire = redisTemplate.opsForValue().getOperations().getExpire(redisKeyOfJwt, TimeUnit.MILLISECONDS); + val expire = this.redisTemplate.opsForValue().getOperations().getExpire(redisKeyOfJwt, TimeUnit.MILLISECONDS); if (ObjectUtil.isNull(expire) || expire <= 0) { throw new SecurityException(HttpStatus.UNAUTHORIZED, "JWT is expired (Redis expiration)"); } // Check if the current JWT is equal to the one in Redis. // If it's noe equal, that indicates current user has signed out or logged in before. // Both situations reveal the JWT has expired. - val jwtInRedis = (String) redisTemplate.opsForValue().get(redisKeyOfJwt); + val jwtInRedis = (String) this.redisTemplate.opsForValue().get(redisKeyOfJwt); if (!StrUtil.equals(jwt, jwtInRedis)) { throw new SecurityException(HttpStatus.UNAUTHORIZED, "JWT is expired (Not equaled)"); } @@ -125,17 +128,17 @@ public Claims parseJwt(String jwt) throws SecurityException { @Override public void invalidateJwt(HttpServletRequest request) throws SecurityException { - val jwt = getJwtFromRequest(request); - val username = getUsernameFromJwt(jwt); + val jwt = this.getJwtFromRequest(request); + val username = this.getUsernameFromJwt(jwt); // Delete JWT from redis - String redisKeyOfJwt = String.format("%s%s", jwtConfiguration.getJwtRedisKeyPrefix(), username); - val deletedKeyNumber = redisTemplate.opsForValue().getOperations().delete(redisKeyOfJwt); + String redisKeyOfJwt = String.format("%s%s", this.jwtConfiguration.getJwtRedisKeyPrefix(), username); + val deletedKeyNumber = this.redisTemplate.opsForValue().getOperations().delete(redisKeyOfJwt); log.error("Invalidate JWT. Redis key of JWT = {}, deleted = {}", redisKeyOfJwt, deletedKeyNumber); } @Override public String getUsernameFromJwt(String jwt) throws SecurityException { - val claims = parseJwt(jwt); + val claims = this.parseJwt(jwt); return claims.getSubject(); } @@ -153,4 +156,15 @@ public String getJwtFromRequest(HttpServletRequest request) { } return null; } + + @Override + @SneakyThrows + public ParseJwtResponse parse(HttpServletRequest request) { + val jwt = this.getJwtFromRequest(request); + val claims = this.parseJwt(jwt); + val parseJwtResponse = new ParseJwtResponse(); + parseJwtResponse.setId(Long.parseLong(claims.getId())); + parseJwtResponse.setUsername(claims.getSubject()); + return parseJwtResponse; + } } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/user/entity/persistence/User.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/user/entity/persistence/User.java index 37bb3f7a..5955aa7f 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/user/entity/persistence/User.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/user/entity/persistence/User.java @@ -1,9 +1,12 @@ package com.jmsoftware.maf.authcenter.user.entity.persistence; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; -import java.util.Date; +import java.time.LocalDateTime; import static com.baomidou.mybatisplus.annotation.FieldFill.INSERT; import static com.baomidou.mybatisplus.annotation.FieldFill.UPDATE; @@ -19,125 +22,95 @@ @SuppressWarnings("jol") @TableName(value = User.TABLE_NAME) public class User { + public static final String TABLE_NAME = "user"; + public static final String COL_ID = "id"; + public static final String COL_USERNAME = "username"; + public static final String COL_EMAIL = "email"; + public static final String COL_CELLPHONE = "cellphone"; + public static final String COL_PASSWORD = "password"; + public static final String COL_FULL_NAME = "full_name"; + public static final String COL_BIRTHDAY = "birthday"; + public static final String COL_GENDER = "gender"; + public static final String COL_AVATAR = "avatar"; + public static final String COL_STATUS = "status"; + public static final String COL_CREATED_BY = "created_by"; + public static final String COL_CREATED_TIME = "created_time"; + public static final String COL_MODIFIED_BY = "modified_by"; + public static final String COL_MODIFIED_TIME = "modified_time"; + public static final String COL_DELETED = "deleted"; /** * Primary key of user */ @TableId(value = COL_ID, type = IdType.AUTO) private Long id; - /** * Username */ @TableField(value = COL_USERNAME) private String username; - /** * Email */ @TableField(value = COL_EMAIL) private String email; - /** * Cellphone number */ @TableField(value = COL_CELLPHONE) private String cellphone; - /** * Password */ @TableField(value = COL_PASSWORD) private String password; - /** * Full name */ @TableField(value = COL_FULL_NAME) private String fullName; - /** * Birthday */ @TableField(value = COL_BIRTHDAY) - private Date birthday; - + private LocalDateTime birthday; /** * 26 gender options */ @TableField(value = COL_GENDER) private Object gender; - /** * User avatar full path on SFTP server */ @TableField(value = COL_AVATAR) private String avatar; - /** * Status. 1 - enabled, 2 - disabled */ @TableField(value = COL_STATUS) private Byte status; - /** * Created by */ @TableField(value = COL_CREATED_BY, fill = INSERT) private Long createdBy; - /** * Created time */ @TableField(value = COL_CREATED_TIME, fill = INSERT) - private Date createdTime; - + private LocalDateTime createdTime; /** * Modified by */ @TableField(value = COL_MODIFIED_BY, fill = UPDATE) private Long modifiedBy; - /** * Modified time */ @TableField(value = COL_MODIFIED_TIME, fill = UPDATE) - private Date modifiedTime; - + private LocalDateTime modifiedTime; /** * Delete flag. */ @TableField(value = COL_DELETED, fill = INSERT) private Byte deleted; - - public static final String TABLE_NAME = "user"; - - public static final String COL_ID = "id"; - - public static final String COL_USERNAME = "username"; - - public static final String COL_EMAIL = "email"; - - public static final String COL_CELLPHONE = "cellphone"; - - public static final String COL_PASSWORD = "password"; - - public static final String COL_FULL_NAME = "full_name"; - - public static final String COL_BIRTHDAY = "birthday"; - - public static final String COL_GENDER = "gender"; - - public static final String COL_AVATAR = "avatar"; - - public static final String COL_STATUS = "status"; - - public static final String COL_CREATED_BY = "created_by"; - - public static final String COL_CREATED_TIME = "created_time"; - - public static final String COL_MODIFIED_BY = "modified_by"; - - public static final String COL_MODIFIED_TIME = "modified_time"; - - public static final String COL_DELETED = "deleted"; } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/user/service/impl/UserServiceImpl.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/user/service/impl/UserServiceImpl.java index 3fbcd77c..bf3defdf 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/user/service/impl/UserServiceImpl.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/user/service/impl/UserServiceImpl.java @@ -24,7 +24,7 @@ import com.jmsoftware.maf.common.exception.SecurityException; import com.jmsoftware.maf.springcloudstarter.configuration.MafConfiguration; import com.jmsoftware.maf.springcloudstarter.configuration.MafProjectProperty; -import com.jmsoftware.maf.springcloudstarter.util.UsernameUtil; +import com.jmsoftware.maf.springcloudstarter.util.UserUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import lombok.val; @@ -131,7 +131,7 @@ public boolean logout(HttpServletRequest request) throws SecurityException { @Override public String getUserStatus(@Valid @NotNull GetUserStatusPayload payload) { - log.info("Current username: {}", UsernameUtil.getCurrentUsername()); + log.info("Current username: {}", UserUtil.getCurrentUsername()); return UserStatus.ofValue(payload.getStatus()).getDescription(); } diff --git a/auth-center/src/main/resources/application-development-docker.yml b/auth-center/src/main/resources/application-development-docker.yml index f071294d..aea1e370 100644 --- a/auth-center/src/main/resources/application-development-docker.yml +++ b/auth-center/src/main/resources/application-development-docker.yml @@ -40,3 +40,10 @@ redis: maf: configuration: swagger-enabled: true + +minio: + endpoint: http://maf-minio + port: 9000 + access-key: maf_minio_root_user + secret-key: jm@minio + bucket-name: maf diff --git a/auth-center/src/main/resources/application-development-local.yml b/auth-center/src/main/resources/application-development-local.yml index c48ed62b..ce58fb7a 100644 --- a/auth-center/src/main/resources/application-development-local.yml +++ b/auth-center/src/main/resources/application-development-local.yml @@ -45,3 +45,10 @@ logging: maf: configuration: swagger-enabled: true + +minio: + endpoint: http://localhost + port: 9900 + access-key: maf_minio_root_user + secret-key: jm@minio + bucket-name: maf diff --git a/auth-center/src/main/resources/application-production.yml b/auth-center/src/main/resources/application-production.yml index 0736b0bc..5c808175 100644 --- a/auth-center/src/main/resources/application-production.yml +++ b/auth-center/src/main/resources/application-production.yml @@ -40,3 +40,10 @@ redis: maf: configuration: swagger-enabled: false + +minio: + endpoint: http://maf-minio + port: 9000 + access-key: maf_minio_root_user + secret-key: jm@minio + bucket-name: maf diff --git a/auth-center/src/main/resources/application-stage.yml b/auth-center/src/main/resources/application-stage.yml index 0736b0bc..5c808175 100644 --- a/auth-center/src/main/resources/application-stage.yml +++ b/auth-center/src/main/resources/application-stage.yml @@ -40,3 +40,10 @@ redis: maf: configuration: swagger-enabled: false + +minio: + endpoint: http://maf-minio + port: 9000 + access-key: maf_minio_root_user + secret-key: jm@minio + bucket-name: maf diff --git a/auth-center/src/main/resources/application-test.yml b/auth-center/src/main/resources/application-test.yml index ae3c624b..81332a9d 100644 --- a/auth-center/src/main/resources/application-test.yml +++ b/auth-center/src/main/resources/application-test.yml @@ -40,3 +40,10 @@ redis: maf: configuration: swagger-enabled: true + +minio: + endpoint: http://maf-minio + port: 9000 + access-key: maf_minio_root_user + secret-key: jm@minio + bucket-name: maf diff --git a/auth-center/src/main/resources/application.yml b/auth-center/src/main/resources/application.yml index 605a318b..78fdb450 100644 --- a/auth-center/src/main/resources/application.yml +++ b/auth-center/src/main/resources/application.yml @@ -196,3 +196,6 @@ maf: jwt: # an hour ttl: 3600000 + +minio: + enabled: true