commit
ba0f614636
|
@ -1,4 +1,14 @@
|
|||
|
||||
sourceSets {
|
||||
main {
|
||||
resources {
|
||||
srcDirs "src/main/java"
|
||||
include '**/*.properties'
|
||||
include '**/*.xml'
|
||||
include '**/*.dtd'
|
||||
include '**/*.class'
|
||||
}
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
compile("org.springframework.boot:spring-boot-configuration-processor")
|
||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package com.diboot.core.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.diboot.core.util.JSON;
|
||||
|
||||
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;
|
||||
|
||||
public Long getId() {
|
||||
|
|
|
@ -208,7 +208,7 @@ public class BaseServiceImpl<M extends BaseCrudMapper<T>, T> extends ServiceImpl
|
|||
List<KeyValue> keyValueList = new ArrayList<>(mapList.size());
|
||||
for(Map<String, Object> map : mapList){
|
||||
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){
|
||||
kv.setExt(map.get(keyValueArray[2]));
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.diboot.core.vo.DictionaryVO;
|
|||
import com.diboot.core.vo.KeyValue;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -21,6 +22,7 @@ import java.util.List;
|
|||
* @version 2.0
|
||||
* @date 2019/01/01
|
||||
*/
|
||||
@Primary
|
||||
@Service("dictionaryService")
|
||||
public class DictionaryServiceImpl extends BaseServiceImpl<DictionaryMapper, Dictionary> implements DictionaryService {
|
||||
private static final Logger log = LoggerFactory.getLogger(DictionaryServiceImpl.class);
|
||||
|
|
|
@ -253,6 +253,18 @@ public class S extends StringUtils{
|
|||
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;
|
||||
|
||||
import com.diboot.core.util.S;
|
||||
import com.diboot.core.util.V;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -38,10 +39,8 @@ public class JsonResult implements Serializable {
|
|||
public JsonResult(Object data, String... additionalMsg){
|
||||
this.code = Status.OK.code();
|
||||
this.msg = Status.OK.label();
|
||||
initMsg(additionalMsg);
|
||||
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){
|
||||
this.code = status.code();
|
||||
this.msg = status.label();
|
||||
if(V.notEmpty(additionalMsg)){
|
||||
this.msg += ": " + additionalMsg[0];
|
||||
}
|
||||
initMsg(additionalMsg);
|
||||
this.data = null;
|
||||
}
|
||||
|
||||
|
@ -64,9 +61,7 @@ public class JsonResult implements Serializable {
|
|||
public JsonResult(Status status, Object data, String... additionalMsg){
|
||||
this.code = status.code();
|
||||
this.msg = status.label();
|
||||
if(V.notEmpty(additionalMsg)){
|
||||
this.msg += ": " + additionalMsg[0];
|
||||
}
|
||||
initMsg(additionalMsg);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
@ -99,4 +94,20 @@ public class JsonResult implements Serializable {
|
|||
public Object getData() {
|
||||
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 java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -125,6 +126,10 @@ public class BaseServiceTest {
|
|||
success = dictionaryService.createEntities(dictionaryList);
|
||||
Assert.assertTrue(success);
|
||||
|
||||
dictionaryList.get(2).setCreateTime(new Date());
|
||||
dictionaryList.get(2).setItemValue("HZ2");
|
||||
dictionaryService.updateEntity(dictionaryList.get(2));
|
||||
|
||||
success = clearTestData(TYPE);
|
||||
Assert.assertTrue(success);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue