package com.yc.crm.mail.service;
|
|
import com.yc.action.grid.GridUtils;
|
import com.yc.crm.mail.entity.T482107Entity;
|
import com.yc.service.BaseService;
|
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-08-23 09:27
|
* @Description:
|
*/
|
@Service
|
public class MailFolderImpl extends BaseService implements MailFolderIfc {
|
@Transactional(rollbackFor = Exception.class)
|
@Override
|
public String saveFolder(T482107Entity folder) {
|
String sql = "set nocount on\n";
|
try {
|
sql += "declare @rowId varchar(40),@parentRowId varchar(40) =" + GridUtils.prossSqlParm(folder.getParentRowId()) + "\n";
|
sql += "exec getXXXX @rowId output \n";//获取一个rowId
|
sql += "insert into t482107(companyId,companyName,folder_name,userCode,userName,sort_id,create_time,update_time,rowId,treeControl,parentRowId) " +
|
"values (" + GridUtils.prossSqlParm(folder.getCompanyId()) + "," + GridUtils.prossSqlParm(folder.getCompanyName()) + "," +
|
GridUtils.prossSqlParm(folder.getFolderName()) + "," + GridUtils.prossSqlParm(folder.getUserCode()) + "," +
|
GridUtils.prossSqlParm(folder.getUserName()) + "," + folder.getSortId() + ",getdate(),getdate(),@rowId," +
|
GridUtils.prossSqlParm(folder.getTreeControl()) + ",@parentRowId)";
|
sql += "select @rowId as rowId";
|
return jdbcTemplate.queryForObject(sql, String.class);
|
} catch (Exception e) {
|
throw e;
|
}
|
}
|
|
@Transactional(rollbackFor = Exception.class)
|
@Override
|
public Integer updateFolder(T482107Entity folder) {
|
String sql = "set nocount on\n";
|
try {
|
sql += "update t482107 set folder_name=" + GridUtils.prossSqlParm(folder.getFolderName()) +
|
",sort_id=" + folder.getSortId() + ",update_time=getdate() " + //",rowId=" + GridUtils.prossSqlParm(folder.getRowId()) +
|
",treeControl=" + GridUtils.prossSqlParm(folder.getTreeControl()) + ",parentRowId=" + GridUtils.prossSqlParm(folder.getParentRowId()) +
|
"where folder_id=" + folder.getFolderId() + " and userCode=" + GridUtils.prossSqlParm(folder.getUserCode()) + "\n";
|
sql += "select @@ROWCOUNT";
|
return jdbcTemplate.queryForObject(sql, Integer.class);
|
} catch (Exception e) {
|
throw e;
|
}
|
}
|
|
@Transactional(rollbackFor = Exception.class)
|
@Override
|
public Integer deleteFolder(String userCode, Integer folderId) {
|
String sql = "set nocount on\n";
|
try {
|
sql += "delete t482107 where userCode='" + userCode + "' and folder_id=" + folderId + "\n";
|
sql += "select @@ROWCOUNT";
|
return jdbcTemplate.queryForObject(sql, Integer.class);
|
} catch (Exception e) {
|
throw e;
|
}
|
}
|
|
@Override
|
public List<T482107Entity> getMailFolder(String userCode) {
|
String sql = "set nocount on\n";
|
try {
|
sql += "select companyId,companyName,folder_id,folder_name,userCode,userName,sort_id,create_time,update_time," +
|
"isnull(rowId,'') as rowId,treeControl," +
|
"isnull(parentRowId,'') as parentRowId from t482107 where userCode=" + GridUtils.prossSqlParm(userCode);
|
// if (StringUtils.isNotBlank(search)) {
|
// sql += " and folder_name like '%" + search + "%'";
|
// }
|
sql += " order by folder_id \n";
|
return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482107Entity.class));
|
} catch (Exception e) {
|
throw e;
|
}
|
}
|
}
|