|
@@ -1,6 +1,7 @@
|
|
|
package xyz.luxnk.lproject.module;
|
|
package xyz.luxnk.lproject.module;
|
|
|
|
|
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
|
|
+import org.apache.shiro.authz.annotation.RequiresUser;
|
|
|
import org.nutz.aop.interceptor.ioc.TransAop;
|
|
import org.nutz.aop.interceptor.ioc.TransAop;
|
|
|
import org.nutz.dao.Cnd;
|
|
import org.nutz.dao.Cnd;
|
|
|
import org.nutz.dao.Dao;
|
|
import org.nutz.dao.Dao;
|
|
@@ -35,8 +36,15 @@ public class UserModule extends BaseModule {
|
|
|
|
|
|
|
|
@At("/")
|
|
@At("/")
|
|
|
@Ok("jsp:jsp.user.list") // 真实路径是 /WEB-INF/jsp/user/list.jsp
|
|
@Ok("jsp:jsp.user.list") // 真实路径是 /WEB-INF/jsp/user/list.jsp
|
|
|
|
|
+ @RequiresUser
|
|
|
public void index() {}
|
|
public void index() {}
|
|
|
|
|
|
|
|
|
|
+ @GET
|
|
|
|
|
+ @At("/login")
|
|
|
|
|
+ @Filters
|
|
|
|
|
+ @Ok("jsp:jsp.user.login") // 重定向到登录jsp
|
|
|
|
|
+ public void loginPage() {}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 统计用户数
|
|
* 统计用户数
|
|
|
* @return
|
|
* @return
|
|
@@ -66,7 +74,7 @@ public class UserModule extends BaseModule {
|
|
|
return re.setv("ok", false).setv("msg", "用户名或密码错误");
|
|
return re.setv("ok", false).setv("msg", "用户名或密码错误");
|
|
|
} else {
|
|
} else {
|
|
|
session.setAttribute("me", userId);
|
|
session.setAttribute("me", userId);
|
|
|
- //SecurityUtils.getSubject().login(new SimpleShiroToken(userId));
|
|
|
|
|
|
|
+ SecurityUtils.getSubject().login(new SimpleShiroToken(userId));
|
|
|
return re.setv("ok", true);
|
|
return re.setv("ok", true);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -125,6 +133,7 @@ public class UserModule extends BaseModule {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@At
|
|
@At
|
|
|
|
|
+ @RequiresUser
|
|
|
public Object add(@Param("..")UserInfo userInfo) { // 两个点号是表示按对象属性一一设置
|
|
public Object add(@Param("..")UserInfo userInfo) { // 两个点号是表示按对象属性一一设置
|
|
|
NutMap re = new NutMap();
|
|
NutMap re = new NutMap();
|
|
|
String msg = checkUser(userInfo, true);
|
|
String msg = checkUser(userInfo, true);
|
|
@@ -142,6 +151,7 @@ public class UserModule extends BaseModule {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@At
|
|
@At
|
|
|
|
|
+ @RequiresUser
|
|
|
public Object update(@Param("password")String password, @Attr("me")String me) {
|
|
public Object update(@Param("password")String password, @Attr("me")String me) {
|
|
|
NutMap re = new NutMap();
|
|
NutMap re = new NutMap();
|
|
|
if (Strings.isBlank(password) || password.length() < 6) {
|
|
if (Strings.isBlank(password) || password.length() < 6) {
|
|
@@ -159,6 +169,7 @@ public class UserModule extends BaseModule {
|
|
|
*/
|
|
*/
|
|
|
@At
|
|
@At
|
|
|
@Aop(TransAop.READ_COMMITTED)
|
|
@Aop(TransAop.READ_COMMITTED)
|
|
|
|
|
+ @RequiresUser
|
|
|
public Object delete(@Param("id")String id, @Attr("me")String me) {
|
|
public Object delete(@Param("id")String id, @Attr("me")String me) {
|
|
|
if (me.equals(id)) {
|
|
if (me.equals(id)) {
|
|
|
return new NutMap().setv("ok", false).setv("msg", "不能删除当前用户!");
|
|
return new NutMap().setv("ok", false).setv("msg", "不能删除当前用户!");
|
|
@@ -175,6 +186,7 @@ public class UserModule extends BaseModule {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@At
|
|
@At
|
|
|
|
|
+ @RequiresUser
|
|
|
public Object query(@Param("name")String name, @Param("..")Pager pager) {
|
|
public Object query(@Param("name")String name, @Param("..")Pager pager) {
|
|
|
Cnd cnd = Strings.isBlank(name)? null : Cnd.where("name", "like", "%" + name + "%");
|
|
Cnd cnd = Strings.isBlank(name)? null : Cnd.where("name", "like", "%" + name + "%");
|
|
|
QueryResult qr = new QueryResult();
|
|
QueryResult qr = new QueryResult();
|