xinyb
2024-09-04 4284431e6755e854a7de7afb2ef09e461d3e72eb
提交 | 用户 | 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.T482107Entity;
5 import com.yc.service.BaseService;
6 import org.apache.commons.lang3.StringUtils;
7 import org.springframework.jdbc.core.BeanPropertyRowMapper;
428443 8 import org.springframework.stereotype.Service;
385e2d 9
X 10 import java.util.List;
11
12 /**
13  * @BelongsProject: eCoWorksV3
14  * @BelongsPackage: com.yc.crm.mail.service
15  * @author: xinyb
16  * @CreateTime: 2024-08-23  09:27
17  * @Description:
18  */
428443 19 @Service
385e2d 20 public class MailFolderImpl extends BaseService implements MailFolderIfc {
X 21     @Override
22     public void saveFolder(T482107Entity folder) {
23         String sql = "set nocount on\n";
24         try {
428443 25             sql += "insert into t482107(companyId,companyName,folder_name,userCode,userName,sort_id,create_time,update_time,rowId,treeControl,parentRowId) " +
385e2d 26                     "values (" + GridUtils.prossSqlParm(folder.getCompanyId()) + "," + GridUtils.prossSqlParm(folder.getCompanyName()) + "," +
X 27                     GridUtils.prossSqlParm(folder.getFolderName()) + "," + GridUtils.prossSqlParm(folder.getUserCode()) + "," +
428443 28                     GridUtils.prossSqlParm(folder.getUserName()) + "," + folder.getSortId() + ",getdate(),getdate()," +
X 29                     GridUtils.prossSqlParm(folder.getRowId()) + "," + GridUtils.prossSqlParm(folder.getTreeControl()) + "," + GridUtils.prossSqlParm(folder.getParentRowId()) + ")";
385e2d 30             jdbcTemplate.update(sql);
X 31         } catch (Exception e) {
32             throw e;
33         }
34     }
35
36     @Override
37     public Integer updateFolder(T482107Entity folder) {
38         String sql = "set nocount on\n";
39         try {
428443 40             sql += "update t482107 set folder_name=" + GridUtils.prossSqlParm(folder.getFolderName()) +
X 41                     ",sort_id=" + folder.getSortId() + ",update_time=getdate() " + ",rowId=" + GridUtils.prossSqlParm(folder.getRowId()) +
42                     ",treeControl=" + GridUtils.prossSqlParm(folder.getTreeControl()) + ",parentRowId=" + GridUtils.prossSqlParm(folder.getParentRowId()) +
43                     "where folder_id=" + folder.getFolderId() + " and userCode=" + GridUtils.prossSqlParm(folder.getUserCode()) + "\n";
385e2d 44             sql += "select @@ROWCOUNT";
f5cc47 45             return jdbcTemplate.queryForObject(sql, Integer.class);
385e2d 46         } catch (Exception e) {
X 47             throw e;
48         }
49     }
50
51     @Override
52     public Integer deleteFolder(String userCode, Integer folderId) {
53         String sql = "set nocount on\n";
54         try {
428443 55             sql += "delete t482107 where userCode='" + userCode + "' and folder_id=" + folderId + "\n";
385e2d 56             sql += "select @@ROWCOUNT";
f5cc47 57             return jdbcTemplate.queryForObject(sql, Integer.class);
385e2d 58         } catch (Exception e) {
X 59             throw e;
60         }
61     }
62
63     @Override
f5cc47 64     public List<T482107Entity> getMailFolder(String userCode, String search) {
385e2d 65         String sql = "set nocount on\n";
X 66         try {
428443 67             sql += "select companyId,companyName,folder_id,folder_name,userCode,userName,sort_id,create_time,update_time,rowId,treeControl,parentRowId " +
f5cc47 68                     "from t482107 where userCode=" + GridUtils.prossSqlParm(userCode);
X 69             if (StringUtils.isNotBlank(search)) {
428443 70                 sql += " and folder_name like '%" + search + "%'";
385e2d 71             }
428443 72             sql += " order by folder_id \n";
385e2d 73             return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482107Entity.class));
X 74         } catch (Exception e) {
75             throw e;
76         }
77     }
78 }