提交 cf7ddc2b authored 作者: zgy's avatar zgy

修改session过期时间

上级 024d5074
......@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
......@@ -25,7 +26,7 @@ import java.util.Map;
*/
@Controller
@RequestMapping("tbcfarticle")
public class TbCfArticleController extends AbstractController {
public class TbCfArticleController extends AbstractController {
@Autowired
private TbCfArticleService tbCfArticleService;
......@@ -107,4 +108,16 @@ public class TbCfArticleController extends AbstractController {
return R.ok().put("list", list);
}
@RequestMapping("/changeStatus")
@ResponseBody
@RequiresPermissions("tbcfarticle:changeStatus")
public R changeStatus(@RequestParam("isShow") Integer isShow, @RequestBody String ids[]) {
int res = tbCfArticleService.changeStatus(isShow, ids);
if (res>0){
return R.ok();
}
return R.error("操作失败");
}
}
package com.platform.dao;
import com.platform.entity.TbCfArticleEntity;
import org.apache.ibatis.annotations.Param;
/**
* 文章表Dao
......@@ -10,4 +11,5 @@ import com.platform.entity.TbCfArticleEntity;
*/
public interface TbCfArticleDao extends BaseDao<TbCfArticleEntity> {
int changeStatus(@Param("isShow") Integer isShow, @Param("ids") String ids[]);
}
......@@ -8,11 +8,13 @@ import java.util.Date;
* 表名 tb_cf_article
*
* @author lipengjun
* @date 2020-03-25 15:15:05
* @date 2020-04-15 10:58:12
*/
public class TbCfArticleEntity implements Serializable {
private static final long serialVersionUID = 1L;
private String account;
/**
* 文章ID
*/
......@@ -46,9 +48,13 @@ public class TbCfArticleEntity implements Serializable {
*/
private Integer delFlag;
/**
* 是否置顶 是:Y 否:N
* 是否置顶 0:否 1:置顶
*/
private String top;
private Integer top;
/**
* 是否展示
*/
private Integer isShow;
/**
* 创建时间
*/
......@@ -58,16 +64,6 @@ public class TbCfArticleEntity implements Serializable {
*/
private Date updatetime;
private String account;
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
/**
* 设置:文章ID
*/
......@@ -81,6 +77,7 @@ public class TbCfArticleEntity implements Serializable {
public String getId() {
return id;
}
/**
* 设置:文章标题
*/
......@@ -94,6 +91,7 @@ public class TbCfArticleEntity implements Serializable {
public String getTitle() {
return title;
}
/**
* 设置:文章内容
*/
......@@ -107,6 +105,7 @@ public class TbCfArticleEntity implements Serializable {
public String getContent() {
return content;
}
/**
* 设置:图片
*/
......@@ -120,6 +119,7 @@ public class TbCfArticleEntity implements Serializable {
public String getPicture() {
return picture;
}
/**
* 设置:系统用户:0 普通用户:1
*/
......@@ -133,6 +133,7 @@ public class TbCfArticleEntity implements Serializable {
public Integer getAuthorType() {
return authorType;
}
/**
* 设置:作者
*/
......@@ -146,6 +147,7 @@ public class TbCfArticleEntity implements Serializable {
public String getAuthor() {
return author;
}
/**
* 设置:点赞人数
*/
......@@ -159,6 +161,7 @@ public class TbCfArticleEntity implements Serializable {
public Long getLikeNum() {
return likeNum;
}
/**
* 设置:删除标志 0:已删除 1:正常
*/
......@@ -172,19 +175,29 @@ public class TbCfArticleEntity implements Serializable {
public Integer getDelFlag() {
return delFlag;
}
public Integer getTop() {
return top;
}
public void setTop(Integer top) {
this.top = top;
}
/**
* 设置:是否置顶 是:Y 否:N
* 设置:是否展示
*/
public void setTop(String top) {
this.top = top;
public void setIsShow(Integer isShow) {
this.isShow = isShow;
}
/**
* 获取:是否置顶 是:Y 否:N
* 获取:是否展示
*/
public String getTop() {
return top;
public Integer getIsShow() {
return isShow;
}
/**
* 设置:创建时间
*/
......@@ -198,6 +211,7 @@ public class TbCfArticleEntity implements Serializable {
public Date getCreatetime() {
return createtime;
}
/**
* 设置:更新时间
*/
......@@ -211,4 +225,12 @@ public class TbCfArticleEntity implements Serializable {
public Date getUpdatetime() {
return updatetime;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
}
package com.platform.service;
import com.platform.entity.TbCfArticleEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.io.UnsupportedEncodingException;
import java.util.List;
......@@ -69,4 +71,6 @@ public interface TbCfArticleService {
* @return 删除条数
*/
int deleteBatch(String[] ids);
int changeStatus(Integer isShow, String ids[]);
}
......@@ -80,4 +80,9 @@ public class TbCfArticleServiceImpl implements TbCfArticleService {
public int deleteBatch(String[] ids) {
return tbCfArticleDao.deleteBatch(ids);
}
@Override
public int changeStatus(Integer isShow, String[] ids) {
return tbCfArticleDao.changeStatus(isShow, ids);
}
}
......@@ -13,6 +13,7 @@
<result property="likeNum" column="like_num"/>
<result property="delFlag" column="del_flag"/>
<result property="top" column="top"/>
<result property="isShow" column="is_show"/>
<result property="createtime" column="createTime"/>
<result property="updatetime" column="updateTime"/>
</resultMap>
......@@ -28,6 +29,7 @@
`like_num`,
`del_flag`,
`top`,
`is_show`,
`createTime`,
`updateTime`
from tb_cf_article
......@@ -45,6 +47,7 @@
`like_num`,
`del_flag`,
`top`,
is_show,
`createTime`,
`updateTime`,
u.account account
......@@ -59,7 +62,7 @@
order by ${sidx} ${order}
</when>
<otherwise>
order by createTime desc
order by top desc,createTime desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
......@@ -70,9 +73,9 @@
<select id="queryTotal" resultType="int">
select count(*) from tb_cf_article
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND title LIKE concat('%',#{name},'%')
</if>
<if test="name != null and name.trim() != ''">
AND title LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.platform.entity.TbCfArticleEntity">
......@@ -86,6 +89,7 @@
`like_num`,
`del_flag`,
`top`,
`is_show`,
`createTime`,
`updateTime`)
values(
......@@ -98,6 +102,7 @@
#{likeNum},
#{delFlag},
#{top},
#{isShow},
#{createtime},
#{updatetime})
</insert>
......@@ -113,12 +118,18 @@
<if test="likeNum != null">`like_num` = #{likeNum},</if>
<if test="delFlag != null">`del_flag` = #{delFlag},</if>
<if test="top != null">`top` = #{top},</if>
<if test="isShow != null">`is_show` = #{isShow},</if>
<if test="createtime != null">`createTime` = #{createtime},</if>
<if test="updatetime != null">`updateTime` = #{updatetime}</if>
</set>
where id = #{id}
</update>
<update id="changeStatus">
update tb_cf_article set is_show=#{isShow} where id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<delete id="delete">
delete from tb_cf_article where id = #{value}
</delete>
......
......@@ -25,6 +25,14 @@
#if($shiro.hasPermission("tbcfarticle:delete"))
<i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
#end
#if($shiro.hasPermission("tbcfarticle:changeStatus"))
<i-button type="success" @click="changeStatus(1)"><i class="fa fa-arrow-up"></i>&nbsp;显示
</i-button>
#end
#if($shiro.hasPermission("tbcfarticle:changeStatus"))
<i-button type="warning" @click="changeStatus(0)"><i class="fa fa-arrow-down"></i>&nbsp;隐藏
</i-button>
#end
</div>
</Row>
<table id="jqGrid"></table>
......@@ -56,6 +64,13 @@
<i-input v-model="tbCfArticle.author" placeholder="260977204970 or ctehillah@gmail.com"
@on-blur="queryAccount"/>
</Form-item>
<Form-item label="是否显示" prop="isShow">
<i-Switch size="large" v-model="isShow" true-color="#13ce66" false-color="#eeddff"
>
<span slot="open">显示</span>
<span slot="close">隐藏</span>
</i-Switch>
</Form-item>
<Form-item label="图片" prop="picture">
<!-- <i-input v-model="xPicture.pictureUrl" placeholder="图片地址"/> -->
<upload
......
......@@ -6,6 +6,7 @@ $(function () {
{label: '文章标题', name: 'title', index: 'title', width: 80},
{label: '图片', name: 'picture', index: 'picture', width: 80, formatter: imageFormat},
{label: '作者', name: 'account', index: 'account', width: 80, formatter: accountFormat},
{label: '是否显示', name: 'isShow', index: 'isShow', width: 80, formatter: validFormat},
{label: '创建时间', name: 'createtime', index: 'createTime', width: 80}
]
});
......@@ -39,7 +40,9 @@ let vm = new Vue({
name: ''
},
disabled: false,
flag: true
flag: true,
isShow: false
},
methods: {
......@@ -74,6 +77,8 @@ let vm = new Vue({
vm.reload();
},
add: function () {
vm.account = true;
vm.isShow = false;
vm.disabled = false;
vm.showList = false;
vm.title = "新增";
......@@ -92,9 +97,34 @@ let vm = new Vue({
vm.getInfo(id);
},
changeStatus: function (status) {
let Ids = getSelectedRows("#jqGrid");
if (Ids == null) {
return;
}
Ajax.request({
url: "../tbcfarticle/changeStatus?isShow=" + status,
params: JSON.stringify(Ids),
type: "POST",
contentType: "application/json",
successCallback: function () {
alert('操作成功', function (index) {
vm.reload();
});
}
});
},
saveOrUpdate: function (event) {
let flag = this.queryAccount();
let flag = vm.flag;
if (vm.tbCfArticle.authorType === 1 && vm.tbCfArticle.id == null) {
flag = this.queryAccount();
}
if (flag) {
if (!vm.isShow) {
vm.tbCfArticle.isShow = 0;
} else {
vm.tbCfArticle.isShow = 1;
}
let url = vm.tbCfArticle.id == null ? "../tbcfarticle/save" : "../tbcfarticle/update";
vm.tbCfArticle.picture = this.uploadList.map(res => res).join(',');
vm.tbCfArticle.content = encodeURI(UE.getEditor('content').getContent()); // 富文本取值
......@@ -142,6 +172,9 @@ let vm = new Vue({
successCallback: function (r) {
vm.account = true;
vm.tbCfArticle = r.tbCfArticle;
if (vm.tbCfArticle.isShow === 1) {
vm.isShow = true;
}
let content = vm.tbCfArticle.content;
vm.uploadList = vm.tbCfArticle.picture.split(',');
if (content != null) {
......
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">
<!-- 继承自AuthorizingRealm的自定义Realm,即指定Shiro验证用户登录的类为自定义的UserRealm.java -->
<bean id="userRealm" class="com.platform.shiro.UserRealm"/>
<!-- 继承自AuthorizingRealm的自定义Realm,即指定Shiro验证用户登录的类为自定义的UserRealm.java -->
<bean id="userRealm" class="com.platform.shiro.UserRealm"/>
<bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
<!-- 设置session过期时间为1小时(单位:毫秒),默认为30分钟 -->
<property name="globalSessionTimeout" value="86400000"></property>
<property name="sessionValidationSchedulerEnabled" value="true"></property>
<property name="sessionIdUrlRewritingEnabled" value="false"></property>
</bean>
<!-- Shiro默认会使用Servlet容器的Session,可通过sessionMode属性来指定使用Shiro原生Session -->
<!-- 即<property name="sessionMode" value="native"/>,详细说明见官方文档 -->
<!-- 这里主要是设置自定义的单Realm应用,若有多个Realm,可使用'realms'属性代替 -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="sessionManager" ref="sessionManager"></property>
<property name="realm" ref="userRealm"/>
</bean>
<bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
<!-- 设置session过期时间为1小时(单位:毫秒),默认为30分钟 -->
<property name="globalSessionTimeout" value="2592000000"></property>
<property name="sessionValidationSchedulerEnabled" value="true"></property>
<property name="sessionIdUrlRewritingEnabled" value="false"></property>
</bean>
<!-- Shiro主过滤器本身功能十分强大,其强大之处就在于它支持任何基于URL路径表达式的、自定义的过滤器的执行 -->
<!-- Web应用中,Shiro可控制的Web请求必须经过Shiro主过滤器的拦截,Shiro对基于Spring的Web应用提供了完美的支持 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<!-- Shiro的核心安全接口,这个属性是必须的 -->
<property name="securityManager" ref="securityManager"/>
<!-- 要求登录时的链接(可根据项目的URL进行替换),非必须的属性,默认会自动寻找Web工程根目录下的"/login.html"页面 -->
<property name="loginUrl" value="/login.html"/>
<!-- 登录成功后要跳转的连接 -->
<property name="successUrl" value="/index.html"/>
<!-- 用户访问未对其授权的资源时,所显示的连接 -->
<!-- 若想更明显的测试此属性可以修改它的值,如unauthor.jsp,登录后访问/admin/listUser.jsp就看见浏览器会显示unauthor.jsp -->
<property name="unauthorizedUrl" value="/"/>
<!-- Shiro连接约束配置,即过滤链的定义 -->
<!-- 此处可配合我的这篇文章来理解各个过滤连的作用http://blog.csdn.net/jadyer/article/details/12172839 -->
<!-- 下面value值的第一个'/'代表的路径是相对于HttpServletRequest.getContextPath()的值来的 -->
<!-- anon:它对应的过滤器里面是空的,什么都没做,这里.do和.jsp后面的*表示参数,比方说login.jsp?main这种 -->
<!-- authc:该过滤器下的页面必须验证后才能访问,它是Shiro内置的一个拦截器org.apache.shiro.web.filter.authc.FormAuthenticationFilter -->
<property name="filterChainDefinitions">
<value>
/statics/**=anon
/api/**=anon
/login.html=anon
/sys/login=anon
/captcha.jpg=anon
/**=authc
</value>
</property>
</bean>
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
<!-- AOP式方法级权限检查 -->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor">
<property name="proxyTargetClass" value="true" />
</bean>
<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager"/>
</bean>
<!-- Shiro默认会使用Servlet容器的Session,可通过sessionMode属性来指定使用Shiro原生Session -->
<!-- 即<property name="sessionMode" value="native"/>,详细说明见官方文档 -->
<!-- 这里主要是设置自定义的单Realm应用,若有多个Realm,可使用'realms'属性代替 -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="sessionManager" ref="sessionManager"></property>
<property name="realm" ref="userRealm"/>
</bean>
<!-- Shiro主过滤器本身功能十分强大,其强大之处就在于它支持任何基于URL路径表达式的、自定义的过滤器的执行 -->
<!-- Web应用中,Shiro可控制的Web请求必须经过Shiro主过滤器的拦截,Shiro对基于Spring的Web应用提供了完美的支持 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<!-- Shiro的核心安全接口,这个属性是必须的 -->
<property name="securityManager" ref="securityManager"/>
<!-- 要求登录时的链接(可根据项目的URL进行替换),非必须的属性,默认会自动寻找Web工程根目录下的"/login.html"页面 -->
<property name="loginUrl" value="/login.html"/>
<!-- 登录成功后要跳转的连接 -->
<property name="successUrl" value="/index.html"/>
<!-- 用户访问未对其授权的资源时,所显示的连接 -->
<!-- 若想更明显的测试此属性可以修改它的值,如unauthor.jsp,登录后访问/admin/listUser.jsp就看见浏览器会显示unauthor.jsp -->
<property name="unauthorizedUrl" value="/"/>
<!-- Shiro连接约束配置,即过滤链的定义 -->
<!-- 此处可配合我的这篇文章来理解各个过滤连的作用http://blog.csdn.net/jadyer/article/details/12172839 -->
<!-- 下面value值的第一个'/'代表的路径是相对于HttpServletRequest.getContextPath()的值来的 -->
<!-- anon:它对应的过滤器里面是空的,什么都没做,这里.do和.jsp后面的*表示参数,比方说login.jsp?main这种 -->
<!-- authc:该过滤器下的页面必须验证后才能访问,它是Shiro内置的一个拦截器org.apache.shiro.web.filter.authc.FormAuthenticationFilter -->
<property name="filterChainDefinitions">
<value>
/statics/**=anon
/api/**=anon
/login.html=anon
/sys/login=anon
/captcha.jpg=anon
/**=authc
</value>
</property>
</bean>
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
<!-- AOP式方法级权限检查 -->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
depends-on="lifecycleBeanPostProcessor">
<property name="proxyTargetClass" value="true"/>
</bean>
<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager"/>
</bean>
</beans>
\ No newline at end of file
......@@ -14,8 +14,8 @@ import java.util.Map;
public class TokenService {
@Autowired
private ApiTokenMapper tokenDao;
//12小时后过期
private final static int EXPIRE = 3600 * 12;
//10天后过期
private final static int EXPIRE = 3600 * 240;
public TokenEntity queryByUserId(Long userId) {
return tokenDao.queryByUserId(userId);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论