Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
82f9915f74
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user