commit
ba0f614636
|
@ -1,4 +1,14 @@
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
resources {
|
||||||
|
srcDirs "src/main/java"
|
||||||
|
include '**/*.properties'
|
||||||
|
include '**/*.xml'
|
||||||
|
include '**/*.dtd'
|
||||||
|
include '**/*.class'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
compile("org.springframework.boot:spring-boot-configuration-processor")
|
compile("org.springframework.boot:spring-boot-configuration-processor")
|
||||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package com.diboot.core.entity;
|
package com.diboot.core.entity;
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.diboot.core.util.JSON;
|
import com.diboot.core.util.JSON;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -37,7 +34,7 @@ public abstract class BaseEntity implements Serializable {
|
||||||
/***
|
/***
|
||||||
* 默认记录创建时间字段,新建时由数据库赋值
|
* 默认记录创建时间字段,新建时由数据库赋值
|
||||||
*/
|
*/
|
||||||
@TableField(update="now()")
|
@TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
|
|
|
@ -208,7 +208,7 @@ public class BaseServiceImpl<M extends BaseCrudMapper<T>, T> extends ServiceImpl
|
||||||
List<KeyValue> keyValueList = new ArrayList<>(mapList.size());
|
List<KeyValue> keyValueList = new ArrayList<>(mapList.size());
|
||||||
for(Map<String, Object> map : mapList){
|
for(Map<String, Object> map : mapList){
|
||||||
if(map.get(keyValueArray[0]) != null){
|
if(map.get(keyValueArray[0]) != null){
|
||||||
KeyValue kv = new KeyValue((String)map.get(keyValueArray[0]), map.get(keyValueArray[1]));
|
KeyValue kv = new KeyValue(S.valueOf(map.get(keyValueArray[0])), map.get(keyValueArray[1]));
|
||||||
if(keyValueArray.length > 2){
|
if(keyValueArray.length > 2){
|
||||||
kv.setExt(map.get(keyValueArray[2]));
|
kv.setExt(map.get(keyValueArray[2]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.diboot.core.vo.DictionaryVO;
|
||||||
import com.diboot.core.vo.KeyValue;
|
import com.diboot.core.vo.KeyValue;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@ import java.util.List;
|
||||||
* @version 2.0
|
* @version 2.0
|
||||||
* @date 2019/01/01
|
* @date 2019/01/01
|
||||||
*/
|
*/
|
||||||
|
@Primary
|
||||||
@Service("dictionaryService")
|
@Service("dictionaryService")
|
||||||
public class DictionaryServiceImpl extends BaseServiceImpl<DictionaryMapper, Dictionary> implements DictionaryService {
|
public class DictionaryServiceImpl extends BaseServiceImpl<DictionaryMapper, Dictionary> implements DictionaryService {
|
||||||
private static final Logger log = LoggerFactory.getLogger(DictionaryServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(DictionaryServiceImpl.class);
|
||||||
|
|
|
@ -253,6 +253,18 @@ public class S extends StringUtils{
|
||||||
return UUID.randomUUID().toString().replaceAll("-", "");
|
return UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 将object转换为字符串
|
||||||
|
* @param o
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String valueOf(Object o) {
|
||||||
|
if (o == null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return String.valueOf(o);
|
||||||
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 生成指定位数的数字/验证码
|
* 生成指定位数的数字/验证码
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.diboot.core.vo;
|
package com.diboot.core.vo;
|
||||||
|
|
||||||
|
import com.diboot.core.util.S;
|
||||||
import com.diboot.core.util.V;
|
import com.diboot.core.util.V;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -38,10 +39,8 @@ public class JsonResult implements Serializable {
|
||||||
public JsonResult(Object data, String... additionalMsg){
|
public JsonResult(Object data, String... additionalMsg){
|
||||||
this.code = Status.OK.code();
|
this.code = Status.OK.code();
|
||||||
this.msg = Status.OK.label();
|
this.msg = Status.OK.label();
|
||||||
|
initMsg(additionalMsg);
|
||||||
this.data = data;
|
this.data = data;
|
||||||
if(V.notEmpty(additionalMsg)){
|
|
||||||
this.msg += ": " + additionalMsg[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
|
@ -52,9 +51,7 @@ public class JsonResult implements Serializable {
|
||||||
public JsonResult(Status status, String... additionalMsg){
|
public JsonResult(Status status, String... additionalMsg){
|
||||||
this.code = status.code();
|
this.code = status.code();
|
||||||
this.msg = status.label();
|
this.msg = status.label();
|
||||||
if(V.notEmpty(additionalMsg)){
|
initMsg(additionalMsg);
|
||||||
this.msg += ": " + additionalMsg[0];
|
|
||||||
}
|
|
||||||
this.data = null;
|
this.data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,9 +61,7 @@ public class JsonResult implements Serializable {
|
||||||
public JsonResult(Status status, Object data, String... additionalMsg){
|
public JsonResult(Status status, Object data, String... additionalMsg){
|
||||||
this.code = status.code();
|
this.code = status.code();
|
||||||
this.msg = status.label();
|
this.msg = status.label();
|
||||||
if(V.notEmpty(additionalMsg)){
|
initMsg(additionalMsg);
|
||||||
this.msg += ": " + additionalMsg[0];
|
|
||||||
}
|
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,4 +94,20 @@ public class JsonResult implements Serializable {
|
||||||
public Object getData() {
|
public Object getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 赋值msg(去掉重复前缀以支持与BusinessException嵌套使用)
|
||||||
|
* @param additionalMsg
|
||||||
|
*/
|
||||||
|
private void initMsg(String... additionalMsg){
|
||||||
|
if(V.notEmpty(additionalMsg)){
|
||||||
|
if(S.startsWith(additionalMsg[0], this.msg)){
|
||||||
|
this.msg = additionalMsg[0];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.msg += ": " + additionalMsg[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,6 +126,10 @@ public class BaseServiceTest {
|
||||||
success = dictionaryService.createEntities(dictionaryList);
|
success = dictionaryService.createEntities(dictionaryList);
|
||||||
Assert.assertTrue(success);
|
Assert.assertTrue(success);
|
||||||
|
|
||||||
|
dictionaryList.get(2).setCreateTime(new Date());
|
||||||
|
dictionaryList.get(2).setItemValue("HZ2");
|
||||||
|
dictionaryService.updateEntity(dictionaryList.get(2));
|
||||||
|
|
||||||
success = clearTestData(TYPE);
|
success = clearTestData(TYPE);
|
||||||
Assert.assertTrue(success);
|
Assert.assertTrue(success);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue