xinyb
7 天以前 f632e7d7c25d8a86b1f6718f467bfef0d3c09058
src/com/yc/crm/mail/service/MailFolderImpl.java
@@ -3,7 +3,6 @@
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;
@@ -21,34 +20,39 @@
public class MailFolderImpl extends BaseService implements MailFolderIfc {
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void saveFolder(T482107Entity folder) {
    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()," +
                    GridUtils.prossSqlParm(folder.getRowId()) + "," + GridUtils.prossSqlParm(folder.getTreeControl()) + "," + GridUtils.prossSqlParm(folder.getParentRowId()) + ")";
            jdbcTemplate.update(sql);
                    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()) +
                    ",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";
                    " 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) {
@@ -63,15 +67,15 @@
    }
    @Override
    public List<T482107Entity> getMailFolder(String userCode, String search) {
    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 + "%'";
            }
//            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) {