mirror of https://github.com/Rekoe/rk_svnadmin
fix
parent
06c45a85ab
commit
5eeac83a9c
|
@ -23,6 +23,7 @@ import org.tmatesoft.svn.core.wc.SVNCommitClient;
|
|||
import org.tmatesoft.svn.core.wc.SVNWCUtil;
|
||||
|
||||
import com.rekoe.domain.Pj;
|
||||
import com.rekoe.domain.PjGrUsr;
|
||||
import com.rekoe.domain.ProjectConfig;
|
||||
import com.rekoe.domain.User;
|
||||
import com.rekoe.domain.Usr;
|
||||
|
@ -52,6 +53,7 @@ public class MvcSetup implements Setup {
|
|||
});
|
||||
ioc.get(FreeMarkerConfigurer.class, "mapTags");
|
||||
Dao dao = ioc.get(Dao.class);
|
||||
dao.create(PjGrUsr.class, false);
|
||||
// dao.clear(OAuthUser.class);
|
||||
Daos.createTablesInPackage(dao, User.class.getPackage().getName(), false);
|
||||
Daos.migration(dao, Usr.class, true, true, false);
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.io.Serializable;
|
|||
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Index;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.PK;
|
||||
import org.nutz.dao.entity.annotation.Readonly;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
|
@ -24,7 +23,7 @@ public class PjGrUsr implements Serializable {
|
|||
/**
|
||||
* 项目
|
||||
*/
|
||||
@Name
|
||||
@Column
|
||||
private String pj;
|
||||
/**
|
||||
* 用户
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
@ -13,7 +14,7 @@ import org.nutz.mvc.annotation.Param;
|
|||
import com.rekoe.annotation.PermissionTag;
|
||||
import com.rekoe.common.Message;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.Usr;
|
||||
import com.rekoe.domain.PjGr;
|
||||
import com.rekoe.module.BaseAction;
|
||||
import com.rekoe.service.ProjectGroupService;
|
||||
|
||||
|
@ -28,7 +29,7 @@ public class AdminProjectGroupAct extends BaseAction {
|
|||
@Ok("fm:template.admin.project_group.list")
|
||||
@RequiresPermissions({ "project.group:view" })
|
||||
@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);
|
||||
return projectGroupService.getObjListByPager(page, 20, Cnd.where("pj", "=", pj));
|
||||
}
|
||||
|
@ -37,14 +38,20 @@ public class AdminProjectGroupAct extends BaseAction {
|
|||
@Ok("fm:template.admin.project_group.add")
|
||||
@RequiresPermissions({ "project.group:add" })
|
||||
@PermissionTag(name = "添加项目用户组", tag = "SVN账号管理", enable = true)
|
||||
public void add() {
|
||||
public String add(@Param("pj") String pj) {
|
||||
return pj;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("project.group:add")
|
||||
@PermissionTag(name = "添加项目用户组", tag = "SVN账号管理", enable = false)
|
||||
public Message o_save(@Param("::group.") Usr 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()));
|
||||
if (Lang.isEmpty(old)) {
|
||||
projectGroupService.insert(group);
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
return Message.error("error", req);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rekoe.module.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -9,8 +10,13 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.aop.interceptor.async.Async;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
@ -19,11 +25,13 @@ import com.rekoe.annotation.PermissionTag;
|
|||
import com.rekoe.common.Message;
|
||||
import com.rekoe.common.page.Pagination;
|
||||
import com.rekoe.domain.Pj;
|
||||
import com.rekoe.domain.PjGrAuth;
|
||||
import com.rekoe.domain.PjGrUsr;
|
||||
import com.rekoe.domain.ProjectConfig;
|
||||
import com.rekoe.domain.Usr;
|
||||
import com.rekoe.module.BaseAction;
|
||||
import com.rekoe.service.EmailService;
|
||||
import com.rekoe.service.ProjectAuthService;
|
||||
import com.rekoe.service.ProjectConfigService;
|
||||
import com.rekoe.service.ProjectGroupUsrService;
|
||||
import com.rekoe.service.ProjectService;
|
||||
|
@ -133,24 +141,51 @@ public class AdminProjectGroupUsrAct extends BaseAction {
|
|||
@Async
|
||||
public void sendProjectOpenEmail(Pj project, ProjectConfig conf, List<Usr> getList, EmailService emailService) {
|
||||
for (Usr usr : getList) {
|
||||
Map<String, Object> root = new HashMap<>();
|
||||
root.put("usr", usr.getUsr());
|
||||
root.put("name", usr.getName());
|
||||
root.put("pwd", EncryptUtil.decrypt(usr.getPsw()));
|
||||
root.put("project", project.getDes());
|
||||
root.put("url", conf.getDomainPath() + project.getPj());
|
||||
emailService.projectOpen(usr.getEmail(), root);
|
||||
sendProjectOpenEmail1(project, conf, usr, emailService);
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendProjectOpenEmail(Pj project, ProjectConfig conf, Usr usr, EmailService emailService) {
|
||||
private final static Log log = Logs.get();
|
||||
@Inject
|
||||
private ProjectAuthService projectAuthService;
|
||||
|
||||
private void sendProjectOpenEmail1(Pj project, ProjectConfig conf, Usr usr, EmailService emailService) {
|
||||
if (Lang.isEmpty(usr)) {
|
||||
log.error("send open email user empty");
|
||||
return;
|
||||
}
|
||||
Map<String, Object> root = new HashMap<>();
|
||||
root.put("usr", usr.getUsr());
|
||||
root.put("name", usr.getName());
|
||||
root.put("pwd", EncryptUtil.decrypt(usr.getPsw()));
|
||||
root.put("project", project.getDes());
|
||||
root.put("url", conf.getDomainPath() + project.getPj());
|
||||
emailService.projectOpen(usr.getEmail(), root);
|
||||
String url = conf.getDomainPath() + project.getPj();
|
||||
root.put("url", url);
|
||||
List<String> urlList = new ArrayList<String>();
|
||||
Cnd cnd = Cnd.where("pj", "=", project.getPj()).and("usr", "=", usr.getUsr());
|
||||
List<PjGrUsr> list = projectGroupUsrService.query(cnd);
|
||||
if (Lang.isEmpty(list)) {
|
||||
log.errorf("Cant Not Set User %s Project %s Gruop", usr.getUsr(), project.getPj());
|
||||
return;
|
||||
}
|
||||
for (PjGrUsr pgu : list) {
|
||||
List<PjGrAuth> $list = projectAuthService.loadPjGrAuth(project.getPj(), pgu.getGr());
|
||||
for (PjGrAuth pjauth : $list) {
|
||||
String res = pjauth.getRes();
|
||||
res = StringUtils.remove(res, "[" + pjauth.getPj() + ":");
|
||||
res = StringUtils.remove(res, "]");
|
||||
urlList.add(url + res);
|
||||
}
|
||||
}
|
||||
root.put("urls", urlList);
|
||||
boolean send = emailService.projectOpen(usr.getEmail(), root);
|
||||
if (send) {
|
||||
log.info("email send OK");
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendProjectOpenEmail(Pj project, ProjectConfig conf, Usr usr, EmailService emailService) {
|
||||
sendProjectOpenEmail1(project, conf, usr, emailService);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,13 +77,19 @@ public class AdminSvnUserAct extends BaseAction {
|
|||
@PermissionTag(name = "SVN添加账号", tag = "SVN账号管理", enable = false)
|
||||
public Message o_save(@Param("::user.") Usr user, HttpServletRequest req) {
|
||||
boolean isOk = svnUserService.nameOk(user.getUsr());
|
||||
if (isOk) {
|
||||
boolean isEmail = Strings.isEmail(user.getEmail());
|
||||
if (isOk && isEmail) {
|
||||
user.setPsw(EncryptUtil.encrypt(R.UU64().substring(0, 10)));
|
||||
isOk = svnUserService.insert(user);
|
||||
} else {
|
||||
isOk = false;
|
||||
}
|
||||
if (isOk) {
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
if (!isEmail) {
|
||||
return Message.error("email error", req);
|
||||
}
|
||||
return Message.error("error", req);
|
||||
}
|
||||
|
||||
|
|
|
@ -296,6 +296,10 @@ public class ProjectAuthService extends BaseService<PjAuth> {
|
|||
}
|
||||
}
|
||||
|
||||
public List<PjGrAuth> loadPjGrAuth(String pj, String gr) {
|
||||
return dao().query(PjGrAuth.class, Cnd.where("pj", "=", pj).and("gr", "=", gr));
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化资源.如果资源没有[],自动加上[relateRoot:/]
|
||||
*
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
${name}: 您好 <br/>
|
||||
|
||||
您在项目《${project}》申请的svn信息如下<br/>
|
||||
地址:${url}<br/>
|
||||
项目地址:${url}<br/>
|
||||
<#list urls as u>
|
||||
加载地址:${u}<br/>
|
||||
</#list>
|
||||
账号:${usr}<br/>
|
||||
密码:${pwd }<br/><br/>
|
||||
密码信息请妥善保管。系统邮件请勿回复
|
||||
|
|
|
@ -26,7 +26,7 @@ $(function() {
|
|||
</@p.td><@p.tr/>
|
||||
<@p.text width="30" label="描述" id="pj.des" name="pj.des" value="" maxlength="100" class="required" required="true"/><@p.tr/>
|
||||
<@p.td colspan="2">
|
||||
<@p.submit code="global.submit" onclick="Cms.add();"/>
|
||||
<@p.submit code="global.submit" onclick="Cms.add('o_save.rk','list.rk');"/>
|
||||
</@p.td><@p.tr/>
|
||||
</@p.form>
|
||||
</div>
|
||||
|
|
|
@ -23,7 +23,7 @@ $(function() {
|
|||
<@p.hidden name="pj" id="pj" value='${obj}' />
|
||||
<@p.text width="30" label="目录" id="file" name="file" value="" maxlength="100" class="required" required="true" help="说明: 若trunk下如果要增加目录请使用 trunk/filename"/><@p.tr/>
|
||||
<@p.td>
|
||||
<@p.submit code="global.submit" onclick="Cms.add('file_save','file_add.rk');"/>
|
||||
<@p.submit code="global.submit" onclick="Cms.add('file_save','file_add.rk?pj=${obj}');"/>
|
||||
</@p.td><@p.tr/>
|
||||
</@p.form>
|
||||
</div>
|
||||
|
|
|
@ -77,7 +77,7 @@ function all_email(pj){
|
|||
</@shiro.hasPermission>
|
||||
<@p.column title="设置权限" align="center"><a href="rep?pj=${project.pj}">设置权限</a></@p.column><#t/>
|
||||
<@p.column title="添加目录" align="center"><a href="file_add?pj=${project.pj}">添加目录</a></@p.column><#t/>
|
||||
<@p.column title="初始化" align="center"><a href="onclick="javascript:void(0);" init('${project.pj}')">初始化</a></@p.column><#t/>
|
||||
<@p.column title="初始化" align="center"><a href="javascript:void(0);" onclick="init('${project.pj}')">初始化</a></@p.column><#t/>
|
||||
<@shiro.hasPermission name="svn.project:auth.manager">
|
||||
<@p.column title="编辑" align="center">
|
||||
<a href="javascript:void(0);" onclick="Cms.deleted('${project.pj}')" class="pn-opt">删除</a><#rt/>
|
||||
|
|
|
@ -183,7 +183,7 @@
|
|||
<td>${pjAuth.gr!""}${pjAuth.usr!pjAuth.usrName}:(${pjAuth.usr})</td>
|
||||
<td><#if "r"== pjAuth.rw>可读<#elseif "rw"== pjAuth.rw>可读可写<#else>没有权限</#if></td>
|
||||
<@shiro.hasPermission name="svn.project:auth.manager">
|
||||
<td><a href="javascript:if(confirm('确认删除?')){del('pjauth/delete?pj=${pjAuth.pj}&res=${pjAuth.res}&gr=${pjAuth.gr}&usr=${pjAuth.usr}')}">删除</a></td>
|
||||
<td><a href="javascript:if(confirm('确认删除?')){del('delete?pj=${pjAuth.pj}&res=${pjAuth.res}&gr=${pjAuth.gr}&usr=${pjAuth.usr}')}">删除</a></td>
|
||||
</@shiro.hasPermission>
|
||||
</tr>
|
||||
</#list>
|
||||
|
|
|
@ -25,7 +25,7 @@ $(function() {
|
|||
<@p.text width="30" label="用户组" id="pgu.gr" name="pgu.gr" value="" maxlength="100" class="required" required="true"/><@p.tr/>
|
||||
<@p.text width="30" label="描述" id="pgu.des" name="pgu.des" value="" maxlength="100" class="required" required="true"/><@p.tr/>
|
||||
<@p.td colspan="2">
|
||||
<@p.submit code="global.submit" onclick="Cms.add();"/>
|
||||
<@p.submit code="global.submit" onclick="Cms.add('o_save.rk','list.rk?pj=${obj}');"/>
|
||||
</@p.td><@p.tr/>
|
||||
</@p.form>
|
||||
</div>
|
||||
|
|
|
@ -25,7 +25,7 @@ function deleted(pj,gr,usr){
|
|||
$.message(message);
|
||||
if (message.type == "success")
|
||||
{
|
||||
window.location.href = back;
|
||||
window.location.href = "list.rk";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -77,7 +77,7 @@ function email(pj,usr){
|
|||
<@p.column title="姓名" align="center">${group.usrName}</@p.column><#t/>
|
||||
<@shiro.hasPermission name="project.group:delete">
|
||||
<@p.column title="删除" align="center">
|
||||
<a href="javascript:void(0);" onclick="deleted('${group.pj}','${group.gr}')" class="pn-opt">删除</a><#rt/>
|
||||
<a href="javascript:void(0);" onclick="deleted('${group.pj}','${group.gr}','${group.usr}')" class="pn-opt">删除</a><#rt/>
|
||||
</@p.column><#t/>
|
||||
</@shiro.hasPermission>
|
||||
<@p.column title="发项目邀请邮件" align="center">
|
||||
|
|
Loading…
Reference in New Issue