From a48459a10fcacf7a7e8418660c25b32d2ac9ebbf Mon Sep 17 00:00:00 2001 From: rekoe Date: Thu, 24 Mar 2016 18:15:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rekoe/module/admin/AdminProjectAct.java | 38 ++++++++++++++++ .../com/rekoe/service/ProjectAuthService.java | 15 +++++++ .../rekoe/service/ProjectGroupService.java | 12 ++++++ .../com/rekoe/service/ProjectService.java | 43 +++++++++++++++---- .../com/rekoe/service/ProjectUserService.java | 13 ++++++ src/main/resources/ioc/dao.js | 2 +- .../WEB-INF/template/admin/project/config.ftl | 22 ++++++++++ .../template/admin/project/frame/left.ftl | 3 +- src/main/webapp/res/cms/js/admin.js | 26 +++++++++++ 9 files changed, 163 insertions(+), 11 deletions(-) create mode 100644 src/main/webapp/WEB-INF/template/admin/project/config.ftl diff --git a/src/main/java/com/rekoe/module/admin/AdminProjectAct.java b/src/main/java/com/rekoe/module/admin/AdminProjectAct.java index 1e87765..e58019e 100644 --- a/src/main/java/com/rekoe/module/admin/AdminProjectAct.java +++ b/src/main/java/com/rekoe/module/admin/AdminProjectAct.java @@ -23,9 +23,11 @@ import com.rekoe.common.Message; import com.rekoe.common.page.Pagination; import com.rekoe.domain.Pj; import com.rekoe.domain.PjAuth; +import com.rekoe.domain.ProjectConfig; import com.rekoe.module.BaseAction; import com.rekoe.service.DefaultTreeService; import com.rekoe.service.ProjectAuthService; +import com.rekoe.service.ProjectConfigService; import com.rekoe.service.ProjectGroupService; import com.rekoe.service.ProjectService; import com.rekoe.service.RepositoryService; @@ -154,6 +156,19 @@ public class AdminProjectAct extends BaseAction { return ""; } + @At + @Ok("json") + @RequiresPermissions({ "svn.project:auth.manager" }) + @PermissionTag(name = "管理项目权限", tag = "SVN项目管理", enable = false) + public Message delete(@Param("id") String id, HttpServletRequest req) { + try { + projectService.delete(id); + } catch (Exception e) { + return Message.error(e.getMessage(), req); + } + return Message.success("ok", req); + } + @At("/pjauth/delete") @Ok("fm:template.admin.project.pjauth") @RequiresPermissions({ "svn.project:auth.manager" }) @@ -166,4 +181,27 @@ public class AdminProjectAct extends BaseAction { } return pjauth(pj, res, Mvcs.getReq()); } + + @Inject + private ProjectConfigService projectConfigService; + + @At + @Ok("fm:template.admin.project.config") + @RequiresPermissions({ "svn.project:conf" }) + @PermissionTag(name = "配置管理", tag = "SVN项目管理", enable = true) + public ProjectConfig conf() { + return projectConfigService.get(); + } + + @At("/conf/update") + @Ok("json") + @RequiresPermissions({ "svn.project:conf" }) + @PermissionTag(name = "配置管理", tag = "SVN项目管理", enable = false) + public Message conf_update(@Param("::conf.") ProjectConfig conf, HttpServletRequest req) { + boolean isRight = projectConfigService.update(conf.getRepositoryPath(), conf.getDomainPath()); + if (isRight) { + return Message.success("ok", req); + } + return Message.error("erroe", req); + } } diff --git a/src/main/java/com/rekoe/service/ProjectAuthService.java b/src/main/java/com/rekoe/service/ProjectAuthService.java index dd209d7..e7ffbb9 100644 --- a/src/main/java/com/rekoe/service/ProjectAuthService.java +++ b/src/main/java/com/rekoe/service/ProjectAuthService.java @@ -362,4 +362,19 @@ public class ProjectAuthService extends BaseService { dao().execute(sql); return list; } + + /** + * 删除项目 资源的权限 + * + * @param pj + * 项目 + */ + public void deletePj(String pj) { + Sql sql = Sqls.create("delete from pj_gr_auth $condition"); + sql.setCondition(Cnd.where("pj", "=", pj)); + dao().execute(sql); + sql = Sqls.create("delete from pj_usr_auth $condition"); + sql.setCondition(Cnd.where("pj", "=", pj)); + dao().execute(sql); + } } diff --git a/src/main/java/com/rekoe/service/ProjectGroupService.java b/src/main/java/com/rekoe/service/ProjectGroupService.java index e442472..9cf343b 100644 --- a/src/main/java/com/rekoe/service/ProjectGroupService.java +++ b/src/main/java/com/rekoe/service/ProjectGroupService.java @@ -66,4 +66,16 @@ public class ProjectGroupService extends BaseService { result.setDes(rs.getString("des")); return result; } + + /** + * 删除 + * + * @param pj + * 项目 + */ + public void deletePj(String pj) { + Sql sql = Sqls.create("delete from pj_gr $condition"); + sql.setCondition(Cnd.where("pj", "=", pj)); + dao().execute(sql); + } } diff --git a/src/main/java/com/rekoe/service/ProjectService.java b/src/main/java/com/rekoe/service/ProjectService.java index 3ca0cdd..7d8ca04 100644 --- a/src/main/java/com/rekoe/service/ProjectService.java +++ b/src/main/java/com/rekoe/service/ProjectService.java @@ -3,8 +3,10 @@ package com.rekoe.service; import java.io.File; import org.apache.commons.lang3.StringUtils; +import org.nutz.aop.interceptor.ioc.TransAop; import org.nutz.dao.Cnd; import org.nutz.dao.Dao; +import org.nutz.ioc.aop.Aop; import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.lang.Lang; @@ -118,35 +120,58 @@ public class ProjectService extends BaseService { } svnService.exportConfig(pj.getPj()); } - + /** * 获取项目的相对根路径.例如项目的path=e:/svn/projar,则返回projar。如果path为空,则返回项目ID - * @param pj 项目id + * + * @param pj + * 项目id * @return 项目的相对根路径 * @since 3.0.3 */ - public String getRelateRootPath(String pj){ + public String getRelateRootPath(String pj) { Pj p = this.get(pj); - if(p == null || StringUtils.isBlank(p.getPath())){ + if (p == null || StringUtils.isBlank(p.getPath())) { return pj; } return getRelateRootPath(pj); } + /** * 获取项目的相对根路径.例如项目的path=e:/svn/projar,则返回projar。如果path为空,则返回项目ID - * @param pj 项目 + * + * @param pj + * 项目 * @return 项目的相对根路径 * @since 3.0.3 */ - public String getRelateRootPath(Pj pj){ + public String getRelateRootPath(Pj pj) { String path = pj.getPath(); - if(StringUtils.isBlank(path)){ + if (StringUtils.isBlank(path)) { return pj.getPj(); } path = StringUtils.replace(path, "\\", "/"); - while(path.endsWith("/")){ - path = path.substring(0, path.length()-1); + while (path.endsWith("/")) { + path = path.substring(0, path.length() - 1); } return StringUtils.substringAfterLast(path, "/"); } + + @Inject + private ProjectGroupUsrService projectGroupUsrService; + + @Inject + private ProjectUserService projectUserService; + @Inject + private ProjectService projectService; + + @Aop(TransAop.READ_COMMITTED) + public void delete(String pj) { + projectAuthService.deletePj(pj); + projectGroupUsrService.deletePj(pj); + projectGroupService.deletePj(pj); + projectUserService.deletePj(pj); + svnService.exportConfig(pj); + projectService.delete(pj); + } } \ No newline at end of file diff --git a/src/main/java/com/rekoe/service/ProjectUserService.java b/src/main/java/com/rekoe/service/ProjectUserService.java index fd968f4..2a191a4 100644 --- a/src/main/java/com/rekoe/service/ProjectUserService.java +++ b/src/main/java/com/rekoe/service/ProjectUserService.java @@ -4,6 +4,7 @@ import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; +import org.nutz.dao.Cnd; import org.nutz.dao.Dao; import org.nutz.dao.Sqls; import org.nutz.dao.sql.Sql; @@ -46,4 +47,16 @@ public class ProjectUserService extends BaseService { dao().execute(sql); return sql.getObject(PjUsr.class); } + + /** + * 删除这个项目的用户 + * + * @param pj + * 项目 + */ + public void deletePj(String pj) { + Sql sql = Sqls.create("delete from pj_usr $condition");// where pj = ?"; + sql.setCondition(Cnd.where("pj", "=", pj)); + dao().execute(sql); + } } diff --git a/src/main/resources/ioc/dao.js b/src/main/resources/ioc/dao.js index 1ef1388..86944fd 100644 --- a/src/main/resources/ioc/dao.js +++ b/src/main/resources/ioc/dao.js @@ -54,7 +54,7 @@ var ioc = { "system_role", "system_user", "system_server", " system_user_server", "system_user_role", "verify_server", "official_server", "server_history", "platform_user", - "cdkey_category" ], + "cdkey_category", "project_config" ], enableWhenTrans : false, // 事务作用域内不启用缓存,默认也是false db : "MYSQL" } diff --git a/src/main/webapp/WEB-INF/template/admin/project/config.ftl b/src/main/webapp/WEB-INF/template/admin/project/config.ftl new file mode 100644 index 0000000..6452b4b --- /dev/null +++ b/src/main/webapp/WEB-INF/template/admin/project/config.ftl @@ -0,0 +1,22 @@ + + + + + +<#include "/template/admin/head.ftl"/> + + +
+
<@s.m "global.position"/>: <@s.m "cmsAdminGlobal.function"/> - <@s.m "global.add"/>
+
+
+
+<@p.form id="jvForm" action="update" labelWidth="12" onsubmit="return false;"> +<@p.hidden id="conf.id" name="conf.id" value='${obj.id}' /> +<@p.text width="30" label="仓库路径" id="conf.repositoryPath" name="conf.repositoryPath" value="${obj.repositoryPath}" maxlength="100" class="required" required="true"/><@p.tr/> +<@p.text width="30" label="访问url" id="conf.domainPath" name="conf.domainPath" value="${obj.domainPath}" maxlength="100" class="required" required="true"/><@p.tr/> +<@p.td colspan="1"><@p.submit code="global.submit" onclick="Cms.updateAll('conf/update','conf.rk');"/>   <@p.reset code="global.reset"/><@p.tr/> + +
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/template/admin/project/frame/left.ftl b/src/main/webapp/WEB-INF/template/admin/project/frame/left.ftl index 479f73b..21a00a5 100644 --- a/src/main/webapp/WEB-INF/template/admin/project/frame/left.ftl +++ b/src/main/webapp/WEB-INF/template/admin/project/frame/left.ftl @@ -18,8 +18,9 @@ h3{ padding:0; margin:0; font-weight:normal; font-size:12px;} <#include "/template/admin/date.ftl"/> diff --git a/src/main/webapp/res/cms/js/admin.js b/src/main/webapp/res/cms/js/admin.js index c3be293..c1a7bdf 100644 --- a/src/main/webapp/res/cms/js/admin.js +++ b/src/main/webapp/res/cms/js/admin.js @@ -139,4 +139,30 @@ Cms.update = function(id){ } }); return false; +} + +Cms.updateAll = function(url,back){ + $.dialog({ + type: "warn", + content: '确定要修改此记录?', + ok: 'Ok', + cancel: 'Cancel', + onOk: function() { + $.ajax({ + url: url, + type: "POST", + data: $('#jvForm').serialize(), + dataType: "json", + cache: false, + success: function(message) { + $.message(message); + if (message.type == "success") + { + window.location.href = back; + } + } + }); + } + }); + return false; } \ No newline at end of file