xinyb
2024-08-30 f5cc47742dd3d2f2ffd8443ffc82a912683f7824
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
package com.yc.crm.mail.service;
 
import com.yc.action.grid.GridUtils;
import com.yc.crm.mail.entity.T482108Entity;
import com.yc.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
/**
 * @BelongsProject: eCoWorksV3
 * @BelongsPackage: com.yc.crm.mail.service
 * @author: xinyb
 * @CreateTime: 2024-08-08  08:56
 * @Description:
 */
@Service
public class MailQuickTextImpl extends BaseService implements MailQuickTextIfc {
    @Override
    public void saveQuickText(T482108Entity quickText) {
        String sql = "set nocount on\n";
        try {
            sql += "insert into t482108(companyId,companyName,text_Name,userCode,userName,content,sort_id,create_time,update_time) " +
                    "values (" + GridUtils.prossSqlParm(quickText.getCompanyId()) + "," + GridUtils.prossSqlParm(quickText.getCompanyName()) + "," +
                    GridUtils.prossSqlParm(quickText.getTextName()) + "," + GridUtils.prossSqlParm(quickText.getUserCode()) + "," +
                    GridUtils.prossSqlParm(quickText.getUserName()) + "," + GridUtils.prossSqlParm(quickText.getContent()) + "," +
                    quickText.getSortId() + ",getdate(),getdate())";
            jdbcTemplate.update(sql);
        } catch (Exception e) {
            throw e;
        }
    }
 
    @Override
    public Integer updateQuickText(T482108Entity quickText) {
        String sql = "set nocount on\n";
        try {
            sql += "update t482108 set text_Name=" + GridUtils.prossSqlParm(quickText.getTextName()) + ",content=" + GridUtils.prossSqlParm(quickText.getContent()) +
                    ",sort_id=" + quickText.getSortId() + ",update_time=getdate() " +
                    "where text_id=" + quickText.getTextId() + " and userCode=" + GridUtils.prossSqlParm(quickText.getUserCode()) + "\n";
            sql += "select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
    }
 
    @Override
    public Integer deleteQuickText(String userCode, Integer textId) {
        String sql = "set nocount on\n";
        try {
            sql += "delete t482108 where userCode='" + userCode + "' and textId=" + textId + "\n";
            sql += "select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
    }
 
    @Override
    public List<T482108Entity> getMailQuickText(String userCode,String search) {
        String sql = "set nocount on\n";
        try {
            sql += "select companyId,companyName,textId,textName,userCode,userName,content,sortId,createTime,updateTime" +
                    "from t482108 where userCode=" + GridUtils.prossSqlParm(userCode);
            if (StringUtils.isNotBlank(search)) {
                sql += " and TextName like '%" + search+"%'";
            }
            sql += " order by textId" + "\n";
            return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482108Entity.class));
        } catch (Exception e) {
            throw e;
        }
    }
}