Commit 04a5afbe authored by 黄毅's avatar 黄毅

1

parent 20ccd90c
/**
*
*/
package com.egolm.admin.service;
import java.util.List;
import java.util.Map;
import com.egolm.admin.pojo.TIcon;
import com.egolm.admin.pojo.TIconGroup;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
/**
*
* @author huang.yi
* @date 2018年8月7日
* @Description IconManageService
*
*/
public interface IconManageService {
public List<Map<String, Object>> query(Map<String, Object> params, Page page);
public Map<String, Object> showGroupDetail(Map<String, Object> params);
public List<Map<String, Object>> showDetail(Map<String, Object> params);
public Rjx saveGroup(TIconGroup iconGroup, List<TIcon> iconList);
public Rjx save(List<TIcon> iconList);
public TIconGroup checkGroupNO(String groupNO);
public Rjx updateGroup(TIconGroup iconGroup, List<TIcon> iconList);
public TIconGroup getIconGroup(String groupNO);
public Rjx update(List<TIcon> iconList);
}
/**
*
*/
package com.egolm.admin.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.egolm.admin.config.XException;
import com.egolm.admin.pojo.TIcon;
import com.egolm.admin.pojo.TIconGroup;
import com.egolm.admin.pojo.TLinkList;
import com.egolm.admin.service.IconManageService;
import com.egolm.admin.util.AdminContstrant;
import com.egolm.admin.util.I18NUtils;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
/**
*
* @author huang.yi
* @date 2018年8月7日
* @Description IconManageImpl
*
*/
@Service
public class IconManageImpl implements IconManageService {
private static final Log logger = LogFactory.getLog(IconManageImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
/**
* 首页查询
*/
@Override
public List<Map<String, Object>> query(Map<String, Object> params, Page page){
String searchParam = (String) params.get("queryParam");
String langId = (String) params.get("LangID");
String sql = "select a.sGroupNO groupNO, a.sGroupName groupName, count(b.sIconNO) IconCount , a.sCaption caption,a.nTag tag, "
+ " a.sCreateUser createUser,a.sUpdateUser updateUser ,a.dLastUpdateTime lastUpdateTime from tIconGroup a left join tIcon b on a.sGroupNO = b.sGroupNO where a.nTag&1 =0";
if(!StringUtil.isEmpty(searchParam)) {
sql += " and (a.sGroupNO like '%"+searchParam+"%' or a.sGroupName like '%"+searchParam+"%' or a.sCaption like '%"+searchParam+"%') ";
}
sql += " GROUP BY a.sGroupNO, a.sGroupName, a.sCaption, a.nTag, a.sCreateUser, a.sUpdateUser, a.dLastUpdateTime";
return jdbcTemplate.limit(sql, page);
}
/**
* 详情查询dataList-0
*/
@Override
public Map<String, Object> showGroupDetail(Map<String, Object> params){
String groupNO = (String) params.get("groupNO");
String langId = (String) params.get("LangID");
String sql = "select sGroupNO groupNO, sGroupName groupName, sCaption caption, nTag tag from tIconGroup where sGroupNO = ?";
return jdbcTemplate.queryForMap(sql, groupNO);
}
/**
* 详情查询dataList-1
*/
@Override
public List<Map<String, Object>> showDetail(Map<String, Object> params){
String groupNO = (String) params.get("groupNO");
String langId = (String) params.get("LangID");
String sql = "select sGroupNO groupNO, sIconNO iconNO, sIconPath iconPath, sDefaultTxt defaultTxt, sDefaultLinkType defaultLinkType, sDefaultLink defaultLink from tIcon where sGroupNO = ?" ;
return jdbcTemplate.queryForList(sql, groupNO);
}
/**
* 保存数据到tIconGroup表
*/
@Override
public Rjx saveGroup(TIconGroup iconGroup, List<TIcon> iconList) {
iconGroup.setdCreateDate(new Date());
iconGroup.setdLastUpdateTime(new Date());
iconGroup.setdUpdateDate(new Date());
TIconGroup iconG = checkGroupNO(iconGroup.getsGroupNO());
if (iconG != null) {
return Rjx.jsonErr().set(AdminContstrant.I18n_KEY, "Msg_GroupNO_exists"); // .setMessage("图标组编号已存在");
}
int i = jdbcTemplate.save(iconGroup);
if(i > 0) {
Rjx result = save(iconList);
System.out.println("result" + result);
if(result.getCode() == 200) {
return Rjx.jsonOk().set(AdminContstrant.I18n_KEY,"Msg_Save_Success"); //.setMessage("保存成功");
}else {
return Rjx.jsonErr().set(AdminContstrant.I18n_KEY,"Msg_Save_Error"); //.setMessage("保存失败");
}
}else {
return Rjx.jsonErr().set(AdminContstrant.I18n_KEY,"Msg_Save_Error"); //.setMessage("保存失败");
}
}
/**
* 保存数据到tIcon表
*/
@Override
public Rjx save(List<TIcon> iconList) {
try {
jdbcTemplate.batchSave(iconList);
return Rjx.json().setCode(200);
}catch(Exception e){
new XException(I18NUtils.getMessage(AdminContstrant.I18n_KEY, "Msg_Update_Success"), e);//新增失败
}
return Rjx.jsonErr().set(AdminContstrant.I18n_KEY,"Msg_Update_Error");
}
/**
* 修改tIconGroup表
*/
@Override
public Rjx updateGroup(TIconGroup iconGroup, List<TIcon> iconList) {
iconGroup.setdUpdateDate(new Date());
iconGroup.setdLastUpdateTime(new Date());
int i = jdbcTemplate.update(iconGroup);
if(i > 0) {
Rjx result = update(iconList);
System.out.println("result" + result);
if(result.getCode() == 200) {
return Rjx.jsonOk().set(AdminContstrant.I18n_KEY,"Msg_Update_Success"); //.setMessage("更新成功");
}else {
return Rjx.jsonErr().set(AdminContstrant.I18n_KEY,"Msg_Update_Error"); //.setMessage("更新失败");
}
}else {
return Rjx.jsonErr().set(AdminContstrant.I18n_KEY,"Msg_Update_Error"); //.setMessage("更新失败");
}
}
/**
* 修改tIconGroup表
*/
@Override
public Rjx update(List<TIcon> iconList) {
try {
for(TIcon icon : iconList) {
jdbcTemplate.update(icon);
}
return Rjx.json().setCode(200);
}catch(Exception e){
new XException(I18NUtils.getMessage(AdminContstrant.I18n_KEY, "Msg_Save_Error"), e);//更新失败
}
return Rjx.jsonErr().set(AdminContstrant.I18n_KEY,"Msg_Save_Error");
}
/**
* 获取单个icongroup
*/
@Override
public TIconGroup getIconGroup(String groupNO) {
try {
String sql = "SELECT * FROM tIconGroup WHERE sGroupNO = ? AND nTag&1=0";
return jdbcTemplate.queryForBean(sql, TIconGroup.class, groupNO);
} catch (Exception e) {
logger.info("组编号不存在 groupNO:"+groupNO);
}
return null;
}
/**
* 检查编号是否已存在
*/
@Override
public TIconGroup checkGroupNO(String groupNO) {
try {
String sql = "SELECT * FROM tIconGroup WHERE sGroupNO = ? AND nTag&1=0";
return jdbcTemplate.queryForBean(sql, TIconGroup.class, groupNO);
} catch (Exception e) {
logger.info("重复的 groupNO:"+groupNO);
}
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment