code clean
This commit is contained in:
parent
c7c9ed1198
commit
f729548036
@ -19,7 +19,7 @@ public class ViewModelableSerializer implements ObjectSerializer {
|
|||||||
@Override
|
@Override
|
||||||
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
|
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
serializer.write(((ViewModelable) object).toMap());
|
serializer.write(((ViewModelable<?>) object).toMap());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
serializer.writeNull();
|
serializer.writeNull();
|
||||||
|
@ -58,6 +58,7 @@ public class ViewModel<T>
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public <A> A getAttr(String name) {
|
public <A> A getAttr(String name) {
|
||||||
return attrs != null ? (A) attrs.get(name) : null;
|
return attrs != null ? (A) attrs.get(name) : null;
|
||||||
}
|
}
|
||||||
@ -93,7 +94,7 @@ public class ViewModel<T>
|
|||||||
else {
|
else {
|
||||||
if (data instanceof ViewModelable) {
|
if (data instanceof ViewModelable) {
|
||||||
mapRtn = new HashMap<String, Object>();
|
mapRtn = new HashMap<String, Object>();
|
||||||
mapRtn.put("data", ((ViewModelable) data).toMap());
|
mapRtn.put("data", ((ViewModelable<?>) data).toMap());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Object jsonData = JSON.toJSON(data);
|
Object jsonData = JSON.toJSON(data);
|
||||||
|
@ -134,7 +134,7 @@ public class Search implements Serializable {
|
|||||||
criteria.add(new Criterion(CriterionType.IS_NULL, col, value));
|
criteria.add(new Criterion(CriterionType.IS_NULL, col, value));
|
||||||
}
|
}
|
||||||
else if (value instanceof Collection) {
|
else if (value instanceof Collection) {
|
||||||
in(col, (Collection) value);
|
in(col, (Collection<?>) value);
|
||||||
}
|
}
|
||||||
else if (value.getClass().isArray()) {
|
else if (value.getClass().isArray()) {
|
||||||
in(col, (Object[]) value);
|
in(col, (Object[]) value);
|
||||||
|
@ -12,6 +12,8 @@ import lombok.RequiredArgsConstructor;
|
|||||||
@Getter
|
@Getter
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SqlFragment implements Serializable {
|
public class SqlFragment implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final String sql;
|
private final String sql;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@ import java.util.Arrays;
|
|||||||
public class ViewModelSerializerTest {
|
public class ViewModelSerializerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void test() {
|
public void test() {
|
||||||
SerializeConfig.getGlobalInstance()
|
SerializeConfig.getGlobalInstance()
|
||||||
.put(ViewModel.class, new ViewModelableSerializer());
|
.put(ViewModel.class, new ViewModelableSerializer());
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package me.chyxion.tigon.shiro.cache.shiro;
|
package me.chyxion.tigon.shiro.cache.shiro;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import org.slf4j.LoggerFactory;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
@ -25,9 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
* chyxion@163.com <br>
|
* chyxion@163.com <br>
|
||||||
* May 12, 2016 1:25:02 PM
|
* May 12, 2016 1:25:02 PM
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class UserIdKeyRedisSessionCache implements SessionCache {
|
public class UserIdKeyRedisSessionCache implements SessionCache {
|
||||||
private static final Logger log =
|
|
||||||
LoggerFactory.getLogger(UserIdKeyRedisSessionCache.class);
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected RedisTemplate<Serializable, Serializable> redisTpl;
|
protected RedisTemplate<Serializable, Serializable> redisTpl;
|
||||||
@ -166,6 +164,6 @@ public class UserIdKeyRedisSessionCache implements SessionCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected ValueOperations<Serializable, Serializable> valueOp() {
|
protected ValueOperations<Serializable, Serializable> valueOp() {
|
||||||
return redisTpl.<Serializable, Serializable>opsForValue();
|
return redisTpl.opsForValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user