commit
409137951c
11
README.md
11
README.md
|
@ -7,17 +7,19 @@
|
|||
# diboot-v2
|
||||
diboot 2.0版本项目,实现: diboot-core全新内核 + diboot-shiro-*权限控制 + diboot-components-*基础组件 + diboot-devtools代码生成平台。
|
||||
|
||||
> diboot的设计目标:面向开发人员的低代码开发平台,提高开发质量和效率,提高代码可维护性。
|
||||
> diboot的设计目标:面向开发人员的低代码开发平台,提高开发效率和质量,提高代码可维护性。
|
||||
|
||||
## 技术交流QQ群: 731690096
|
||||
|
||||
> 复杂的事情简单化,简单的事情标准化,标准的事情流程化,流程的事情自动化
|
||||
|
||||
**2.0版devtools将于国庆节后发布,敬请期待。不多说了,我要给祖国母亲庆生去了 : )**
|
||||
**2.0版devtools预计将于10月份发布,敬请期待。**
|
||||
|
||||
|
||||
## 一、 diboot-core: 精简优化内核
|
||||
全新精简内核,主要实现<font color="red">单表CRUD无SQL 和 多表关联查询绑定的无SQL</font>实现方案,并提供其他常用开发场景的简单封装。
|
||||
全新精简内核,主要实现<font color="red">单表CRUD无SQL 和 多表关联查询绑定的无SQL</font>实现方案,并提供查询绑定等常用开发场景的简单封装。
|
||||
|
||||
(基于diboot-core 2.x版本的CRUD和简单关联的功能实现,代码量比1.x版本减少60%+)
|
||||
### 单表CRUD无SQL
|
||||
> 基于Mybatis-Plus实现(Mybatis-Plus具备通用Mapper方案和灵活的查询构造器)
|
||||
### 多表关联查询无SQL(适用于多数关联场景,自动实现拆分成单表查询和结果绑定,保障性能佳和维护易)
|
||||
|
@ -28,6 +30,9 @@ diboot 2.0版本项目,实现: diboot-core全新内核 + diboot-shiro-*权限
|
|||
##### 3. @BindEntity 注解自动绑定单个其他表实体Entity
|
||||
##### 4. @BindEntityList 注解自动绑定其他表实体集合List<Entity>
|
||||
|
||||
### Entity/DTO自动转换为QueryWrapper
|
||||
> @BindQuery注解声明映射的查询条件,Controller中直接绑定转换为QueryWrapper
|
||||
|
||||
具体请查看: [diboot-core README](https://github.com/dibo-software/diboot-v2/tree/master/diboot-core "注解自动绑定多表关联").
|
||||
|
||||
|
||||
|
|
|
@ -160,15 +160,22 @@ public class QueryBuilder {
|
|||
|
||||
/**
|
||||
* 获取数据表的列名(驼峰转下划线蛇形命名)
|
||||
* <br>
|
||||
* 列名取值优先级: @BindQuery.field > @TableField.value > field.name
|
||||
*
|
||||
* @param field
|
||||
* @return
|
||||
*/
|
||||
private static String getColumnName(Field field){
|
||||
BindQuery annotation = field.getAnnotation(BindQuery.class);
|
||||
if (annotation != null && V.notEmpty(annotation.field())){
|
||||
return annotation.field();
|
||||
String columnName = "";
|
||||
if (field.isAnnotationPresent(BindQuery.class)) {
|
||||
columnName = field.getAnnotation(BindQuery.class).field();
|
||||
}
|
||||
return S.toSnakeCase(field.getName());
|
||||
else if (field.isAnnotationPresent(TableField.class)) {
|
||||
columnName = field.getAnnotation(TableField.class).value();
|
||||
}
|
||||
return V.notEmpty(columnName) ? columnName : S.toSnakeCase(field.getName());
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
apply plugin: 'org.springframework.boot'
|
||||
|
||||
dependencies {
|
||||
|
||||
// compile("com.diboot:diboot-shiro:2.0.1")
|
||||
compile project(":diboot-shiro-wx-mp")
|
||||
compile project(":diboot-shiro-wx-cp")
|
||||
compile project(":diboot-components-msg")
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.diboot.example.config;
|
|||
|
||||
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
|
||||
//import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
|
@ -24,6 +24,11 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据字典类
|
||||
*
|
||||
* @author wee
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dictionary")
|
||||
@AuthorizationPrefix(name = "数据字典", code = "dictionary", prefix = "dictionary")
|
||||
|
@ -38,18 +43,24 @@ public class DictionaryController extends BaseCrudRestController {
|
|||
return dictionaryService;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取列表页数据
|
||||
* */
|
||||
/**
|
||||
* 获取列表页数据
|
||||
*
|
||||
* @param dictionary
|
||||
* @param pagination
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@AuthorizationWrapper(value = @RequiresPermissions("list"), name = "列表")
|
||||
public JsonResult list(Dictionary dictionary, Pagination pagination, HttpServletRequest request) throws Exception {
|
||||
//构建查询条件
|
||||
QueryWrapper<Dictionary> queryWrapper = super.buildQueryWrapper(dictionary);
|
||||
queryWrapper.lambda().eq(Dictionary::getParentId, 0)
|
||||
.orderByAsc(Dictionary::getSortId);
|
||||
.orderByAsc(Dictionary::getSortId);
|
||||
//获取实体list
|
||||
List<Dictionary> dictionaryList = dictionaryService.getEntityList(queryWrapper, pagination);
|
||||
List<Dictionary> dictionaryList = dictionaryService.getEntityList(queryWrapper, pagination);
|
||||
//筛选出在列表页展示的字段
|
||||
List<DictionaryListVO> dicVoList = RelationsBinder.convertAndBind(dictionaryList, DictionaryListVO.class);
|
||||
//返回结果
|
||||
|
@ -61,21 +72,21 @@ public class DictionaryController extends BaseCrudRestController {
|
|||
* */
|
||||
@GetMapping("/{id}")
|
||||
@AuthorizationWrapper(value = @RequiresPermissions("read"), name = "读取")
|
||||
public JsonResult getEntity(@PathVariable("id") Long id, HttpServletRequest request){
|
||||
public JsonResult getEntity(@PathVariable("id") Long id, HttpServletRequest request) {
|
||||
DictionaryVO vo = dictionaryService.getViewObject(id, DictionaryVO.class);
|
||||
return new JsonResult(vo);
|
||||
}
|
||||
|
||||
/*
|
||||
* 新建
|
||||
* */
|
||||
* 新建
|
||||
* */
|
||||
@PostMapping("/")
|
||||
@AuthorizationWrapper(value = @RequiresPermissions("create"), name = "新建")
|
||||
public JsonResult create(@RequestBody DictionaryVO entityVO, HttpServletRequest request){
|
||||
boolean success = dictionaryService.createDictionary(entityVO);
|
||||
if(success){
|
||||
public JsonResult create(@RequestBody DictionaryVO entityVO, HttpServletRequest request) {
|
||||
boolean success = dictionaryService.createDictionary(entityVO);
|
||||
if (success) {
|
||||
return new JsonResult(Status.OK);
|
||||
}else{
|
||||
} else {
|
||||
return new JsonResult(Status.FAIL_OPERATION);
|
||||
}
|
||||
}
|
||||
|
@ -85,12 +96,12 @@ public class DictionaryController extends BaseCrudRestController {
|
|||
* */
|
||||
@PutMapping("/{id}")
|
||||
@AuthorizationWrapper(value = @RequiresPermissions("update"), name = "更新")
|
||||
public JsonResult update(@PathVariable("id")Long id, @RequestBody DictionaryVO entityVO, HttpServletRequest request){
|
||||
public JsonResult update(@PathVariable("id") Long id, @RequestBody DictionaryVO entityVO, HttpServletRequest request) {
|
||||
entityVO.setId(id);
|
||||
boolean success = dictionaryService.updateDictionary(entityVO);
|
||||
if(success){
|
||||
if (success) {
|
||||
return new JsonResult(Status.OK);
|
||||
}else{
|
||||
} else {
|
||||
return new JsonResult(Status.FAIL_OPERATION);
|
||||
}
|
||||
}
|
||||
|
@ -100,12 +111,12 @@ public class DictionaryController extends BaseCrudRestController {
|
|||
* */
|
||||
@DeleteMapping("/{id}")
|
||||
@AuthorizationWrapper(value = @RequiresPermissions("delete"), name = "删除")
|
||||
public JsonResult delete(@PathVariable("id") Long id){
|
||||
public JsonResult delete(@PathVariable("id") Long id) {
|
||||
boolean success = dictionaryService.deleteDictionary(id);
|
||||
if(success){
|
||||
if (success) {
|
||||
return new JsonResult(Status.OK);
|
||||
}else{
|
||||
return new JsonResult(Status.FAIL_OPERATION );
|
||||
} else {
|
||||
return new JsonResult(Status.FAIL_OPERATION);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,16 +124,16 @@ public class DictionaryController extends BaseCrudRestController {
|
|||
* 校验类型编码是否重复
|
||||
* */
|
||||
@GetMapping("/checkTypeRepeat")
|
||||
public JsonResult checkTypeRepeat(@RequestParam(required = false) Long id,@RequestParam String type, HttpServletRequest request){
|
||||
if(V.notEmpty(type)){
|
||||
public JsonResult checkTypeRepeat(@RequestParam(required = false) Long id, @RequestParam String type, HttpServletRequest request) {
|
||||
if (V.notEmpty(type)) {
|
||||
LambdaQueryWrapper<Dictionary> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(Dictionary::getType, type)
|
||||
.eq(Dictionary::getParentId, 0);
|
||||
if(V.notEmpty(id)){
|
||||
.eq(Dictionary::getParentId, 0);
|
||||
if (V.notEmpty(id)) {
|
||||
wrapper.ne(Dictionary::getId, id);
|
||||
}
|
||||
List<Dictionary> dictionaryList = dictionaryService.getEntityList(wrapper);
|
||||
if(V.isEmpty(dictionaryList)){
|
||||
if (V.isEmpty(dictionaryList)) {
|
||||
return new JsonResult(Status.OK);
|
||||
}
|
||||
return new JsonResult(Status.FAIL_OPERATION, "类型编码已存在");
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
|||
* @version v2.0
|
||||
* @date 2019/7/8
|
||||
*/
|
||||
@Service("dictionaryService")
|
||||
@Service("exampleDictionaryService")
|
||||
@Slf4j
|
||||
public class DictionaryServiceImpl extends BaseServiceImpl<DictionaryMapper, Dictionary> implements DictionaryService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DictionaryServiceImpl.class);
|
||||
|
|
Loading…
Reference in New Issue