Merge remote-tracking branch 'origin/master'

This commit is contained in:
geek 2017-06-28 14:51:45 +09:00
commit 82f9915f74
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,21 @@
package com.loafle.overflow.module.commons;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Created by insanity on 17. 6. 28.
*/
public class OFService {
@Autowired
private ObjectMapper mapper;
public String toString(Object o) {
try {
return mapper.writeValueAsString(o);
}catch(Exception e) {
return e.getMessage();
}
}
}

View File

@ -0,0 +1,27 @@
package com.loafle.overflow.module.target.service;
import com.loafle.overflow.module.commons.OFService;
import com.loafle.overflow.module.target.dao.TargetDAO;
import com.loafle.overflow.module.target.model.Target;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Created by insanity on 17. 6. 28.
*/
public class TargetService extends OFService {
@Autowired
private TargetDAO targetDAO;
public String regist(Target target) {
Target t = this.targetDAO.save(target);
return toString(t);
}
public String read(String id) {
Target t = this.targetDAO.findOne(Long.valueOf(id));
return toString(t);
}
}