xinyb
2024-09-18 57c8bf0a91f08d6fbd31d2b5c4e66f0945607bb0
提交 | 用户 | age
385e2d 1 package com.yc.crm.mail.service;
X 2
3 import com.yc.action.grid.GridUtils;
4 import com.yc.crm.mail.entity.T482108Entity;
5 import com.yc.service.BaseService;
6 import org.apache.commons.lang3.StringUtils;
7 import org.springframework.jdbc.core.BeanPropertyRowMapper;
8 import org.springframework.stereotype.Service;
048b74 9 import org.springframework.transaction.annotation.Transactional;
385e2d 10
X 11 import java.util.List;
12
13 /**
14  * @BelongsProject: eCoWorksV3
15  * @BelongsPackage: com.yc.crm.mail.service
16  * @author: xinyb
17  * @CreateTime: 2024-08-08  08:56
18  * @Description:
19  */
20 @Service
21 public class MailQuickTextImpl extends BaseService implements MailQuickTextIfc {
048b74 22     @Transactional(rollbackFor = Exception.class)
385e2d 23     @Override
X 24     public void saveQuickText(T482108Entity quickText) {
25         String sql = "set nocount on\n";
26         try {
f5cc47 27             sql += "insert into t482108(companyId,companyName,text_Name,userCode,userName,content,sort_id,create_time,update_time) " +
385e2d 28                     "values (" + GridUtils.prossSqlParm(quickText.getCompanyId()) + "," + GridUtils.prossSqlParm(quickText.getCompanyName()) + "," +
X 29                     GridUtils.prossSqlParm(quickText.getTextName()) + "," + GridUtils.prossSqlParm(quickText.getUserCode()) + "," +
30                     GridUtils.prossSqlParm(quickText.getUserName()) + "," + GridUtils.prossSqlParm(quickText.getContent()) + "," +
31                     quickText.getSortId() + ",getdate(),getdate())";
32             jdbcTemplate.update(sql);
33         } catch (Exception e) {
34             throw e;
35         }
36     }
048b74 37     @Transactional(rollbackFor = Exception.class)
385e2d 38     @Override
X 39     public Integer updateQuickText(T482108Entity quickText) {
40         String sql = "set nocount on\n";
41         try {
f5cc47 42             sql += "update t482108 set text_Name=" + GridUtils.prossSqlParm(quickText.getTextName()) + ",content=" + GridUtils.prossSqlParm(quickText.getContent()) +
X 43                     ",sort_id=" + quickText.getSortId() + ",update_time=getdate() " +
44                     "where text_id=" + quickText.getTextId() + " and userCode=" + GridUtils.prossSqlParm(quickText.getUserCode()) + "\n";
385e2d 45             sql += "select @@ROWCOUNT";
f5cc47 46             return jdbcTemplate.queryForObject(sql, Integer.class);
385e2d 47         } catch (Exception e) {
X 48             throw e;
49         }
50     }
51
52     @Override
53     public Integer deleteQuickText(String userCode, Integer textId) {
54         String sql = "set nocount on\n";
55         try {
428443 56             sql += "delete t482108 where userCode='" + userCode + "' and text_id=" + textId + "\n";
385e2d 57             sql += "select @@ROWCOUNT";
f5cc47 58             return jdbcTemplate.queryForObject(sql, Integer.class);
385e2d 59         } catch (Exception e) {
X 60             throw e;
61         }
62     }
63
64     @Override
f5cc47 65     public List<T482108Entity> getMailQuickText(String userCode,String search) {
385e2d 66         String sql = "set nocount on\n";
X 67         try {
428443 68             sql += "select companyId,companyName,text_id,text_name,userCode,userName,content,sort_id,create_time,update_time " +
X 69                     " from t482108 where userCode=" + GridUtils.prossSqlParm(userCode);
f5cc47 70             if (StringUtils.isNotBlank(search)) {
428443 71                 sql += " and Text_name like '%" + search+"%'";
385e2d 72             }
428443 73             sql += " order by text_id" + "\n";
385e2d 74             return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482108Entity.class));
X 75         } catch (Exception e) {
76             throw e;
77         }
78     }
79 }