| 5432 |
amar.kumar |
1 |
package in.shop2020.user.handler;
|
|
|
2 |
|
|
|
3 |
import java.util.ArrayList;
|
|
|
4 |
import java.util.List;
|
|
|
5 |
|
|
|
6 |
import org.apache.commons.logging.Log;
|
|
|
7 |
import org.apache.commons.logging.LogFactory;
|
|
|
8 |
import org.apache.http.auth.UsernamePasswordCredentials;
|
|
|
9 |
import org.apache.thrift.TException;
|
|
|
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
11 |
import org.springframework.stereotype.Service;
|
|
|
12 |
|
|
|
13 |
import in.shop2020.model.v1.user.UserNote;
|
|
|
14 |
import in.shop2020.user.persistence.MiscellaneousMapper;
|
|
|
15 |
import in.shop2020.user.util.Converter;
|
|
|
16 |
|
|
|
17 |
@Service
|
|
|
18 |
public class MiscellaneousHandler {
|
|
|
19 |
|
|
|
20 |
@Autowired
|
|
|
21 |
private MiscellaneousMapper miscMapper;
|
|
|
22 |
|
|
|
23 |
private static final Log log = LogFactory.getLog(MiscellaneousHandler.class);
|
|
|
24 |
|
|
|
25 |
public void putUserNote(long user_id, long entity_id,
|
|
|
26 |
String slide, String note) throws TException{
|
|
|
27 |
List<UserNote> userNote = getUserNotes(user_id, entity_id);
|
|
|
28 |
if(userNote==null || userNote.size()==0) {
|
|
|
29 |
in.shop2020.user.domain.UserNote newUserNote = new in.shop2020.user.domain.UserNote();
|
|
|
30 |
newUserNote.setUser_id(user_id);
|
|
|
31 |
newUserNote.setEntity_id(entity_id);
|
|
|
32 |
newUserNote.setSlide(slide);
|
|
|
33 |
newUserNote.setNote(note);
|
|
|
34 |
miscMapper.insertUserNote(newUserNote);
|
|
|
35 |
} else {
|
|
|
36 |
miscMapper.updateUserNote(user_id, entity_id, note);
|
|
|
37 |
}
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
public List<UserNote> getUserNotes(long user_id, long entity_id)
|
|
|
41 |
throws TException{
|
|
|
42 |
List<in.shop2020.user.domain.UserNote> userNotes = miscMapper.getUserNotes(user_id, entity_id);
|
|
|
43 |
|
|
|
44 |
if(userNotes!=null) {
|
|
|
45 |
List<UserNote> tUserNotes = new ArrayList<UserNote>();
|
|
|
46 |
for(in.shop2020.user.domain.UserNote userNote : userNotes) {
|
|
|
47 |
tUserNotes.add(Converter.toThriftUserNote(userNote));
|
|
|
48 |
}
|
|
|
49 |
return tUserNotes;
|
|
|
50 |
}
|
|
|
51 |
return null;
|
|
|
52 |
}
|
|
|
53 |
}
|