* 修改绑定列名逻辑
This commit is contained in:
parent
743f459c18
commit
8d90b658da
|
@ -160,15 +160,22 @@ public class QueryBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取数据表的列名(驼峰转下划线蛇形命名)
|
* 获取数据表的列名(驼峰转下划线蛇形命名)
|
||||||
|
* <br>
|
||||||
|
* 列名取值优先级: @BindQuery.field > @TableField.value > field.name
|
||||||
|
*
|
||||||
* @param field
|
* @param field
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static String getColumnName(Field field){
|
private static String getColumnName(Field field){
|
||||||
BindQuery annotation = field.getAnnotation(BindQuery.class);
|
String columnName = "";
|
||||||
if (annotation != null && V.notEmpty(annotation.field())){
|
if (field.isAnnotationPresent(BindQuery.class)) {
|
||||||
return annotation.field();
|
columnName = field.getAnnotation(BindQuery.class).field();
|
||||||
}
|
}
|
||||||
return S.toSnakeCase(field.getName());
|
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'
|
apply plugin: 'org.springframework.boot'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
// compile("com.diboot:diboot-shiro:2.0.1")
|
||||||
compile project(":diboot-shiro-wx-mp")
|
compile project(":diboot-shiro-wx-mp")
|
||||||
compile project(":diboot-shiro-wx-cp")
|
compile project(":diboot-shiro-wx-cp")
|
||||||
compile project(":diboot-components-msg")
|
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.DefaultSqlInjector;
|
||||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
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 com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
|
@ -24,6 +24,11 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据字典类
|
||||||
|
*
|
||||||
|
* @author wee
|
||||||
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/dictionary")
|
@RequestMapping("/dictionary")
|
||||||
@AuthorizationPrefix(name = "数据字典", code = "dictionary", prefix = "dictionary")
|
@AuthorizationPrefix(name = "数据字典", code = "dictionary", prefix = "dictionary")
|
||||||
|
@ -38,9 +43,15 @@ public class DictionaryController extends BaseCrudRestController {
|
||||||
return dictionaryService;
|
return dictionaryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* 获取列表页数据
|
* 获取列表页数据
|
||||||
* */
|
*
|
||||||
|
* @param dictionary
|
||||||
|
* @param pagination
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@AuthorizationWrapper(value = @RequiresPermissions("list"), name = "列表")
|
@AuthorizationWrapper(value = @RequiresPermissions("list"), name = "列表")
|
||||||
public JsonResult list(Dictionary dictionary, Pagination pagination, HttpServletRequest request) throws Exception {
|
public JsonResult list(Dictionary dictionary, Pagination pagination, HttpServletRequest request) throws Exception {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||||
* @version v2.0
|
* @version v2.0
|
||||||
* @date 2019/7/8
|
* @date 2019/7/8
|
||||||
*/
|
*/
|
||||||
@Service("dictionaryService")
|
@Service("exampleDictionaryService")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DictionaryServiceImpl extends BaseServiceImpl<DictionaryMapper, Dictionary> implements DictionaryService {
|
public class DictionaryServiceImpl extends BaseServiceImpl<DictionaryMapper, Dictionary> implements DictionaryService {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DictionaryServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(DictionaryServiceImpl.class);
|
||||||
|
|
Loading…
Reference in New Issue