Commit 277a6f9d authored by 曲欣红's avatar 曲欣红

主题模板管理

parent 7351e790
package com.egolm.admin.controller;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.egolm.admin.config.XException;
import com.egolm.admin.pojo.TPlatformTheme;
import com.egolm.admin.service.ThemeTemplateService;
import com.egolm.admin.service.impl.ThemeTemplateServiceImpl;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api(tags={"主题模板配置"})
@RestController
@RequestMapping("theme")
public class ThemeTemplateConfController {
private static final Log logger = LogFactory.getLog(ThemeTemplateConfController.class);
@Autowired
private ThemeTemplateService ttService;
@ApiOperation("新增主题")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "LangID", dataType = "String", required = true, value = "语言"),
@ApiImplicitParam(paramType = "query", name = "sThemeNO", dataType = "String", required = true, value = "主题编号"),
@ApiImplicitParam(paramType = "query", name = "sThemeName", dataType = "String", required = true, value = "主题名称"),
@ApiImplicitParam(paramType = "query", name = "sThemeAuthor", dataType = "String", required = true, value = "主题作者"),
@ApiImplicitParam(paramType = "query", name = "sCaption", dataType = "String", required = true, value = "主题说明"),
@ApiImplicitParam(paramType = "query", name = "sThemeJson", dataType = "String", required = true, value = "主题配置"),
@ApiImplicitParam(paramType = "query", name = "sSnapshot1", dataType = "String", required = true, value = "主题快照1"),
@ApiImplicitParam(paramType = "query", name = "sSnapshot2", dataType = "String", required = true, value = "主题快照2"),
@ApiImplicitParam(paramType = "query", name = "sSnapshot3", dataType = "String", required = true, value = "主题快照3"),
@ApiImplicitParam(paramType = "query", name = "sMemo", dataType = "String", required = true, value = "备注"),
@ApiImplicitParam(paramType = "query", name = "nTag", dataType = "int", required = true, value = "状态"),
@ApiImplicitParam(paramType = "query", name = "sCreateUser", dataType = "String", required = true, value = "创建人"),
})
@ResponseBody
@PostMapping(value = "/insert")
public Object insert(
String sMemo,
String sThemeAuthor,
String sSnapshot1,
String sSnapshot2,
String sThemeNO,
Integer nTag,
String sCaption,
String sCreateUser,
String sThemeJson,
String sThemeName,
String sSnapshot3
) {
Date d = new Date();
TPlatformTheme tPlatformTheme = new TPlatformTheme(
sMemo,
d,
sThemeAuthor,
d,
sSnapshot1,
sSnapshot2,
sThemeNO,
nTag,
sCaption,
sCreateUser,
sThemeJson,
sThemeName,
sCreateUser,
d,
sSnapshot3
);
ttService.insert(tPlatformTheme);
return Rjx.jsonOk().set("detail", ttService.selectByNO(sThemeNO)).toString();
}
@ApiOperation("新增主题")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "LangID", dataType = "String", required = true, value = "语言"),
@ApiImplicitParam(paramType = "query", name = "sThemeNO", dataType = "String", required = true, value = "主题编号"),
@ApiImplicitParam(paramType = "query", name = "sThemeName", dataType = "String", required = true, value = "主题名称"),
@ApiImplicitParam(paramType = "query", name = "sThemeAuthor", dataType = "String", required = true, value = "主题作者"),
@ApiImplicitParam(paramType = "query", name = "sCaption", dataType = "String", required = true, value = "主题说明"),
@ApiImplicitParam(paramType = "query", name = "sThemeJson", dataType = "String", required = true, value = "主题配置"),
@ApiImplicitParam(paramType = "query", name = "sSnapshot1", dataType = "String", required = true, value = "主题快照1"),
@ApiImplicitParam(paramType = "query", name = "sSnapshot2", dataType = "String", required = true, value = "主题快照2"),
@ApiImplicitParam(paramType = "query", name = "sSnapshot3", dataType = "String", required = true, value = "主题快照3"),
@ApiImplicitParam(paramType = "query", name = "sMemo", dataType = "String", required = true, value = "备注"),
@ApiImplicitParam(paramType = "query", name = "nTag", dataType = "int", required = true, value = "状态"),
@ApiImplicitParam(paramType = "query", name = "sUpdateUser", dataType = "String", required = true, value = "修改人"),
})
@ResponseBody
@PostMapping(value = "/update")
public Object update(
String sMemo,
String sThemeAuthor,
String sSnapshot1,
String sSnapshot2,
String sThemeNO,
Integer nTag,
String sCaption,
String sUpdateUser,
String sThemeJson,
String sThemeName,
String sSnapshot3
) {
Date d = new Date();
TPlatformTheme tPlatformTheme = new TPlatformTheme(
sMemo,//sMemo备注
d,//dLastUpdateTime最后更新时间
sThemeAuthor,//sThemeAuthor作者
d,//dCreateDate创建时间
sSnapshot1,//sSnapshot1快照1
sSnapshot2,//sSnapshot2快照2
sThemeNO,//sThemeNO模板编号
nTag,//nTag状态
sCaption,//sCaption说明
sUpdateUser,//sUpdateUser修改人
sThemeJson,//sThemeJson模板配置
sThemeName,//sThemeName模板名称
sUpdateUser,//sCreateUser创建人
d,//dUpdateDate更新日期
sSnapshot3//sSnapshot3快照3
);
return Rjx.jsonOk().set("detail", ttService.update(tPlatformTheme)).toString();
}
@ApiOperation("用户列表查询")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "searchKey", dataType = "String", required = false, value = "用户编码/名称"),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "long", required = false, value = "页码"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "long", required = false, value = "每页显示记录条数"),
})
@ResponseBody
@GetMapping("/getUserList")
public Object query(String searchKey, Long index, Long limit){
if(StringUtil.isEmpty(index)){
index = 1L;
}
if(StringUtil.isEmpty(limit)){
limit = 10L;
}
Page page = new Page();
page.setIndex(index);
page.setLimit(limit);
page.setLimitKey(" dLastUpdateTime desc ");
List<Map<String, Object>> themeList = ttService.queryList(searchKey, page);
return Rjx.jsonOk().set("list", themeList).setPage(page).toString();
}
}
package com.egolm.admin.service;
import java.util.List;
import java.util.Map;
import com.egolm.admin.pojo.TPlatformTheme;
import com.egolm.common.jdbc.Page;
public interface ThemeTemplateService {
public TPlatformTheme insert(TPlatformTheme theme);
public TPlatformTheme selectByNO(String themeNO);
public TPlatformTheme update(TPlatformTheme theme);
public List<Map<String, Object>> queryList(String searchKey, Page page);
}
package com.egolm.admin.service.impl;
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.stereotype.Service;
import com.egolm.admin.config.XException;
import com.egolm.admin.controller.OSSFileController;
import com.egolm.admin.pojo.TPlatformTheme;
import com.egolm.admin.service.ThemeTemplateService;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
@Service
public class ThemeTemplateServiceImpl implements ThemeTemplateService{
private static final Log logger = LogFactory.getLog(ThemeTemplateServiceImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public TPlatformTheme insert(TPlatformTheme theme) {
try{
jdbcTemplate.save(theme);
}catch(Exception e){
throw new XException("新增失败", e);
}
return selectByNO(theme.getsThemeNO());
}
@Override
public TPlatformTheme selectByNO(String themeNO) {
try{
String sql = "select * from tPlatformTheme where sThemeNO = ?";
return jdbcTemplate.queryForBean(sql, TPlatformTheme.class, themeNO);
}catch(Exception e){
throw new XException("查询失败", e);
}
}
@Override
public TPlatformTheme update(TPlatformTheme theme) {
try{
String sql = "update tPlatformTheme set sThemeName = ?, sThemeAuthor = ?, sCaption = ?, sThemeJson = ?, sSnapshot1 = ?, sSnapshot2 = ?, sSnapshot3 = ?, sMemo = ?, nTag = ?, sUpdateUser = ?, dUpdateDate = ?, dLastUpdateTime = ? where sThemeNO = ?";
jdbcTemplate.update(
sql,
theme.getsThemeName(),
theme.getsThemeAuthor(),
theme.getsCaption(),
theme.getsThemeJson(),
theme.getsSnapshot1(),
theme.getsSnapshot2(),
theme.getsSnapshot3(),
theme.getsMemo(),
theme.getnTag(),
theme.getsUpdateUser(),
theme.getdUpdateDate(),
theme.getdLastUpdateTime(),
theme.getsThemeNO()
);
}catch(Exception e){
throw new XException("修改失败", e);
}
return selectByNO(theme.getsThemeNO());
}
@Override
public List<Map<String, Object>> queryList(String searchKey, Page page) {
try{
String sql = "select * from tPlatformTheme where nTag&1 = 0";
List<Map<String, Object>> themes = null;
if(StringUtil.isNotEmpty(searchKey)){
sql += " and (sThemeNO like ? or sThemeName like ? or sThemeAuthor like ? or sCaption like ?)";
String keyWord = "%"+searchKey+"%";
themes = jdbcTemplate.limit(sql, page, keyWord, keyWord, keyWord, keyWord);
}else{
themes = jdbcTemplate.limit(sql, page);
}
return themes;
}catch(Exception e){
throw new XException("修改失败", e);
}
}
}
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