diff --git a/src/main/java/com/rekoe/domain/Usr.java b/src/main/java/com/rekoe/domain/Usr.java index f173067..44ba930 100644 --- a/src/main/java/com/rekoe/domain/Usr.java +++ b/src/main/java/com/rekoe/domain/Usr.java @@ -43,6 +43,10 @@ public class Usr implements Serializable { @Column private String email; + @Column("is_lock") + @Default("0") + private boolean lock; + /** * @return 用户ID */ diff --git a/src/main/java/com/rekoe/filter/SelectServerActionFilter.java b/src/main/java/com/rekoe/filter/SelectServerActionFilter.java deleted file mode 100644 index 77c04bd..0000000 --- a/src/main/java/com/rekoe/filter/SelectServerActionFilter.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.rekoe.filter; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; - -import org.nutz.integration.shiro.NutShiro; -import org.nutz.ioc.loader.annotation.Inject; -import org.nutz.ioc.loader.annotation.IocBean; -import org.nutz.lang.Lang; -import org.nutz.mvc.ActionContext; -import org.nutz.mvc.ActionFilter; -import org.nutz.mvc.View; -import org.nutz.mvc.view.UTF8JsonView; -import org.nutz.mvc.view.ViewWrapper; -import org.nutz.plugins.view.freemarker.FreeMarkerConfigurer; -import org.nutz.plugins.view.freemarker.FreemarkerView; - -import com.rekoe.common.Message; - -@IocBean -public class SelectServerActionFilter implements ActionFilter { - - @Inject - private FreeMarkerConfigurer freeMarkerConfigurer; - - public View match(final ActionContext ctx) { - HttpSession session = ctx.getRequest().getSession(); - Object sid = session.getAttribute("sid"); - if (Lang.isEmpty(sid)) { - if (NutShiro.isAjax(ctx.getRequest())) { - ctx.getResponse().setHeader("loginStatus", getResStatus()); - return new ViewWrapper(UTF8JsonView.COMPACT, getResStatus()); - } - return getErrView(ctx.getRequest()); - } - return null; - } - - public String getResStatus() { - return "select_server"; - } - - public View getErrView(HttpServletRequest req) { - return new ViewWrapper(new FreemarkerView(freeMarkerConfigurer, "template/admin/common/error"), Message.error("admin.common.error.no.server", req)); - } -} diff --git a/src/main/java/com/rekoe/module/admin/AdminSvnUserAct.java b/src/main/java/com/rekoe/module/admin/AdminSvnUserAct.java index 1a02bff..aedfada 100644 --- a/src/main/java/com/rekoe/module/admin/AdminSvnUserAct.java +++ b/src/main/java/com/rekoe/module/admin/AdminSvnUserAct.java @@ -59,8 +59,22 @@ public class AdminSvnUserAct extends BaseAction { @Ok("fm:template.admin.svn_user.list") @RequiresPermissions({ "svn.user:view" }) @PermissionTag(name = "SVN浏览账号", tag = "SVN账号管理") - public Pagination list(@Param(value = "pageNumber", df = "1") int page) { - return svnUserService.getObjListByPager(page, 20, Cnd.where("usr", "<>", "*")); + public Pagination list(@Param(value = "pageNumber", df = "1") int page, HttpServletRequest req) { + req.setAttribute("page", page); + req.setAttribute("action", "list.rk"); + req.setAttribute("lock", 0); + return svnUserService.getObjListByPager(page, 20, Cnd.where("usr", "<>", "*").and("is_lock", "=", false)); + } + + @At + @Ok("fm:template.admin.svn_user.list") + @RequiresPermissions({ "svn.user:view" }) + @PermissionTag(name = "SVN浏览账号", tag = "SVN账号管理") + public Pagination lock_list(@Param(value = "pageNumber", df = "1") int page, HttpServletRequest req) { + req.setAttribute("page", page); + req.setAttribute("action", "lock_list.rk"); + req.setAttribute("lock", 1); + return svnUserService.getObjListByPager(page, 20, Cnd.where("usr", "<>", "*").and("is_lock", "=", true)); } @At @@ -194,6 +208,52 @@ public class AdminSvnUserAct extends BaseAction { return Message.success("ok", req); } + @At + @Ok("json") + @RequiresPermissions("svn.user:add") + @PermissionTag(name = "SVN添加账号", tag = "SVN账号管理", enable = false) + public Message lock(@Param("usr") String usr, @Attr("usr") Usr manager, HttpServletRequest req) { + Usr user = svnUserService.fetch(Cnd.where("usr", "=", usr)); + if (user == null) { + return Message.error("error.account.empty", req); + } + String code = RandomStringUtils.random(7, RANDOM_ARRY_CHAR); + boolean value = true; + svnUserService.update(Chain.make("psw", EncryptUtil.encrypt(code)).add("is_lock", value), Cnd.where("usr", "=", usr)); + String salt = new SecureRandomNumberGenerator().nextBytes().toBase64(); + String pwd = new Sha256Hash(code, salt, 1024).toBase64(); + userService.update(Chain.make("salt", salt).add("password", pwd).add("is_locked", value), Cnd.where("name", "=", usr)); + if (usr.equals(manager.getUsr())) { + req.getSession().setAttribute("usr", svnUserService.fetch(Cnd.where("usr", "=", usr))); + } + List list = svnUserService.getPjList(usr); + if (list != null) { + for (Pj pj : list) { + try { + this.svnService.exportConfig(pj); + } catch (Exception e) { + log.errorf("project %s ,error %s", pj.getPj(), e.getMessage()); + } + } + } + return Message.success("ok", req); + } + + @At + @Ok("json") + @RequiresPermissions("svn.user:add") + @PermissionTag(name = "SVN添加账号", tag = "SVN账号管理", enable = false) + public Message unlock(@Param("usr") String usr, @Attr("usr") Usr manager, HttpServletRequest req) { + Usr user = svnUserService.fetch(Cnd.where("usr", "=", usr)); + if (user == null) { + return Message.error("error.account.empty", req); + } + boolean value = false; + svnUserService.update(Chain.make("is_lock", value), Cnd.where("usr", "=", usr)); + userService.update(Chain.make("is_locked", value), Cnd.where("name", "=", usr)); + return Message.success("ok", req); + } + @Async private void emailNotify(Usr user, EmailService emailService, ProjectConfig conf, String to, String pwd) { if (conf.isEmailNotify() && Strings.isEmail(to)) { diff --git a/src/main/java/com/rekoe/mvc/ProcessTimeProcessor.java b/src/main/java/com/rekoe/mvc/ProcessTimeProcessor.java deleted file mode 100644 index 619473d..0000000 --- a/src/main/java/com/rekoe/mvc/ProcessTimeProcessor.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.rekoe.mvc; - -import javax.servlet.http.HttpServletRequest; - -import org.nutz.log.Log; -import org.nutz.log.Logs; -import org.nutz.mvc.ActionContext; -import org.nutz.mvc.impl.processor.AbstractProcessor; - -/** - * 执行时间过滤器 - */ -public class ProcessTimeProcessor extends AbstractProcessor { - private final static Log log = Logs.get() ; - /** - * 请求执行开始时间 - */ - public static final String START_TIME = "_start_time"; - - @Override - public void process(ActionContext ac) throws Throwable { - long time = System.currentTimeMillis(); - HttpServletRequest request = ac.getRequest(); - request.setAttribute(START_TIME, time); - doNext(ac); - time = System.currentTimeMillis() - time; - log.debugf("process in {%s} ms: {%s}", time, request.getRequestURI()); - } -} diff --git a/src/main/java/com/rekoe/mvc/RkCmsNutFilter.java b/src/main/java/com/rekoe/mvc/RkCmsNutFilter.java deleted file mode 100644 index e88310d..0000000 --- a/src/main/java/com/rekoe/mvc/RkCmsNutFilter.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.rekoe.mvc; - -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; - -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; - -import org.nutz.mvc.NutFilter; - -public class RkCmsNutFilter extends NutFilter { - - protected Set prefixs = new HashSet(); - - - public void init(FilterConfig conf) throws ServletException { - super.init(conf); - prefixs.add(conf.getServletContext().getContextPath() + "/druid/"); - prefixs.add(conf.getServletContext().getContextPath() + "/res/"); - prefixs.add(conf.getServletContext().getContextPath() + "/thirdparty/"); - prefixs.add(conf.getServletContext().getContextPath() + "/tinyeditor/"); - } - - @Override - public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { - if (req instanceof HttpServletRequest) { - String uri = ((HttpServletRequest) req).getRequestURI(); - for (String prefix : prefixs) { - if (uri.startsWith(prefix)) { - chain.doFilter(req, resp); - return; - } - } - } - super.doFilter(req, resp, chain); - } -} diff --git a/src/main/java/com/rekoe/mvc/mvc-chains.js b/src/main/java/com/rekoe/mvc/mvc-chains.js deleted file mode 100644 index 876e645..0000000 --- a/src/main/java/com/rekoe/mvc/mvc-chains.js +++ /dev/null @@ -1,16 +0,0 @@ -var chain={ - "default" : { - "ps" : [ - "org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor", - "org.nutz.mvc.impl.processor.EncodingProcessor", - "org.nutz.mvc.impl.processor.ModuleProcessor", - "org.nutz.integration.shiro.NutShiroProcessor", - "org.nutz.mvc.impl.processor.ActionFiltersProcessor", - "org.nutz.mvc.impl.processor.AdaptorProcessor", - "org.nutz.mvc.impl.processor.MethodInvokeProcessor", - "com.rekoe.mvc.ProcessTimeProcessor", - "org.nutz.mvc.impl.processor.ViewProcessor" - ], - "error" : 'org.nutz.mvc.impl.processor.FailProcessor' - } -}; \ No newline at end of file diff --git a/src/main/java/com/rekoe/service/ProjectGroupUsrService.java b/src/main/java/com/rekoe/service/ProjectGroupUsrService.java index 0ed914c..a10c0ba 100644 --- a/src/main/java/com/rekoe/service/ProjectGroupUsrService.java +++ b/src/main/java/com/rekoe/service/ProjectGroupUsrService.java @@ -67,7 +67,7 @@ public class ProjectGroupUsrService extends BaseService { */ public Pagination getList(String pj, String gr, int page) { Pager pager = dao().createPager(page, 20); - Sql sql = Sqls.create("select a.pj,a.usr,a.gr,b.name as usrname from pj_gr_usr a left join usr b on (a.usr = b.usr) where a.pj=@pj and a.gr=@gr order by a.usr"); + Sql sql = Sqls.create("select a.pj,a.usr,a.gr,b.name as usrname from pj_gr_usr a left join usr b on (a.usr = b.usr) where a.pj=@pj and a.gr=@gr and b.is_lock=false order by a.usr"); sql.setParam("pj", pj).setParam("gr", gr); sql.setPager(pager); final List list = new ArrayList(); @@ -95,7 +95,7 @@ public class ProjectGroupUsrService extends BaseService { * @return 项目的组用户列表 */ public List getList(String pj) { - Sql sql = Sqls.create("select a.pj,a.gr,b.usr,c.name as usrname from pj_gr a left join pj_gr_usr b on (a.pj=b.pj and a.gr=b.gr) left join usr c on (b.usr = c.usr) where a.pj=@pj order by a.gr,b.usr"); + Sql sql = Sqls.create("select a.pj,a.gr,b.usr,c.name as usrname from pj_gr a left join pj_gr_usr b on (a.pj=b.pj and a.gr=b.gr) left join usr c on (b.usr = c.usr) where a.pj=@pj and c.is_lock=falsd order by a.gr,b.usr"); sql.setParam("pj", pj); final List list = new ArrayList(); sql.setCallback(new SqlCallback() { diff --git a/src/main/java/com/rekoe/service/SvnUserService.java b/src/main/java/com/rekoe/service/SvnUserService.java index 543955b..97968ca 100644 --- a/src/main/java/com/rekoe/service/SvnUserService.java +++ b/src/main/java/com/rekoe/service/SvnUserService.java @@ -73,7 +73,7 @@ public class SvnUserService extends BaseService { * @return 项目组未选的用户(不包括*) */ public List listUnSelected(String pj, String gr) { - Sql sql = Sqls.create("select usr,name,psw,email,role from usr a where a.usr <> '*' " + " and not exists (select usr from pj_gr_usr b where a.usr = b.usr and b.pj=@pj and b.gr=@gr) order by a.usr"); + Sql sql = Sqls.create("select usr,name,psw,email,role from usr a where a.usr <> '*' " + " and not exists (select usr from pj_gr_usr b where a.usr = b.usr and b.pj=@pj and b.gr=@gr) and a.is_lock=false order by a.usr"); sql.setParam("pj", pj).setParam("gr", gr); final List list = new ArrayList(); sql.setCallback(new SqlCallback() { @@ -91,7 +91,7 @@ public class SvnUserService extends BaseService { } public List listSelected(String pj) { - Sql sql = Sqls.create("select * from usr a where a.usr <> '*' " + " and exists (select usr from pj_gr_usr b where a.usr = b.usr and b.pj=@pj) order by a.usr"); + Sql sql = Sqls.create("select * from usr a where a.usr <> '*' " + " and exists (select usr from pj_gr_usr b where a.usr = b.usr and b.pj=@pj) and a.is_lock=false order by a.usr"); sql.setParam("pj", pj); final List list = new ArrayList(); sql.setCallback(new SqlCallback() { diff --git a/src/main/java/com/rekoe/service/UsrService.java b/src/main/java/com/rekoe/service/UsrService.java index 36a2939..835416e 100644 --- a/src/main/java/com/rekoe/service/UsrService.java +++ b/src/main/java/com/rekoe/service/UsrService.java @@ -6,6 +6,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import org.nutz.dao.Cnd; import org.nutz.dao.Dao; import org.nutz.dao.Sqls; import org.nutz.dao.sql.Sql; @@ -32,7 +33,7 @@ public class UsrService extends BaseService { * @return 所有用户列表 */ public List getList() { - return dao().query(getEntityClass(), null); + return dao().query(getEntityClass(), Cnd.where("is_lock", "=", false)); } /** diff --git a/src/main/java/com/rekoe/web/freemarker/ProcessTimeDirective.java b/src/main/java/com/rekoe/web/freemarker/ProcessTimeDirective.java index 0bf707b..fbe0b63 100644 --- a/src/main/java/com/rekoe/web/freemarker/ProcessTimeDirective.java +++ b/src/main/java/com/rekoe/web/freemarker/ProcessTimeDirective.java @@ -1,7 +1,5 @@ package com.rekoe.web.freemarker; -import static com.rekoe.mvc.ProcessTimeProcessor.START_TIME; - import java.io.IOException; import java.io.Writer; import java.text.DecimalFormat; @@ -38,7 +36,7 @@ public class ProcessTimeDirective implements TemplateDirectiveModel { } private long getStartTime(Environment env) throws TemplateModelException { - TemplateModel startTime = env.getGlobalVariable(START_TIME); + TemplateModel startTime = env.getGlobalVariable("_t_start"); if (startTime == null) { log.warn("Variable '{}' not found in GlobalVariable", "START_TIME"); return -1; @@ -46,7 +44,7 @@ public class ProcessTimeDirective implements TemplateDirectiveModel { if (startTime instanceof TemplateNumberModel) { return ((TemplateNumberModel) startTime).getAsNumber().longValue(); } else { - throw new NutConfigException(START_TIME); + throw new NutConfigException("_t_start"); } } diff --git a/src/main/webapp/WEB-INF/template/admin/svn_user/frame/left.ftl b/src/main/webapp/WEB-INF/template/admin/svn_user/frame/left.ftl index 1b73bf3..55bd8aa 100644 --- a/src/main/webapp/WEB-INF/template/admin/svn_user/frame/left.ftl +++ b/src/main/webapp/WEB-INF/template/admin/svn_user/frame/left.ftl @@ -20,6 +20,9 @@ h3{ padding:0; margin:0; font-weight:normal; font-size:12px;}
  • <@s.m "global.admin.index"/>
  • <@perm_chow perm="svn.user">
  • 账号列表
  • + + <@perm_chow perm="svn.user"> +
  • 已锁账号列表
  • diff --git a/src/main/webapp/WEB-INF/template/admin/svn_user/list.ftl b/src/main/webapp/WEB-INF/template/admin/svn_user/list.ftl index 69b5f4d..907ec16 100644 --- a/src/main/webapp/WEB-INF/template/admin/svn_user/list.ftl +++ b/src/main/webapp/WEB-INF/template/admin/svn_user/list.ftl @@ -11,7 +11,7 @@ function getTableForm() { function rest(usr){ $.dialog({ type: "warn", - content: '确定要充值用户密码?', + content: '确定要重置用户密码?', ok: 'Ok', cancel: 'Cancel', onOk: function() { @@ -33,6 +33,38 @@ function rest(usr){ }); return false; } + +function lock(usr,lock){ + var rl = 'lock.rk'; + var text = '确定要锁定此账号?'; + if(lock==1){ + text = '确定要解锁此账号?'; + rl = 'unlock.rk'; + } + $.dialog({ + type: "warn", + content: text, + ok: 'Ok', + cancel: 'Cancel', + onOk: function() { + $.ajax({ + url: rl, + type: "POST", + data: {"usr":usr}, + dataType: "json", + cache: false, + success: function(message) { + $.message(message); + if (message.type == "success") + { + window.location.href = "${action}?pageNumber=${page}"; + } + } + }); + } + }); + return false; +} @@ -58,6 +90,13 @@ function rest(usr){ <@p.column title="密码重置" align="center"> 密码重置<#rt/> <#t/> + <@p.column title="账号锁定" align="center"> + <#if lock==0> + 账号锁定<#rt/> + <#else> + 账号解锁<#rt/> + + <#t/> diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index eb3ba73..55d9a3e 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -35,11 +35,15 @@ nutz - com.rekoe.mvc.RkCmsNutFilter + org.nutz.mvc.NutFilter modules com.rekoe.MainModule + + exclusions + /res/*,*.html,/static/* + nutz @@ -65,7 +69,7 @@ 500 /WEB-INF/jsp/500.jsp - + 946080000