mirror of https://github.com/Rekoe/rk_svnadmin
up jar version
parent
b514e99c5d
commit
0af14b3d52
14
pom.xml
14
pom.xml
|
@ -39,7 +39,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid</artifactId>
|
<artifactId>druid</artifactId>
|
||||||
<version>1.0.19</version>
|
<version>1.0.24</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>jconsole</artifactId>
|
<artifactId>jconsole</artifactId>
|
||||||
|
@ -54,17 +54,17 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.nutz</groupId>
|
<groupId>org.nutz</groupId>
|
||||||
<artifactId>nutz-plugins-views</artifactId>
|
<artifactId>nutz-plugins-views</artifactId>
|
||||||
<version>1.r.54.r2</version>
|
<version>1.r.57</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.nutz</groupId>
|
<groupId>org.nutz</groupId>
|
||||||
<artifactId>nutz</artifactId>
|
<artifactId>nutz</artifactId>
|
||||||
<version>1.r.56</version>
|
<version> 1.r.57.r3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.nutz</groupId>
|
<groupId>org.nutz</groupId>
|
||||||
<artifactId>nutz-web</artifactId>
|
<artifactId>nutz-web</artifactId>
|
||||||
<version>1.b.52</version>
|
<version>1.r.57</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.restfb</groupId>
|
<groupId>com.restfb</groupId>
|
||||||
|
@ -100,12 +100,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.nutz</groupId>
|
<groupId>org.nutz</groupId>
|
||||||
<artifactId>nutz-plugins-daocache</artifactId>
|
<artifactId>nutz-plugins-daocache</artifactId>
|
||||||
<version>1.b.53.r2</version>
|
<version> 1.r.57</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.nutz</groupId>
|
<groupId>org.nutz</groupId>
|
||||||
<artifactId>nutz-integration-quartz</artifactId>
|
<artifactId>nutz-integration-quartz</artifactId>
|
||||||
<version>1.b.53</version>
|
<version>1.r.57.r2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.json</groupId>
|
<groupId>org.json</groupId>
|
||||||
|
@ -120,7 +120,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.nutz</groupId>
|
<groupId>org.nutz</groupId>
|
||||||
<artifactId>nutz-integration-shiro</artifactId>
|
<artifactId>nutz-integration-shiro</artifactId>
|
||||||
<version>1.b.53.r2</version>
|
<version>1.r.57</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>shiro-core</artifactId>
|
<artifactId>shiro-core</artifactId>
|
||||||
|
|
|
@ -27,8 +27,8 @@ import com.rekoe.domain.PjGrUsr;
|
||||||
import com.rekoe.domain.ProjectConfig;
|
import com.rekoe.domain.ProjectConfig;
|
||||||
import com.rekoe.domain.User;
|
import com.rekoe.domain.User;
|
||||||
import com.rekoe.domain.Usr;
|
import com.rekoe.domain.Usr;
|
||||||
|
import com.rekoe.service.AuthorityService;
|
||||||
import com.rekoe.service.ProjectConfigService;
|
import com.rekoe.service.ProjectConfigService;
|
||||||
import com.rekoe.service.UserService;
|
|
||||||
|
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
|
|
||||||
|
@ -73,8 +73,7 @@ public class MvcSetup implements Setup {
|
||||||
dao.update(user);
|
dao.update(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UserService userService = ioc.get(UserService.class);
|
ioc.get(AuthorityService.class).initFormPackage("com.rekoe");
|
||||||
userService.initFormPackages("com.rekoe");
|
|
||||||
ioc.get(ProjectConfigService.class).init();
|
ioc.get(ProjectConfigService.class).init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,18 @@ public class User implements Serializable {
|
||||||
@ColDefine(type = ColType.BOOLEAN)
|
@ColDefine(type = ColType.BOOLEAN)
|
||||||
private boolean system;
|
private boolean system;
|
||||||
|
|
||||||
|
@Column("is_del")
|
||||||
|
@ColDefine(type = ColType.BOOLEAN)
|
||||||
|
private boolean del;
|
||||||
|
|
||||||
|
public boolean isDel() {
|
||||||
|
return del;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDel(boolean del) {
|
||||||
|
this.del = del;
|
||||||
|
}
|
||||||
|
|
||||||
public String getProviderid() {
|
public String getProviderid() {
|
||||||
return providerid;
|
return providerid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.nutz.integration.shiro.annotation.NutzRequiresPermissions;
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.lang.util.NutMap;
|
import org.nutz.lang.util.NutMap;
|
||||||
|
@ -17,7 +18,6 @@ import org.nutz.mvc.annotation.At;
|
||||||
import org.nutz.mvc.annotation.Ok;
|
import org.nutz.mvc.annotation.Ok;
|
||||||
import org.nutz.mvc.annotation.Param;
|
import org.nutz.mvc.annotation.Param;
|
||||||
|
|
||||||
import com.rekoe.annotation.PermissionTag;
|
|
||||||
import com.rekoe.common.Message;
|
import com.rekoe.common.Message;
|
||||||
import com.rekoe.common.page.Pagination;
|
import com.rekoe.common.page.Pagination;
|
||||||
import com.rekoe.domain.Pj;
|
import com.rekoe.domain.Pj;
|
||||||
|
@ -43,23 +43,20 @@ public class AdminProjectAct extends BaseAction {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.project.list")
|
@Ok("fm:template.admin.project.list")
|
||||||
@RequiresPermissions({ "svn.project:view" })
|
@NutzRequiresPermissions(value = "svn.project:view", name = "浏览项目", tag = "SVN项目管理", enable = true)
|
||||||
@PermissionTag(name = "SVN浏览项目", tag = "SVN项目管理")
|
|
||||||
public Pagination list(@Param(value = "pageNumber", df = "1") int page) {
|
public Pagination list(@Param(value = "pageNumber", df = "1") int page) {
|
||||||
return projectService.getObjListByPager(page, 20, null);
|
return projectService.getObjListByPager(page, 20, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.project.add")
|
@Ok("fm:template.admin.project.add")
|
||||||
@RequiresPermissions({ "svn.project:add" })
|
@NutzRequiresPermissions(value = "svn.project:add", name = "添加项目", tag = "SVN项目管理", enable = true)
|
||||||
@PermissionTag(name = "SVN添加项目", tag = "SVN项目管理", enable = true)
|
|
||||||
public void add() {
|
public void add() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.project.edit")
|
@Ok("fm:template.admin.project.edit")
|
||||||
@RequiresPermissions({ "svn.project:edit" })
|
@NutzRequiresPermissions(value = "svn.project:edit", name = "编辑项目", tag = "SVN项目管理", enable = true)
|
||||||
@PermissionTag(name = "SVN编辑项目", tag = "SVN项目管理", enable = false)
|
|
||||||
public Pj edit(@Param("pj") String pj) {
|
public Pj edit(@Param("pj") String pj) {
|
||||||
return projectService.get(pj);
|
return projectService.get(pj);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +64,6 @@ public class AdminProjectAct extends BaseAction {
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions("svn.project:add")
|
@RequiresPermissions("svn.project:add")
|
||||||
@PermissionTag(name = "SVN添加项目", tag = "SVN项目管理", enable = false)
|
|
||||||
public Message o_save(@Param("::pj.") Pj pj, HttpServletRequest req) {
|
public Message o_save(@Param("::pj.") Pj pj, HttpServletRequest req) {
|
||||||
boolean isOk = projectService.nameOk(pj.getPj());
|
boolean isOk = projectService.nameOk(pj.getPj());
|
||||||
if (isOk) {
|
if (isOk) {
|
||||||
|
@ -82,7 +78,7 @@ public class AdminProjectAct extends BaseAction {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.project.rep")
|
@Ok("fm:template.admin.project.rep")
|
||||||
@RequiresPermissions({ "svn.project:view" })
|
@RequiresPermissions("svn.project:view")
|
||||||
public String rep(@Param("pj") String pj, HttpServletRequest req) {
|
public String rep(@Param("pj") String pj, HttpServletRequest req) {
|
||||||
Pj project = projectService.get(pj);
|
Pj project = projectService.get(pj);
|
||||||
String root = repositoryService.getRepositoryRoot(project);
|
String root = repositoryService.getRepositoryRoot(project);
|
||||||
|
@ -119,7 +115,7 @@ public class AdminProjectAct extends BaseAction {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions({ "svn.project:edit" })
|
@RequiresPermissions("svn.project:edit")
|
||||||
public Message init(@Param("pj") String pj, HttpServletRequest req) {
|
public Message init(@Param("pj") String pj, HttpServletRequest req) {
|
||||||
Pj project = projectService.get(pj);
|
Pj project = projectService.get(pj);
|
||||||
if (project.isInitTempl()) {
|
if (project.isInitTempl()) {
|
||||||
|
@ -134,7 +130,7 @@ public class AdminProjectAct extends BaseAction {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.project.pjauth")
|
@Ok("fm:template.admin.project.pjauth")
|
||||||
@RequiresPermissions({ "svn.project:view" })
|
@RequiresPermissions("svn.project:view")
|
||||||
public String pjauth(@Param("pj") String pj, @Param("res") String res, @Param("entity") PjAuth entity, HttpServletRequest req) {
|
public String pjauth(@Param("pj") String pj, @Param("res") String res, @Param("entity") PjAuth entity, HttpServletRequest req) {
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
entity = new PjAuth();
|
entity = new PjAuth();
|
||||||
|
@ -168,7 +164,7 @@ public class AdminProjectAct extends BaseAction {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("raw")
|
@Ok("raw")
|
||||||
@RequiresPermissions({ "svn.project:view" })
|
@RequiresPermissions("svn.project:view")
|
||||||
public String ajaxTreeService(HttpServletRequest req, HttpServletResponse response) {
|
public String ajaxTreeService(HttpServletRequest req, HttpServletResponse response) {
|
||||||
NutMap params = CommonUtils.getRequestParametersMap(req);
|
NutMap params = CommonUtils.getRequestParametersMap(req);
|
||||||
com.rekoe.domain.Ajax ajax = treeService.execute(params);
|
com.rekoe.domain.Ajax ajax = treeService.execute(params);
|
||||||
|
@ -180,8 +176,7 @@ public class AdminProjectAct extends BaseAction {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions({ "svn.project:auth.manager" })
|
@NutzRequiresPermissions(value = "svn.project:auth.manager", name = "管理项目权限", tag = "SVN项目管理", enable = true)
|
||||||
@PermissionTag(name = "管理项目权限", tag = "SVN项目管理", enable = false)
|
|
||||||
public Message delete(@Param("id") String id, HttpServletRequest req) {
|
public Message delete(@Param("id") String id, HttpServletRequest req) {
|
||||||
try {
|
try {
|
||||||
projectService.delete(id);
|
projectService.delete(id);
|
||||||
|
@ -194,7 +189,6 @@ public class AdminProjectAct extends BaseAction {
|
||||||
@At("/pjauth/delete")
|
@At("/pjauth/delete")
|
||||||
@Ok("fm:template.admin.project.pjauth")
|
@Ok("fm:template.admin.project.pjauth")
|
||||||
@RequiresPermissions({ "svn.project:auth.manager" })
|
@RequiresPermissions({ "svn.project:auth.manager" })
|
||||||
@PermissionTag(name = "管理项目权限", tag = "SVN项目管理", enable = true)
|
|
||||||
public String pjauth_delete(@Param("gr") String gr, @Param("pj") String pj, @Param("res") String res, @Param("usr") String usr) {
|
public String pjauth_delete(@Param("gr") String gr, @Param("pj") String pj, @Param("res") String res, @Param("usr") String usr) {
|
||||||
if (StringUtils.isNotBlank(gr)) {
|
if (StringUtils.isNotBlank(gr)) {
|
||||||
projectAuthService.deleteByGr(pj, gr, res);
|
projectAuthService.deleteByGr(pj, gr, res);
|
||||||
|
@ -209,28 +203,22 @@ public class AdminProjectAct extends BaseAction {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.project.config")
|
@Ok("fm:template.admin.project.config")
|
||||||
@RequiresPermissions({ "svn.project:conf" })
|
@NutzRequiresPermissions(value = "svn.project:conf", name = "配置管理", tag = "SVN项目管理", enable = true)
|
||||||
@PermissionTag(name = "配置管理", tag = "SVN项目管理", enable = true)
|
|
||||||
public ProjectConfig conf() {
|
public ProjectConfig conf() {
|
||||||
return projectConfigService.get();
|
return projectConfigService.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@At("/conf/update")
|
@At("/conf/update")
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions({ "svn.project:conf" })
|
@RequiresPermissions("svn.project:conf")
|
||||||
@PermissionTag(name = "配置管理", tag = "SVN项目管理", enable = false)
|
|
||||||
public Message conf_update(@Param("::conf.") ProjectConfig conf, HttpServletRequest req) {
|
public Message conf_update(@Param("::conf.") ProjectConfig conf, HttpServletRequest req) {
|
||||||
boolean isRight = projectConfigService.update(conf);
|
projectConfigService.update(conf);
|
||||||
if (isRight) {
|
return Message.success("ok", req);
|
||||||
return Message.success("ok", req);
|
|
||||||
}
|
|
||||||
return Message.error("erroe", req);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions("svn.project:update")
|
@NutzRequiresPermissions(value = "svn.project:update", name = "SVN编辑项目", tag = "SVN项目管理", enable = true)
|
||||||
@PermissionTag(name = "SVN编辑项目", tag = "SVN项目管理", enable = true)
|
|
||||||
public Message o_update(@Param("::pj.") Pj pj, HttpServletRequest req) {
|
public Message o_update(@Param("::pj.") Pj pj, HttpServletRequest req) {
|
||||||
projectService.update(pj);
|
projectService.update(pj);
|
||||||
return Message.success("ok", req);
|
return Message.success("ok", req);
|
||||||
|
@ -239,7 +227,6 @@ public class AdminProjectAct extends BaseAction {
|
||||||
@At("/pjauth/save")
|
@At("/pjauth/save")
|
||||||
@Ok("fm:template.admin.project.pjauth")
|
@Ok("fm:template.admin.project.pjauth")
|
||||||
@RequiresPermissions({ "svn.project:auth.manager" })
|
@RequiresPermissions({ "svn.project:auth.manager" })
|
||||||
@PermissionTag(name = "管理项目权限", tag = "SVN项目管理", enable = false)
|
|
||||||
public String pjauth_save(@Param("rw") String rw, @Param("grs") String[] grs, @Param("pj") String pj, @Param("res") String res, @Param("usrs") String[] usrs) {
|
public String pjauth_save(@Param("rw") String rw, @Param("grs") String[] grs, @Param("pj") String pj, @Param("res") String res, @Param("usrs") String[] usrs) {
|
||||||
PjAuth entity = new PjAuth();
|
PjAuth entity = new PjAuth();
|
||||||
entity.setPj(pj);
|
entity.setPj(pj);
|
||||||
|
@ -252,7 +239,6 @@ public class AdminProjectAct extends BaseAction {
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.project.add_dir")
|
@Ok("fm:template.admin.project.add_dir")
|
||||||
@RequiresPermissions("svn.project:update")
|
@RequiresPermissions("svn.project:update")
|
||||||
@PermissionTag(name = "SVN编辑项目", tag = "SVN项目管理", enable = false)
|
|
||||||
public String file_add(@Param("pj") String pj) {
|
public String file_add(@Param("pj") String pj) {
|
||||||
return pj;
|
return pj;
|
||||||
}
|
}
|
||||||
|
@ -263,7 +249,6 @@ public class AdminProjectAct extends BaseAction {
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions("svn.project:update")
|
@RequiresPermissions("svn.project:update")
|
||||||
@PermissionTag(name = "SVN编辑项目", tag = "SVN项目管理", enable = false)
|
|
||||||
public Message file_save(@Param("pj") String pj, @Param("file") String file, HttpServletRequest req) {
|
public Message file_save(@Param("pj") String pj, @Param("file") String file, HttpServletRequest req) {
|
||||||
doCommit.mkdirs(pj, new String[] { file });
|
doCommit.mkdirs(pj, new String[] { file });
|
||||||
return Message.success("ok", req);
|
return Message.success("ok", req);
|
||||||
|
@ -272,7 +257,6 @@ public class AdminProjectAct extends BaseAction {
|
||||||
@At("/pjauth_delete")
|
@At("/pjauth_delete")
|
||||||
@Ok("fm:template.admin.project.pjauth")
|
@Ok("fm:template.admin.project.pjauth")
|
||||||
@RequiresPermissions("svn.project:auth.manager")
|
@RequiresPermissions("svn.project:auth.manager")
|
||||||
@PermissionTag(name = "SVN编辑项目", tag = "SVN项目管理", enable = false)
|
|
||||||
public String pjauth_delete(@Param("pj") String pj, @Param("gr") String gr, @Param("usr") String usr, @Param("res") String res, HttpServletRequest req) {
|
public String pjauth_delete(@Param("pj") String pj, @Param("gr") String gr, @Param("usr") String usr, @Param("res") String res, HttpServletRequest req) {
|
||||||
if (StringUtils.isNotBlank(gr)) {
|
if (StringUtils.isNotBlank(gr)) {
|
||||||
projectAuthService.deleteByGr(pj, gr, res);
|
projectAuthService.deleteByGr(pj, gr, res);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
|
import org.nutz.integration.shiro.annotation.NutzRequiresPermissions;
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.lang.Lang;
|
import org.nutz.lang.Lang;
|
||||||
|
@ -11,7 +12,6 @@ import org.nutz.mvc.annotation.At;
|
||||||
import org.nutz.mvc.annotation.Ok;
|
import org.nutz.mvc.annotation.Ok;
|
||||||
import org.nutz.mvc.annotation.Param;
|
import org.nutz.mvc.annotation.Param;
|
||||||
|
|
||||||
import com.rekoe.annotation.PermissionTag;
|
|
||||||
import com.rekoe.common.Message;
|
import com.rekoe.common.Message;
|
||||||
import com.rekoe.common.page.Pagination;
|
import com.rekoe.common.page.Pagination;
|
||||||
import com.rekoe.domain.PjGr;
|
import com.rekoe.domain.PjGr;
|
||||||
|
@ -27,8 +27,7 @@ public class AdminProjectGroupAct extends BaseAction {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.project_group.list")
|
@Ok("fm:template.admin.project_group.list")
|
||||||
@RequiresPermissions({ "project.group:view" })
|
@NutzRequiresPermissions(value = "project.group:view", name = "SVN浏览账号", tag = "SVN账号管理", enable = true)
|
||||||
@PermissionTag(name = "SVN浏览账号", tag = "SVN账号管理")
|
|
||||||
public Pagination list(@Param(value = "pageNumber", df = "1") Integer page, @Param("pj") String pj, HttpServletRequest req) {
|
public Pagination list(@Param(value = "pageNumber", df = "1") Integer page, @Param("pj") String pj, HttpServletRequest req) {
|
||||||
req.setAttribute("pj", pj);
|
req.setAttribute("pj", pj);
|
||||||
return projectGroupService.getObjListByPager(page, 20, Cnd.where("pj", "=", pj));
|
return projectGroupService.getObjListByPager(page, 20, Cnd.where("pj", "=", pj));
|
||||||
|
@ -36,8 +35,7 @@ public class AdminProjectGroupAct extends BaseAction {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.project_group.add")
|
@Ok("fm:template.admin.project_group.add")
|
||||||
@RequiresPermissions({ "project.group:add" })
|
@NutzRequiresPermissions(value = "project.group:add", name = "添加项目用户组", tag = "SVN账号管理", enable = true)
|
||||||
@PermissionTag(name = "添加项目用户组", tag = "SVN账号管理", enable = true)
|
|
||||||
public String add(@Param("pj") String pj) {
|
public String add(@Param("pj") String pj) {
|
||||||
return pj;
|
return pj;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +43,6 @@ public class AdminProjectGroupAct extends BaseAction {
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions("project.group:add")
|
@RequiresPermissions("project.group:add")
|
||||||
@PermissionTag(name = "添加项目用户组", tag = "SVN账号管理", enable = false)
|
|
||||||
public Message o_save(@Param("::pgu.") PjGr group, HttpServletRequest req) {
|
public Message o_save(@Param("::pgu.") PjGr group, HttpServletRequest req) {
|
||||||
PjGr old = projectGroupService.fetch(Cnd.where("pj", "=", group.getPj()).and("gr", "=", group.getGr()));
|
PjGr old = projectGroupService.fetch(Cnd.where("pj", "=", group.getPj()).and("gr", "=", group.getGr()));
|
||||||
if (Lang.isEmpty(old)) {
|
if (Lang.isEmpty(old)) {
|
||||||
|
@ -57,8 +54,7 @@ public class AdminProjectGroupAct extends BaseAction {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions("project.group:delete")
|
@NutzRequiresPermissions(value = "project.group:delete", name = "删除项目用户组", tag = "SVN账号管理", enable = true)
|
||||||
@PermissionTag(name = "删除项目用户组", tag = "SVN账号管理", enable = true)
|
|
||||||
public Message delete(@Param("pj") String pj, @Param("gr") String gr, HttpServletRequest req) {
|
public Message delete(@Param("pj") String pj, @Param("gr") String gr, HttpServletRequest req) {
|
||||||
projectGroupService.delete(pj, gr);
|
projectGroupService.delete(pj, gr);
|
||||||
return Message.success("ok", req);
|
return Message.success("ok", req);
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.nutz.mvc.annotation.At;
|
||||||
import org.nutz.mvc.annotation.Ok;
|
import org.nutz.mvc.annotation.Ok;
|
||||||
import org.nutz.mvc.annotation.Param;
|
import org.nutz.mvc.annotation.Param;
|
||||||
|
|
||||||
import com.rekoe.annotation.PermissionTag;
|
|
||||||
import com.rekoe.common.Message;
|
import com.rekoe.common.Message;
|
||||||
import com.rekoe.common.page.Pagination;
|
import com.rekoe.common.page.Pagination;
|
||||||
import com.rekoe.domain.Pj;
|
import com.rekoe.domain.Pj;
|
||||||
|
@ -51,7 +50,6 @@ public class AdminProjectGroupUsrAct extends BaseAction {
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.project_group_usr.list")
|
@Ok("fm:template.admin.project_group_usr.list")
|
||||||
@RequiresPermissions({ "project.group:view" })
|
@RequiresPermissions({ "project.group:view" })
|
||||||
@PermissionTag(name = "SVN浏览账号", tag = "SVN账号管理")
|
|
||||||
public Pagination list(@Param(value = "pageNumber", df = "1") int page, @Param("pj") String pj, @Param("gr") String gr, HttpServletRequest req) {
|
public Pagination list(@Param(value = "pageNumber", df = "1") int page, @Param("pj") String pj, @Param("gr") String gr, HttpServletRequest req) {
|
||||||
req.setAttribute("pj", pj);
|
req.setAttribute("pj", pj);
|
||||||
req.setAttribute("gr", gr);
|
req.setAttribute("gr", gr);
|
||||||
|
@ -64,7 +62,6 @@ public class AdminProjectGroupUsrAct extends BaseAction {
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.project_group_usr.add")
|
@Ok("fm:template.admin.project_group_usr.add")
|
||||||
@RequiresPermissions({ "project.group:add" })
|
@RequiresPermissions({ "project.group:add" })
|
||||||
@PermissionTag(name = "添加项目组用户", tag = "SVN账号管理", enable = true)
|
|
||||||
public String add(@Param("pj") String pj, @Param("gr") String gr, HttpServletRequest req) {
|
public String add(@Param("pj") String pj, @Param("gr") String gr, HttpServletRequest req) {
|
||||||
req.setAttribute("pj", pj);
|
req.setAttribute("pj", pj);
|
||||||
req.setAttribute("gr", gr);
|
req.setAttribute("gr", gr);
|
||||||
|
@ -75,7 +72,6 @@ public class AdminProjectGroupUsrAct extends BaseAction {
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions("project.group:add")
|
@RequiresPermissions("project.group:add")
|
||||||
@PermissionTag(name = "添加项目组用户", tag = "SVN账号管理", enable = false)
|
|
||||||
public Message o_save(@Param("pj") String pj, @Param("gr") String gr, @Param("usrs") String[] usrs, HttpServletRequest req) {
|
public Message o_save(@Param("pj") String pj, @Param("gr") String gr, @Param("usrs") String[] usrs, HttpServletRequest req) {
|
||||||
if (usrs == null || usrs.length == 0) {
|
if (usrs == null || usrs.length == 0) {
|
||||||
return Message.error("error", req);
|
return Message.error("error", req);
|
||||||
|
@ -98,7 +94,6 @@ public class AdminProjectGroupUsrAct extends BaseAction {
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions("project.group:delete")
|
@RequiresPermissions("project.group:delete")
|
||||||
@PermissionTag(name = "删除项目组用户", tag = "SVN账号管理", enable = true)
|
|
||||||
public Message delete(@Param("pj") String pj, @Param("gr") String gr, @Param("usr") String usr, HttpServletRequest req) {
|
public Message delete(@Param("pj") String pj, @Param("gr") String gr, @Param("usr") String usr, HttpServletRequest req) {
|
||||||
projectGroupUsrService.delete(pj, gr, usr);
|
projectGroupUsrService.delete(pj, gr, usr);
|
||||||
svnService.exportConfig(pj);
|
svnService.exportConfig(pj);
|
||||||
|
@ -117,7 +112,6 @@ public class AdminProjectGroupUsrAct extends BaseAction {
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions("project.group:add")
|
@RequiresPermissions("project.group:add")
|
||||||
@PermissionTag(name = "添加项目组用户", tag = "SVN账号管理", enable = false)
|
|
||||||
public Message all_email(@Param("pj") String pj, HttpServletRequest req) {
|
public Message all_email(@Param("pj") String pj, HttpServletRequest req) {
|
||||||
Pj project = projectService.get(pj);
|
Pj project = projectService.get(pj);
|
||||||
ProjectConfig conf = projectConfigService.get();
|
ProjectConfig conf = projectConfigService.get();
|
||||||
|
@ -129,7 +123,6 @@ public class AdminProjectGroupUsrAct extends BaseAction {
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions("project.group:add")
|
@RequiresPermissions("project.group:add")
|
||||||
@PermissionTag(name = "添加项目组用户", tag = "SVN账号管理", enable = false)
|
|
||||||
public Message email(@Param("pj") String pj, @Param("usr") String usr, HttpServletRequest req) {
|
public Message email(@Param("pj") String pj, @Param("usr") String usr, HttpServletRequest req) {
|
||||||
Pj project = projectService.get(pj);
|
Pj project = projectService.get(pj);
|
||||||
ProjectConfig conf = projectConfigService.get();
|
ProjectConfig conf = projectConfigService.get();
|
||||||
|
@ -162,7 +155,7 @@ public class AdminProjectGroupUsrAct extends BaseAction {
|
||||||
root.put("url", url);
|
root.put("url", url);
|
||||||
List<String> urlList = new ArrayList<String>();
|
List<String> urlList = new ArrayList<String>();
|
||||||
Cnd cnd = Cnd.where("pj", "=", project.getPj()).and("usr", "=", usr.getUsr());
|
Cnd cnd = Cnd.where("pj", "=", project.getPj()).and("usr", "=", usr.getUsr());
|
||||||
List<PjGrUsr> list = projectGroupUsrService.query(cnd,null);
|
List<PjGrUsr> list = projectGroupUsrService.query(cnd, null);
|
||||||
if (Lang.isEmpty(list)) {
|
if (Lang.isEmpty(list)) {
|
||||||
log.errorf("Cant Not Set User %s Project %s Gruop", usr.getUsr(), project.getPj());
|
log.errorf("Cant Not Set User %s Project %s Gruop", usr.getUsr(), project.getPj());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
|
import org.nutz.integration.shiro.annotation.NutzRequiresPermissions;
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.lang.Lang;
|
import org.nutz.lang.Lang;
|
||||||
|
@ -14,7 +15,6 @@ import org.nutz.mvc.annotation.At;
|
||||||
import org.nutz.mvc.annotation.Ok;
|
import org.nutz.mvc.annotation.Ok;
|
||||||
import org.nutz.mvc.annotation.Param;
|
import org.nutz.mvc.annotation.Param;
|
||||||
|
|
||||||
import com.rekoe.annotation.PermissionTag;
|
|
||||||
import com.rekoe.common.Message;
|
import com.rekoe.common.Message;
|
||||||
import com.rekoe.domain.Permission;
|
import com.rekoe.domain.Permission;
|
||||||
import com.rekoe.domain.PermissionCategory;
|
import com.rekoe.domain.PermissionCategory;
|
||||||
|
@ -44,16 +44,14 @@ public class AdminRoleAct {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.user.role.list")
|
@Ok("fm:template.admin.user.role.list")
|
||||||
@RequiresPermissions("system.role:view")
|
@NutzRequiresPermissions(value = "system.role:view", name = "浏览角色", tag = "角色管理", enable = true)
|
||||||
@PermissionTag(name = "浏览角色", tag = "角色管理")
|
|
||||||
public Object list(@Param(value = "pageNumber", df = "1") int pageNumber) {
|
public Object list(@Param(value = "pageNumber", df = "1") int pageNumber) {
|
||||||
return roleService.getRoleListByPager(pageNumber, 20);
|
return roleService.getRoleListByPager(pageNumber, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.user.role.edit")
|
@Ok("fm:template.admin.user.role.edit")
|
||||||
@RequiresPermissions("system.role:edit")
|
@NutzRequiresPermissions(value = "system.role:edit", name = "编辑角色", tag = "角色管理", enable = true)
|
||||||
@PermissionTag(name = "编辑角色", tag = "角色管理")
|
|
||||||
public Object edit(@Param("id") long id, HttpServletRequest req) {
|
public Object edit(@Param("id") long id, HttpServletRequest req) {
|
||||||
Role role = roleService.view(id);
|
Role role = roleService.view(id);
|
||||||
List<PermissionCategory> pcList = permissionCategoryService.list();
|
List<PermissionCategory> pcList = permissionCategoryService.list();
|
||||||
|
@ -81,8 +79,7 @@ public class AdminRoleAct {
|
||||||
*/
|
*/
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.user.role.add")
|
@Ok("fm:template.admin.user.role.add")
|
||||||
@RequiresPermissions("system.role:add")
|
@NutzRequiresPermissions(value = "system.role:add", name = "添加角色", tag = "角色管理", enable = true)
|
||||||
@PermissionTag(name = "添加角色", tag = "角色管理")
|
|
||||||
public List<PermissionCategory> add(HttpServletRequest req) {
|
public List<PermissionCategory> add(HttpServletRequest req) {
|
||||||
return permissionCategoryService.list();
|
return permissionCategoryService.list();
|
||||||
}
|
}
|
||||||
|
@ -90,7 +87,6 @@ public class AdminRoleAct {
|
||||||
@At
|
@At
|
||||||
@Ok(">>:${obj==true?'/role/list.rk':'/admin/common/unauthorized.rk'}")
|
@Ok(">>:${obj==true?'/role/list.rk':'/admin/common/unauthorized.rk'}")
|
||||||
@RequiresPermissions("system.role:add")
|
@RequiresPermissions("system.role:add")
|
||||||
@PermissionTag(name = "添加角色", tag = "角色管理", enable = false)
|
|
||||||
public boolean save(@Param("name") String name, @Param("description") String desc, @Param("authorities") int[] ids) {
|
public boolean save(@Param("name") String name, @Param("description") String desc, @Param("authorities") int[] ids) {
|
||||||
Role role = roleService.fetchByName(name);
|
Role role = roleService.fetchByName(name);
|
||||||
if (Lang.isEmpty(role)) {
|
if (Lang.isEmpty(role)) {
|
||||||
|
@ -106,8 +102,7 @@ public class AdminRoleAct {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions("system.role:delete")
|
@NutzRequiresPermissions(value = "system.role:delete", name = "删除角色", tag = "角色管理", enable = true)
|
||||||
@PermissionTag(name = "删除角色", tag = "角色管理")
|
|
||||||
public Message delete(@Param("ids") Long[] uids, HttpServletRequest req) {
|
public Message delete(@Param("ids") Long[] uids, HttpServletRequest req) {
|
||||||
for (Long id : uids) {
|
for (Long id : uids) {
|
||||||
roleService.delete(id);
|
roleService.delete(id);
|
||||||
|
|
|
@ -80,7 +80,8 @@ public class AdminSvnUserAct extends BaseAction {
|
||||||
boolean isEmail = Strings.isEmail(user.getEmail());
|
boolean isEmail = Strings.isEmail(user.getEmail());
|
||||||
if (isOk && isEmail) {
|
if (isOk && isEmail) {
|
||||||
user.setPsw(EncryptUtil.encrypt(R.UU64().substring(0, 10)));
|
user.setPsw(EncryptUtil.encrypt(R.UU64().substring(0, 10)));
|
||||||
isOk = svnUserService.insert(user);
|
svnUserService.insert(user);
|
||||||
|
isOk = true;
|
||||||
} else {
|
} else {
|
||||||
isOk = false;
|
isOk = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,22 +13,24 @@ import org.apache.shiro.crypto.RandomNumberGenerator;
|
||||||
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
|
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
|
||||||
import org.apache.shiro.crypto.hash.Sha256Hash;
|
import org.apache.shiro.crypto.hash.Sha256Hash;
|
||||||
import org.apache.shiro.subject.Subject;
|
import org.apache.shiro.subject.Subject;
|
||||||
|
import org.nutz.dao.Chain;
|
||||||
|
import org.nutz.dao.Cnd;
|
||||||
|
import org.nutz.integration.shiro.annotation.NutzRequiresPermissions;
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.lang.Lang;
|
import org.nutz.lang.Lang;
|
||||||
import org.nutz.lang.Mirror;
|
import org.nutz.lang.Mirror;
|
||||||
|
import org.nutz.lang.Strings;
|
||||||
import org.nutz.mvc.NutConfigException;
|
import org.nutz.mvc.NutConfigException;
|
||||||
import org.nutz.mvc.annotation.At;
|
import org.nutz.mvc.annotation.At;
|
||||||
import org.nutz.mvc.annotation.Attr;
|
import org.nutz.mvc.annotation.Attr;
|
||||||
import org.nutz.mvc.annotation.Fail;
|
import org.nutz.mvc.annotation.Fail;
|
||||||
import org.nutz.mvc.annotation.Filters;
|
|
||||||
import org.nutz.mvc.annotation.Ok;
|
import org.nutz.mvc.annotation.Ok;
|
||||||
import org.nutz.mvc.annotation.Param;
|
import org.nutz.mvc.annotation.Param;
|
||||||
import org.nutz.web.Webs;
|
import org.nutz.web.Webs;
|
||||||
import org.nutz.web.ajax.Ajax;
|
import org.nutz.web.ajax.Ajax;
|
||||||
|
|
||||||
import com.alibaba.druid.util.DruidWebUtils;
|
import com.alibaba.druid.util.DruidWebUtils;
|
||||||
import com.rekoe.annotation.PermissionTag;
|
|
||||||
import com.rekoe.common.Message;
|
import com.rekoe.common.Message;
|
||||||
import com.rekoe.common.page.Pagination;
|
import com.rekoe.common.page.Pagination;
|
||||||
import com.rekoe.domain.Role;
|
import com.rekoe.domain.Role;
|
||||||
|
@ -59,35 +61,29 @@ public class AdminUserAct {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.user.list")
|
@Ok("fm:template.admin.user.list")
|
||||||
@RequiresPermissions({ "system.user:view" })
|
@NutzRequiresPermissions(value = "system.user:view", name = "浏览账号", tag = "账号管理", enable = true)
|
||||||
@PermissionTag(name = "浏览账号", tag = "账号管理")
|
|
||||||
public Pagination list(@Param(value = "pageNumber", df = "1") int pageNumber) {
|
public Pagination list(@Param(value = "pageNumber", df = "1") int pageNumber) {
|
||||||
return userService.getUserListByPager(pageNumber, 20);
|
return userService.getUserListByPager(pageNumber, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.user.add")
|
@Ok("fm:template.admin.user.add")
|
||||||
@RequiresPermissions({ "system.user:add" })
|
@RequiresPermissions("system.user:add")
|
||||||
@PermissionTag(name = "添加账号", tag = "账号管理", enable = false)
|
|
||||||
public List<Role> add() {
|
public List<Role> add() {
|
||||||
return roleService.list();
|
return roleService.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions("system.user:delete")
|
@NutzRequiresPermissions(value = "system.user:delete", name = "删除账号", tag = "账号管理", enable = true)
|
||||||
@PermissionTag(name = "删除账号", tag = "账号管理")
|
|
||||||
public Message delete(@Param("ids") int[] uids, HttpServletRequest req) {
|
public Message delete(@Param("ids") int[] uids, HttpServletRequest req) {
|
||||||
for (int id : uids) {
|
userService.update(Chain.make("is_del", true), Cnd.where("id", "id", uids));
|
||||||
userService.delete(id);
|
|
||||||
}
|
|
||||||
return Message.success("admin.message.success", req);
|
return Message.success("admin.message.success", req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok(">>:${obj==true?'/admin/user/list.rk':'/admin/common/unauthorized.rk'}")
|
@Ok(">>:${obj==true?'/admin/user/list.rk':'/admin/common/unauthorized.rk'}")
|
||||||
@RequiresPermissions({ "system.user:add" })
|
@NutzRequiresPermissions(value = "system.user:add", name = "添加账号", tag = "账号管理", enable = true)
|
||||||
@PermissionTag(name = "添加账号", tag = "账号管理", enable = false)
|
|
||||||
public boolean save(HttpServletRequest req, @Param("username") String username, @Param("password") String password, @Param("isEnabled") boolean isEnabled, @Param("roleIds") int[] roleIds) {
|
public boolean save(HttpServletRequest req, @Param("username") String username, @Param("password") String password, @Param("isEnabled") boolean isEnabled, @Param("roleIds") int[] roleIds) {
|
||||||
return userService.save(username, password, isEnabled, req.getRemoteAddr(), roleIds);
|
return userService.save(username, password, isEnabled, req.getRemoteAddr(), roleIds);
|
||||||
}
|
}
|
||||||
|
@ -95,21 +91,19 @@ public class AdminUserAct {
|
||||||
@At("/check/username")
|
@At("/check/username")
|
||||||
@Ok("raw")
|
@Ok("raw")
|
||||||
public boolean checkName(@Param("username") String username) {
|
public boolean checkName(@Param("username") String username) {
|
||||||
User user = userService.fetchByName(username);
|
return Lang.isEmpty(userService.fetchByName(username)) ? true : false;
|
||||||
return Lang.isEmpty(user) ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@At("/check_email")
|
@At("/check_email")
|
||||||
@Ok("raw")
|
@Ok("raw")
|
||||||
public boolean checkEmail(@Param("email") String email) {
|
public boolean checkEmail(@Param("email") String email) {
|
||||||
return StringUtils.isBlank(email) ? false : email.matches("\\w+@\\w+\\.(com\\.cn)|\\w+@\\w+\\.(com|cn)");
|
return Strings.isEmail(email);
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.user.edit")
|
@Ok("fm:template.admin.user.edit")
|
||||||
@Fail("json")
|
@Fail("json")
|
||||||
@RequiresPermissions({ "system.user:edit" })
|
@NutzRequiresPermissions(value = "system.user:edit", name = "编辑账号", tag = "账号管理", enable = true)
|
||||||
@PermissionTag(name = "编辑账号", tag = "账号管理")
|
|
||||||
public User edit(@Attr(Webs.ME) User user, @Param("id") long id, HttpServletRequest req) {
|
public User edit(@Attr(Webs.ME) User user, @Param("id") long id, HttpServletRequest req) {
|
||||||
User editUser = userService.view(id);
|
User editUser = userService.view(id);
|
||||||
if (Lang.isEmpty(editUser) || editUser.isLocked()) {
|
if (Lang.isEmpty(editUser) || editUser.isLocked()) {
|
||||||
|
@ -131,7 +125,7 @@ public class AdminUserAct {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok(">>:/admin/user/list")
|
@Ok(">>:/admin/user/list")
|
||||||
@RequiresPermissions({ "system.user:edit" })
|
@RequiresPermissions("system.user:edit")
|
||||||
public Object update(@Param("id") long id, @Param("allServer") Boolean allServer, @Param("serverIds") Integer[] serverIds, @Param("roleIds") Integer[] roleIds) {
|
public Object update(@Param("id") long id, @Param("allServer") Boolean allServer, @Param("serverIds") Integer[] serverIds, @Param("roleIds") Integer[] roleIds) {
|
||||||
User user = userService.fetch(id);
|
User user = userService.fetch(id);
|
||||||
userService.removeUserUpdata(user);
|
userService.removeUserUpdata(user);
|
||||||
|
@ -145,8 +139,7 @@ public class AdminUserAct {
|
||||||
*/
|
*/
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions("system.user:lock")
|
@NutzRequiresPermissions(value = "system.user:lock", name = "锁定账号", tag = "账号管理", enable = true)
|
||||||
@PermissionTag(name = "锁定账号", tag = "账号管理")
|
|
||||||
public Message lock(@Param("id") long id, HttpServletRequest req) {
|
public Message lock(@Param("id") long id, HttpServletRequest req) {
|
||||||
User user = userService.view(id);
|
User user = userService.view(id);
|
||||||
if (Lang.isEmpty(user)) {
|
if (Lang.isEmpty(user)) {
|
||||||
|
@ -178,6 +171,7 @@ public class AdminUserAct {
|
||||||
|
|
||||||
@At("/profile/edit")
|
@At("/profile/edit")
|
||||||
@Ok("fm:template.admin.profile.edit")
|
@Ok("fm:template.admin.profile.edit")
|
||||||
|
@RequiresUser
|
||||||
public Subject profileEdit() {
|
public Subject profileEdit() {
|
||||||
return SecurityUtils.getSubject();
|
return SecurityUtils.getSubject();
|
||||||
}
|
}
|
||||||
|
@ -188,7 +182,6 @@ public class AdminUserAct {
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.user.add_user")
|
@Ok("fm:template.admin.user.add_user")
|
||||||
@RequiresPermissions("system.user:add")
|
@RequiresPermissions("system.user:add")
|
||||||
@PermissionTag(name = "添加账号", tag = "账号管理")
|
|
||||||
public void add_user() {
|
public void add_user() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +212,6 @@ public class AdminUserAct {
|
||||||
|
|
||||||
@At("/profile/re_update")
|
@At("/profile/re_update")
|
||||||
@Ok(">>:${obj?'/admin/main':'/admin/common/unauthorized.rk'}")
|
@Ok(">>:${obj?'/admin/main':'/admin/common/unauthorized.rk'}")
|
||||||
@Filters
|
|
||||||
public boolean regUpate(@Param("username") String username, @Param("password") String password, @Attr("me") User suser) {
|
public boolean regUpate(@Param("username") String username, @Param("password") String password, @Attr("me") User suser) {
|
||||||
if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
|
if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.nutz.integration.shiro.annotation.NutzRequiresPermissions;
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.mvc.annotation.At;
|
import org.nutz.mvc.annotation.At;
|
||||||
|
@ -39,24 +40,21 @@ public class PermissionAct {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.user.permission.list")
|
@Ok("fm:template.admin.user.permission.list")
|
||||||
@RequiresPermissions({ "system.permission:view" })
|
@NutzRequiresPermissions(value = "system.permission:view", name = "浏览权限", tag = "权限管理", enable = true)
|
||||||
@PermissionTag(name = "浏览权限", tag = "权限管理")
|
|
||||||
public Pagination list(@Param(value = "pageNumber", df = "1") int pageNumber) {
|
public Pagination list(@Param(value = "pageNumber", df = "1") int pageNumber) {
|
||||||
return permissionService.getPermissionListByPager(pageNumber);
|
return permissionService.getPermissionListByPager(pageNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@At("/list_category/?")
|
@At("/list_category/?")
|
||||||
@Ok("fm:template.admin.user.permission.list")
|
@Ok("fm:template.admin.user.permission.list")
|
||||||
@RequiresPermissions({ "system.permission:view" })
|
@RequiresPermissions("system.permission:view")
|
||||||
@PermissionTag(name = "浏览权限分类", tag = "权限管理", enable = false)
|
public Pagination listCategory(String id, @Param(value = "pageNumber", df = "1") int pageNumber) {
|
||||||
public Pagination listCategory(String id, @Param(value = "pageNumber", df = "1") Integer pageNumber) {
|
|
||||||
return permissionService.getPermissionListByPager(pageNumber, id);
|
return permissionService.getPermissionListByPager(pageNumber, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.user.permission.edit")
|
@Ok("fm:template.admin.user.permission.edit")
|
||||||
@RequiresPermissions({ "system.permission:edit" })
|
@NutzRequiresPermissions(value = "system.permission:edit", name = "编辑限分类", tag = "权限管理", enable = true)
|
||||||
@PermissionTag(name = "编辑限分类", tag = "权限管理")
|
|
||||||
public List<PermissionCategory> edit(long id, HttpServletRequest req) {
|
public List<PermissionCategory> edit(long id, HttpServletRequest req) {
|
||||||
Permission permission = permissionService.fetch(id);
|
Permission permission = permissionService.fetch(id);
|
||||||
req.setAttribute("permission", permission);
|
req.setAttribute("permission", permission);
|
||||||
|
@ -65,8 +63,7 @@ public class PermissionAct {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.user.permission.add")
|
@Ok("fm:template.admin.user.permission.add")
|
||||||
@RequiresPermissions({ "system.permission:add" })
|
@NutzRequiresPermissions(value = "system.permission:add", name = "添加权限", tag = "权限管理", enable = true)
|
||||||
@PermissionTag(name = "添加权限", tag = "权限管理")
|
|
||||||
public List<PermissionCategory> add() {
|
public List<PermissionCategory> add() {
|
||||||
List<PermissionCategory> list = permissionCategoryService.list();
|
List<PermissionCategory> list = permissionCategoryService.list();
|
||||||
return list;
|
return list;
|
||||||
|
@ -74,8 +71,7 @@ public class PermissionAct {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions({ "system.permission:delete" })
|
@NutzRequiresPermissions(value = "system.permission:delete", name = "删除权限", tag = "权限管理", enable = true)
|
||||||
@PermissionTag(name = "删除权限", tag = "权限管理")
|
|
||||||
public Message delete(@Attr(Webs.ME) User user, @Param("id") long id, HttpServletRequest req) {
|
public Message delete(@Attr(Webs.ME) User user, @Param("id") long id, HttpServletRequest req) {
|
||||||
Permission permission = permissionService.fetch(id);
|
Permission permission = permissionService.fetch(id);
|
||||||
if (permission.isLocked() && !user.isSystem()) {
|
if (permission.isLocked() && !user.isSystem()) {
|
||||||
|
@ -87,8 +83,7 @@ public class PermissionAct {
|
||||||
|
|
||||||
@At
|
@At
|
||||||
@Ok(">>:/admin/permission/list.rk")
|
@Ok(">>:/admin/permission/list.rk")
|
||||||
@RequiresPermissions({ "system.permission:edit" })
|
@RequiresPermissions("system.permission:edit")
|
||||||
@PermissionTag(name = "编辑权限", tag = "权限管理", enable = false)
|
|
||||||
public boolean update(@Param("::permission.") Permission permission, @Param("description") String description, @Param("name") String name, @Param("id") String id) {
|
public boolean update(@Param("::permission.") Permission permission, @Param("description") String description, @Param("name") String name, @Param("id") String id) {
|
||||||
permission.setName(name);
|
permission.setName(name);
|
||||||
permission.setDescription(description);
|
permission.setDescription(description);
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.nutz.mvc.annotation.At;
|
||||||
import org.nutz.mvc.annotation.Ok;
|
import org.nutz.mvc.annotation.Ok;
|
||||||
import org.nutz.mvc.annotation.Param;
|
import org.nutz.mvc.annotation.Param;
|
||||||
|
|
||||||
import com.rekoe.annotation.PermissionTag;
|
|
||||||
import com.rekoe.common.Message;
|
import com.rekoe.common.Message;
|
||||||
import com.rekoe.common.page.Pagination;
|
import com.rekoe.common.page.Pagination;
|
||||||
import com.rekoe.domain.PermissionCategory;
|
import com.rekoe.domain.PermissionCategory;
|
||||||
|
@ -33,7 +32,6 @@ public class PermissionCategoryAct {
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.user.permission_category.list")
|
@Ok("fm:template.admin.user.permission_category.list")
|
||||||
@RequiresPermissions({ "system.permission:view" })
|
@RequiresPermissions({ "system.permission:view" })
|
||||||
@PermissionTag(name = "浏览权限", tag = "权限管理", enable = false)
|
|
||||||
public Pagination list(@Param(value = "pageNumber", df = "1") Integer pageNumber) {
|
public Pagination list(@Param(value = "pageNumber", df = "1") Integer pageNumber) {
|
||||||
return permissionCategoryService.getPermissionCategoryListByPager(pageNumber);
|
return permissionCategoryService.getPermissionCategoryListByPager(pageNumber);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +39,6 @@ public class PermissionCategoryAct {
|
||||||
@At
|
@At
|
||||||
@Ok("fm:template.admin.user.permission_category.edit")
|
@Ok("fm:template.admin.user.permission_category.edit")
|
||||||
@RequiresPermissions({ "system.permission:edit" })
|
@RequiresPermissions({ "system.permission:edit" })
|
||||||
@PermissionTag(name = "编辑权限", tag = "权限管理", enable = false)
|
|
||||||
public PermissionCategory edit(String id) {
|
public PermissionCategory edit(String id) {
|
||||||
return permissionCategoryService.fetchByID(id);
|
return permissionCategoryService.fetchByID(id);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +46,6 @@ public class PermissionCategoryAct {
|
||||||
@At
|
@At
|
||||||
@Ok(">>:/admin/permission/category/list.rk")
|
@Ok(">>:/admin/permission/category/list.rk")
|
||||||
@RequiresPermissions({ "system.permission:edit" })
|
@RequiresPermissions({ "system.permission:edit" })
|
||||||
@PermissionTag(name = "编辑权限", tag = "权限管理", enable = false)
|
|
||||||
public boolean update(@Param("name") String name, @Param("id") String id) {
|
public boolean update(@Param("name") String name, @Param("id") String id) {
|
||||||
permissionCategoryService.update(Chain.make("name", name), Cnd.where("id", "=", id));
|
permissionCategoryService.update(Chain.make("name", name), Cnd.where("id", "=", id));
|
||||||
return true;
|
return true;
|
||||||
|
@ -64,7 +60,6 @@ public class PermissionCategoryAct {
|
||||||
@At
|
@At
|
||||||
@Ok(">>:/admin/permission/category/list.rk")
|
@Ok(">>:/admin/permission/category/list.rk")
|
||||||
@RequiresPermissions({ "system.permission:add" })
|
@RequiresPermissions({ "system.permission:add" })
|
||||||
@PermissionTag(name = "添加权限", tag = "权限管理", enable = false)
|
|
||||||
public void save(@Param("name") String name) {
|
public void save(@Param("name") String name) {
|
||||||
PermissionCategory pc = new PermissionCategory();
|
PermissionCategory pc = new PermissionCategory();
|
||||||
pc.setName(name);
|
pc.setName(name);
|
||||||
|
@ -74,7 +69,6 @@ public class PermissionCategoryAct {
|
||||||
@At
|
@At
|
||||||
@Ok("json")
|
@Ok("json")
|
||||||
@RequiresPermissions({ "system.permission:delete" })
|
@RequiresPermissions({ "system.permission:delete" })
|
||||||
@PermissionTag(name = "删除权限", tag = "权限管理", enable = false)
|
|
||||||
public Message delete(@Param("id") String id, HttpServletRequest req) {
|
public Message delete(@Param("id") String id, HttpServletRequest req) {
|
||||||
PermissionCategory pc = permissionCategoryService.fetchByID(id);
|
PermissionCategory pc = permissionCategoryService.fetchByID(id);
|
||||||
if (pc.isLocked()) {
|
if (pc.isLocked()) {
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.rekoe.service;
|
||||||
|
|
||||||
|
public interface AuthorityService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扫描RequiresPermissions和RequiresRoles注解
|
||||||
|
*
|
||||||
|
* @param pkg
|
||||||
|
* 需要扫描的package
|
||||||
|
*/
|
||||||
|
void initFormPackage(String... pkgs);
|
||||||
|
}
|
|
@ -0,0 +1,161 @@
|
||||||
|
package com.rekoe.service;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.nutz.dao.Cnd;
|
||||||
|
import org.nutz.dao.Dao;
|
||||||
|
import org.nutz.integration.shiro.annotation.NutzRequiresPermissions;
|
||||||
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
|
import org.nutz.lang.ContinueLoop;
|
||||||
|
import org.nutz.lang.Each;
|
||||||
|
import org.nutz.lang.ExitLoop;
|
||||||
|
import org.nutz.lang.Lang;
|
||||||
|
import org.nutz.lang.LoopException;
|
||||||
|
import org.nutz.resource.Scans;
|
||||||
|
|
||||||
|
import com.rekoe.domain.Permission;
|
||||||
|
import com.rekoe.domain.PermissionCategory;
|
||||||
|
|
||||||
|
@IocBean(name = "authorityService")
|
||||||
|
public class AuthorityServiceImpl implements AuthorityService {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Dao dao;
|
||||||
|
|
||||||
|
class PermissionTagClzz {
|
||||||
|
|
||||||
|
private String premission;
|
||||||
|
private String tag;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public PermissionTagClzz(String premission, String tag, String name) {
|
||||||
|
super();
|
||||||
|
this.premission = premission;
|
||||||
|
this.tag = tag;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPremission() {
|
||||||
|
return premission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPremission(String premission) {
|
||||||
|
this.premission = premission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTag() {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTag(String tag) {
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initFormPackage(String... pkgs) {
|
||||||
|
List<Class<?>> allClazz = new ArrayList<>();
|
||||||
|
for (String pkg : pkgs) {
|
||||||
|
List<Class<?>> scanPackage = Scans.me().scanPackage(pkg);
|
||||||
|
allClazz.addAll(scanPackage);
|
||||||
|
}
|
||||||
|
Set<String> rpTagNames = new HashSet<>();
|
||||||
|
final Set<String> permissions = new HashSet<String>();
|
||||||
|
final Map<String, PermissionTagClzz> perTagMap = new HashMap<>();
|
||||||
|
for (Class<?> klass : allClazz) {
|
||||||
|
for (Method method : klass.getMethods()) {
|
||||||
|
NutzRequiresPermissions rp = method.getAnnotation(NutzRequiresPermissions.class);
|
||||||
|
if (rp != null && rp.value() != null) {
|
||||||
|
if (rp.enable() == false)
|
||||||
|
continue;
|
||||||
|
rpTagNames.add(rp.tag());
|
||||||
|
for (String permission : rp.value()) {
|
||||||
|
if (permission != null && !permission.endsWith("*")) {
|
||||||
|
permissions.add(permission);
|
||||||
|
perTagMap.put(permission, new PermissionTagClzz(permission, rp.tag(), rp.name()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 整理出 需要添加权限的所有的权限分类
|
||||||
|
final Iterator<Entry<String, PermissionTagClzz>> iter = perTagMap.entrySet().iterator();
|
||||||
|
final Set<String> perTags = new HashSet<String>();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
Entry<String, PermissionTagClzz> entry = iter.next();
|
||||||
|
PermissionTagClzz ptc = entry.getValue();
|
||||||
|
String name = ptc.getTag();
|
||||||
|
perTags.add(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
dao.each(PermissionCategory.class, null, new Each<PermissionCategory>() {
|
||||||
|
public void invoke(int index, PermissionCategory ele, int length) throws ExitLoop, ContinueLoop, LoopException {
|
||||||
|
perTags.remove(ele.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 把分类数据插入到数据库
|
||||||
|
final Map<String, String> tagIds = new HashMap<String, String>();
|
||||||
|
for (String name : perTags) {
|
||||||
|
PermissionCategory pc = new PermissionCategory();
|
||||||
|
pc.setLocked(true);
|
||||||
|
pc.setName(name);
|
||||||
|
dao.insert(pc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 把全部权限查出来一一检查
|
||||||
|
dao.each(Permission.class, null, new Each<Permission>() {
|
||||||
|
public void invoke(int index, Permission ele, int length) throws ExitLoop, ContinueLoop, LoopException {
|
||||||
|
permissions.remove(ele.getName());
|
||||||
|
perTagMap.remove(ele.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Iterator<Entry<String, PermissionTagClzz>> iterator = perTagMap.entrySet().iterator();
|
||||||
|
Set<String> tagNames = new HashSet<String>();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
Entry<String, PermissionTagClzz> entry = iterator.next();
|
||||||
|
tagNames.add(entry.getValue().getTag());
|
||||||
|
}
|
||||||
|
dao.each(PermissionCategory.class, Cnd.where("name", "in", tagNames), new Each<PermissionCategory>() {
|
||||||
|
public void invoke(int index, PermissionCategory ele, int length) throws ExitLoop, ContinueLoop, LoopException {
|
||||||
|
tagIds.put(ele.getName(), ele.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
List<Permission> newSet = new ArrayList<>();
|
||||||
|
final Iterator<Entry<String, PermissionTagClzz>> $iter = perTagMap.entrySet().iterator();
|
||||||
|
while ($iter.hasNext()) {
|
||||||
|
Entry<String, PermissionTagClzz> entry = $iter.next();
|
||||||
|
PermissionTagClzz ptc = entry.getValue();
|
||||||
|
String name = ptc.getTag();
|
||||||
|
Permission p = new Permission();
|
||||||
|
p.setDescription(ptc.getName());
|
||||||
|
p.setPermissionCategoryId(tagIds.get(name));
|
||||||
|
p.setName(entry.getKey());
|
||||||
|
newSet.add(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Lang.isEmpty(newSet)) {
|
||||||
|
dao.fastInsert(newSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -62,18 +62,18 @@ public class BaseService<T> extends IdEntityService<T> {
|
||||||
public void delete(String[] ids) {
|
public void delete(String[] ids) {
|
||||||
dao().clear(getEntityClass(), Cnd.where("id", "in", ids));
|
dao().clear(getEntityClass(), Cnd.where("id", "in", ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(String id) {
|
public void delete(String id) {
|
||||||
dao().clear(getEntityClass(), Cnd.where("id", "in", id));
|
dao().clear(getEntityClass(), Cnd.where("id", "in", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean insert(T t) {
|
public T insert(T t) {
|
||||||
try {
|
try {
|
||||||
dao().insert(t);
|
return dao().insert(t);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getRandomStr(String str, String num) {
|
protected String getRandomStr(String str, String num) {
|
||||||
|
|
|
@ -12,11 +12,9 @@ import org.nutz.service.IdEntityService;
|
||||||
|
|
||||||
import com.rekoe.common.page.Pagination;
|
import com.rekoe.common.page.Pagination;
|
||||||
import com.rekoe.domain.PermissionCategory;
|
import com.rekoe.domain.PermissionCategory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 科技㊣²º¹³
|
* @author 科技㊣²º¹³ 2014年2月3日 下午4:48:45 http://www.rekoe.com QQ:5382211
|
||||||
* 2014年2月3日 下午4:48:45
|
|
||||||
* http://www.rekoe.com
|
|
||||||
* QQ:5382211
|
|
||||||
*/
|
*/
|
||||||
@IocBean(args = { "refer:dao" })
|
@IocBean(args = { "refer:dao" })
|
||||||
public class PermissionCategoryService extends IdEntityService<PermissionCategory> {
|
public class PermissionCategoryService extends IdEntityService<PermissionCategory> {
|
||||||
|
@ -36,8 +34,8 @@ public class PermissionCategoryService extends IdEntityService<PermissionCategor
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insert(PermissionCategory permission) {
|
public PermissionCategory insert(PermissionCategory permission) {
|
||||||
dao().insert(permission);
|
return dao().insert(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermissionCategory fetchByID(String id) {
|
public PermissionCategory fetchByID(String id) {
|
||||||
|
@ -48,8 +46,8 @@ public class PermissionCategoryService extends IdEntityService<PermissionCategor
|
||||||
return fetchByID(id);
|
return fetchByID(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(PermissionCategory permission) {
|
public int update(PermissionCategory permission) {
|
||||||
dao().update(permission);
|
return dao().update(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(String id) {
|
public void remove(String id) {
|
||||||
|
@ -60,9 +58,8 @@ public class PermissionCategoryService extends IdEntityService<PermissionCategor
|
||||||
return Lang.isEmpty(pageNumber) ? 1 : pageNumber;
|
return Lang.isEmpty(pageNumber) ? 1 : pageNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pagination getPermissionCategoryListByPager(Integer pageNumber) {
|
public Pagination getPermissionCategoryListByPager(int pageNumber) {
|
||||||
int pageSize = 20;
|
int pageSize = 20;
|
||||||
pageNumber = getPageNumber(pageNumber);
|
|
||||||
Pager pager = dao().createPager(pageNumber, pageSize);
|
Pager pager = dao().createPager(pageNumber, pageSize);
|
||||||
List<PermissionCategory> list = dao().query(PermissionCategory.class, null, pager);
|
List<PermissionCategory> list = dao().query(PermissionCategory.class, null, pager);
|
||||||
pager.setRecordCount(dao().count(PermissionCategory.class, null));
|
pager.setRecordCount(dao().count(PermissionCategory.class, null));
|
||||||
|
|
|
@ -44,16 +44,16 @@ public class PermissionService extends IdEntityService<Permission> {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insert(Permission permission) {
|
public Permission insert(Permission permission) {
|
||||||
dao().insert(permission);
|
return dao().insert(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Permission view(Long id) {
|
public Permission view(Long id) {
|
||||||
return fetch(id);
|
return fetch(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Permission permission) {
|
public int update(Permission permission) {
|
||||||
dao().update(permission);
|
return dao().update(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getPageNumber(Integer pageNumber) {
|
protected int getPageNumber(Integer pageNumber) {
|
||||||
|
|
|
@ -35,9 +35,8 @@ public class ProjectConfigService extends BaseService<ProjectConfig> {
|
||||||
dao().update(conf);
|
dao().update(conf);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public boolean update(ProjectConfig conf) {
|
public int update(ProjectConfig conf) {
|
||||||
dao().update(conf);
|
return dao().update(conf);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|
|
@ -175,8 +175,8 @@ public class ProjectService extends BaseService<Pj> {
|
||||||
dao().clear(getEntityClass(), Cnd.where("pj", "=", pj));
|
dao().clear(getEntityClass(), Cnd.where("pj", "=", pj));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Pj pj) {
|
public int update(Pj pj) {
|
||||||
dao().update(pj);
|
return dao().update(pj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,10 +32,9 @@ public class RoleService extends BaseService<Role> {
|
||||||
return query(null, null);
|
return query(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean insert(Role role) {
|
public Role insert(Role role) {
|
||||||
role = dao().insert(role);
|
role = dao().insert(role);
|
||||||
dao().insertRelation(role, "permissions");
|
return dao().insertRelation(role, "permissions");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(Long id) {
|
public void delete(Long id) {
|
||||||
|
@ -48,8 +47,8 @@ public class RoleService extends BaseService<Role> {
|
||||||
return dao().fetchLinks(fetch(id), "permissions");
|
return dao().fetchLinks(fetch(id), "permissions");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Role role) {
|
public int update(Role role) {
|
||||||
dao().update(role);
|
return dao().update(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Role fetchByName(String name) {
|
public Role fetchByName(String name) {
|
||||||
|
|
|
@ -1,36 +1,20 @@
|
||||||
package com.rekoe.service;
|
package com.rekoe.service;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
||||||
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
|
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
|
||||||
import org.apache.shiro.crypto.hash.Sha256Hash;
|
import org.apache.shiro.crypto.hash.Sha256Hash;
|
||||||
import org.nutz.dao.Chain;
|
import org.nutz.dao.Chain;
|
||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
import org.nutz.dao.Dao;
|
import org.nutz.dao.Dao;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.lang.ContinueLoop;
|
|
||||||
import org.nutz.lang.Each;
|
|
||||||
import org.nutz.lang.ExitLoop;
|
|
||||||
import org.nutz.lang.Lang;
|
import org.nutz.lang.Lang;
|
||||||
import org.nutz.lang.LoopException;
|
|
||||||
import org.nutz.lang.Times;
|
import org.nutz.lang.Times;
|
||||||
import org.nutz.lang.random.R;
|
import org.nutz.lang.random.R;
|
||||||
import org.nutz.resource.Scans;
|
|
||||||
|
|
||||||
import com.rekoe.annotation.PermissionTag;
|
|
||||||
import com.rekoe.common.page.Pagination;
|
import com.rekoe.common.page.Pagination;
|
||||||
import com.rekoe.domain.Permission;
|
|
||||||
import com.rekoe.domain.PermissionCategory;
|
|
||||||
import com.rekoe.domain.Role;
|
import com.rekoe.domain.Role;
|
||||||
import com.rekoe.domain.User;
|
import com.rekoe.domain.User;
|
||||||
|
|
||||||
|
@ -51,8 +35,8 @@ public class UserService extends BaseService<User> {
|
||||||
return query(null, null);
|
return query(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(User user) {
|
public int update(User user) {
|
||||||
dao().update(user);
|
return dao().update(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(long uid, String password, boolean isLocked, Integer[] ids) {
|
public void update(long uid, String password, boolean isLocked, Integer[] ids) {
|
||||||
|
@ -78,10 +62,9 @@ public class UserService extends BaseService<User> {
|
||||||
dao().update(User.class, Chain.make("password", new Sha256Hash(password, salt, 1024).toBase64()).add("salt", salt), Cnd.where("id", "=", uid));
|
dao().update(User.class, Chain.make("password", new Sha256Hash(password, salt, 1024).toBase64()).add("salt", salt), Cnd.where("id", "=", uid));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean insert(User user) {
|
public User insert(User user) {
|
||||||
user = dao().insert(user);
|
user = dao().insert(user);
|
||||||
dao().insertRelation(user, "roles");
|
return dao().insertRelation(user, "roles");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean save(String username, String password, boolean isEnabled, String addr, int[] roleIds) {
|
public boolean save(String username, String password, boolean isEnabled, String addr, int[] roleIds) {
|
||||||
|
@ -184,136 +167,6 @@ public class UserService extends BaseService<User> {
|
||||||
dao().update(user, "^(locked)$");
|
dao().update(user, "^(locked)$");
|
||||||
}
|
}
|
||||||
|
|
||||||
class PermissionTagClzz {
|
|
||||||
|
|
||||||
private String premission;
|
|
||||||
private String tag;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public PermissionTagClzz(String premission, String tag, String name) {
|
|
||||||
super();
|
|
||||||
this.premission = premission;
|
|
||||||
this.tag = tag;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPremission() {
|
|
||||||
return premission;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPremission(String premission) {
|
|
||||||
this.premission = premission;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTag() {
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTag(String tag) {
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initFormPackages(String... pkgs) {
|
|
||||||
List<Class<?>> allClazz = new ArrayList<>();
|
|
||||||
for (String pkg : pkgs) {
|
|
||||||
List<Class<?>> scanPackage = Scans.me().scanPackage(pkg);
|
|
||||||
allClazz.addAll(scanPackage);
|
|
||||||
}
|
|
||||||
Set<String> rpTagNames = new HashSet<>();
|
|
||||||
final Set<String> permissions = new HashSet<String>();
|
|
||||||
final Map<String, PermissionTagClzz> perTagMap = new HashMap<>();
|
|
||||||
for (Class<?> klass : allClazz) {
|
|
||||||
for (Method method : klass.getMethods()) {
|
|
||||||
RequiresPermissions rp = method.getAnnotation(RequiresPermissions.class);
|
|
||||||
if (rp != null && rp.value() != null) {
|
|
||||||
PermissionTag rpTag = method.getAnnotation(PermissionTag.class);
|
|
||||||
if (rpTag == null || rpTag.enable() == false)
|
|
||||||
continue;
|
|
||||||
rpTagNames.add(rpTag.tag());
|
|
||||||
for (String permission : rp.value()) {
|
|
||||||
if (permission != null && !permission.endsWith("*")) {
|
|
||||||
permissions.add(permission);
|
|
||||||
perTagMap.put(permission, new PermissionTagClzz(permission, rpTag.tag(), rpTag.name()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 整理出 需要添加权限的所有的权限分类
|
|
||||||
final Iterator<Entry<String, PermissionTagClzz>> iter = perTagMap.entrySet().iterator();
|
|
||||||
final Set<String> perTags = new HashSet<String>();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
Entry<String, PermissionTagClzz> entry = iter.next();
|
|
||||||
PermissionTagClzz ptc = entry.getValue();
|
|
||||||
String name = ptc.getTag();
|
|
||||||
perTags.add(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
dao().each(PermissionCategory.class, null, new Each<PermissionCategory>() {
|
|
||||||
public void invoke(int index, PermissionCategory ele, int length) throws ExitLoop, ContinueLoop, LoopException {
|
|
||||||
perTags.remove(ele.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 把分类数据插入到数据库
|
|
||||||
final Map<String, String> tagIds = new HashMap<String, String>();
|
|
||||||
for (String name : perTags) {
|
|
||||||
PermissionCategory pc = new PermissionCategory();
|
|
||||||
pc.setLocked(true);
|
|
||||||
pc.setName(name);
|
|
||||||
dao().insert(pc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 把全部权限查出来一一检查
|
|
||||||
dao().each(Permission.class, null, new Each<Permission>() {
|
|
||||||
public void invoke(int index, Permission ele, int length) throws ExitLoop, ContinueLoop, LoopException {
|
|
||||||
permissions.remove(ele.getName());
|
|
||||||
perTagMap.remove(ele.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Iterator<Entry<String, PermissionTagClzz>> iterator = perTagMap.entrySet().iterator();
|
|
||||||
Set<String> tagNames = new HashSet<String>();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
Entry<String, PermissionTagClzz> entry = iterator.next();
|
|
||||||
tagNames.add(entry.getValue().getTag());
|
|
||||||
}
|
|
||||||
dao().each(PermissionCategory.class, Cnd.where("name", "in", tagNames), new Each<PermissionCategory>() {
|
|
||||||
public void invoke(int index, PermissionCategory ele, int length) throws ExitLoop, ContinueLoop, LoopException {
|
|
||||||
tagIds.put(ele.getName(), ele.getId());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
List<Permission> newSet = new ArrayList<>();
|
|
||||||
final Iterator<Entry<String, PermissionTagClzz>> $iter = perTagMap.entrySet().iterator();
|
|
||||||
while ($iter.hasNext()) {
|
|
||||||
Entry<String, PermissionTagClzz> entry = $iter.next();
|
|
||||||
PermissionTagClzz ptc = entry.getValue();
|
|
||||||
String name = ptc.getTag();
|
|
||||||
Permission p = new Permission();
|
|
||||||
p.setDescription(ptc.getName());
|
|
||||||
p.setLocked(true);
|
|
||||||
p.setPermissionCategoryId(tagIds.get(name));
|
|
||||||
p.setName(entry.getKey());
|
|
||||||
newSet.add(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Lang.isEmpty(newSet)) {
|
|
||||||
dao().fastInsert(newSet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadRolePermission(User user) {
|
public void loadRolePermission(User user) {
|
||||||
List<Role> roleList = user.getRoles();
|
List<Role> roleList = user.getRoles();
|
||||||
for (Role role : roleList) {
|
for (Role role : roleList) {
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class PublicKeyAuthentication {
|
||||||
sess.close();
|
sess.close();
|
||||||
/* Close the connection */
|
/* Close the connection */
|
||||||
conn.close();
|
conn.close();
|
||||||
|
br.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace(System.err);
|
e.printStackTrace(System.err);
|
||||||
System.exit(2);
|
System.exit(2);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
db.url=jdbc:mysql://192.168.1.223:3306/rk_svnadmin?useUnicode=true&characterEncoding=utf-8
|
#db.url=jdbc:mysql://192.168.3.2:3306/rk_svnadmin?useUnicode=true&characterEncoding=utf-8
|
||||||
|
db.url=jdbc:mysql://192.168.3.223:3306/rk_svnadmin?useUnicode=true&characterEncoding=utf-8
|
||||||
db.username=root
|
db.username=root
|
||||||
|
#db.password=kfzx_sy!@#%
|
||||||
db.password=root
|
db.password=root
|
||||||
db.maxActive=50
|
db.maxActive=50
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue