田源
2024-03-07 4b4083fd73dc27ece42f4835483565eef0e4f608
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.vci.server.base.delegate;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
 
import com.vci.common.objects.UserEntity;
import com.vci.corba.common.data.UserEntityInfo;
import com.vci.server.base.persistence.dao.BaseService;
 
public class BaseDelegate {
    protected UserEntityInfo userEntityInfo = null;
    public UserEntity userEntity = null;
    
    public BaseDelegate() {
        
    }
    public BaseDelegate(UserEntityInfo userEntityInfo){
        this.userEntityInfo = userEntityInfo;
        this.userEntity = UserEntityDelegate.changeUserEntityInfoToEntity(this.userEntityInfo);
    }
    public UserEntityInfo getUserEntityInfo() {
        return userEntityInfo;
    }
    public void setUserEntityInfo(UserEntityInfo userEntityInfo) {
        this.userEntityInfo = userEntityInfo;
        this.userEntity = UserEntityDelegate.changeUserEntityInfoToEntity(this.userEntityInfo);
    }
    public void setUserEntityInfoToService(BaseService service, UserEntityInfo userEntityInfo){
        service.setUserEntity(userEntity);
    }
    public UserEntity getUserEntity() {
        return userEntity;
    }
    public void setUserEntity(UserEntity userEntity) {
        this.userEntity = userEntity;
    }
    
 
    public final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    private SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
 
    public final String DATE_FORMAT_OLD = "yyyyMMdd HH:mm:ss";
    private SimpleDateFormat sdf_old = new SimpleDateFormat(DATE_FORMAT_OLD);
    
    private String defaultDateString = "1977-01-01 00:00:00";
    public String getStringFromDate(Date date){
        String res = defaultDateString;
        try{
            if(date != null){
                res = sdf.format(date);
            }
        }catch(Exception ex){
            ex.printStackTrace();
        }
        return res;
    }
    
    public Date getDateFromString(String string){
        Date res = new Date();
        try {
            res = sdf.parse(defaultDateString);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        try{
            res = sdf.parse(string);
        }catch(Exception ex){
            try{
                res = sdf_old.parse(string);
            }
            catch (Exception ex1){
                ex1.printStackTrace();
            }
        }
        
        return res;
    }
 
//    protected QueryParamInfo convertQueryParam(QueryParam obj){
//        QueryParamInfo info = new QueryParamInfo();
//        info.customQueryString = obj.getCustomQueryString();
//        info.pageIndex = obj.getPageIndex();
//        info.pageSize = obj.getPageSize();
//        return info;
//    }
//    protected QueryParam convertQueryParam(QueryParamInfo info){
//        QueryParam obj = new QueryParam();
//        obj.setCustomQueryString(info.customQueryString);
//        obj.setPageIndex(info.pageIndex);
//        obj.setPageSize(info.pageSize);
//        return obj;
//    }
}