Skip to content

Commit

Permalink
Merge pull request #128 from geekidea/dev
Browse files Browse the repository at this point in the history
fix CodeGenerator/ SysUser / mysql_spring_boot_plus.sql
  • Loading branch information
springboot-plus authored Mar 31, 2020
2 parents c824049 + ecf6276 commit d631394
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 94 deletions.
158 changes: 84 additions & 74 deletions docs/db/mysql_spring_boot_plus.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static void printTip(ConfigurableApplicationContext context) {
tip.append(" generator: 代码生成模块,启动类:SpringBootPlusGenerator,请根据实际情况进行配置\n");
tip.append(" scheduled: 任务调度模块\n");
tip.append(" system: 系统管理模块\n");
tip.append(" 6.FAQ:https://springboot.plus/faq.html\n");
tip.append(" 6.FAQ:https://springboot.plus/faq\n");
tip.append(" 7.如开发中遇到bug及问题,欢迎提交ISSUES:https://github.com/geekidea/spring-boot-plus/issues\n");
tip.append(" 8.QQ:625301326,进群答案:springboot.plus\n");
tip.append(" \n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;

/**
* spring-boot-plus代码生成器
Expand Down Expand Up @@ -82,7 +83,7 @@ public void init(String tableName, GeneratorProperties generatorProperties) {
}
// 如果包路径为空,转换包名称路径
if (StringUtils.isNotBlank(parentPackage)) {
generatorProperties.setParentPackagePath(parentPackage.replaceAll("\\.", File.separator));
generatorProperties.setParentPackagePath(parentPackage.replaceAll("\\.", Matcher.quoteReplacement(File.separator)));
}

String mavenModuleName = generatorProperties.getMavenModuleName();
Expand Down Expand Up @@ -130,17 +131,9 @@ public void generator(String tableName, String pkIdName, GeneratorProperties gen
String resourcesOutputDir = null;
String mapperXmlOutputDir = null;


if (StringUtils.isBlank(outputDir)) {
// 使用application.yml配置时,默认路径设置
// String currentProjectPath = System.getProperty(GeneratorConstant.USER_DIR);
// File rootProjectFile = new File(currentProjectPath);
// String rootProjectPath = rootProjectFile.getParent();
// 从java启动时,默认路径设置
String currentClassPath = this.getClass().getClassLoader().getResource("").getFile();
File file = new File(currentClassPath);
String rootProjectPath = file.getParentFile().getParentFile().getParentFile().getAbsolutePath();
outputDir = rootProjectPath + File.separator + mavenModuleName;
String rootProjectFile = System.getProperty(GeneratorConstant.USER_DIR);
outputDir = rootProjectFile + File.separator + mavenModuleName;
}
log.info("outputDir: {}", outputDir);
javaOutputDir = outputDir + GeneratorConstant.JAVA_DIR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import io.geekidea.springbootplus.generator.properties.GeneratorProperties;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
* spring-boot-plus代码生成器入口类
*
Expand All @@ -51,6 +53,8 @@ public static void main(String[] args) {

// 设置表信息
generatorProperties.addTable("foo_bar","id");
// 设置表前缀
// generatorProperties.setTablePrefix(Arrays.asList("tb_"));

// 数据源配置
generatorProperties.getDataSourceConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
Expand Down Expand Up @@ -66,7 +68,7 @@ public class SysUserController extends BaseController {
@RequiresPermissions("sys:user:add")
@OperationLog(name = "添加系统用户", type = OperationLogType.ADD)
@ApiOperation(value = "添加系统用户", response = ApiResult.class)
public ApiResult<Boolean> addSysUser(@Validated @RequestBody SysUser sysUser) throws Exception {
public ApiResult<Boolean> addSysUser(@Validated(Add.class) @RequestBody SysUser sysUser) throws Exception {
boolean flag = sysUserService.saveSysUser(sysUser);
return ApiResult.result(flag);
}
Expand All @@ -78,7 +80,7 @@ public ApiResult<Boolean> addSysUser(@Validated @RequestBody SysUser sysUser) th
@RequiresPermissions("sys:user:update")
@OperationLog(name = "修改系统用户", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改系统用户", response = ApiResult.class)
public ApiResult<Boolean> updateSysUser(@Validated @RequestBody SysUser sysUser) throws Exception {
public ApiResult<Boolean> updateSysUser(@Validated(Update.class) @RequestBody SysUser sysUser) throws Exception {
boolean flag = sysUserService.updateSysUser(sysUser);
return ApiResult.result(flag);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
Expand Down Expand Up @@ -50,12 +51,12 @@ public class SysUser extends BaseEntity {
private static final long serialVersionUID = 1L;

@ApiModelProperty("主键")
@NotNull(message = "ID不能为空",groups = {Update.class})
@NotNull(message = "ID不能为空", groups = {Update.class})
@TableId(value = "id", type = IdType.AUTO)
private Long id;

@ApiModelProperty("用户名")
@NotNull(message = "用户名不能为空")
@NotNull(message = "用户名不能为空", groups = {Add.class})
private String username;

@ApiModelProperty("昵称")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,16 @@ public boolean saveSysUser(SysUser sysUser) throws Exception {
// 生成盐值
String salt = null;
String password = sysUser.getPassword();
String encryptPassword = null;
// 如果密码为空,则设置默认密码
if (StringUtils.isBlank(password)) {
salt = springBootPlusProperties.getLoginInitSalt();
encryptPassword = springBootPlusProperties.getLoginInitPassword();
password = springBootPlusProperties.getLoginInitPassword();
} else {
salt = SaltUtil.generateSalt();
}
// 密码加密
encryptPassword = PasswordUtil.encrypt(password, salt);
sysUser.setSalt(salt);
sysUser.setPassword(encryptPassword);
sysUser.setPassword(PasswordUtil.encrypt(password, salt));

// 如果头像为空,则设置默认头像
if (StringUtils.isBlank(sysUser.getHead())) {
Expand Down

0 comments on commit d631394

Please sign in to comment.