package com.yc.crm.mail.service;
|
|
import com.yc.action.grid.GridUtils;
|
import com.yc.crm.base.entity.T482115Entity;
|
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-09-04 15:28
|
* @Description:
|
*/
|
@Service
|
public class MailTagImpl extends BaseService implements MailTagIfc {
|
@Transactional(rollbackFor = Exception.class)
|
@Override
|
public void saveTag(T482115Entity tag) {
|
String sql = "set nocount on\n";
|
try {
|
sql += "insert into t482115(companyId,companyName,tag_name,userCode,userName,sort_id,create_time,update_time,tag_desc,system_flag,tag_color,tag_type) " +
|
"values(" + GridUtils.prossSqlParm(tag.getCompanyId()) + "," + GridUtils.prossSqlParm(tag.getCompanyName()) + "," +
|
GridUtils.prossSqlParm(tag.getTagName()) + "," + GridUtils.prossSqlParm(tag.getUserCode()) + "," + GridUtils.prossSqlParm(tag.getUserName()) + "," +
|
tag.getSortId() + ",getdate(),getdate()," + GridUtils.prossSqlParm(tag.getTagDesc()) + ",'" + tag.isSystemFlag() + "'," +
|
GridUtils.prossSqlParm(tag.getTagColor()) + "," + tag.getTagType() + ")";
|
jdbcTemplate.update(sql);
|
} catch (Exception e) {
|
throw e;
|
}
|
}
|
|
@Transactional(rollbackFor = Exception.class)
|
@Override
|
public Integer updateTag(T482115Entity tag) {
|
String sql = "set nocount on\n";
|
try {
|
sql += "update t482115 set tag_name=" + GridUtils.prossSqlParm(tag.getTagName()) + ",sort_id=" + tag.getSortId() + "," +
|
"update_time=getdate(),tag_desc=" + GridUtils.prossSqlParm(tag.getTagDesc()) + ",system_flag='" + tag.isSystemFlag() + "'," +
|
"tag_color=" + GridUtils.prossSqlParm(tag.getTagColor()) + ",tag_type=" + tag.getTagType() +
|
" where tag_id=" + tag.getTagId() + " and userCode=" + GridUtils.prossSqlParm(tag.getUserCode()) + "\n";
|
sql += "select @@ROWCOUNT";
|
return jdbcTemplate.queryForObject(sql, Integer.class);
|
} catch (Exception e) {
|
throw e;
|
}
|
}
|
|
@Transactional(rollbackFor = Exception.class)
|
@Override
|
public Integer deleteTag(String userCode, Integer tagId) {
|
String sql = "set nocount on\n";
|
try {
|
sql += "delete t482115 where tag_id=" + tagId + " and userCode='" + userCode + "'\n";
|
sql += "select @@ROWCOUNT";
|
return jdbcTemplate.queryForObject(sql, Integer.class);
|
} catch (Exception e) {
|
throw e;
|
}
|
}
|
|
@Override
|
public List<T482115Entity> getTagList(String userCode, String search, Integer type) {
|
String sql = "set nocount on\n";
|
try {
|
sql += "select companyId,companyName,tag_id,tag_name,userCode,userName,sort_id,create_time,update_time,tag_desc,system_flag,tag_color,tag_type " +
|
"from t482115 where userCode=" + GridUtils.prossSqlParm(userCode);
|
if (!type.equals(-1)) {
|
sql += " and system_flag=" + type;
|
}
|
if (StringUtils.isNotBlank(search)) {
|
sql += " and tag_name like '%" + search + "%'";
|
}
|
sql += " order by tag_id \n";
|
return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482115Entity.class));
|
} catch (Exception e) {
|
throw e;
|
}
|
}
|
|
|
}
|