Commit 8515fac5 authored by 张永's avatar 张永

增加 平台主题配置接口

parent a4c013eb
package com.egolm.admin.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.egolm.admin.pojo.TPlatformLayout;
import com.egolm.admin.pojo.TPlatformTheme;
import com.egolm.admin.service.PlatformLayoutService;
import com.egolm.admin.service.ThemeTemplateService;
import com.egolm.admin.util.AdminContstrant;
import com.egolm.admin.util.I18NUtils;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api(tags={"平台主题配置"})
@RestController
@RequestMapping("layout")
public class PlatformLayoutController {
@Autowired
private PlatformLayoutService platformLayoutService;
@Autowired
private ThemeTemplateService themeTemplateService;
@ApiOperation("查询(只有一条)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "LangID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
})
@RequestMapping(value = "/query",method=RequestMethod.GET)
public String query(HttpServletRequest request) {
String LangID = request.getParameter("LangID");
if(!StringUtil.isNotEmpty(LangID)) {
return Rjx.json().setCode(-1).setMessage(I18NUtils.getMessage(LangID, "Msg_Parameter_empty")).toJson();
}
Map<String,Object> params = new HashMap<String,Object>();
List<Map<String,Object>> layoutList = platformLayoutService.query(params);
if(layoutList != null && layoutList.size() >0) {
return Rjx.jsonOk().set("detail", layoutList.get(0)).toString();
}else {
return Rjx.jsonOk().set("detail", new HashMap<String,Object>()).toString();
}
}
@ApiOperation("保存或修改")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "LangID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "platformNO", dataType = "String", required = false, value = "平台编号(为空表示新增,不为空表示修改)", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "platformName", dataType = "String", required = false, value = "平台名称", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "logoPath1", dataType = "String", required = true, value = "logo1", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "logoPath2", dataType = "String", required = true, value = "logo2", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "logoPath3", dataType = "String", required = true, value = "logo3", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "themeNO", dataType = "String", required = false, value = "主题编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "memo", dataType = "String", required = false, value = "备注", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "userNO", dataType = "String", required = true, value = "用户NO", defaultValue = ""),
})
@RequestMapping(value = "/saveUpdate",method=RequestMethod.POST)
public String saveUpdate(HttpServletRequest request) {
String LangID = request.getParameter("LangID");
String platformNO = request.getParameter("platformNO");
String platformName = request.getParameter("platformName");
String logoPath1 = request.getParameter("logoPath1");
String logoPath2 = request.getParameter("logoPath2");
String logoPath3 = request.getParameter("logoPath3");
String themeNO = request.getParameter("themeNO");
String memo = request.getParameter("memo");
String userNO = request.getParameter("userNO");
Rjx rjx = null;
String themeJSON = "";
if(StringUtil.isNotUndefinedAndNull(themeNO,LangID)) { //验证主题是否存在,取主题配置
try {
TPlatformTheme tPlatformTheme = themeTemplateService.selectByNO(themeNO, LangID);
if(tPlatformTheme != null) {
themeJSON = tPlatformTheme.getsThemeJson();
}
} catch (Exception e) {
return Rjx.json().setCode(-1).setMessage(I18NUtils.getMessage(LangID, "Msg_No_Template")).toJson();
}
}
if(StringUtil.isNotUndefinedAndNull(platformNO)) { //修改
if(!StringUtil.isNotEmpty(LangID,userNO)) {
return Rjx.json().setCode(-1).setMessage(I18NUtils.getMessage(LangID, "Msg_Parameter_empty")).toJson();
}
TPlatformLayout layout = platformLayoutService.getLayoutByNO(platformNO);
if(layout != null) {
layout.setsPlatformName(platformName);
layout.setsLogoPath1(logoPath1);
layout.setsLogoPath2(logoPath2);
layout.setsLogoPath3(logoPath3);
layout.setsThemeNO(themeNO);
layout.setsThemeJson(themeJSON);
layout.setsMemo(memo);
rjx = platformLayoutService.saveOrUpdate(layout);
}else {
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(LangID, "Msg_No_Template")).toJson(); //主题不存在
}
}else { //新增
if(!StringUtil.isNotEmpty(LangID,platformName,logoPath1,logoPath2,logoPath3,userNO)) {
return Rjx.json().setCode(-1).setMessage(I18NUtils.getMessage(LangID, "Msg_Parameter_empty")).toJson();
}
Map<String,Object> params = new HashMap<String,Object>(); //检查是否存在平台主题 存在不允许新增
List<Map<String,Object>> layoutList = platformLayoutService.query(params);
if(layoutList != null && layoutList.size() >0) {
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(LangID, "Msg_Layout_exists")).toJson();
}
TPlatformLayout layout = new TPlatformLayout();
layout.setsPlatformName(platformName);
layout.setsLogoPath1(logoPath1);
layout.setsLogoPath2(logoPath2);
layout.setsLogoPath3(logoPath3);
layout.setsThemeNO(themeNO);
layout.setsThemeJson(themeJSON);
layout.setsMemo(memo);
layout.setnTag(0);
layout.setsCreateUser(userNO);
layout.setsUpdateUser(userNO);
rjx = platformLayoutService.saveOrUpdate(layout);
}
Rjx result = Rjx.json();
result.setCode(rjx.getCode());
result.setMessage(I18NUtils.getMessage(LangID, rjx.get(AdminContstrant.I18n_KEY)+""));
return result.toJson();
}
}
package com.egolm.admin.service;
import java.util.List;
import java.util.Map;
import com.egolm.admin.pojo.TPlatformLayout;
import com.egolm.common.bean.Rjx;
public interface PlatformLayoutService {
public List<Map<String,Object>> query(Map<String,Object> params);
public Rjx saveOrUpdate(TPlatformLayout layout);
public TPlatformLayout getLayoutByNO(String NO);
}
package com.egolm.admin.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.egolm.admin.pojo.TPlatformLayout;
import com.egolm.admin.service.PlatformLayoutService;
import com.egolm.admin.util.AdminContstrant;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
/**
*
* @ClassName: PlatformLayoutServiceImpl
* @Description:平台基本配置表
* @author: zhang.yong
* @date: 2018年8月7日 下午4:24:28
*
*/
@Service
public class PlatformLayoutServiceImpl implements PlatformLayoutService {
@Autowired
@Qualifier("shopJdbcTemplate")
private JdbcTemplate jdbcTemplate;
@Override
public List<Map<String, Object>> query(Map<String, Object> params) {
String sql = "SELECT sPlatformNO playformNO,sPlatformName platformName,sLogoPath1 logoPath1 ,sLogoPath2 logoPath2,sLogoPath3 logoPath3,sThemeNO themeNO,sThemeJson themeJson,sMemo memo,dLastUpdateTime lastUpdateTime "
+ " FROM tPlatformLayout "
+ "WHERE nTag &1=0 ORDER BY dLastUpdateTime DESC ";
return jdbcTemplate.queryForList(sql);
}
/**
* 保存或修改
* <p>Title: saveOrUpdate</p>
* <p>Description: </p>
* @param layout
* @return
* @see com.egolm.admin.service.PlatformLayoutService#saveOrUpdate(com.egolm.admin.pojo.TPlatformLayout)
*/
@Override
public Rjx saveOrUpdate(TPlatformLayout layout) {
String platformNO = layout.getsPlatformNO();
layout.setdUpdateDate(new Date());
layout.setdLastUpdateTime(new Date());
if(StringUtil.isNotEmpty(platformNO)) { //修改
int i = jdbcTemplate.update(layout);
if(i >0) {
return Rjx.jsonOk().set(AdminContstrant.I18n_KEY,"Msg_Update_Success");//.setMessage("更新成功");
}else {
return Rjx.jsonErr().set(AdminContstrant.I18n_KEY,"Msg_Update_Error");//.setMessage("更新失败");
}
}else { //新增
layout.setsPlatformNO(StringUtil.getId(30));
layout.setdCreateDate(new Date());
int i = jdbcTemplate.save(layout);
if(i>0) {
return Rjx.jsonOk().set(AdminContstrant.I18n_KEY,"Msg_Save_Success"); //.setMessage("保存成功");
}else {
return Rjx.jsonErr().set(AdminContstrant.I18n_KEY,"Msg_Save_Error"); //.setMessage("保存失败");
}
}
}
@Override
public TPlatformLayout getLayoutByNO(String NO) {
try {
String sql = "select * from tPlatformLayout where nTag&1=0 and sPlatformNO = ?";
return jdbcTemplate.queryForBean(sql, TPlatformLayout.class, NO);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
......@@ -6,6 +6,7 @@ Msg_Save_Success=保存成功
Msg_Save_Error=保存失败
Msg_Update_Success=更新成功
Msg_Update_Error=更新失败
Msg_Layout_exists=已存在平台主题,不允许新增
#qu
Msg_Query_Error=查询失败
......
......@@ -6,7 +6,7 @@ Msg_Save_Success= Save success
Msg_Save_Error= Save failure
Msg_Update_Success= Update success
Msg_Update_Error= Update failure
Msg_Layout_exists=There is a platform theme that is not allowed to add
#qu
Msg_Query_Error= Query failure
Msg_No_Template= Without this template
......
......@@ -6,6 +6,7 @@ Msg_Save_Success=\u4FDD\u5B58\u6210\u529F
Msg_Save_Error=\u4FDD\u5B58\u5931\u8D25
Msg_Update_Success=\u66F4\u65B0\u6210\u529F
Msg_Update_Error=\u66F4\u65B0\u5931\u8D25
Msg_Layout_exists=\u5DF2\u5B58\u5728\u5E73\u53F0\u4E3B\u9898,\u4E0D\u5141\u8BB8\u65B0\u589E
#qu
Msg_Query_Error=\u67e5\u8be2\u5931\u8d25
......
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