xinyb
2024-09-14 048b74abb063e9b7b32f42f3e6c2951e602aac6c
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
package com.yc.crm.mail.service;
 
import com.yc.action.grid.GridUtils;
import com.yc.crm.base.entity.T482115Entity;
import com.yc.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
 
/**
 * @BelongsProject: eCoWorksV3
 * @BelongsPackage: com.yc.crm.mail.service
 * @author: xinyb
 * @CreateTime: 2024-09-04  15:28
 * @Description:
 */
@Service
public class MailTagImpl extends BaseService implements MailTagIfc {
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void saveTag(T482115Entity tag) {
        String sql = "set nocount on\n";
        try {
            sql += "insert into t482115(companyId,companyName,tag_name,userCode,userName,sort_id,create_time,update_time,tag_desc,system_flag,tag_color,tag_type) " +
                    "values(" + GridUtils.prossSqlParm(tag.getCompanyId()) + "," + GridUtils.prossSqlParm(tag.getCompanyName()) + "," +
                    GridUtils.prossSqlParm(tag.getTagName()) + "," + GridUtils.prossSqlParm(tag.getUserCode()) + "," + GridUtils.prossSqlParm(tag.getUserName()) + "," +
                    tag.getSortId() + ",getdate(),getdate()," + GridUtils.prossSqlParm(tag.getTagDesc()) + ",'" + tag.isSystemFlag() + "'," +
                    GridUtils.prossSqlParm(tag.getTagColor()) + "," + tag.getTagType() + ")";
            jdbcTemplate.update(sql);
        } catch (Exception e) {
            throw e;
        }
    }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateTag(T482115Entity tag) {
        String sql = "set nocount on\n";
        try {
            sql += "update t482115 set tag_name=" + GridUtils.prossSqlParm(tag.getTagName()) + ",sort_id=" + tag.getSortId() + "," +
                    "update_time=getdate(),tag_desc=" + GridUtils.prossSqlParm(tag.getTagDesc()) + ",system_flag='" + tag.isSystemFlag() + "'," +
                    "tag_color=" + GridUtils.prossSqlParm(tag.getTagColor()) + ",tag_type=" + tag.getTagType() +
                    " where tag_id=" + tag.getTagId() + " and userCode=" + GridUtils.prossSqlParm(tag.getUserCode()) + "\n";
            sql += "select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
    }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteTag(String userCode, Integer tagId) {
        String sql = "set nocount on\n";
        try {
            sql += "delete t482115  where tag_id=" + tagId + " and userCode='" + userCode + "'\n";
            sql += "select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
        } catch (Exception e) {
            throw e;
        }
    }
 
    @Override
    public List<T482115Entity> getTagList(String userCode, String search) {
        String sql = "set nocount on\n";
        try {
            sql += "select companyId,companyName,tag_id,tag_name,userCode,userName,sort_id,create_time,update_time,tag_desc,system_flag,tag_color,tag_type " +
                    "from t482115 where userCode=" + GridUtils.prossSqlParm(userCode);
            if (StringUtils.isNotBlank(search)) {
                sql += " and tag_name like '%" + search + "%'";
            }
            sql += " order by tag_id \n";
            return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482115Entity.class));
        } catch (Exception e) {
            throw e;
        }
    }
}