重置账号

pull/3/head
rekoe 2016-03-29 19:00:50 +08:00
parent 50a3d85581
commit c3a061b020
3 changed files with 25 additions and 5 deletions

View File

@ -14,7 +14,10 @@ import org.nutz.dao.Cnd;
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.Strings; import org.nutz.lang.Strings;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Attr;
import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param; import org.nutz.mvc.annotation.Param;
@ -27,6 +30,7 @@ import com.rekoe.domain.Usr;
import com.rekoe.module.BaseAction; import com.rekoe.module.BaseAction;
import com.rekoe.service.EmailService; import com.rekoe.service.EmailService;
import com.rekoe.service.ProjectConfigService; import com.rekoe.service.ProjectConfigService;
import com.rekoe.service.ProjectService;
import com.rekoe.service.SvnService; import com.rekoe.service.SvnService;
import com.rekoe.service.SvnUserService; import com.rekoe.service.SvnUserService;
import com.rekoe.utils.EncryptUtil; import com.rekoe.utils.EncryptUtil;
@ -35,6 +39,8 @@ import com.rekoe.utils.EncryptUtil;
@At("/admin/svn/user") @At("/admin/svn/user")
public class AdminSvnUserAct extends BaseAction { public class AdminSvnUserAct extends BaseAction {
private final static Log log = Logs.get();
private static final char[] RANDOM_ARRY_CHAR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray(); private static final char[] RANDOM_ARRY_CHAR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray();
@Inject @Inject
@ -79,6 +85,9 @@ public class AdminSvnUserAct extends BaseAction {
@Inject @Inject
private SvnService svnService; private SvnService svnService;
@Inject
private ProjectService projectService;
/** /**
* *
* *
@ -90,17 +99,25 @@ public class AdminSvnUserAct extends BaseAction {
@Ok("json") @Ok("json")
@RequiresPermissions("svn.user:add") @RequiresPermissions("svn.user:add")
@PermissionTag(name = "SVN添加账号", tag = "SVN账号管理", enable = false) @PermissionTag(name = "SVN添加账号", tag = "SVN账号管理", enable = false)
public Message restpwd(@Param("usr") String usr, HttpServletRequest req) { public Message restpwd(@Param("usr") String usr, @Attr("usr") Usr manager, HttpServletRequest req) {
Usr user = svnUserService.fetch(Cnd.where("usr", "=", usr)); Usr user = svnUserService.fetch(Cnd.where("usr", "=", usr));
if (user == null) { if (user == null) {
return Message.error("error.account.empty", req); return Message.error("error.account.empty", req);
} }
String code = RandomStringUtils.random(7, RANDOM_ARRY_CHAR); String code = RandomStringUtils.random(7, RANDOM_ARRY_CHAR);
svnUserService.update(Chain.make("psw", EncryptUtil.encrypt(code)), Cnd.where("usr", "=", usr)); svnUserService.update(Chain.make("psw", EncryptUtil.encrypt(code)), Cnd.where("usr", "=", usr));
if (usr.equals(manager.getUsr())) {
req.getSession().setAttribute("usr", svnUserService.fetch(Cnd.where("usr", "=", usr)));
}
List<Pj> list = svnUserService.getPjList(usr); List<Pj> list = svnUserService.getPjList(usr);
if (list != null) { if (list != null) {
for (Pj pj : list) { for (Pj pj : list) {
this.svnService.exportConfig(pj); try {
this.svnService.exportConfig(pj);
} catch (Exception e) {
projectService.deleteDB(pj.getPj());
log.errorf("project %s ,error %s", pj.getPj(), e.getMessage());
}
} }
} }
ProjectConfig conf = projectConfigService.get(); ProjectConfig conf = projectConfigService.get();

View File

@ -163,11 +163,15 @@ public class ProjectService extends BaseService<Pj> {
@Aop(TransAop.READ_COMMITTED) @Aop(TransAop.READ_COMMITTED)
public void delete(String pj) { public void delete(String pj) {
deleteDB(pj);
svnService.exportConfig(pj);
}
public void deleteDB(String pj) {
projectAuthService.deletePj(pj); projectAuthService.deletePj(pj);
projectGroupUsrService.deletePj(pj); projectGroupUsrService.deletePj(pj);
projectGroupService.deletePj(pj); projectGroupService.deletePj(pj);
projectUserService.deletePj(pj); projectUserService.deletePj(pj);
svnService.exportConfig(pj);
dao().clear(getEntityClass(), Cnd.where("pj", "=", pj)); dao().clear(getEntityClass(), Cnd.where("pj", "=", pj));
} }
@ -181,7 +185,7 @@ public class ProjectService extends BaseService<Pj> {
* @return () * @return ()
*/ */
public List<Pj> getList(String usr) { public List<Pj> getList(String usr) {
Sql sql = Sqls.create("select p.pj,p.path,p.url,p.des,p.type,pm.pj manager from ( " + " select distinct a.pj,a.path,a.url,a.des,a.type from pj a where " + " exists (select b.usr from pj_gr_usr b where a.pj=b.pj and b.usr=@usr) " + " or exists(select c.usr from pj_usr_auth c where a.pj=c.pj and c.usr=@usr) " + " ) p " + " left join ( " + " select distinct a.pj from pj a where " + " exists (select b.usr from pj_gr_usr b where a.pj=b.pj and b.usr=@usr and b.gr like @like)" + " ) pm on p.pj=pm.pj"); Sql sql = Sqls.create("select p.pj,p.des,p.type,pm.pj manager from ( " + " select distinct a.pj,a.des,a.type from pj a where " + " exists (select b.usr from pj_gr_usr b where a.pj=b.pj and b.usr=@usr) " + " or exists(select c.usr from pj_usr_auth c where a.pj=c.pj and c.usr=@usr) " + " ) p " + " left join ( " + " select distinct a.pj from pj a where " + " exists (select b.usr from pj_gr_usr b where a.pj=b.pj and b.usr=@usr and b.gr like @like)" + " ) pm on p.pj=pm.pj");
final List<Pj> list = new ArrayList<Pj>(); final List<Pj> list = new ArrayList<Pj>();
sql.setCallback(new SqlCallback() { sql.setCallback(new SqlCallback() {

View File

@ -94,7 +94,6 @@ public class RepositoryService {
result = StringUtils.replace(result, "\b", " "); result = StringUtils.replace(result, "\b", " ");
result = StringUtils.replace(result, "<", " ");// eg. <br/> result = StringUtils.replace(result, "<", " ");// eg. <br/>
result = StringUtils.replace(result, "(", " ");// eg. () result = StringUtils.replace(result, "(", " ");// eg. ()
result = result.trim(); result = result.trim();
int blank = result.indexOf(" "); int blank = result.indexOf(" ");
if (blank != -1) { if (blank != -1) {