xinyb
9 天以前 b7ef4bb09e69ba27c29ea06a7f348f753c530a44
提交 | 用户 | 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.springframework.jdbc.core.BeanPropertyRowMapper;
428443 7 import org.springframework.stereotype.Service;
048b74 8 import org.springframework.transaction.annotation.Transactional;
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 {
048b74 21     @Transactional(rollbackFor = Exception.class)
385e2d 22     @Override
658898 23     public String saveFolder(T482107Entity folder) {
385e2d 24         String sql = "set nocount on\n";
X 25         try {
658898 26             sql += "declare @rowId varchar(40),@parentRowId varchar(40) =" + GridUtils.prossSqlParm(folder.getParentRowId()) + "\n";
X 27             sql += "exec getXXXX @rowId output \n";//获取一个rowId
428443 28             sql += "insert into t482107(companyId,companyName,folder_name,userCode,userName,sort_id,create_time,update_time,rowId,treeControl,parentRowId) " +
385e2d 29                     "values (" + GridUtils.prossSqlParm(folder.getCompanyId()) + "," + GridUtils.prossSqlParm(folder.getCompanyName()) + "," +
X 30                     GridUtils.prossSqlParm(folder.getFolderName()) + "," + GridUtils.prossSqlParm(folder.getUserCode()) + "," +
658898 31                     GridUtils.prossSqlParm(folder.getUserName()) + "," + folder.getSortId() + ",getdate(),getdate(),@rowId," +
X 32                     GridUtils.prossSqlParm(folder.getTreeControl()) + ",@parentRowId)";
33             sql += "select @rowId as rowId";
34             return jdbcTemplate.queryForObject(sql, String.class);
385e2d 35         } catch (Exception e) {
X 36             throw e;
37         }
38     }
658898 39
048b74 40     @Transactional(rollbackFor = Exception.class)
385e2d 41     @Override
X 42     public Integer updateFolder(T482107Entity folder) {
43         String sql = "set nocount on\n";
44         try {
428443 45             sql += "update t482107 set folder_name=" + GridUtils.prossSqlParm(folder.getFolderName()) +
658898 46                     ",sort_id=" + folder.getSortId() + ",update_time=getdate() " + //",rowId=" + GridUtils.prossSqlParm(folder.getRowId()) +
428443 47                     ",treeControl=" + GridUtils.prossSqlParm(folder.getTreeControl()) + ",parentRowId=" + GridUtils.prossSqlParm(folder.getParentRowId()) +
X 48                     "where folder_id=" + folder.getFolderId() + " and userCode=" + GridUtils.prossSqlParm(folder.getUserCode()) + "\n";
385e2d 49             sql += "select @@ROWCOUNT";
f5cc47 50             return jdbcTemplate.queryForObject(sql, Integer.class);
385e2d 51         } catch (Exception e) {
X 52             throw e;
53         }
54     }
658898 55
048b74 56     @Transactional(rollbackFor = Exception.class)
385e2d 57     @Override
X 58     public Integer deleteFolder(String userCode, Integer folderId) {
59         String sql = "set nocount on\n";
60         try {
428443 61             sql += "delete t482107 where userCode='" + userCode + "' and folder_id=" + folderId + "\n";
385e2d 62             sql += "select @@ROWCOUNT";
f5cc47 63             return jdbcTemplate.queryForObject(sql, Integer.class);
385e2d 64         } catch (Exception e) {
X 65             throw e;
66         }
67     }
68
69     @Override
b7ef4b 70     public List<T482107Entity> getMailFolder(String userCode) {
385e2d 71         String sql = "set nocount on\n";
X 72         try {
53241c 73             sql += "select companyId,companyName,folder_id,folder_name,userCode,userName,sort_id,create_time,update_time," +
X 74                     "isnull(rowId,'') as rowId,treeControl," +
75                     "isnull(parentRowId,'') as parentRowId from t482107 where userCode=" + GridUtils.prossSqlParm(userCode);
b7ef4b 76 //            if (StringUtils.isNotBlank(search)) {
X 77 //                sql += " and folder_name like '%" + search + "%'";
78 //            }
428443 79             sql += " order by folder_id \n";
385e2d 80             return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482107Entity.class));
X 81         } catch (Exception e) {
82             throw e;
83         }
84     }
85 }