Commit e1bc9c7f authored by zhangyong's avatar zhangyong

1

parent 72feb32f
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.TBanner;
import com.egolm.admin.service.BannerService;
import com.egolm.admin.util.AdminContstrant;
import com.egolm.admin.util.I18NUtils;
import com.egolm.common.DateUtil;
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={"Banner配置管理"})
@RestController
@RequestMapping("banner")
public class BannerController {
@Autowired
private BannerService bannerService;
@ApiOperation("新增")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "idx", dataType = "int", required = true, value = "序号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "title", dataType = "String", required = true, value = "标题", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "imagePath", dataType = "String", required = true, value = "图片地址", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "linkType", dataType = "String", required = true, value = "链接类型", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "linkPath", dataType = "String", required = false, value = "链接地址", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "startTime", dataType = "String", required = true, value = "开始时间", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "endTime", dataType = "String", required = true, value = "结束时间", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "orgList", dataType = "String", required = true, value = "组织机构(多个以逗号分隔)", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "userNO", dataType = "String", required = true, value = "创建人", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
})
@RequestMapping(value = "/save",method=RequestMethod.POST)
public String save(HttpServletRequest request) {
String idx = request.getParameter("idx");
String title = request.getParameter("title");
String imagePath = request.getParameter("imagePath");
String linkType = request.getParameter("linkType");
String linkPath = request.getParameter("linkPath");
String orgList = request.getParameter("orgList");
String startTime = request.getParameter("startTime");
String endTime = request.getParameter("endTime");
String userNO = request.getParameter("userNO");
String langID = request.getParameter("langID");
if(!StringUtil.isNotEmpty(idx,title,imagePath,linkType,userNO,orgList,startTime,endTime,langID)) {
return Rjx.json().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Parameter_empty")).toJson();
}
TBanner banner = new TBanner();
banner.setnIdx(Integer.valueOf(idx));
banner.setsTitle(title);
banner.setsImagePath(imagePath);
banner.setsLinkType(linkType);
banner.setsLinkPath(linkPath);
banner.setsOrgList(orgList);
banner.setdStartTime(DateUtil.parse(startTime,DateUtil.FMT_DATE));
banner.setdEndTime(DateUtil.parse(endTime,DateUtil.FMT_DATE));
banner.setsCreateUser(userNO);
banner.setsUpdateUser(userNO);
Rjx rjx = bannerService.save(banner);
Rjx result = Rjx.json();
result.setCode(rjx.getCode());
result.setMessage(I18NUtils.getMessage(langID, rjx.get(AdminContstrant.I18n_KEY)+""));
return result.toJson();
}
@ApiOperation("编辑")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "itemId", dataType = "int", required = true, value = "主键", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "idx", dataType = "int", required = true, value = "序号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "title", dataType = "String", required = true, value = "标题", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "imagePath", dataType = "String", required = true, value = "图片地址", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "linkType", dataType = "String", required = true, value = "链接类型", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "linkPath", dataType = "String", required = false, value = "链接地址", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "startTime", dataType = "String", required = true, value = "开始时间", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "endTime", dataType = "String", required = true, value = "结束时间", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "userNO", dataType = "String", required = true, value = "修改人", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
})
@RequestMapping(value = "/modify",method=RequestMethod.POST)
public String modify(HttpServletRequest request) {
String itemId = request.getParameter("itemId");
String idx = request.getParameter("idx");
String title = request.getParameter("title");
String imagePath = request.getParameter("imagePath");
String linkType = request.getParameter("linkType");
String linkPath = request.getParameter("linkPath");
String startTime = request.getParameter("startTime");
String endTime = request.getParameter("endTime");
String userNO = request.getParameter("userNO");
String langID = request.getParameter("langID");
if(!StringUtil.isNotEmpty(itemId,idx,title,imagePath,linkType,userNO,startTime,endTime,langID)) {
return Rjx.json().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Parameter_empty")).toJson();
}
TBanner banner = bannerService.getBannerById(itemId);
if(banner != null) {
banner.setnIdx(Integer.valueOf(idx));
banner.setsTitle(title);
banner.setsImagePath(imagePath);
banner.setsLinkType(linkType);
banner.setsLinkPath(linkPath);
banner.setdStartTime(DateUtil.parse(startTime,DateUtil.FMT_DATE));
banner.setdEndTime(DateUtil.parse(endTime,DateUtil.FMT_DATE));
banner.setsUpdateUser(userNO);
Rjx rjx = bannerService.update(banner);
Rjx result = Rjx.jsonOk();
result.setMessage(I18NUtils.getMessage(langID, rjx.get(AdminContstrant.I18n_KEY)+""));
return result.toJson();
}else {
return Rjx.jsonErr().setCode(-100).setMessage("数据不存在").toJson();
}
}
@ApiOperation("删除")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "itemId", dataType = "int", required = true, value = "主键", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "userNO", dataType = "String", required = true, value = "修改人", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
})
@RequestMapping(value = "/delete",method=RequestMethod.GET)
public String delete(HttpServletRequest request) {
String itemId = request.getParameter("itemId");
String userNO = request.getParameter("userNO");
String langID = request.getParameter("langID");
if(!StringUtil.isNotEmpty(itemId,userNO,langID)) {
return Rjx.json().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Parameter_empty")).toJson();
}
Rjx result = bannerService.delete(Integer.valueOf(itemId),userNO);
Rjx rjx = result.json();
rjx.setMessage(I18NUtils.getMessage(langID, result.get(AdminContstrant.I18n_KEY)+""));
return rjx.toJson();
}
@ApiOperation("查询")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "orgNO", dataType = "String", required = true, value = "组织机构", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "LangID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "int", required = true, value = "页码", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "int", required = true, value = "每页显示数", defaultValue = "10"),
})
@RequestMapping(value = "/list",method=RequestMethod.GET)
public String list(HttpServletRequest request) {
String orgNO = request.getParameter("orgNO");
String langID = request.getParameter("langID");
String index = request.getParameter("index");
String limit = request.getParameter("limit");
Map<String,Object> params = new HashMap<String,Object>();
params.put("orgNO",orgNO);
params.put("langID",langID);
Page page = new Page();
page.setIndex(Long.valueOf(index));
page.setLimit(Long.valueOf(limit));
page.setLimitKey(" nIdx desc ");
List<Map<String,Object>> list = bannerService.query(params, page);
return Rjx.jsonOk().set("list", list).toJson();
}
}
......@@ -8,7 +8,7 @@ import java.util.Date;
/**
* @author 曲欣亮
* @since 2018-08-06
* @since 2018-10-13
* @version v-1.0
*/
@Entity(name="tBanner")
......@@ -16,32 +16,36 @@ public class TBanner implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private String sCreateUser;
private String sOrgList;
private Date dLastUpdateTime;
private String sTitle;
private Date dUpdateDate;
private Date dCreateDate;
private String sLinkPath;
private String sOrgList;
private Date dStartTime;
@Id
private Integer nItem;
private Date dCreateDate;
private Integer nTag;
private String sImagePath;
private Date dLastUpdateTime;
private String sUpdateUser;
private String sLinkType;
private Integer nIdx;
private String sUpdateUser;
private String sCreateUser;
private Integer nTag;
private Date dUpdateDate;
private Date dEndTime;
/**
......@@ -53,42 +57,54 @@ public class TBanner implements java.io.Serializable {
/**
* 全参数构造方法
* @param sCreateUser
* @param sOrgList
* @param dLastUpdateTime
* @param sTitle
* @param dUpdateDate
* @param dCreateDate
* @param sLinkPath
* @param sOrgList
* @param dStartTime
* @param nItem
* @param dCreateDate
* @param nTag
* @param sImagePath
* @param dLastUpdateTime
* @param sUpdateUser
* @param sLinkType
* @param nIdx
* @param sUpdateUser
* @param nTag
* @param sCreateUser
* @param dUpdateDate
* @param dEndTime
*/
public TBanner(String sCreateUser, String sTitle, Date dUpdateDate, String sLinkPath, String sOrgList, Integer nItem, Date dCreateDate, String sImagePath, Date dLastUpdateTime, String sLinkType, Integer nIdx, String sUpdateUser, Integer nTag) {
this.sCreateUser = sCreateUser;
public TBanner(String sOrgList, Date dLastUpdateTime, String sTitle, Date dCreateDate, String sLinkPath, Date dStartTime, Integer nItem, Integer nTag, String sImagePath, String sUpdateUser, String sLinkType, Integer nIdx, String sCreateUser, Date dUpdateDate, Date dEndTime) {
this.sOrgList = sOrgList;
this.dLastUpdateTime = dLastUpdateTime;
this.sTitle = sTitle;
this.dUpdateDate = dUpdateDate;
this.dCreateDate = dCreateDate;
this.sLinkPath = sLinkPath;
this.sOrgList = sOrgList;
this.dStartTime = dStartTime;
this.nItem = nItem;
this.dCreateDate = dCreateDate;
this.nTag = nTag;
this.sImagePath = sImagePath;
this.dLastUpdateTime = dLastUpdateTime;
this.sUpdateUser = sUpdateUser;
this.sLinkType = sLinkType;
this.nIdx = nIdx;
this.sUpdateUser = sUpdateUser;
this.nTag = nTag;
this.sCreateUser = sCreateUser;
this.dUpdateDate = dUpdateDate;
this.dEndTime = dEndTime;
}
public void setsCreateUser(String sCreateUser) {
this.sCreateUser = sCreateUser;
public void setsOrgList(String sOrgList) {
this.sOrgList = sOrgList;
}
public String getsCreateUser() {
return sCreateUser;
public String getsOrgList() {
return sOrgList;
}
public void setdLastUpdateTime(Date dLastUpdateTime) {
this.dLastUpdateTime = dLastUpdateTime;
}
public Date getdLastUpdateTime() {
return dLastUpdateTime;
}
public void setsTitle(String sTitle) {
......@@ -99,12 +115,12 @@ public class TBanner implements java.io.Serializable {
return sTitle;
}
public void setdUpdateDate(Date dUpdateDate) {
this.dUpdateDate = dUpdateDate;
public void setdCreateDate(Date dCreateDate) {
this.dCreateDate = dCreateDate;
}
public Date getdUpdateDate() {
return dUpdateDate;
public Date getdCreateDate() {
return dCreateDate;
}
public void setsLinkPath(String sLinkPath) {
......@@ -115,12 +131,12 @@ public class TBanner implements java.io.Serializable {
return sLinkPath;
}
public void setsOrgList(String sOrgList) {
this.sOrgList = sOrgList;
public void setdStartTime(Date dStartTime) {
this.dStartTime = dStartTime;
}
public String getsOrgList() {
return sOrgList;
public Date getdStartTime() {
return dStartTime;
}
public void setnItem(Integer nItem) {
......@@ -131,12 +147,12 @@ public class TBanner implements java.io.Serializable {
return nItem;
}
public void setdCreateDate(Date dCreateDate) {
this.dCreateDate = dCreateDate;
public void setnTag(Integer nTag) {
this.nTag = nTag;
}
public Date getdCreateDate() {
return dCreateDate;
public Integer getnTag() {
return nTag;
}
public void setsImagePath(String sImagePath) {
......@@ -147,12 +163,12 @@ public class TBanner implements java.io.Serializable {
return sImagePath;
}
public void setdLastUpdateTime(Date dLastUpdateTime) {
this.dLastUpdateTime = dLastUpdateTime;
public void setsUpdateUser(String sUpdateUser) {
this.sUpdateUser = sUpdateUser;
}
public Date getdLastUpdateTime() {
return dLastUpdateTime;
public String getsUpdateUser() {
return sUpdateUser;
}
public void setsLinkType(String sLinkType) {
......@@ -171,20 +187,28 @@ public class TBanner implements java.io.Serializable {
return nIdx;
}
public void setsUpdateUser(String sUpdateUser) {
this.sUpdateUser = sUpdateUser;
public void setsCreateUser(String sCreateUser) {
this.sCreateUser = sCreateUser;
}
public String getsUpdateUser() {
return sUpdateUser;
public String getsCreateUser() {
return sCreateUser;
}
public void setnTag(Integer nTag) {
this.nTag = nTag;
public void setdUpdateDate(Date dUpdateDate) {
this.dUpdateDate = dUpdateDate;
}
public Integer getnTag() {
return nTag;
public Date getdUpdateDate() {
return dUpdateDate;
}
public void setdEndTime(Date dEndTime) {
this.dEndTime = dEndTime;
}
public Date getdEndTime() {
return dEndTime;
}
}
......
package com.egolm.admin.service;
import java.util.List;
import java.util.Map;
import com.egolm.admin.pojo.TBanner;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
public interface BannerService {
public Rjx save(TBanner banner);
public TBanner getBannerById(String id) ;
public Rjx update(TBanner banner);
public Rjx delete(int id,String userNO);
public List<Map<String,Object>> query(Map<String,Object> params,Page page);
}
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.pojo.TBanner;
import com.egolm.admin.service.BannerService;
import com.egolm.admin.util.AdminContstrant;
import com.egolm.common.DateUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
@Service
public class BannerServiceImpl implements BannerService {
private static final Log logger = LogFactory.getLog(BannerServiceImpl.class);
@Autowired
@Qualifier("shopJdbcTemplate")
private JdbcTemplate jdbcTemplate;
public Rjx save(TBanner banner) {
banner.setnTag(0);
banner.setdCreateDate(new Date());
banner.setdUpdateDate(new Date());
banner.setdLastUpdateTime(new Date());
int i = jdbcTemplate.save(banner);
if (i > 0) {
return Rjx.jsonOk().set(AdminContstrant.I18n_KEY, "Msg_Save_Success"); // .setMessage("保存成功");
}
return Rjx.jsonErr().setCode(-100).set(AdminContstrant.I18n_KEY, "Msg_Save_Error"); // .setMessage("保存失败");
}
public TBanner getBannerById(String id) {
try {
String sql = "SELECT * FROM tBanner WHERE nTag&1=0 AND nItem = ?";
return jdbcTemplate.queryForBean(sql, TBanner.class,id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public Rjx update(TBanner banner) {
banner.setdUpdateDate(new Date());
banner.setdLastUpdateTime(new Date());
int i = jdbcTemplate.update(banner);
if(i >0) {
return Rjx.jsonOk().set(AdminContstrant.I18n_KEY,"Msg_Update_Success");//.setMessage("更新成功");
}
return Rjx.jsonErr().setCode(-100).set(AdminContstrant.I18n_KEY,"Msg_Update_Error");//.setMessage("更新失败");
}
public Rjx delete(int id,String userNO) {
String sql = "UPDATE tBanner SET nTag = 1 ,sUpdateUser = ? ,dUpdateDate = getdate(), dLastUpdateTime = getdate() WHERE nItem = ?";
int i = jdbcTemplate.update(sql,userNO,id);
return Rjx.jsonOk().set(AdminContstrant.I18n_KEY, "Msg_Del_Success");
}
public List<Map<String,Object>> query(Map<String,Object> params,Page page){
String nowDate = DateUtil.format(new Date(),DateUtil.FMT_DATE);
String orgNO = params.get("orgNO")+"";
List<Map<String,Object>> list = null;
String sql = "SELECT * FROM tBanner WHERE nTag&1=0 and dStartTime <= ? AND dEndTime >= ? ";
if(!orgNO.equals("-1")) {
sql += " AND sOrgList LIKE '%"+orgNO+"%' ";
}
list = jdbcTemplate.limit(sql, page,nowDate,nowDate);
return list;
}
}
......@@ -6,6 +6,8 @@ Msg_Save_Success= Save success
Msg_Save_Error= Save failure
Msg_Update_Success= Update success
Msg_Update_Error= Update failure
Msg_Del_Success=Delete success
Msg_Del_Error=Delete failure
Msg_Layout_exists=There is a platform theme that is not allowed to add
#qu
Msg_Query_Error= Query failure
......
......@@ -6,6 +6,8 @@ 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_Del_Success=\u5220\u9664\u6210\u529F
Msg_Del_Error=\u5220\u9664\u5931\u8D25
Msg_Layout_exists=\u5DF2\u5B58\u5728\u5E73\u53F0\u4E3B\u9898,\u4E0D\u5141\u8BB8\u65B0\u589E
#qu
......
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