Commit f6dfb323 by tang

新增轮播图模块

parent 36c0f1f3
/**
* Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.thinkgem.jeesite.modules.adv.dao;
import com.thinkgem.jeesite.common.persistence.CrudDao;
import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
import com.thinkgem.jeesite.modules.adv.entity.YoukaAdv;
/**
* 轮播图DAO接口
* @author tangting
* @version 2018-06-19
*/
@MyBatisDao
public interface YoukaAdvDao extends CrudDao<YoukaAdv> {
}
\ No newline at end of file
/**
* Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.thinkgem.jeesite.modules.adv.entity;
import org.hibernate.validator.constraints.Length;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.thinkgem.jeesite.common.persistence.DataEntity;
/**
* 轮播图Entity
* @author tangting
* @version 2018-06-19
*/
public class YoukaAdv extends DataEntity<YoukaAdv> {
private String code; // 唯一随机码
private String type; // 类型 WEB 网页链接 P-广告 HP-首页广告 W-网页链接 A-app轮播图
private String title; // 轮播图标题
private String href; // 链接 可以是相对路径也可以是绝对路径
private String target; // 目标 _blank _self _parent _top
private String picture; // 图片地址
private String weight; // 排序序号 倒序
private String status; // 状态 0 下线 1 上线 2 删除
private String clicks; // 点击数量
private Date expireTime; // 失效时间 0无失效时间 秒数
private Date beginTime; // 开始时间 0立即开始 秒数
public YoukaAdv() {
}
public YoukaAdv(String code, String type, String title, String href, String target, String picture, String weight, String status, String clicks, Date expireTime, Date beginTime) {
this.code = code;
this.type = type;
this.title = title;
this.href = href;
this.target = target;
this.picture = picture;
this.weight = weight;
this.status = status;
this.clicks = clicks;
this.expireTime = expireTime;
this.beginTime = beginTime;
}
@Length(min=1, max=200, message="唯一随机码长度必须介于 1 和 200 之间")
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Length(min=1, max=100, message="类型 WEB 网页链接 P-广告 HP-首页广告 W-网页链接 A-app轮播图长度必须介于 1 和 100 之间")
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Length(min=1, max=100, message="轮播图标题长度必须介于 1 和 100 之间")
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Length(min=0, max=1024, message="链接 可以是相对路径也可以是绝对路径长度必须介于 0 和 1024 之间")
public String getHref() {
return href;
}
public void setHref(String href) {
this.href = href;
}
@Length(min=0, max=20, message="目标 _blank _self _parent _top长度必须介于 0 和 20 之间")
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
@Length(min=0, max=300, message="图片地址长度必须介于 0 和 300 之间")
public String getPicture() {
return picture;
}
public void setPicture(String picture) {
this.picture = picture;
}
@Length(min=0, max=11, message="排序序号 倒序长度必须介于 0 和 11 之间")
public String getWeight() {
return weight;
}
public void setWeight(String weight) {
this.weight = weight;
}
@Length(min=0, max=1, message="状态 0 下线 1 上线 2 删除长度必须介于 0 和 1 之间")
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Length(min=1, max=11, message="点击数量长度必须介于 1 和 11 之间")
public String getClicks() {
return clicks;
}
public void setClicks(String clicks) {
this.clicks = clicks;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
public Date getExpireTime() {
return expireTime;
}
public void setExpireTime(Date expireTime) {
this.expireTime = expireTime;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.thinkgem.jeesite.modules.adv.service;
import java.util.Date;
import java.util.List;
import com.thinkgem.jeesite.common.utils.IdGen;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.adv.entity.YoukaAdv;
import com.thinkgem.jeesite.modules.adv.dao.YoukaAdvDao;
/**
* 轮播图Service
* @author tangting
* @version 2018-06-19
*/
@Service
@Transactional(readOnly = true)
public class YoukaAdvService extends CrudService<YoukaAdvDao, YoukaAdv> {
public YoukaAdv get(String id) {
return super.get(id);
}
public List<YoukaAdv> findList(YoukaAdv youkaAdv) {
return super.findList(youkaAdv);
}
public Page<YoukaAdv> findPage(Page<YoukaAdv> page, YoukaAdv youkaAdv) {
return super.findPage(page, youkaAdv);
}
@Override
@Transactional(readOnly = false)
public void save(YoukaAdv youkaAdv) {
if(youkaAdv.getId() != null && !"".equals(youkaAdv.getId())){
youkaAdv.preUpdate();
youkaAdv.setUpdateDate(new Date());
youkaAdv.setUpdateBy(UserUtils.getUser());
dao.update(youkaAdv);
}else{
youkaAdv.preInsert();
youkaAdv.setCode( IdGen.randomBase62(64));
youkaAdv.setClicks("0");
youkaAdv.setCreateBy(UserUtils.getUser());
youkaAdv.setUpdateBy(UserUtils.getUser());
youkaAdv.setUpdateDate(new Date());
youkaAdv.setCreateDate(new Date());
dao.insert(youkaAdv);
}
}
@Transactional(readOnly = false)
public void delete(YoukaAdv youkaAdv) {
super.delete(youkaAdv);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.thinkgem.jeesite.modules.adv.web;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.adv.entity.YoukaAdv;
import com.thinkgem.jeesite.modules.adv.service.YoukaAdvService;
/**
* 轮播图Controller
* @author tangting
* @version 2018-06-19
*/
@Controller
@RequestMapping(value = "${adminPath}/youka/adv")
public class YoukaAdvController extends BaseController {
@Autowired
private YoukaAdvService youkaAdvService;
@ModelAttribute
public YoukaAdv get(@RequestParam(required=false) String id) {
YoukaAdv entity = null;
if (StringUtils.isNotBlank(id)){
entity = youkaAdvService.get(id);
}
if (entity == null){
entity = new YoukaAdv();
}
return entity;
}
@RequiresPermissions("youka:adv:view")
@RequestMapping(value = {"list", ""})
public String list(YoukaAdv youkaAdv, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<YoukaAdv> page = youkaAdvService.findPage(new Page<YoukaAdv>(request, response), youkaAdv);
model.addAttribute("page", page);
return "modules/adv/advList";
}
@RequiresPermissions("youka:adv:view")
@RequestMapping(value = "form")
public String form(YoukaAdv youkaAdv, Model model) {
model.addAttribute("youkaAdv", youkaAdv);
return "modules/adv/advForm";
}
@RequiresPermissions("youka:adv:save")
@RequestMapping(value = "save")
public String save(YoukaAdv youkaAdv, Model model, RedirectAttributes redirectAttributes) {
if (!beanValidator(model, youkaAdv)){
return form(youkaAdv, model);
}
youkaAdvService.save(youkaAdv);
addMessage(redirectAttributes, "保存轮播图成功");
return "redirect:"+Global.getAdminPath()+"/youka/adv/list?repage";
}
@RequiresPermissions("youka:adv:save")
@RequestMapping(value = "delete")
public String delete(YoukaAdv youkaAdv, RedirectAttributes redirectAttributes) {
youkaAdvService.delete(youkaAdv);
addMessage(redirectAttributes, "删除轮播图成功");
return "redirect:"+Global.getAdminPath()+"/youka/adv/list?repage";
}
}
\ No newline at end of file
......@@ -96,7 +96,7 @@ public class ArticleService extends CrudService<ArticleDao, Article> {
if (StringUtils.isNotBlank(article.getViewConfig())){
article.setViewConfig(StringEscapeUtils.unescapeHtml4(article.getViewConfig()));
}
ArticleData articleData = new ArticleData();;
if (StringUtils.isBlank(article.getId())){
article.preInsert();
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.thinkgem.jeesite.modules.adv.dao.YoukaAdvDao">
<sql id="youkaAdvColumns">
a.id AS "id",
a.code AS "code",
a.type AS "type",
a.title AS "title",
a.href AS "href",
a.target AS "target",
a.picture AS "picture",
a.weight AS "weight",
a.status AS "status",
a.clicks AS "clicks",
a.expire_time AS "expireTime",
a.begin_time AS "beginTime",
a.create_date AS "createDate",
a.create_by AS "createBy.id",
a.update_date AS "updateDate",
a.update_by AS "updateBy.id"
</sql>
<sql id="youkaAdvJoins">
</sql>
<select id="get" resultType="YoukaAdv">
SELECT
<include refid="youkaAdvColumns"/>
FROM youka_adv a
<include refid="youkaAdvJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="YoukaAdv">
SELECT
<include refid="youkaAdvColumns"/>
FROM youka_adv a
<include refid="youkaAdvJoins"/>
<where>
<if test="title != null and title != ''">
AND a.title LIKE
<if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="YoukaAdv">
SELECT
<include refid="youkaAdvColumns"/>
FROM youka_adv a
<include refid="youkaAdvJoins"/>
<where>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO youka_adv(
code,
type,
title,
href,
target,
picture,
weight,
status,
clicks,
expire_time,
begin_time,
create_date,
create_by,
update_date,
update_by
) VALUES (
#{code},
#{type},
#{title},
#{href},
#{target},
#{picture},
#{weight},
#{status},
#{clicks},
#{expireTime},
#{beginTime},
#{createDate},
#{createBy.id},
#{updateDate},
#{updateBy.id}
)
</insert>
<update id="update">
UPDATE youka_adv SET
code = #{code},
type = #{type},
title = #{title},
href = #{href},
target = #{target},
picture = #{picture},
weight = #{weight},
status = #{status},
clicks = #{clicks},
expire_time = #{expireTime},
begin_time = #{beginTime},
update_date = #{updateDate},
update_by = #{updateBy.id}
WHERE id = #{id}
</update>
<update id="delete">
DELETE FROM youka_adv
WHERE id = #{id}
</update>
</mapper>
\ No newline at end of file
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>轮播图管理</title>
<meta name="decorator" content="default"/>
<script type="text/javascript">
$(document).ready(function() {
//$("#name").focus();
$("#inputForm").validate({
submitHandler: function(form){
loading('正在提交,请稍等...');
form.submit();
},
errorContainer: "#messageBox",
errorPlacement: function(error, element) {
$("#messageBox").text("输入有误,请先更正。");
if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
error.appendTo(element.parent().parent());
} else {
error.insertAfter(element);
}
}
});
});
</script>
</head>
<body>
<ul class="nav nav-tabs">
<li><a href="${ctx}/youka/adv/list">轮播图列表</a></li>
<li class="active"><a href="${ctx}/youka/adv/form?id=${youkaAdv.id}">轮播图<shiro:hasPermission name="youka:adv:edit">${not empty youkaAdv.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="youka:adv:edit">查看</shiro:lacksPermission></a></li>
</ul><br/>
<form:form id="inputForm" modelAttribute="youkaAdv" action="${ctx}/youka/adv/save" method="post" class="form-horizontal">
<form:hidden path="id"/>
<sys:message content="${message}"/>
<!--
<div class="control-group">
<label class="control-label">唯一随机码:</label>
<div class="controls">
<form:input path="code" htmlEscape="false" maxlength="200" class="input-xlarge required"/>
<span class="help-inline"><font color="red">*</font> </span>
</div>
</div>
-->
<div class="control-group">
<label class="control-label">类型:</label>
<div class="controls">
<form:select path="type">
<form:option value="A">app轮播图</form:option>
<form:option value="P">广告</form:option>
<form:option value="HP">首页广告</form:option>
<form:option value="W">网页链接</form:option>
</form:select>
<span class="help-inline"><font color="red">*</font> </span>
</div>
</div>
<div class="control-group">
<label class="control-label">标题:</label>
<div class="controls">
<form:input path="title" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
<span class="help-inline"><font color="red">*</font> </span>
</div>
</div>
<div class="control-group">
<label class="control-label">链接:</label>
<div class="controls">
<form:input path="href" htmlEscape="false" maxlength="1024" class="input-xlarge "/>
</div>
</div>
<div class="control-group">
<label class="control-label">目标:</label>
<div class="controls">
<form:input path="target" htmlEscape="false" maxlength="20" class="input-xlarge "/>
</div>
</div>
<div class="control-group">
<label class="control-label">图片地址:</label>
<div class="controls">
<form:hidden id="nameImage" path="picture" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
<sys:ckfinder input="nameImage" type="images" uploadPath="/adv" selectMultiple="false" maxWidth="100" maxHeight="100"/>
<span class="help-inline"><font color="red">*</font> </span>
</div>
</div>
<div class="control-group">
<label class="control-label">序号:</label>
<div class="controls">
<form:input path="weight" htmlEscape="false" maxlength="11" class="input-xlarge required"/>
<span class="help-inline"><font color="red">*</font> </span>
</div>
</div>
<div class="control-group">
<label class="control-label">状态:</label>
<div class="controls">
<form:select path="status" cssStyle="width: 100px">
<form:option value="0">
下线
</form:option>
<form:option value="1">
上线
</form:option>
</form:select>
</div>
</div>
<div class="control-group">
<label class="control-label">开始时间:</label>
<div class="controls">
<input name="beginTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
value="<fmt:formatDate value="${youkaAdv.beginTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
</div>
</div>
<div class="control-group">
<label class="control-label">失效时间:</label>
<div class="controls">
<input name="expireTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
value="<fmt:formatDate value="${youkaAdv.expireTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
</div>
</div>
<div class="form-actions">
<shiro:hasPermission name="youka:adv:save"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
</div>
</form:form>
</body>
</html>
\ No newline at end of file
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>轮播图管理</title>
<meta name="decorator" content="default"/>
<script type="text/javascript">
$(document).ready(function() {
});
function page(n,s){
$("#pageNo").val(n);
$("#pageSize").val(s);
$("#searchForm").submit();
return false;
}
</script>
</head>
<body>
<ul class="nav nav-tabs">
<li class="active"><a href="${ctx}/youka/adv/list">轮播图列表</a></li>
<shiro:hasPermission name="youka:adv:view"><li><a href="${ctx}/youka/adv/form">轮播图添加</a></li></shiro:hasPermission>
</ul>
<form:form id="searchForm" modelAttribute="youkaAdv" action="${ctx}/youka/adv/list" method="post" class="breadcrumb form-search">
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}" callback="page();"/>
<ul class="ul-form">
<li><label>标题</label>
<form:input path="title" htmlEscape="false" maxlength="100" class="input-medium"/>
</li>
<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" onclick="return page();"/></li>
<li class="clearfix"></li>
</ul>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>序号</th>
<th>标题</th>
<th>链接</th>
<th>图片地址</th>
<th>状态</th>
<th>排序序号</th>
<th>开始时间</th>
<th>失效时间</th>
<th>修改时间</th>
<shiro:hasPermission name="youka:adv:save"><th>操作</th></shiro:hasPermission>
</tr>
</thead>
<tbody>
<c:forEach items="${page.list}" var="youkaAdv" varStatus="indexs">
<tr>
<td>${indexs.index}</td>
<td>
${youkaAdv.title}
</td>
<td>
${youkaAdv.href}
</td>
<td>
${youkaAdv.picture}
</td>
<td>
<c:if test="${youkaAdv.status eq '0'}">下线</c:if>
<c:if test="${youkaAdv.status eq '1'}">上线</c:if>
<c:if test="${youkaAdv.status eq '2'}">已删除</c:if>
</td>
<td>
${youkaAdv.weight}
</td>
<td>
<fmt:formatDate value="${youkaAdv.beginTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
</td>
<td>
<fmt:formatDate value="${youkaAdv.expireTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
</td>
<td>
<fmt:formatDate value="${youkaAdv.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
</td>
<shiro:hasPermission name="youka:adv:save"><td>
<a href="${ctx}/youka/adv/form?id=${youkaAdv.id}">修改</a>
<a href="${ctx}/youka/adv/delete?id=${youkaAdv.id}" onclick="return confirmx('确认要删除该单表吗?', this.href)">删除</a>
</td></shiro:hasPermission>
</tr>
</c:forEach>
</tbody>
</table>
<div class="pagination">${page}</div>
</body>
</html>
\ No newline at end of file
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