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.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-08-23 09:27 * @Description: */ @Service public class MailFolderImpl extends BaseService implements MailFolderIfc { @Transactional(rollbackFor = Exception.class) @Override public void saveFolder(T482107Entity folder) { String sql = "set nocount on\n"; try { 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()," + GridUtils.prossSqlParm(folder.getRowId()) + "," + GridUtils.prossSqlParm(folder.getTreeControl()) + "," + GridUtils.prossSqlParm(folder.getParentRowId()) + ")"; jdbcTemplate.update(sql); } 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 getMailFolder(String userCode, String search) { String sql = "set nocount on\n"; try { sql += "select companyId,companyName,folder_id,folder_name,userCode,userName,sort_id,create_time,update_time,rowId,treeControl,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; } } }