测试用户
2023-04-13 43393f2bb11cbf9e6af40077bbc5284660e8a754
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
package com.common.core.service;
 
import com.common.annotation.Table;
import com.common.core.domain.BaseModel;
 
import java.util.List;
 
 
/**
 * @author 廖振钦
 * @Date 2022-01-12
 * */
public abstract class BaseCryptoService<M extends BaseModel<M>> extends CryptoService{
 
    protected final M dao;
 
    protected BaseCryptoService(M dao) {
        this.dao = dao;
    }
 
 
    public String getTableName(){
        Table table = dao.getClass().getAnnotation(Table.class);
        return table.tableName();
    }
 
    /**
     * 新增
     * @return    是否新增成功
     */
    public boolean save(M model) {
        model = encryptoModel(model);
        return model.save();
    }
 
    /**
     * 修改
     * @return    是否修改成功
     */
    public boolean update(M model) {
        model = encryptoModel(model);
        return model.update();
    }
 
 
    /**
     * 新增or修改
     * @return    是否新增or修改成功
     */
    public boolean saveOrUpdate(M model){
        if(null == model.getId()){
            return save(model);
        }else{
            return update(model);
        }
    }
 
    /**
     *
     * */
    public boolean LogicDeleteById(Object id){
        M m = findById(id);
        m.setIsDelete(1);
        return m.update();
    }
 
    /**
     *
     * */
    public M findById(Object id){
        M m = dao.findById(id);;
        return decryptoModel(m);
    }
 
    /**
     *
     * */
    public List<M> find(String sql, Object... objects){
        List<M> listmodel = dao.find(sql,objects);
        return decryptoModel(listmodel);
    }
 
}