Skip to content

Commit 3d734c7

Browse files
author
smallchill
committed
🎉 2.1.0.RELEASE
1 parent c7112fd commit 3d734c7

File tree

140 files changed

+3384
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+3384
-622
lines changed

blade-auth/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<artifactId>SpringBlade</artifactId>
1010
<groupId>org.springblade</groupId>
11-
<version>2.0.0</version>
11+
<version>2.1.0</version>
1212
</parent>
1313

1414
<artifactId>blade-auth</artifactId>

blade-auth/src/main/java/org/springblade/auth/controller/AuthController.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import io.swagger.annotations.ApiOperation;
2020
import io.swagger.annotations.ApiParam;
2121
import lombok.AllArgsConstructor;
22-
import org.springblade.core.log.annotation.ApiLog;
2322
import org.springblade.core.secure.AuthInfo;
2423
import org.springblade.core.secure.utils.SecureUtil;
2524
import org.springblade.core.tool.api.R;
@@ -45,31 +44,32 @@
4544
@Api(value = "用户授权认证", tags = "授权接口")
4645
public class AuthController {
4746

48-
IUserClient client;
47+
private IUserClient client;
4948

50-
@ApiLog("登录用户验证")
5149
@PostMapping("token")
52-
@ApiOperation(value = "获取认证token", notes = "传入账号:account,密码:password")
53-
public R<AuthInfo> token(@ApiParam(value = "账号", required = true) @RequestParam String account,
50+
@ApiOperation(value = "获取认证token", notes = "传入租户编号:tenantCode,账号:account,密码:password")
51+
public R<AuthInfo> token(@ApiParam(value = "租户编号", required = true) @RequestParam String tenantCode,
52+
@ApiParam(value = "账号", required = true) @RequestParam String account,
5453
@ApiParam(value = "密码", required = true) @RequestParam String password) {
5554

5655
if (Func.hasEmpty(account, password)) {
5756
return R.fail("接口调用不合法");
5857
}
5958

60-
R<UserInfo> res = client.userInfo(account, DigestUtil.encrypt(password));
59+
R<UserInfo> res = client.userInfo(tenantCode, account, DigestUtil.encrypt(password));
6160

6261
User user = res.getData().getUser();
6362

6463
//验证用户
65-
if (user == null || Func.isEmpty(user.getId())) {
64+
if (Func.isEmpty(user.getId())) {
6665
return R.fail("用户名或密码不正确");
6766
}
6867

6968
//设置jwt参数
7069
Map<String, String> param = new HashMap<>(16);
7170
param.put(SecureUtil.USER_ID, Func.toStr(user.getId()));
7271
param.put(SecureUtil.ROLE_ID, user.getRoleId());
72+
param.put(SecureUtil.TENANT_CODE, user.getTenantCode());
7373
param.put(SecureUtil.ACCOUNT, user.getAccount());
7474
param.put(SecureUtil.USER_NAME, user.getRealName());
7575
param.put(SecureUtil.ROLE_NAME, Func.join(res.getData().getRoles()));

blade-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>SpringBlade</artifactId>
77
<groupId>org.springblade</groupId>
8-
<version>2.0.0</version>
8+
<version>2.1.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ public interface CommonConstant {
2727
*/
2828
String SENTINEL_PROD_ADDR = "192.168.186.129:8858";
2929

30+
/**
31+
* sword 系统名
32+
*/
33+
String SWORD_NAME = "sword";
34+
35+
/**
36+
* saber 系统名
37+
*/
38+
String SABER_NAME = "saber";
39+
3040
/**
3141
* 顶级父节点id
3242
*/

blade-gateway/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>SpringBlade</artifactId>
77
<groupId>org.springblade</groupId>
8-
<version>2.0.0</version>
8+
<version>2.1.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

blade-ops/blade-admin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>blade-ops</artifactId>
77
<groupId>org.springblade</groupId>
8-
<version>2.0.0</version>
8+
<version>2.1.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

blade-ops/blade-develop/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.springblade</groupId>
88
<artifactId>blade-ops</artifactId>
9-
<version>2.0.0</version>
9+
<version>2.1.0</version>
1010
</parent>
1111

1212
<modelVersion>4.0.0</modelVersion>

blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.springblade.core.tool.utils.Func;
2626
import org.springblade.develop.entity.Code;
2727
import org.springblade.develop.service.ICodeService;
28-
import org.springblade.develop.support.BladeGenerator;
28+
import org.springblade.develop.support.BladeCodeGenerator;
2929
import org.springframework.web.bind.annotation.*;
3030
import springfox.documentation.annotations.ApiIgnore;
3131

@@ -37,7 +37,6 @@
3737
* 控制器
3838
*
3939
* @author Chill
40-
* @since 2018-12-24
4140
*/
4241
@RestController
4342
@AllArgsConstructor
@@ -86,7 +85,7 @@ public R submit(@Valid @RequestBody Code code) {
8685
* 删除
8786
*/
8887
@PostMapping("/remove")
89-
@ApiOperation(value = "物理删除", notes = "传入ids", position = 7)
88+
@ApiOperation(value = "删除", notes = "传入ids", position = 7)
9089
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
9190
return R.status(codeService.removeByIds(Func.toIntList(ids)));
9291
}
@@ -96,11 +95,13 @@ public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam
9695
*/
9796
@PostMapping("/gen-code")
9897
@ApiOperation(value = "代码生成", notes = "传入ids", position = 8)
99-
public R genCode(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
98+
public R genCode(@ApiParam(value = "主键集合", required = true) @RequestParam String ids, @RequestParam(defaultValue = "sword") String system) {
10099
Collection<Code> codes = codeService.listByIds(Func.toIntList(ids));
101100
codes.forEach(code -> {
102-
BladeGenerator generator = new BladeGenerator();
101+
BladeCodeGenerator generator = new BladeCodeGenerator();
102+
generator.setSystemName(system);
103103
generator.setServiceName(code.getServiceName());
104+
generator.setCodeName(code.getCodeName());
104105
generator.setPackageName(code.getPackageName());
105106
generator.setPackageDir(code.getApiPath());
106107
generator.setPackageWebDir(code.getWebPath());

blade-ops/blade-develop/src/main/java/org/springblade/develop/support/BladeGenerator.java renamed to blade-ops/blade-develop/src/main/java/org/springblade/develop/support/BladeCodeGenerator.java

Lines changed: 83 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
2828
import lombok.Data;
2929
import lombok.extern.slf4j.Slf4j;
30+
import org.springblade.common.constant.CommonConstant;
3031
import org.springblade.core.tool.utils.Func;
3132
import org.springblade.core.tool.utils.StringUtil;
3233
import org.springframework.core.io.ClassPathResource;
@@ -44,7 +45,15 @@
4445
*/
4546
@Data
4647
@Slf4j
47-
public class BladeGenerator {
48+
public class BladeCodeGenerator {
49+
/**
50+
* 代码所在系统
51+
*/
52+
private String systemName = CommonConstant.SWORD_NAME;
53+
/**
54+
* 代码模块名称
55+
*/
56+
private String codeName;
4857
/**
4958
* 代码所在服务名
5059
*/
@@ -81,6 +90,10 @@ public class BladeGenerator {
8190
* 基础业务字段
8291
*/
8392
private String[] superEntityColumns = {"id", "create_time", "create_user", "update_time", "update_user", "status", "is_deleted"};
93+
/**
94+
* 租户字段
95+
*/
96+
private String tenantColumn = "tenant_code";
8497
/**
8598
* 是否启用swagger
8699
*/
@@ -165,16 +178,25 @@ public void run() {
165178
private InjectionConfig getInjectionConfig() {
166179
String servicePackage = serviceName.split("-").length > 1 ? serviceName.split("-")[1] : serviceName;
167180
// 自定义配置
181+
Map<String, Object> map = new HashMap<>(16);
168182
InjectionConfig cfg = new InjectionConfig() {
169183
@Override
170184
public void initMap() {
171-
Map<String, Object> map = new HashMap<>(16);
185+
map.put("codeName", codeName);
172186
map.put("serviceName", serviceName);
173187
map.put("servicePackage", servicePackage);
188+
map.put("tenantColumn", tenantColumn);
174189
this.setMap(map);
175190
}
176191
};
177192
List<FileOutConfig> focList = new ArrayList<>();
193+
focList.add(new FileOutConfig("/templates/sql/menu.sql.vm") {
194+
@Override
195+
public String outputFile(TableInfo tableInfo) {
196+
map.put("entityKey", (tableInfo.getEntityName().toLowerCase()));
197+
return getOutputDir() + "/" + "/sql/menu.mysql";
198+
}
199+
});
178200
focList.add(new FileOutConfig("/templates/entityVO.java.vm") {
179201
@Override
180202
public String outputFile(TableInfo tableInfo) {
@@ -194,48 +216,63 @@ public String outputFile(TableInfo tableInfo) {
194216
}
195217
});
196218
if (Func.isNotBlank(packageWebDir)) {
197-
focList.add(new FileOutConfig("/templates/sword/action.js.vm") {
198-
@Override
199-
public String outputFile(TableInfo tableInfo) {
200-
return getOutputWebDir() + "/actions" + "/" + tableInfo.getEntityName().toLowerCase() + ".js";
201-
}
202-
});
203-
focList.add(new FileOutConfig("/templates/sword/model.js.vm") {
204-
@Override
205-
public String outputFile(TableInfo tableInfo) {
206-
return getOutputWebDir() + "/models" + "/" + tableInfo.getEntityName().toLowerCase() + ".js";
207-
}
208-
});
209-
focList.add(new FileOutConfig("/templates/sword/service.js.vm") {
210-
@Override
211-
public String outputFile(TableInfo tableInfo) {
212-
return getOutputWebDir() + "/services" + "/" + tableInfo.getEntityName().toLowerCase() + ".js";
213-
}
214-
});
215-
focList.add(new FileOutConfig("/templates/sword/list.js.vm") {
216-
@Override
217-
public String outputFile(TableInfo tableInfo) {
218-
return getOutputWebDir() + "/pages" + "/" + StringUtil.upperFirst(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + ".js";
219-
}
220-
});
221-
focList.add(new FileOutConfig("/templates/sword/add.js.vm") {
222-
@Override
223-
public String outputFile(TableInfo tableInfo) {
224-
return getOutputWebDir() + "/pages" + "/" + StringUtil.upperFirst(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + "Add.js";
225-
}
226-
});
227-
focList.add(new FileOutConfig("/templates/sword/edit.js.vm") {
228-
@Override
229-
public String outputFile(TableInfo tableInfo) {
230-
return getOutputWebDir() + "/pages" + "/" + StringUtil.upperFirst(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + "Edit.js";
231-
}
232-
});
233-
focList.add(new FileOutConfig("/templates/sword/view.js.vm") {
234-
@Override
235-
public String outputFile(TableInfo tableInfo) {
236-
return getOutputWebDir() + "/pages" + "/" + StringUtil.upperFirst(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + "View.js";
237-
}
238-
});
219+
if (Func.equals(systemName, CommonConstant.SWORD_NAME)) {
220+
focList.add(new FileOutConfig("/templates/sword/action.js.vm") {
221+
@Override
222+
public String outputFile(TableInfo tableInfo) {
223+
return getOutputWebDir() + "/actions" + "/" + tableInfo.getEntityName().toLowerCase() + ".js";
224+
}
225+
});
226+
focList.add(new FileOutConfig("/templates/sword/model.js.vm") {
227+
@Override
228+
public String outputFile(TableInfo tableInfo) {
229+
return getOutputWebDir() + "/models" + "/" + tableInfo.getEntityName().toLowerCase() + ".js";
230+
}
231+
});
232+
focList.add(new FileOutConfig("/templates/sword/service.js.vm") {
233+
@Override
234+
public String outputFile(TableInfo tableInfo) {
235+
return getOutputWebDir() + "/services" + "/" + tableInfo.getEntityName().toLowerCase() + ".js";
236+
}
237+
});
238+
focList.add(new FileOutConfig("/templates/sword/list.js.vm") {
239+
@Override
240+
public String outputFile(TableInfo tableInfo) {
241+
return getOutputWebDir() + "/pages" + "/" + StringUtil.upperFirst(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + ".js";
242+
}
243+
});
244+
focList.add(new FileOutConfig("/templates/sword/add.js.vm") {
245+
@Override
246+
public String outputFile(TableInfo tableInfo) {
247+
return getOutputWebDir() + "/pages" + "/" + StringUtil.upperFirst(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + "Add.js";
248+
}
249+
});
250+
focList.add(new FileOutConfig("/templates/sword/edit.js.vm") {
251+
@Override
252+
public String outputFile(TableInfo tableInfo) {
253+
return getOutputWebDir() + "/pages" + "/" + StringUtil.upperFirst(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + "Edit.js";
254+
}
255+
});
256+
focList.add(new FileOutConfig("/templates/sword/view.js.vm") {
257+
@Override
258+
public String outputFile(TableInfo tableInfo) {
259+
return getOutputWebDir() + "/pages" + "/" + StringUtil.upperFirst(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + "View.js";
260+
}
261+
});
262+
} else if (Func.equals(systemName, CommonConstant.SABER_NAME)) {
263+
focList.add(new FileOutConfig("/templates/saber/api.js.vm") {
264+
@Override
265+
public String outputFile(TableInfo tableInfo) {
266+
return getOutputWebDir() + "/api" + "/" + servicePackage.toLowerCase() + "/" + tableInfo.getEntityName().toLowerCase() + ".js";
267+
}
268+
});
269+
focList.add(new FileOutConfig("/templates/saber/crud.vue.vm") {
270+
@Override
271+
public String outputFile(TableInfo tableInfo) {
272+
return getOutputWebDir() + "/views" + "/" + servicePackage.toLowerCase() + "/" + tableInfo.getEntityName().toLowerCase() + ".vue";
273+
}
274+
});
275+
}
239276
}
240277
cfg.setFileOutConfigList(focList);
241278
return cfg;
@@ -264,7 +301,7 @@ private Properties getProperties() {
264301
* @return outputDir
265302
*/
266303
public String getOutputDir() {
267-
return Func.isBlank(packageDir) ? System.getProperty("user.dir") : packageDir + "/src/main/java";
304+
return (Func.isBlank(packageDir) ? System.getProperty("user.dir") + "/blade-ops/blade-develop" : packageDir) + "/src/main/java";
268305
}
269306

270307
/**
@@ -273,7 +310,7 @@ public String getOutputDir() {
273310
* @return outputDir
274311
*/
275312
public String getOutputWebDir() {
276-
return Func.isBlank(packageWebDir) ? System.getProperty("user.dir") : packageWebDir + "/src";
313+
return (Func.isBlank(packageWebDir) ? System.getProperty("user.dir") : packageWebDir) + "/src";
277314
}
278315

279316
/**

blade-ops/blade-develop/src/main/resources/templates/controller.java.vm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import java.util.List;
5252
*/
5353
@RestController
5454
@AllArgsConstructor
55-
@RequestMapping("#if($!{package.ModuleName})/$!{package.ModuleName}#end/$!{table.entityPath}")
55+
@RequestMapping("#if($!{package.ModuleName})/$!{package.ModuleName}#end/$!{cfg.entityKey}")
5656
@Api(value = "$!{table.comment}", tags = "$!{table.comment}接口")
5757
#if($!{superControllerClass})
5858
public class $!{table.controllerName} extends $!{superControllerClass} {
@@ -140,7 +140,7 @@ public class $!{table.controllerName} {
140140
* 删除 $!{table.comment}
141141
*/
142142
@PostMapping("/remove")
143-
@ApiOperation(value = "物理删除", notes = "传入ids", position = 7)
143+
@ApiOperation(value = "删除", notes = "传入ids", position = 7)
144144
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
145145
return R.status($!{table.entityPath}Service.removeByIds(Func.toIntList(ids)));
146146
}

blade-ops/blade-develop/src/main/resources/templates/entity.java.vm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class $!{entity} implements Serializable {
5858

5959
## ---------- BEGIN 字段循环遍历 ----------
6060
#foreach($field in $!{table.fields})
61+
#if($!{field.name}!=$!{cfg.tenantColumn})
6162
#if($!{field.keyFlag})
6263
#set($keyPropertyName=$!{field.propertyName})
6364
#end
@@ -98,7 +99,7 @@ public class $!{entity} implements Serializable {
9899
@TableLogic
99100
#end
100101
private $!{field.propertyType} $!{field.propertyName};
101-
102+
#end
102103
#end
103104
## ---------- END 字段循环遍历 ----------
104105

0 commit comments

Comments
 (0)