parent
55dc6dd0e9
commit
b9eb6e56ee
45 changed files with 34 additions and 3519 deletions
@ -1,97 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.auth.endpoint; |
||||
|
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import me.zhyd.oauth.model.AuthCallback; |
||||
import me.zhyd.oauth.model.AuthToken; |
||||
import me.zhyd.oauth.request.AuthRequest; |
||||
import me.zhyd.oauth.utils.AuthStateUtils; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.social.props.SocialProperties; |
||||
import org.springblade.core.social.utils.SocialUtil; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* 第三方登陆端点 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@NonDS |
||||
@Slf4j |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_AUTH_NAME) |
||||
@ConditionalOnProperty(value = "social.enabled", havingValue = "true") |
||||
@Api(value = "第三方登陆", tags = "第三方登陆端点") |
||||
public class BladeSocialEndpoint { |
||||
|
||||
private final SocialProperties socialProperties; |
||||
|
||||
/** |
||||
* 授权完毕跳转 |
||||
*/ |
||||
@ApiOperation(value = "授权完毕跳转") |
||||
@RequestMapping("/oauth/render/{source}") |
||||
public void renderAuth(@PathVariable("source") String source, HttpServletResponse response) throws IOException { |
||||
AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
||||
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState()); |
||||
response.sendRedirect(authorizeUrl); |
||||
} |
||||
|
||||
/** |
||||
* 获取认证信息 |
||||
*/ |
||||
@ApiOperation(value = "获取认证信息") |
||||
@RequestMapping("/oauth/callback/{source}") |
||||
public Object login(@PathVariable("source") String source, AuthCallback callback) { |
||||
AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
||||
return authRequest.login(callback); |
||||
} |
||||
|
||||
/** |
||||
* 撤销授权 |
||||
*/ |
||||
@ApiOperation(value = "撤销授权") |
||||
@RequestMapping("/oauth/revoke/{source}/{token}") |
||||
public Object revokeAuth(@PathVariable("source") String source, @PathVariable("token") String token) { |
||||
AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
||||
return authRequest.revoke(AuthToken.builder().accessToken(token).build()); |
||||
} |
||||
|
||||
/** |
||||
* 续期accessToken |
||||
*/ |
||||
@ApiOperation(value = "续期令牌") |
||||
@RequestMapping("/oauth/refresh/{source}") |
||||
public Object refreshAuth(@PathVariable("source") String source, String token) { |
||||
AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
||||
return authRequest.refresh(AuthToken.builder().refreshToken(token).build()); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -1,192 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.*; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.secure.annotation.PreAuth; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.constant.RoleConstant; |
||||
import org.springblade.core.tool.jackson.JsonUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springblade.develop.support.BladeCodeGenerator; |
||||
import org.springblade.modules.develop.entity.Code; |
||||
import org.springblade.modules.develop.entity.Datasource; |
||||
import org.springblade.modules.develop.entity.Model; |
||||
import org.springblade.modules.develop.entity.ModelPrototype; |
||||
import org.springblade.modules.develop.service.ICodeService; |
||||
import org.springblade.modules.develop.service.IDatasourceService; |
||||
import org.springblade.modules.develop.service.IModelPrototypeService; |
||||
import org.springblade.modules.develop.service.IModelService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.Collection; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@NonDS |
||||
@ApiIgnore |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/code") |
||||
@Api(value = "代码生成", tags = "代码生成") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
||||
public class CodeController extends BladeController { |
||||
|
||||
private final ICodeService codeService; |
||||
private final IDatasourceService datasourceService; |
||||
private final IModelService modelService; |
||||
private final IModelPrototypeService modelPrototypeService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入code") |
||||
public R<Code> detail(Code code) { |
||||
Code detail = codeService.getOne(Condition.getQueryWrapper(code)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiImplicitParams({ |
||||
@ApiImplicitParam(name = "codeName", value = "模块名", paramType = "query", dataType = "string"), |
||||
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "query", dataType = "string"), |
||||
@ApiImplicitParam(name = "modelName", value = "实体名", paramType = "query", dataType = "string") |
||||
}) |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入code") |
||||
public R<IPage<Code>> list(@ApiIgnore @RequestParam Map<String, Object> code, Query query) { |
||||
IPage<Code> pages = codeService.page(Condition.getPage(query), Condition.getQueryWrapper(code, Code.class)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "新增或修改", notes = "传入code") |
||||
public R submit(@Valid @RequestBody Code code) { |
||||
return R.status(codeService.submit(code)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(codeService.removeByIds(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 复制 |
||||
*/ |
||||
@PostMapping("/copy") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "复制", notes = "传入id") |
||||
public R copy(@ApiParam(value = "主键", required = true) @RequestParam Long id) { |
||||
Code code = codeService.getById(id); |
||||
code.setId(null); |
||||
code.setCodeName(code.getCodeName() + "-copy"); |
||||
return R.status(codeService.save(code)); |
||||
} |
||||
|
||||
/** |
||||
* 代码生成 |
||||
*/ |
||||
@PostMapping("/gen-code") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "代码生成", notes = "传入ids") |
||||
public R genCode(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
Collection<Code> codes = codeService.listByIds(Func.toLongList(ids)); |
||||
codes.forEach(code -> { |
||||
BladeCodeGenerator generator = new BladeCodeGenerator(); |
||||
// 设置基础模型
|
||||
Model model = modelService.getById(code.getModelId()); |
||||
generator.setModelCode(model.getModelCode()); |
||||
generator.setModelClass(model.getModelClass()); |
||||
// 设置模型集合
|
||||
List<ModelPrototype> prototypes = modelPrototypeService.prototypeList(model.getId()); |
||||
generator.setModel(JsonUtil.readMap(JsonUtil.toJson(model))); |
||||
generator.setPrototypes(JsonUtil.readListMap(JsonUtil.toJson(prototypes))); |
||||
if (StringUtil.isNotBlank(code.getSubModelId())) { |
||||
Model subModel = modelService.getById(Func.toLong(code.getSubModelId())); |
||||
List<ModelPrototype> subPrototypes = modelPrototypeService.prototypeList(subModel.getId()); |
||||
generator.setSubModel(JsonUtil.readMap(JsonUtil.toJson(subModel))); |
||||
generator.setSubPrototypes(JsonUtil.readListMap(JsonUtil.toJson(subPrototypes))); |
||||
} |
||||
// 设置数据源
|
||||
Datasource datasource = datasourceService.getById(model.getDatasourceId()); |
||||
generator.setDriverName(datasource.getDriverClass()); |
||||
generator.setUrl(datasource.getUrl()); |
||||
generator.setUsername(datasource.getUsername()); |
||||
generator.setPassword(datasource.getPassword()); |
||||
// 设置基础配置
|
||||
generator.setCodeStyle(code.getCodeStyle()); |
||||
generator.setCodeName(code.getCodeName()); |
||||
generator.setServiceName(code.getServiceName()); |
||||
generator.setPackageName(code.getPackageName()); |
||||
generator.setPackageDir(code.getApiPath()); |
||||
generator.setPackageWebDir(code.getWebPath()); |
||||
generator.setTablePrefix(Func.toStrArray(code.getTablePrefix())); |
||||
generator.setIncludeTables(Func.toStrArray(code.getTableName())); |
||||
// 设置模版信息
|
||||
generator.setTemplateType(code.getTemplateType()); |
||||
generator.setAuthor(code.getAuthor()); |
||||
generator.setSubModelId(code.getSubModelId()); |
||||
generator.setSubFkId(code.getSubFkId()); |
||||
generator.setTreeId(code.getTreeId()); |
||||
generator.setTreePid(code.getTreePid()); |
||||
generator.setTreeName(code.getTreeName()); |
||||
// 设置是否继承基础业务字段
|
||||
generator.setHasSuperEntity(code.getBaseMode() == 2); |
||||
// 设置是否开启包装器模式
|
||||
generator.setHasWrapper(code.getWrapMode() == 2); |
||||
// 设置是否开启远程调用模式
|
||||
generator.setHasFeign(code.getFeignMode() == 2); |
||||
// 设置控制器服务名前缀
|
||||
generator.setHasServiceName(Boolean.TRUE); |
||||
// 启动代码生成
|
||||
generator.run(); |
||||
}); |
||||
return R.success("代码生成成功"); |
||||
} |
||||
|
||||
} |
||||
@ -1,128 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.develop.entity.Datasource; |
||||
import org.springblade.modules.develop.service.IDatasourceService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 数据源配置表 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@NonDS |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/datasource") |
||||
@Api(value = "数据源配置表", tags = "数据源配置表接口") |
||||
public class DatasourceController extends BladeController { |
||||
|
||||
private final IDatasourceService datasourceService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入datasource") |
||||
public R<Datasource> detail(Datasource datasource) { |
||||
Datasource detail = datasourceService.getOne(Condition.getQueryWrapper(datasource)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 数据源配置表 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入datasource") |
||||
public R<IPage<Datasource>> list(Datasource datasource, Query query) { |
||||
IPage<Datasource> pages = datasourceService.page(Condition.getPage(query), Condition.getQueryWrapper(datasource)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 数据源配置表 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入datasource") |
||||
public R save(@Valid @RequestBody Datasource datasource) { |
||||
return R.status(datasourceService.save(datasource)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 数据源配置表 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入datasource") |
||||
public R update(@Valid @RequestBody Datasource datasource) { |
||||
return R.status(datasourceService.updateById(datasource)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 数据源配置表 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入datasource") |
||||
public R submit(@Valid @RequestBody Datasource datasource) { |
||||
datasource.setUrl(datasource.getUrl().replace("&", "&")); |
||||
return R.status(datasourceService.saveOrUpdate(datasource)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 数据源配置表 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(datasourceService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 数据源列表 |
||||
*/ |
||||
@GetMapping("/select") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "下拉数据源", notes = "查询列表") |
||||
public R<List<Datasource>> select() { |
||||
List<Datasource> list = datasourceService.list(); |
||||
return R.data(list); |
||||
} |
||||
|
||||
} |
||||
@ -1,229 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.generator.config.DataSourceConfig; |
||||
import com.baomidou.mybatisplus.generator.config.StrategyConfig; |
||||
import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder; |
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo; |
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.StringPool; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springblade.modules.develop.entity.Datasource; |
||||
import org.springblade.modules.develop.entity.Model; |
||||
import org.springblade.modules.develop.entity.ModelPrototype; |
||||
import org.springblade.modules.develop.service.IDatasourceService; |
||||
import org.springblade.modules.develop.service.IModelPrototypeService; |
||||
import org.springblade.modules.develop.service.IModelService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 数据模型表 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/model") |
||||
@Api(value = "数据模型表", tags = "数据模型表接口") |
||||
public class ModelController extends BladeController { |
||||
|
||||
private final IModelService modelService; |
||||
private final IModelPrototypeService modelPrototypeService; |
||||
private final IDatasourceService datasourceService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入model") |
||||
public R<Model> detail(Model model) { |
||||
Model detail = modelService.getOne(Condition.getQueryWrapper(model)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 数据模型表 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入model") |
||||
public R<IPage<Model>> list(Model model, Query query) { |
||||
IPage<Model> pages = modelService.page(Condition.getPage(query), Condition.getQueryWrapper(model)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 数据模型表 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "新增", notes = "传入model") |
||||
public R save(@Valid @RequestBody Model model) { |
||||
return R.status(modelService.save(model)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 数据模型表 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "修改", notes = "传入model") |
||||
public R update(@Valid @RequestBody Model model) { |
||||
return R.status(modelService.updateById(model)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 数据模型表 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "新增或修改", notes = "传入model") |
||||
public R submit(@Valid @RequestBody Model model) { |
||||
return R.status(modelService.saveOrUpdate(model)); |
||||
} |
||||
|
||||
/** |
||||
* 删除 数据模型表 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(modelService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 模型列表 |
||||
*/ |
||||
@GetMapping("/select") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "模型列表", notes = "模型列表") |
||||
public R<List<Model>> select() { |
||||
List<Model> list = modelService.list(); |
||||
list.forEach(model -> model.setModelName(model.getModelTable() + StringPool.COLON + StringPool.SPACE + model.getModelName())); |
||||
return R.data(list); |
||||
} |
||||
|
||||
/** |
||||
* 获取物理表列表 |
||||
*/ |
||||
@GetMapping("/table-list") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "物理表列表", notes = "传入datasourceId") |
||||
public R<List<TableInfo>> tableList(Long datasourceId) { |
||||
Datasource datasource = datasourceService.getById(datasourceId); |
||||
ConfigBuilder config = getConfigBuilder(datasource); |
||||
List<TableInfo> tableInfoList = config.getTableInfoList().stream() |
||||
.filter(tableInfo -> !StringUtil.startsWithIgnoreCase(tableInfo.getName(), "ACT_")) |
||||
.map(tableInfo -> tableInfo.setComment(tableInfo.getName() + StringPool.COLON + tableInfo.getComment())) |
||||
.collect(Collectors.toList()); |
||||
return R.data(tableInfoList); |
||||
} |
||||
|
||||
/** |
||||
* 获取物理表信息 |
||||
*/ |
||||
@GetMapping("/table-info") |
||||
@ApiOperationSupport(order = 9) |
||||
@ApiOperation(value = "物理表信息", notes = "传入model信息") |
||||
public R<TableInfo> tableInfo(Long modelId, String tableName, Long datasourceId) { |
||||
if (StringUtil.isBlank(tableName)) { |
||||
Model model = modelService.getById(modelId); |
||||
tableName = model.getModelTable(); |
||||
} |
||||
TableInfo tableInfo = getTableInfo(tableName, datasourceId); |
||||
return R.data(tableInfo); |
||||
} |
||||
|
||||
/** |
||||
* 获取字段信息 |
||||
*/ |
||||
@GetMapping("/model-prototype") |
||||
@ApiOperationSupport(order = 10) |
||||
@ApiOperation(value = "物理表字段信息", notes = "传入modelId与datasourceId") |
||||
public R modelPrototype(Long modelId, Long datasourceId) { |
||||
List<ModelPrototype> modelPrototypeList = modelPrototypeService.list(Wrappers.<ModelPrototype>query().lambda().eq(ModelPrototype::getModelId, modelId)); |
||||
if (modelPrototypeList.size() > 0) { |
||||
return R.data(modelPrototypeList); |
||||
} |
||||
Model model = modelService.getById(modelId); |
||||
String tableName = model.getModelTable(); |
||||
TableInfo tableInfo = getTableInfo(tableName, datasourceId); |
||||
if (tableInfo != null) { |
||||
return R.data(tableInfo.getFields()); |
||||
} else { |
||||
return R.fail("未获得相关表信息"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取表信息 |
||||
* |
||||
* @param tableName 表名 |
||||
* @param datasourceId 数据源主键 |
||||
*/ |
||||
private TableInfo getTableInfo(String tableName, Long datasourceId) { |
||||
Datasource datasource = datasourceService.getById(datasourceId); |
||||
ConfigBuilder config = getConfigBuilder(datasource); |
||||
List<TableInfo> tableInfoList = config.getTableInfoList(); |
||||
TableInfo tableInfo = null; |
||||
Iterator<TableInfo> iterator = tableInfoList.stream().filter(table -> table.getName().equals(tableName)).collect(Collectors.toList()).iterator(); |
||||
if (iterator.hasNext()) { |
||||
tableInfo = iterator.next(); |
||||
tableInfo.setEntityName(tableInfo.getEntityName().replace(StringUtil.firstCharToUpper(tableName.split(StringPool.UNDERSCORE)[0]), StringPool.EMPTY)); |
||||
} |
||||
return tableInfo; |
||||
} |
||||
|
||||
/** |
||||
* 获取表配置信息 |
||||
* |
||||
* @param datasource 数据源信息 |
||||
*/ |
||||
private ConfigBuilder getConfigBuilder(Datasource datasource) { |
||||
StrategyConfig strategyConfig = new StrategyConfig.Builder() |
||||
.entityBuilder() |
||||
.naming(NamingStrategy.underline_to_camel) |
||||
.columnNaming(NamingStrategy.underline_to_camel).build(); |
||||
DataSourceConfig datasourceConfig = new DataSourceConfig.Builder( |
||||
datasource.getUrl(), datasource.getUsername(), datasource.getPassword() |
||||
).build(); |
||||
return new ConfigBuilder(null, datasourceConfig, strategyConfig, null, null, null); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -1,137 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.StringPool; |
||||
import org.springblade.modules.develop.entity.ModelPrototype; |
||||
import org.springblade.modules.develop.service.IModelPrototypeService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 数据原型表 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/model-prototype") |
||||
@Api(value = "数据原型表", tags = "数据原型表接口") |
||||
public class ModelPrototypeController extends BladeController { |
||||
|
||||
private final IModelPrototypeService modelPrototypeService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入modelPrototype") |
||||
public R<ModelPrototype> detail(ModelPrototype modelPrototype) { |
||||
ModelPrototype detail = modelPrototypeService.getOne(Condition.getQueryWrapper(modelPrototype)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 数据原型表 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入modelPrototype") |
||||
public R<IPage<ModelPrototype>> list(ModelPrototype modelPrototype, Query query) { |
||||
IPage<ModelPrototype> pages = modelPrototypeService.page(Condition.getPage(query), Condition.getQueryWrapper(modelPrototype)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 数据原型表 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入modelPrototype") |
||||
public R save(@Valid @RequestBody ModelPrototype modelPrototype) { |
||||
return R.status(modelPrototypeService.save(modelPrototype)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 数据原型表 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入modelPrototype") |
||||
public R update(@Valid @RequestBody ModelPrototype modelPrototype) { |
||||
return R.status(modelPrototypeService.updateById(modelPrototype)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 数据原型表 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入modelPrototype") |
||||
public R submit(@Valid @RequestBody ModelPrototype modelPrototype) { |
||||
return R.status(modelPrototypeService.saveOrUpdate(modelPrototype)); |
||||
} |
||||
|
||||
/** |
||||
* 批量新增或修改 数据原型表 |
||||
*/ |
||||
@PostMapping("/submit-list") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "批量新增或修改", notes = "传入modelPrototype集合") |
||||
public R submitList(@Valid @RequestBody List<ModelPrototype> modelPrototypes) { |
||||
return R.status(modelPrototypeService.submitList(modelPrototypes)); |
||||
} |
||||
|
||||
/** |
||||
* 删除 数据原型表 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(modelPrototypeService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 数据原型列表 |
||||
*/ |
||||
@GetMapping("/select") |
||||
@ApiOperationSupport(order = 9) |
||||
@ApiOperation(value = "数据原型列表", notes = "数据原型列表") |
||||
public R<List<ModelPrototype>> select(@ApiParam(value = "数据模型Id", required = true) @RequestParam Long modelId) { |
||||
List<ModelPrototype> list = modelPrototypeService.list(Wrappers.<ModelPrototype>query().lambda().eq(ModelPrototype::getModelId, modelId)); |
||||
list.forEach(prototype -> prototype.setComment(prototype.getJdbcName() + StringPool.COLON + StringPool.SPACE + prototype.getComment())); |
||||
return R.data(list); |
||||
} |
||||
|
||||
} |
||||
@ -1,42 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.modules.develop.entity.Model; |
||||
import org.springblade.modules.develop.entity.ModelPrototype; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 代码模型DTO |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class ModelDTO extends Model { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 代码建模原型 |
||||
*/ |
||||
private List<ModelPrototype> prototypes; |
||||
|
||||
} |
||||
@ -1,180 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableLogic; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@TableName("blade_code") |
||||
@ApiModel(value = "Code对象", description = "Code对象") |
||||
public class Code implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.ASSIGN_ID) |
||||
private Long id; |
||||
|
||||
/** |
||||
* 数据模型主键 |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
@ApiModelProperty(value = "数据模型主键") |
||||
private Long modelId; |
||||
|
||||
/** |
||||
* 模块名称 |
||||
*/ |
||||
@ApiModelProperty(value = "服务名称") |
||||
private String serviceName; |
||||
|
||||
/** |
||||
* 模块名称 |
||||
*/ |
||||
@ApiModelProperty(value = "模块名称") |
||||
private String codeName; |
||||
|
||||
/** |
||||
* 表名 |
||||
*/ |
||||
@ApiModelProperty(value = "表名") |
||||
private String tableName; |
||||
|
||||
/** |
||||
* 实体名 |
||||
*/ |
||||
@ApiModelProperty(value = "表前缀") |
||||
private String tablePrefix; |
||||
|
||||
/** |
||||
* 主键名 |
||||
*/ |
||||
@ApiModelProperty(value = "主键名") |
||||
private String pkName; |
||||
|
||||
/** |
||||
* 后端包名 |
||||
*/ |
||||
@ApiModelProperty(value = "后端包名") |
||||
private String packageName; |
||||
|
||||
/** |
||||
* 模版类型 |
||||
*/ |
||||
@ApiModelProperty(value = "模版类型") |
||||
private String templateType; |
||||
|
||||
/** |
||||
* 作者信息 |
||||
*/ |
||||
@ApiModelProperty(value = "作者信息") |
||||
private String author; |
||||
|
||||
/** |
||||
* 子表模型主键 |
||||
*/ |
||||
@ApiModelProperty(value = "子表模型主键") |
||||
private String subModelId; |
||||
|
||||
/** |
||||
* 子表绑定外键 |
||||
*/ |
||||
@ApiModelProperty(value = "子表绑定外键") |
||||
private String subFkId; |
||||
|
||||
/** |
||||
* 树主键字段 |
||||
*/ |
||||
@ApiModelProperty(value = "树主键字段") |
||||
private String treeId; |
||||
|
||||
/** |
||||
* 树父主键字段 |
||||
*/ |
||||
@ApiModelProperty(value = "树父主键字段") |
||||
private String treePid; |
||||
|
||||
/** |
||||
* 树名称字段 |
||||
*/ |
||||
@ApiModelProperty(value = "树名称字段") |
||||
private String treeName; |
||||
|
||||
/** |
||||
* 基础业务模式 |
||||
*/ |
||||
@ApiModelProperty(value = "基础业务模式") |
||||
private Integer baseMode; |
||||
|
||||
/** |
||||
* 包装器模式 |
||||
*/ |
||||
@ApiModelProperty(value = "包装器模式") |
||||
private Integer wrapMode; |
||||
|
||||
/** |
||||
* 远程调用模式 |
||||
*/ |
||||
@ApiModelProperty(value = "远程调用模式") |
||||
private Integer feignMode; |
||||
|
||||
/** |
||||
* 代码风格 |
||||
*/ |
||||
@ApiModelProperty(value = "代码风格") |
||||
private String codeStyle; |
||||
|
||||
/** |
||||
* 后端路径 |
||||
*/ |
||||
@ApiModelProperty(value = "后端路径") |
||||
private String apiPath; |
||||
|
||||
/** |
||||
* 前端路径 |
||||
*/ |
||||
@ApiModelProperty(value = "前端路径") |
||||
private String webPath; |
||||
|
||||
/** |
||||
* 是否已删除 |
||||
*/ |
||||
@TableLogic |
||||
@ApiModelProperty(value = "是否已删除") |
||||
private Integer isDeleted; |
||||
|
||||
|
||||
} |
||||
@ -1,71 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
/** |
||||
* 数据源配置表实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@TableName("blade_datasource") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "Datasource对象", description = "数据源配置表") |
||||
public class Datasource extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 名称 |
||||
*/ |
||||
@ApiModelProperty(value = "名称") |
||||
private String name; |
||||
/** |
||||
* 驱动类 |
||||
*/ |
||||
@ApiModelProperty(value = "驱动类") |
||||
private String driverClass; |
||||
/** |
||||
* 连接地址 |
||||
*/ |
||||
@ApiModelProperty(value = "连接地址") |
||||
private String url; |
||||
/** |
||||
* 用户名 |
||||
*/ |
||||
@ApiModelProperty(value = "用户名") |
||||
private String username; |
||||
/** |
||||
* 密码 |
||||
*/ |
||||
@ApiModelProperty(value = "密码") |
||||
private String password; |
||||
/** |
||||
* 备注 |
||||
*/ |
||||
@ApiModelProperty(value = "备注") |
||||
private String remark; |
||||
|
||||
|
||||
} |
||||
@ -1,74 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
/** |
||||
* 数据模型表实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@TableName("blade_model") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "Model对象", description = "数据模型表") |
||||
public class Model extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 数据源主键 |
||||
*/ |
||||
@ApiModelProperty(value = "数据源主键") |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
private Long datasourceId; |
||||
/** |
||||
* 模型名称 |
||||
*/ |
||||
@ApiModelProperty(value = "模型名称") |
||||
private String modelName; |
||||
/** |
||||
* 模型编号 |
||||
*/ |
||||
@ApiModelProperty(value = "模型编号") |
||||
private String modelCode; |
||||
/** |
||||
* 物理表名 |
||||
*/ |
||||
@ApiModelProperty(value = "物理表名") |
||||
private String modelTable; |
||||
/** |
||||
* 模型类名 |
||||
*/ |
||||
@ApiModelProperty(value = "模型类名") |
||||
private String modelClass; |
||||
/** |
||||
* 模型备注 |
||||
*/ |
||||
@ApiModelProperty(value = "模型备注") |
||||
private String modelRemark; |
||||
|
||||
|
||||
} |
||||
@ -1,119 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
/** |
||||
* 数据原型表实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@TableName("blade_model_prototype") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "ModelPrototype对象", description = "数据原型表") |
||||
public class ModelPrototype extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 模型主键 |
||||
*/ |
||||
@ApiModelProperty(value = "模型主键") |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
private Long modelId; |
||||
/** |
||||
* 物理列名 |
||||
*/ |
||||
@ApiModelProperty(value = "物理列名") |
||||
private String jdbcName; |
||||
/** |
||||
* 物理类型 |
||||
*/ |
||||
@ApiModelProperty(value = "物理类型") |
||||
private String jdbcType; |
||||
/** |
||||
* 实体列名 |
||||
*/ |
||||
@ApiModelProperty(value = "实体列名") |
||||
private String propertyName; |
||||
/** |
||||
* 实体类型 |
||||
*/ |
||||
@ApiModelProperty(value = "实体类型") |
||||
private String propertyType; |
||||
/** |
||||
* 实体类型引用 |
||||
*/ |
||||
@ApiModelProperty(value = "实体类型引用") |
||||
private String propertyEntity; |
||||
/** |
||||
* 注释说明 |
||||
*/ |
||||
@ApiModelProperty(value = "注释说明") |
||||
private String comment; |
||||
/** |
||||
* 列表显示 |
||||
*/ |
||||
@ApiModelProperty(value = "列表显示") |
||||
private Integer isList; |
||||
/** |
||||
* 表单显示 |
||||
*/ |
||||
@ApiModelProperty(value = "表单显示") |
||||
private Integer isForm; |
||||
/** |
||||
* 独占一行 |
||||
*/ |
||||
@ApiModelProperty(value = "独占一行") |
||||
private Integer isRow; |
||||
/** |
||||
* 组件类型 |
||||
*/ |
||||
@ApiModelProperty(value = "组件类型") |
||||
private String componentType; |
||||
/** |
||||
* 字典编码 |
||||
*/ |
||||
@ApiModelProperty(value = "字典编码") |
||||
private String dictCode; |
||||
/** |
||||
* 是否必填 |
||||
*/ |
||||
@ApiModelProperty(value = "是否必填") |
||||
private Integer isRequired; |
||||
/** |
||||
* 查询配置 |
||||
*/ |
||||
@ApiModelProperty(value = "查询配置") |
||||
private Integer isQuery; |
||||
/** |
||||
* 查询类型 |
||||
*/ |
||||
@ApiModelProperty(value = "查询类型") |
||||
private String queryType; |
||||
|
||||
|
||||
} |
||||
@ -1,29 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.modules.develop.entity.Code; |
||||
|
||||
/** |
||||
* Mapper 接口 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface CodeMapper extends BaseMapper<Code> { |
||||
|
||||
} |
||||
@ -1,22 +0,0 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="org.springblade.modules.develop.mapper.CodeMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="codeResultMap" type="org.springblade.modules.develop.entity.Code"> |
||||
<id column="id" property="id"/> |
||||
<result column="datasource_id" property="datasourceId"/> |
||||
<result column="service_name" property="serviceName"/> |
||||
<result column="code_name" property="codeName"/> |
||||
<result column="table_name" property="tableName"/> |
||||
<result column="pk_name" property="pkName"/> |
||||
<result column="base_mode" property="baseMode"/> |
||||
<result column="wrap_mode" property="wrapMode"/> |
||||
<result column="table_prefix" property="tablePrefix"/> |
||||
<result column="package_name" property="packageName"/> |
||||
<result column="api_path" property="apiPath"/> |
||||
<result column="web_path" property="webPath"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
</resultMap> |
||||
|
||||
</mapper> |
||||
@ -1,29 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.modules.develop.entity.Datasource; |
||||
|
||||
/** |
||||
* 数据源配置表 Mapper 接口 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface DatasourceMapper extends BaseMapper<Datasource> { |
||||
|
||||
} |
||||
@ -1,22 +0,0 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="org.springblade.modules.develop.mapper.DatasourceMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="datasourceResultMap" type="org.springblade.modules.develop.entity.Datasource"> |
||||
<result column="id" property="id"/> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="create_dept" property="createDept"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="status" property="status"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
<result column="driver_class" property="driverClass"/> |
||||
<result column="url" property="url"/> |
||||
<result column="username" property="username"/> |
||||
<result column="password" property="password"/> |
||||
<result column="remark" property="remark"/> |
||||
</resultMap> |
||||
|
||||
</mapper> |
||||
@ -1,29 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.modules.develop.entity.Model; |
||||
|
||||
/** |
||||
* 数据模型表 Mapper 接口 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface ModelMapper extends BaseMapper<Model> { |
||||
|
||||
} |
||||
@ -1,27 +0,0 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="org.springblade.modules.develop.mapper.ModelMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="modelResultMap" type="org.springblade.modules.develop.entity.Model"> |
||||
<id column="id" property="id"/> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="status" property="status"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
<result column="datasource_id" property="datasourceId"/> |
||||
<result column="model_name" property="modelName"/> |
||||
<result column="model_code" property="modelCode"/> |
||||
<result column="model_table" property="modelTable"/> |
||||
<result column="model_class" property="modelClass"/> |
||||
<result column="model_remark" property="modelRemark"/> |
||||
</resultMap> |
||||
|
||||
|
||||
<select id="selectModelPage" resultMap="modelResultMap"> |
||||
select * from blade_model where is_deleted = 0 |
||||
</select> |
||||
|
||||
</mapper> |
||||
@ -1,29 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.modules.develop.entity.ModelPrototype; |
||||
|
||||
/** |
||||
* 数据原型表 Mapper 接口 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface ModelPrototypeMapper extends BaseMapper<ModelPrototype> { |
||||
|
||||
} |
||||
@ -1,35 +0,0 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="org.springblade.modules.develop.mapper.ModelPrototypeMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="modelPrototypeResultMap" type="org.springblade.modules.develop.entity.ModelPrototype"> |
||||
<id column="id" property="id"/> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="status" property="status"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
<result column="jdbc_name" property="jdbcName"/> |
||||
<result column="jdbc_type" property="jdbcType"/> |
||||
<result column="comment" property="comment"/> |
||||
<result column="property_type" property="propertyType"/> |
||||
<result column="property_entity" property="propertyEntity"/> |
||||
<result column="property_name" property="propertyName"/> |
||||
<result column="is_form" property="isForm"/> |
||||
<result column="is_row" property="isRow"/> |
||||
<result column="component_type" property="componentType"/> |
||||
<result column="dict_code" property="dictCode"/> |
||||
<result column="is_required" property="isRequired"/> |
||||
<result column="is_list" property="isList"/> |
||||
<result column="is_query" property="isQuery"/> |
||||
<result column="query_type" property="queryType"/> |
||||
</resultMap> |
||||
|
||||
|
||||
<select id="selectModelPrototypePage" resultMap="modelPrototypeResultMap"> |
||||
select * from blade_model_prototype where is_deleted = 0 |
||||
</select> |
||||
|
||||
</mapper> |
||||
@ -1,38 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.service; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import org.springblade.modules.develop.entity.Code; |
||||
|
||||
/** |
||||
* 服务类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface ICodeService extends IService<Code> { |
||||
|
||||
/** |
||||
* 提交 |
||||
* |
||||
* @param code |
||||
* @return |
||||
*/ |
||||
boolean submit(Code code); |
||||
|
||||
} |
||||
@ -1,29 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.service; |
||||
|
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.modules.develop.entity.Datasource; |
||||
|
||||
/** |
||||
* 数据源配置表 服务类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface IDatasourceService extends BaseService<Datasource> { |
||||
|
||||
} |
||||
@ -1,47 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.service; |
||||
|
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.modules.develop.entity.ModelPrototype; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 数据原型表 服务类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface IModelPrototypeService extends BaseService<ModelPrototype> { |
||||
|
||||
/** |
||||
* 批量提交 |
||||
* |
||||
* @param modelPrototypes 原型集合 |
||||
* @return boolean |
||||
*/ |
||||
boolean submitList(List<ModelPrototype> modelPrototypes); |
||||
|
||||
/** |
||||
* 原型列表 |
||||
* |
||||
* @param modelId 模型ID |
||||
* @return List<ModelPrototype> |
||||
*/ |
||||
List<ModelPrototype> prototypeList(Long modelId); |
||||
|
||||
} |
||||
@ -1,29 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.service; |
||||
|
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.modules.develop.entity.Model; |
||||
|
||||
/** |
||||
* 数据模型表 服务类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface IModelService extends BaseService<Model> { |
||||
|
||||
} |
||||
@ -1,40 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springblade.core.tool.constant.BladeConstant; |
||||
import org.springblade.modules.develop.entity.Code; |
||||
import org.springblade.modules.develop.mapper.CodeMapper; |
||||
import org.springblade.modules.develop.service.ICodeService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 服务实现类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Service |
||||
public class CodeServiceImpl extends ServiceImpl<CodeMapper, Code> implements ICodeService { |
||||
|
||||
@Override |
||||
public boolean submit(Code code) { |
||||
code.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
||||
return saveOrUpdate(code); |
||||
} |
||||
|
||||
} |
||||
@ -1,33 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.service.impl; |
||||
|
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.modules.develop.entity.Datasource; |
||||
import org.springblade.modules.develop.mapper.DatasourceMapper; |
||||
import org.springblade.modules.develop.service.IDatasourceService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 数据源配置表 服务实现类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Service |
||||
public class DatasourceServiceImpl extends BaseServiceImpl<DatasourceMapper, Datasource> implements IDatasourceService { |
||||
|
||||
} |
||||
@ -1,55 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.modules.develop.entity.ModelPrototype; |
||||
import org.springblade.modules.develop.mapper.ModelPrototypeMapper; |
||||
import org.springblade.modules.develop.service.IModelPrototypeService; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 数据原型表 服务实现类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Service |
||||
public class ModelPrototypeServiceImpl extends BaseServiceImpl<ModelPrototypeMapper, ModelPrototype> implements IModelPrototypeService { |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public boolean submitList(List<ModelPrototype> modelPrototypes) { |
||||
modelPrototypes.forEach(modelPrototype -> { |
||||
if (modelPrototype.getId() == null) { |
||||
this.save(modelPrototype); |
||||
} else { |
||||
this.updateById(modelPrototype); |
||||
} |
||||
}); |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public List<ModelPrototype> prototypeList(Long modelId) { |
||||
return this.list(Wrappers.<ModelPrototype>lambdaQuery().eq(ModelPrototype::getModelId, modelId)); |
||||
} |
||||
|
||||
} |
||||
@ -1,33 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.develop.service.impl; |
||||
|
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.modules.develop.entity.Model; |
||||
import org.springblade.modules.develop.mapper.ModelMapper; |
||||
import org.springblade.modules.develop.service.IModelService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 数据模型表 服务实现类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Service |
||||
public class ModelServiceImpl extends BaseServiceImpl<ModelMapper, Model> implements IModelService { |
||||
|
||||
} |
||||
@ -1,128 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.resource.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.resource.entity.Attach; |
||||
import org.springblade.modules.resource.service.IAttachService; |
||||
import org.springblade.modules.resource.vo.AttachVO; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.validation.Valid; |
||||
|
||||
/** |
||||
* 附件表 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@NonDS |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_RESOURCE_NAME + "/attach") |
||||
@Api(value = "附件", tags = "附件") |
||||
public class AttachController extends BladeController { |
||||
|
||||
private final IAttachService attachService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入attach") |
||||
public R<Attach> detail(Attach attach) { |
||||
Attach detail = attachService.getOne(Condition.getQueryWrapper(attach)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 附件表 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入attach") |
||||
public R<IPage<Attach>> list(Attach attach, Query query) { |
||||
IPage<Attach> pages = attachService.page(Condition.getPage(query), Condition.getQueryWrapper(attach)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 自定义分页 附件表 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "分页", notes = "传入attach") |
||||
public R<IPage<AttachVO>> page(AttachVO attach, Query query) { |
||||
IPage<AttachVO> pages = attachService.selectAttachPage(Condition.getPage(query), attach); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 附件表 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入attach") |
||||
public R save(@Valid @RequestBody Attach attach) { |
||||
return R.status(attachService.save(attach)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 附件表 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入attach") |
||||
public R update(@Valid @RequestBody Attach attach) { |
||||
return R.status(attachService.updateById(attach)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 附件表 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入attach") |
||||
public R submit(@Valid @RequestBody Attach attach) { |
||||
return R.status(attachService.saveOrUpdate(attach)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 附件表 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(attachService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -1,152 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.resource.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.cache.utils.CacheUtil; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.secure.annotation.PreAuth; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.constant.RoleConstant; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.resource.entity.Oss; |
||||
import org.springblade.modules.resource.service.IOssService; |
||||
import org.springblade.modules.resource.vo.OssVO; |
||||
import org.springblade.modules.resource.wrapper.OssWrapper; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import javax.validation.Valid; |
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.RESOURCE_CACHE; |
||||
|
||||
/** |
||||
* 控制器 |
||||
* |
||||
* @author BladeX |
||||
*/ |
||||
@NonDS |
||||
@ApiIgnore |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_RESOURCE_NAME + "/oss") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
||||
@Api(value = "对象存储接口", tags = "对象存储接口") |
||||
public class OssController extends BladeController { |
||||
|
||||
private final IOssService ossService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入oss") |
||||
public R<OssVO> detail(Oss oss) { |
||||
Oss detail = ossService.getOne(Condition.getQueryWrapper(oss)); |
||||
return R.data(OssWrapper.build().entityVO(detail)); |
||||
} |
||||
|
||||
/** |
||||
* 分页 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入oss") |
||||
public R<IPage<OssVO>> list(Oss oss, Query query) { |
||||
IPage<Oss> pages = ossService.page(Condition.getPage(query), Condition.getQueryWrapper(oss)); |
||||
return R.data(OssWrapper.build().pageVO(pages)); |
||||
} |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "分页", notes = "传入oss") |
||||
public R<IPage<OssVO>> page(OssVO oss, Query query) { |
||||
IPage<OssVO> pages = ossService.selectOssPage(Condition.getPage(query), oss); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入oss") |
||||
public R save(@Valid @RequestBody Oss oss) { |
||||
CacheUtil.clear(RESOURCE_CACHE); |
||||
return R.status(ossService.save(oss)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入oss") |
||||
public R update(@Valid @RequestBody Oss oss) { |
||||
CacheUtil.clear(RESOURCE_CACHE); |
||||
return R.status(ossService.updateById(oss)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入oss") |
||||
public R submit(@Valid @RequestBody Oss oss) { |
||||
CacheUtil.clear(RESOURCE_CACHE); |
||||
return R.status(ossService.submit(oss)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
CacheUtil.clear(RESOURCE_CACHE); |
||||
return R.status(ossService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 启用 |
||||
*/ |
||||
@PostMapping("/enable") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "配置启用", notes = "传入id") |
||||
public R enable(@ApiParam(value = "主键", required = true) @RequestParam Long id) { |
||||
CacheUtil.clear(RESOURCE_CACHE); |
||||
return R.status(ossService.enable(id)); |
||||
} |
||||
|
||||
} |
||||
@ -1,153 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.resource.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.cache.utils.CacheUtil; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.secure.annotation.PreAuth; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.constant.RoleConstant; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.resource.entity.Sms; |
||||
import org.springblade.modules.resource.service.ISmsService; |
||||
import org.springblade.modules.resource.vo.SmsVO; |
||||
import org.springblade.modules.resource.wrapper.SmsWrapper; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import javax.validation.Valid; |
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.RESOURCE_CACHE; |
||||
|
||||
/** |
||||
* 短信配置表 控制器 |
||||
* |
||||
* @author BladeX |
||||
*/ |
||||
@NonDS |
||||
@ApiIgnore |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_RESOURCE_NAME + "/sms") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
||||
@Api(value = "短信配置表", tags = "短信配置表接口") |
||||
public class SmsController extends BladeController { |
||||
|
||||
private final ISmsService smsService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入sms") |
||||
public R<SmsVO> detail(Sms sms) { |
||||
Sms detail = smsService.getOne(Condition.getQueryWrapper(sms)); |
||||
return R.data(SmsWrapper.build().entityVO(detail)); |
||||
} |
||||
|
||||
/** |
||||
* 分页 短信配置表 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入sms") |
||||
public R<IPage<SmsVO>> list(Sms sms, Query query) { |
||||
IPage<Sms> pages = smsService.page(Condition.getPage(query), Condition.getQueryWrapper(sms)); |
||||
return R.data(SmsWrapper.build().pageVO(pages)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 自定义分页 短信配置表 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "分页", notes = "传入sms") |
||||
public R<IPage<SmsVO>> page(SmsVO sms, Query query) { |
||||
IPage<SmsVO> pages = smsService.selectSmsPage(Condition.getPage(query), sms); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 短信配置表 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入sms") |
||||
public R save(@Valid @RequestBody Sms sms) { |
||||
CacheUtil.clear(RESOURCE_CACHE); |
||||
return R.status(smsService.save(sms)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 短信配置表 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入sms") |
||||
public R update(@Valid @RequestBody Sms sms) { |
||||
CacheUtil.clear(RESOURCE_CACHE); |
||||
return R.status(smsService.updateById(sms)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 短信配置表 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入sms") |
||||
public R submit(@Valid @RequestBody Sms sms) { |
||||
CacheUtil.clear(RESOURCE_CACHE); |
||||
return R.status(smsService.submit(sms)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 短信配置表 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
CacheUtil.clear(RESOURCE_CACHE); |
||||
return R.status(smsService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 启用 |
||||
*/ |
||||
@PostMapping("/enable") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "配置启用", notes = "传入id") |
||||
public R enable(@ApiParam(value = "主键", required = true) @RequestParam Long id) { |
||||
CacheUtil.clear(RESOURCE_CACHE); |
||||
return R.status(smsService.enable(id)); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -1,179 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.resource.endpoint; |
||||
|
||||
import io.swagger.annotations.Api; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.SneakyThrows; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.sms.model.SmsCode; |
||||
import org.springblade.core.sms.model.SmsData; |
||||
import org.springblade.core.sms.model.SmsResponse; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.jackson.JsonUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.resource.builder.sms.SmsBuilder; |
||||
import org.springblade.modules.resource.utils.SmsUtil; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import static org.springblade.modules.resource.utils.SmsUtil.*; |
||||
|
||||
/** |
||||
* 短信服务端点 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@NonDS |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_RESOURCE_NAME + "/sms/endpoint") |
||||
@Api(value = "短信服务端点", tags = "短信服务端点") |
||||
public class SmsEndpoint { |
||||
|
||||
/** |
||||
* 短信服务构建类 |
||||
*/ |
||||
private final SmsBuilder smsBuilder; |
||||
|
||||
//================================= 短信服务校验 =================================
|
||||
|
||||
/** |
||||
* 短信验证码发送 |
||||
* |
||||
* @param phone 手机号 |
||||
*/ |
||||
@SneakyThrows |
||||
@PostMapping("/send-validate") |
||||
public R sendValidate(@RequestParam String phone) { |
||||
Map<String, String> params = SmsUtil.getValidateParams(); |
||||
SmsCode smsCode = smsBuilder.template().sendValidate(new SmsData(params).setKey(PARAM_KEY), phone); |
||||
return smsCode.isSuccess() ? R.data(smsCode, SEND_SUCCESS) : R.fail(SEND_FAIL); |
||||
} |
||||
|
||||
/** |
||||
* 校验短信 |
||||
* |
||||
* @param smsCode 短信校验信息 |
||||
*/ |
||||
@SneakyThrows |
||||
@PostMapping("/validate-message") |
||||
public R validateMessage(SmsCode smsCode) { |
||||
boolean validate = smsBuilder.template().validateMessage(smsCode); |
||||
return validate ? R.success(VALIDATE_SUCCESS) : R.fail(VALIDATE_FAIL); |
||||
} |
||||
|
||||
//========== 通用短信自定义发送(支持自定义params参数传递, 推荐用于测试, 不推荐用于生产环境) ==========
|
||||
|
||||
/** |
||||
* 发送信息 |
||||
* |
||||
* @param code 资源编号 |
||||
* @param params 自定义短信参数 |
||||
* @param phones 手机号集合 |
||||
*/ |
||||
@SneakyThrows |
||||
@PostMapping("/send-message") |
||||
public R sendMessage(@RequestParam String code, @RequestParam String params, @RequestParam String phones) { |
||||
SmsData smsData = new SmsData(JsonUtil.readMap(params, String.class, String.class)); |
||||
return send(code, smsData, phones); |
||||
} |
||||
|
||||
//========== 指定短信服务发送(可根据各种场景自定拓展定制, 损失灵活性增加安全性, 推荐用于生产环境) ==========
|
||||
|
||||
/** |
||||
* 短信通知 |
||||
* |
||||
* @param phones 手机号集合 |
||||
*/ |
||||
@SneakyThrows |
||||
@PostMapping("/send-notice") |
||||
public R sendNotice(@RequestParam String phones) { |
||||
Map<String, String> params = new HashMap<>(3); |
||||
params.put("title", "通知标题"); |
||||
params.put("content", "通知内容"); |
||||
params.put("date", "通知时间"); |
||||
SmsData smsData = new SmsData(params); |
||||
return send(smsData, phones); |
||||
} |
||||
|
||||
/** |
||||
* 订单通知 |
||||
* |
||||
* @param phones 手机号集合 |
||||
*/ |
||||
@SneakyThrows |
||||
@PostMapping("/send-order") |
||||
public R sendOrder(@RequestParam String phones) { |
||||
Map<String, String> params = new HashMap<>(3); |
||||
params.put("orderNo", "订单编号"); |
||||
params.put("packageNo", "快递单号"); |
||||
params.put("user", "收件人"); |
||||
SmsData smsData = new SmsData(params); |
||||
return send(smsData, phones); |
||||
} |
||||
|
||||
/** |
||||
* 会议通知 |
||||
* |
||||
* @param phones 手机号集合 |
||||
*/ |
||||
@SneakyThrows |
||||
@PostMapping("/send-meeting") |
||||
public R sendMeeting(@RequestParam String phones) { |
||||
Map<String, String> params = new HashMap<>(2); |
||||
params.put("roomId", "会议室"); |
||||
params.put("topic", "会议主题"); |
||||
params.put("date", "会议时间"); |
||||
SmsData smsData = new SmsData(params); |
||||
return send(smsData, phones); |
||||
} |
||||
|
||||
//================================= 通用短信发送接口 =================================
|
||||
|
||||
/** |
||||
* 通用短信发送接口 |
||||
* |
||||
* @param smsData 短信内容 |
||||
* @param phones 手机号列表 |
||||
* @return 是否发送成功 |
||||
*/ |
||||
private R send(SmsData smsData, String phones) { |
||||
SmsResponse response = smsBuilder.template().sendMessage(smsData, Func.toStrList(phones)); |
||||
return response.isSuccess() ? R.success(SEND_SUCCESS) : R.fail(SEND_FAIL); |
||||
} |
||||
|
||||
/** |
||||
* 通用短信发送接口 |
||||
* |
||||
* @param code 资源编号 |
||||
* @param smsData 短信内容 |
||||
* @param phones 手机号列表 |
||||
* @return 是否发送成功 |
||||
*/ |
||||
private R send(String code, SmsData smsData, String phones) { |
||||
SmsResponse response = smsBuilder.template(code).sendMessage(smsData, Func.toStrList(phones)); |
||||
return response.isSuccess() ? R.success(SEND_SUCCESS) : R.fail(SEND_FAIL); |
||||
} |
||||
|
||||
} |
||||
@ -1,108 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.system.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.*; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.cache.utils.CacheUtil; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.system.entity.Param; |
||||
import org.springblade.modules.system.service.IParamService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.Map; |
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.PARAM_CACHE; |
||||
|
||||
/** |
||||
* 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@NonDS |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_SYSTEM_NAME + "/param") |
||||
@Api(value = "参数管理", tags = "参数管理") |
||||
public class ParamController extends BladeController { |
||||
|
||||
private final IParamService paramService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入param") |
||||
public R<Param> detail(Param param) { |
||||
Param detail = paramService.getOne(Condition.getQueryWrapper(param)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiImplicitParams({ |
||||
@ApiImplicitParam(name = "paramName", value = "参数名称", paramType = "query", dataType = "string"), |
||||
@ApiImplicitParam(name = "paramKey", value = "参数键名", paramType = "query", dataType = "string"), |
||||
@ApiImplicitParam(name = "paramValue", value = "参数键值", paramType = "query", dataType = "string") |
||||
}) |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入param") |
||||
public R<IPage<Param>> list(@ApiIgnore @RequestParam Map<String, Object> param, Query query) { |
||||
IPage<Param> pages = paramService.page(Condition.getPage(query), Condition.getQueryWrapper(param, Param.class)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "新增或修改", notes = "传入param") |
||||
public R submit(@Valid @RequestBody Param param) { |
||||
CacheUtil.clear(PARAM_CACHE); |
||||
CacheUtil.clear(PARAM_CACHE, Boolean.FALSE); |
||||
return R.status(paramService.saveOrUpdate(param)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
CacheUtil.clear(PARAM_CACHE); |
||||
CacheUtil.clear(PARAM_CACHE, Boolean.FALSE); |
||||
return R.status(paramService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -1,150 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.system.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.cache.utils.CacheUtil; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.secure.BladeUser; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.system.entity.Post; |
||||
import org.springblade.modules.system.service.IPostService; |
||||
import org.springblade.modules.system.vo.PostVO; |
||||
import org.springblade.modules.system.wrapper.PostWrapper; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.List; |
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
||||
|
||||
/** |
||||
* 岗位表 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@NonDS |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_SYSTEM_NAME + "/post") |
||||
@Api(value = "岗位", tags = "岗位") |
||||
public class PostController extends BladeController { |
||||
|
||||
private final IPostService postService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入post") |
||||
public R<PostVO> detail(Post post) { |
||||
Post detail = postService.getOne(Condition.getQueryWrapper(post)); |
||||
return R.data(PostWrapper.build().entityVO(detail)); |
||||
} |
||||
|
||||
/** |
||||
* 分页 岗位表 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入post") |
||||
public R<IPage<PostVO>> list(Post post, Query query) { |
||||
IPage<Post> pages = postService.page(Condition.getPage(query), Condition.getQueryWrapper(post)); |
||||
return R.data(PostWrapper.build().pageVO(pages)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 自定义分页 岗位表 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "分页", notes = "传入post") |
||||
public R<IPage<PostVO>> page(PostVO post, Query query) { |
||||
IPage<PostVO> pages = postService.selectPostPage(Condition.getPage(query), post); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 岗位表 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入post") |
||||
public R save(@Valid @RequestBody Post post) { |
||||
CacheUtil.clear(SYS_CACHE); |
||||
return R.status(postService.save(post)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 岗位表 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入post") |
||||
public R update(@Valid @RequestBody Post post) { |
||||
CacheUtil.clear(SYS_CACHE); |
||||
return R.status(postService.updateById(post)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 岗位表 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入post") |
||||
public R submit(@Valid @RequestBody Post post) { |
||||
CacheUtil.clear(SYS_CACHE); |
||||
return R.status(postService.saveOrUpdate(post)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 岗位表 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
CacheUtil.clear(SYS_CACHE); |
||||
return R.status(postService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 下拉数据源 |
||||
*/ |
||||
@GetMapping("/select") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "下拉数据源", notes = "传入post") |
||||
public R<List<Post>> select(String tenantId, BladeUser bladeUser) { |
||||
List<Post> list = postService.list(Wrappers.<Post>query().lambda().eq(Post::getTenantId, Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()))); |
||||
return R.data(list); |
||||
} |
||||
|
||||
} |
||||
@ -1,99 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.system.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.system.entity.Post; |
||||
import org.springblade.modules.system.service.IDeptService; |
||||
import org.springblade.modules.system.service.IPostService; |
||||
import org.springblade.modules.system.service.IRoleService; |
||||
import org.springblade.modules.system.vo.DeptVO; |
||||
import org.springblade.modules.system.vo.PostVO; |
||||
import org.springblade.modules.system.vo.RoleVO; |
||||
import org.springblade.modules.system.wrapper.PostWrapper; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 查询控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@NonDS |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_SYSTEM_NAME + "/search") |
||||
@Api(value = "查询", tags = "查询") |
||||
public class SearchController { |
||||
|
||||
private final IRoleService roleService; |
||||
|
||||
private final IDeptService deptService; |
||||
|
||||
private final IPostService postService; |
||||
|
||||
/** |
||||
* 角色信息查询 |
||||
*/ |
||||
@GetMapping("/role") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "角色信息查询", notes = "传入roleName或者parentId") |
||||
public R<List<RoleVO>> roleSearch(String roleName, Long parentId) { |
||||
return R.data(roleService.search(roleName, parentId)); |
||||
} |
||||
|
||||
/** |
||||
* 部门信息查询 |
||||
*/ |
||||
@GetMapping("/dept") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "部门信息查询", notes = "传入deptName或者parentId") |
||||
public R<List<DeptVO>> deptSearch(String deptName, Long parentId) { |
||||
return R.data(deptService.search(deptName, parentId)); |
||||
} |
||||
|
||||
/** |
||||
* 岗位信息查询 |
||||
*/ |
||||
@GetMapping("/post") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "岗位信息查询", notes = "传入postName") |
||||
public R<IPage<PostVO>> postSearch(String postName, Query query) { |
||||
LambdaQueryWrapper<Post> queryWrapper = Wrappers.<Post>query().lambda(); |
||||
if (Func.isNotBlank(postName)) { |
||||
queryWrapper.like(Post::getPostName, postName); |
||||
} |
||||
IPage<Post> pages = postService.page(Condition.getPage(query), queryWrapper); |
||||
return R.data(PostWrapper.build().pageVO(pages)); |
||||
} |
||||
|
||||
} |
||||
@ -1,233 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.system.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.*; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.cache.utils.CacheUtil; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.secure.BladeUser; |
||||
import org.springblade.core.secure.annotation.PreAuth; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.constant.BladeConstant; |
||||
import org.springblade.core.tool.constant.RoleConstant; |
||||
import org.springblade.core.tool.support.Kv; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.system.entity.Tenant; |
||||
import org.springblade.modules.system.entity.TenantPackage; |
||||
import org.springblade.modules.system.service.ITenantPackageService; |
||||
import org.springblade.modules.system.service.ITenantService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
import static org.springblade.common.cache.SysCache.TENANT_PACKAGE_ID; |
||||
import static org.springblade.common.cache.SysCache.TENANT_TENANT_ID; |
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
||||
import static org.springblade.core.tenant.constant.TenantBaseConstant.TENANT_DATASOURCE_CACHE; |
||||
import static org.springblade.core.tenant.constant.TenantBaseConstant.TENANT_DATASOURCE_EXIST_KEY; |
||||
|
||||
/** |
||||
* 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@NonDS |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_SYSTEM_NAME + "/tenant") |
||||
@Api(value = "租户管理", tags = "租户管理") |
||||
public class TenantController extends BladeController { |
||||
|
||||
private final ITenantService tenantService; |
||||
private final ITenantPackageService tenantPackageService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入tenant") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
||||
public R<Tenant> detail(Tenant tenant) { |
||||
Tenant detail = tenantService.getOne(Condition.getQueryWrapper(tenant)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiImplicitParams({ |
||||
@ApiImplicitParam(name = "tenantId", value = "参数名称", paramType = "query", dataType = "string"), |
||||
@ApiImplicitParam(name = "tenantName", value = "角色别名", paramType = "query", dataType = "string"), |
||||
@ApiImplicitParam(name = "contactNumber", value = "联系电话", paramType = "query", dataType = "string") |
||||
}) |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入tenant") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
||||
public R<IPage<Tenant>> list(@ApiIgnore @RequestParam Map<String, Object> tenant, Query query, BladeUser bladeUser) { |
||||
QueryWrapper<Tenant> queryWrapper = Condition.getQueryWrapper(tenant, Tenant.class); |
||||
IPage<Tenant> pages = tenantService.page(Condition.getPage(query), (!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Tenant::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 下拉数据源 |
||||
*/ |
||||
@GetMapping("/select") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "下拉数据源", notes = "传入tenant") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
||||
public R<List<Tenant>> select(Tenant tenant, BladeUser bladeUser) { |
||||
QueryWrapper<Tenant> queryWrapper = Condition.getQueryWrapper(tenant); |
||||
List<Tenant> list = tenantService.list((!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Tenant::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
||||
return R.data(list); |
||||
} |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "分页", notes = "传入tenant") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
||||
public R<IPage<Tenant>> page(Tenant tenant, Query query) { |
||||
IPage<Tenant> pages = tenantService.selectTenantPage(Condition.getPage(query), tenant); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "新增或修改", notes = "传入tenant") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
||||
public R submit(@Valid @RequestBody Tenant tenant) { |
||||
return R.status(tenantService.submitTenant(tenant)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(tenantService.removeTenant(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 授权配置 |
||||
*/ |
||||
@PostMapping("/setting") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "授权配置", notes = "传入ids,accountNumber,expireTime") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
||||
public R setting(@ApiParam(value = "主键集合", required = true) @RequestParam String ids, @ApiParam(value = "账号额度") Integer accountNumber, @ApiParam(value = "过期时间") Date expireTime) { |
||||
return R.status(tenantService.setting(accountNumber, expireTime, ids)); |
||||
} |
||||
|
||||
/** |
||||
* 数据源配置 |
||||
*/ |
||||
@PostMapping("datasource") |
||||
@ApiOperationSupport(order = 8) |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
||||
@ApiOperation(value = "数据源配置", notes = "传入datasource_id") |
||||
public R datasource(@ApiParam(value = "租户ID", required = true) @RequestParam String tenantId, @ApiParam(value = "数据源ID", required = true) @RequestParam Long datasourceId) { |
||||
CacheUtil.evict(TENANT_DATASOURCE_CACHE, TENANT_DATASOURCE_EXIST_KEY, tenantId, Boolean.FALSE); |
||||
return R.status(tenantService.update(Wrappers.<Tenant>update().lambda().set(Tenant::getDatasourceId, datasourceId).eq(Tenant::getTenantId, tenantId))); |
||||
} |
||||
|
||||
/** |
||||
* 根据名称查询列表 |
||||
* |
||||
* @param name 租户名称 |
||||
*/ |
||||
@GetMapping("/find-by-name") |
||||
@ApiOperationSupport(order = 9) |
||||
@ApiOperation(value = "详情", notes = "传入tenant") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
||||
public R<List<Tenant>> findByName(String name) { |
||||
List<Tenant> list = tenantService.list(Wrappers.<Tenant>query().lambda().like(Tenant::getTenantName, name)); |
||||
return R.data(list); |
||||
} |
||||
|
||||
/** |
||||
* 根据域名查询信息 |
||||
* |
||||
* @param domain 域名 |
||||
*/ |
||||
@GetMapping("/info") |
||||
@ApiOperationSupport(order = 10) |
||||
@ApiOperation(value = "配置信息", notes = "传入domain") |
||||
public R<Kv> info(String domain) { |
||||
Tenant tenant = tenantService.getOne(Wrappers.<Tenant>query().lambda().eq(Tenant::getDomainUrl, domain)); |
||||
Kv kv = Kv.create(); |
||||
if (tenant != null) { |
||||
kv.set("tenantId", tenant.getTenantId()) |
||||
.set("domain", tenant.getDomainUrl()) |
||||
.set("backgroundUrl", tenant.getBackgroundUrl()); |
||||
} |
||||
return R.data(kv); |
||||
} |
||||
|
||||
/** |
||||
* 根据租户ID查询产品包详情 |
||||
* |
||||
* @param tenantId 租户ID |
||||
*/ |
||||
@GetMapping("/package-detail") |
||||
@ApiOperationSupport(order = 11) |
||||
@ApiOperation(value = "产品包详情", notes = "传入tenantId") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
||||
public R<TenantPackage> packageDetail(Long tenantId) { |
||||
Tenant tenant = tenantService.getById(tenantId); |
||||
return R.data(tenantPackageService.getById(tenant.getPackageId())); |
||||
} |
||||
|
||||
/** |
||||
* 产品包配置 |
||||
*/ |
||||
@PostMapping("/package-setting") |
||||
@ApiOperationSupport(order = 12) |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
||||
@ApiOperation(value = "产品包配置", notes = "传入packageId") |
||||
public R packageSetting(@ApiParam(value = "租户ID", required = true) @RequestParam String tenantId, @ApiParam(value = "产品包ID") Long packageId) { |
||||
CacheUtil.evict(SYS_CACHE, TENANT_TENANT_ID, tenantId, Boolean.FALSE); |
||||
CacheUtil.evict(SYS_CACHE, TENANT_PACKAGE_ID, tenantId, Boolean.FALSE); |
||||
return R.status(tenantService.update(Wrappers.<Tenant>update().lambda().set(Tenant::getPackageId, packageId).eq(Tenant::getTenantId, tenantId))); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -1,134 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.system.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.cache.utils.CacheUtil; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.secure.annotation.PreAuth; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.constant.RoleConstant; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.system.entity.TenantPackage; |
||||
import org.springblade.modules.system.service.ITenantPackageService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.List; |
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
||||
|
||||
/** |
||||
* 租户产品表 控制器 |
||||
* |
||||
* @author BladeX |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_SYSTEM_NAME + "/tenant-package") |
||||
@Api(value = "租户产品表", tags = "租户产品表接口") |
||||
public class TenantPackageController extends BladeController { |
||||
|
||||
private final ITenantPackageService tenantPackageService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入tenantPackage") |
||||
public R<TenantPackage> detail(TenantPackage tenantPackage) { |
||||
TenantPackage detail = tenantPackageService.getOne(Condition.getQueryWrapper(tenantPackage)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 租户产品表 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入tenantPackage") |
||||
public R<IPage<TenantPackage>> list(TenantPackage tenantPackage, Query query) { |
||||
IPage<TenantPackage> pages = tenantPackageService.page(Condition.getPage(query), Condition.getQueryWrapper(tenantPackage)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 租户产品表 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "新增", notes = "传入tenantPackage") |
||||
public R save(@Valid @RequestBody TenantPackage tenantPackage) { |
||||
return R.status(tenantPackageService.save(tenantPackage)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 租户产品表 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "修改", notes = "传入tenantPackage") |
||||
public R update(@Valid @RequestBody TenantPackage tenantPackage) { |
||||
return R.status(tenantPackageService.updateById(tenantPackage)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 租户产品表 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "新增或修改", notes = "传入tenantPackage") |
||||
public R submit(@Valid @RequestBody TenantPackage tenantPackage) { |
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
||||
return R.status(tenantPackageService.saveOrUpdate(tenantPackage)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 租户产品表 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
||||
return R.status(tenantPackageService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 下拉数据源 |
||||
*/ |
||||
@GetMapping("/select") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "下拉数据源", notes = "传入tenant") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
||||
public R<List<TenantPackage>> select(TenantPackage tenantPackage) { |
||||
return R.data(tenantPackageService.list(Condition.getQueryWrapper(tenantPackage))); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -1,137 +0,0 @@ |
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.modules.system.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.cache.utils.CacheUtil; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.secure.annotation.PreAuth; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.constant.RoleConstant; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.system.entity.TopMenu; |
||||
import org.springblade.modules.system.service.ITopMenuService; |
||||
import org.springblade.modules.system.vo.GrantVO; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.validation.Valid; |
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.MENU_CACHE; |
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
||||
|
||||
/** |
||||
* 顶部菜单表 控制器 |
||||
* |
||||
* @author BladeX |
||||
*/ |
||||
@NonDS |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_SYSTEM_NAME + "/topmenu") |
||||
@Api(value = "顶部菜单表", tags = "顶部菜单") |
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
||||
public class TopMenuController extends BladeController { |
||||
|
||||
private final ITopMenuService topMenuService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入topMenu") |
||||
public R<TopMenu> detail(TopMenu topMenu) { |
||||
TopMenu detail = topMenuService.getOne(Condition.getQueryWrapper(topMenu)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 顶部菜单表 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入topMenu") |
||||
public R<IPage<TopMenu>> list(TopMenu topMenu, Query query) { |
||||
IPage<TopMenu> pages = topMenuService.page(Condition.getPage(query), Condition.getQueryWrapper(topMenu).lambda().orderByAsc(TopMenu::getSort)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 顶部菜单表 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入topMenu") |
||||
public R save(@Valid @RequestBody TopMenu topMenu) { |
||||
return R.status(topMenuService.save(topMenu)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 顶部菜单表 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入topMenu") |
||||
public R update(@Valid @RequestBody TopMenu topMenu) { |
||||
return R.status(topMenuService.updateById(topMenu)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 顶部菜单表 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入topMenu") |
||||
public R submit(@Valid @RequestBody TopMenu topMenu) { |
||||
return R.status(topMenuService.saveOrUpdate(topMenu)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 顶部菜单表 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(topMenuService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 设置顶部菜单 |
||||
*/ |
||||
@PostMapping("/grant") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "顶部菜单配置", notes = "传入topMenuId集合以及menuId集合") |
||||
public R grant(@RequestBody GrantVO grantVO) { |
||||
CacheUtil.clear(SYS_CACHE); |
||||
CacheUtil.clear(MENU_CACHE); |
||||
CacheUtil.clear(MENU_CACHE, Boolean.FALSE); |
||||
boolean temp = topMenuService.grant(grantVO.getTopMenuIds(), grantVO.getMenuIds()); |
||||
return R.status(temp); |
||||
} |
||||
|
||||
} |
||||
|
Before Width: | Height: | Size: 41 KiB |
Loading…
Reference in new issue