134个文件已删除
4 文件已重命名
13个文件已修改
1 文件已复制
22个文件已添加
| | |
| | | package com.ks.app.aop; |
| | | |
| | | import com.ks.app.entity.AdminUser; |
| | | import com.ks.app.entity.admin.AdminUser; |
| | | import com.ks.app.service.inter.admin.AdminRoleRuleService; |
| | | import com.ks.app.utils.ApiCodeConstant; |
| | | import com.ks.app.utils.SystemInfoUtil; |
| | | import com.ks.app.vo.AcceptAdminData; |
| | |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | |
| | | @Order(2) |
| | | public class AdminApiFilter { |
| | | |
| | | public static final String EDP = "execution(* com.ks.app.controller.admin..*.*(..))"; |
| | | @Resource |
| | | private AdminRoleRuleService adminRoleRuleService; |
| | | |
| | | public static final String EDP = "execution(* com.yeshi.makemoney.app.controller.admin..*.*(..))"; |
| | | |
| | | @Around(EDP) |
| | | public Object around(ProceedingJoinPoint joinPoint) throws IOException { |
| | | Object[] args = joinPoint.getArgs(); |
| | | ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder |
| | | .getRequestAttributes(); |
| | | servletContainer.getResponse().setCharacterEncoding("UTF-8"); |
| | | |
| | | AcceptAdminData acceptAdminData = null; |
| | | for (Object obj : args) { |
| | |
| | | |
| | | if (acceptAdminData != null) { |
| | | HttpSession session = servletContainer.getRequest().getSession(); |
| | | String url = servletContainer.getRequest().getRequestURI(); |
| | | |
| | | acceptAdminData.setSystem(SystemInfoUtil.getAdminSelectedSystem(servletContainer.getRequest().getSession())); |
| | | if (acceptAdminData.getSystem() == null) { |
| | | acceptAdminData.setSystem(SystemInfoUtil.getAdminSelectedSystem(session)); |
| | | if (acceptAdminData.getSystem() == null && !url.endsWith("index.html") && !url.endsWith("login.html")) { |
| | | PrintWriter out = servletContainer.getResponse().getWriter(); |
| | | out.print(JsonUtil.loadFalseResult(ApiCodeConstant.CODE_ERROR_IN_SERVER, "未选择系统")); |
| | | out.close(); |
| | |
| | | if (contextSession != null) { |
| | | Authentication authentication = contextSession.getAuthentication(); |
| | | AdminUser adminUser = (AdminUser) authentication.getPrincipal(); |
| | | //加载权限 |
| | | if (adminUser != null && adminUser.getRules() == null) { |
| | | adminUser.setRules(adminRoleRuleService.listPaths(adminUser.getAccount())); |
| | | } |
| | | acceptAdminData.setAdminUser(adminUser); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | try { |
| | | return joinPoint.proceed(args); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | PrintWriter out = servletContainer.getResponse().getWriter(); |
| | | out.print(JsonUtil.loadFalseResult(ApiCodeConstant.CODE_ERROR_IN_SERVER, "服务器内部错误")); |
| | | out.close(); |
| | |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | |
| | | @Order(2) |
| | | public class SignValidate { |
| | | |
| | | public static final String EDP = "execution(* com.ks.app.controller.client..*.*(..))"; |
| | | public static final String EDP = "execution(* com.yeshi.makemoney.app.controller.client..*.*(..))"; |
| | | |
| | | private Logger logger = LoggerFactory.getLogger(SignValidate.class); |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | |
| | | e.printStackTrace(); |
| | | out = servletContainer.getResponse().getWriter(); |
| | | out.print(JsonUtil.loadFalseResult(ApiCodeConstant.CODE_ERROR_IN_SERVER, "服务器内部错误")); |
| | | logger.error("api:{} params:{}", request.getRequestURI(), JsonUtil.getSimpleGson().toJson(request.getParameterMap()), e); |
| | | return null; |
| | | } |
| | | return obj; |
| | |
| | | @Component |
| | | public class UserLoginValid { |
| | | |
| | | public static final String EDP = "execution(* com.ks.app.controller.client..*.*(..))"; |
| | | public static final String EDP = "execution(* com.yeshi.makemoney.app.controller.client..*.*(..))"; |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | |
| | | import com.google.code.kaptcha.Producer; |
| | | import com.google.code.kaptcha.impl.DefaultKaptcha; |
| | | import com.google.code.kaptcha.util.Config; |
| | | import com.ks.app.entity.AdminUser; |
| | | import com.ks.app.entity.admin.AdminUser; |
| | | import com.ks.app.service.inter.AdminUserService; |
| | | import net.sf.json.JSONObject; |
| | | import org.omg.CORBA.SystemException; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.context.annotation.Bean; |
| | |
| | | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.core.AuthenticationException; |
| | | import org.springframework.security.core.context.SecurityContext; |
| | | import org.springframework.security.core.userdetails.UserDetails; |
| | | import org.springframework.security.core.userdetails.UserDetailsService; |
| | | import org.springframework.security.core.userdetails.UsernameNotFoundException; |
| | |
| | | import org.springframework.security.web.authentication.AuthenticationSuccessHandler; |
| | | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; |
| | | import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; |
| | | import org.springframework.util.AntPathMatcher; |
| | | import org.springframework.web.filter.OncePerRequestFilter; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.StringUtil; |
| | |
| | | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
| | | |
| | | |
| | | private final static String[] STATIC_RESOURCE_PATHS = new String[]{ |
| | | "/**/*.html", "/**/*.css", "/**/*.js", "/**/*.png", "/**/*.jpg", "/**/*.jpeg", "/**/*.gif", "/**/*.xml", "/**/font/*", "/**/fonts/*" |
| | | }; |
| | | |
| | | private Logger logger = LoggerFactory.getLogger(WebSecurityConfig.class); |
| | | |
| | | @Resource |
| | |
| | | |
| | | private final String LOGIN_PROCESSING_URL = "/admin/api/login"; |
| | | |
| | | private final String LOGIN_PAGE_PATH="/7aed59d33d777100/login.html"; |
| | | private final String LOGIN_PAGE_PATH = "/admin/xrtfgp/login.html"; |
| | | |
| | | //图形验证码配置 |
| | | @Bean |
| | |
| | | } |
| | | |
| | | |
| | | //验证码过滤器 |
| | | class VerificationCodeFilter extends OncePerRequestFilter { |
| | | private AuthenticationFailureHandler authenticationFailureHandler = new AuthenticationFailureHandler() { |
| | | /** |
| | | * @author hxh |
| | | * @description 请求之前的验证器 |
| | | * @date 16:51 2022/5/19 |
| | | * @return |
| | | **/ |
| | | class PreRequestVerifyFilter extends OncePerRequestFilter { |
| | | |
| | | //处理验证码出错 |
| | | private AuthenticationFailureHandler verifyCodeFailureHandler = new AuthenticationFailureHandler() { |
| | | @Override |
| | | public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException { |
| | | httpServletResponse.setContentType("application/json;charset=UTF-8"); |
| | |
| | | } |
| | | }; |
| | | |
| | | //处理没有权限 |
| | | private AuthenticationFailureHandler authenticationFailureHandler = new AuthenticationFailureHandler() { |
| | | @Override |
| | | public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException { |
| | | httpServletResponse.setStatus(HttpStatus.FORBIDDEN.value()); |
| | | } |
| | | }; |
| | | |
| | | @Override |
| | | protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException { |
| | | if (!LOGIN_PROCESSING_URL.equalsIgnoreCase(httpServletRequest.getRequestURI())) { |
| | | //非登录接口 |
| | | String url = httpServletRequest.getRequestURI(); |
| | | //不验证静态资源 |
| | | AntPathMatcher pathMatcher = new AntPathMatcher(); |
| | | for (String resource : STATIC_RESOURCE_PATHS) { |
| | | if (pathMatcher.match(resource, url)) { |
| | | filterChain.doFilter(httpServletRequest, httpServletResponse); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | //尚未登录授权的就不需要验证权限了 |
| | | SecurityContext contextSession = (SecurityContext) httpServletRequest.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); |
| | | |
| | | if (contextSession == null) { |
| | | filterChain.doFilter(httpServletRequest, httpServletResponse); |
| | | return; |
| | | } |
| | | Authentication authentication = contextSession.getAuthentication(); |
| | | if (authentication == null) { |
| | | filterChain.doFilter(httpServletRequest, httpServletResponse); |
| | | return; |
| | | } |
| | | AdminUser adminUser = (AdminUser) authentication.getPrincipal(); |
| | | if (adminUser == null) { |
| | | filterChain.doFilter(httpServletRequest, httpServletResponse); |
| | | return; |
| | | } |
| | | |
| | | //验证权限 |
| | | for (String path : adminUser.getRules()) { |
| | | if (pathMatcher.match(path, url)) { |
| | | //有权限 |
| | | filterChain.doFilter(httpServletRequest, httpServletResponse); |
| | | return; |
| | | } |
| | | } |
| | | //无权限 |
| | | authenticationFailureHandler.onAuthenticationFailure(httpServletRequest, httpServletResponse, null); |
| | | } else { |
| | | //登录接口 |
| | | try { |
| | | verificationCode(httpServletRequest); |
| | | filterChain.doFilter(httpServletRequest, httpServletResponse); |
| | | } catch (VerificationCodeException e) { |
| | | authenticationFailureHandler.onAuthenticationFailure(httpServletRequest, httpServletResponse, e); |
| | | verifyCodeFailureHandler.onAuthenticationFailure(httpServletRequest, httpServletResponse, e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | | * @description 验证验证码是否正确 |
| | | * @date 16:54 2022/5/19 |
| | | * @param: httpServletRequest |
| | | **/ |
| | | private void verificationCode(HttpServletRequest httpServletRequest) throws VerificationCodeException { |
| | | String requestCode = httpServletRequest.getParameter("captcha"); |
| | | HttpSession httpSession = httpServletRequest.getSession(); |
| | |
| | | if (StringUtil.isNullOrEmpty(captcha) || StringUtil.isNullOrEmpty(requestCode) || !captcha.equalsIgnoreCase(requestCode)) { |
| | | throw new VerificationCodeException(); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | .and() |
| | | .csrf().disable() |
| | | .rememberMe().userDetailsService(new MyUserDetailsService()) |
| | | .and().exceptionHandling().authenticationEntryPoint(new CustomAuthenticationEntryPoint()); |
| | | http.addFilterBefore(new VerificationCodeFilter(), UsernamePasswordAuthenticationFilter.class); |
| | | .and().exceptionHandling().authenticationEntryPoint(new NotLoginAuthenticationEntryPoint()); |
| | | http.addFilterBefore(new PreRequestVerifyFilter(), UsernamePasswordAuthenticationFilter.class); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | |
| | | //自定义未授权返回 |
| | | class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint { |
| | | /** |
| | | * @author hxh |
| | | * @description 未登录的事件处理 |
| | | * @date 16:55 2022/5/19 |
| | | * @return |
| | | **/ |
| | | class NotLoginAuthenticationEntryPoint implements AuthenticationEntryPoint { |
| | | @Override |
| | | public void commence(HttpServletRequest request, HttpServletResponse response, |
| | | AuthenticationException authException) throws IOException, ServletException { |
| | | String url = request.getRequestURI().toString(); |
| | | String url = request.getRequestURI(); |
| | | if (url.contains("/admin/api/")) { |
| | | response.setStatus(HttpStatus.UNAUTHORIZED.value()); |
| | | } else { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.app.controller.admin; |
| | | |
| | | import com.ks.app.entity.admin.AdminRole; |
| | | import com.ks.app.entity.admin.AdminRoleRule; |
| | | import com.ks.app.service.inter.AdminUserService; |
| | | import com.ks.app.service.inter.admin.AdminRoleRuleService; |
| | | import com.ks.app.service.inter.admin.AdminUserRolesService; |
| | | import com.ks.app.service.query.admin.AdminRoleRuleQuery; |
| | | import com.ks.app.utils.xml.PageNavUtil; |
| | | import com.ks.app.vo.AcceptAdminData; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | | @RequestMapping("/admin/xrtfgp") |
| | | public class AdminController { |
| | | |
| | | @Resource |
| | | private AdminUserService adminUserService; |
| | | |
| | | @Resource |
| | | private AdminRoleRuleService adminRoleRuleService; |
| | | |
| | | @Resource |
| | | private AdminUserRolesService adminUserRolesService; |
| | | |
| | | |
| | | @RequestMapping("index.html") |
| | | public String index(Model model, AcceptAdminData acceptAdminData, HttpServletResponse response) { |
| | | //获取导航页面 |
| | | if (acceptAdminData.getAdminUser() != null) { |
| | | List<AdminRole> adminRoles = adminUserRolesService.listRoleByAdminId(acceptAdminData.getAdminUser().getAccount()); |
| | | AdminRoleRuleQuery query = new AdminRoleRuleQuery(); |
| | | query.setNavPage(true); |
| | | query.setRoles(adminRoles); |
| | | long count = adminRoleRuleService.count(query); |
| | | List<AdminRoleRule> list = adminRoleRuleService.list(query, 1, (int) count); |
| | | List<String> pathList = new ArrayList<>(); |
| | | for (AdminRoleRule roleRule : list) { |
| | | pathList.add(roleRule.getPath()); |
| | | } |
| | | model.addAttribute("pages", PageNavUtil.getPageNavs(pathList)); |
| | | return "index"; |
| | | } else { |
| | | return "login"; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @RequestMapping("login.html") |
| | | public String login(Model model, AcceptAdminData acceptAdminData) { |
| | | return "login"; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.app.controller.admin; |
| | | |
| | | import com.google.gson.*; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.yeshi.makemoney.app.entity.admin.AdminRole; |
| | | import com.yeshi.makemoney.app.entity.admin.AdminRoleRule; |
| | | import com.yeshi.makemoney.app.service.inter.admin.AdminRoleRuleService; |
| | | import com.yeshi.makemoney.app.service.query.admin.AdminRoleRuleQuery; |
| | | import com.yeshi.makemoney.app.vo.AcceptAdminData; |
| | | import com.yeshi.makemoney.app.vo.admin.AdminRoleRuleAdminVO; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.lang.reflect.Type; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | | @RequestMapping("/admin/api/authority") |
| | | public class AdminRoleRuleController { |
| | | |
| | | @Resource |
| | | private AdminRoleRuleService adminRoleRuleService; |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("list") |
| | | public String list(AdminRoleRuleQuery query, int page, int limit) { |
| | | List<AdminRoleRule> list = adminRoleRuleService.list(query, page, limit); |
| | | long count = adminRoleRuleService.count(query); |
| | | JSONObject data = new JSONObject(); |
| | | Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | |
| | | @Override |
| | | public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) { |
| | | return date == null ? new JsonPrimitive("") : new JsonPrimitive(TimeUtil.getGernalTime(date.getTime(), "yyyy.MM.dd HH:mm")); |
| | | } |
| | | }).registerTypeAdapter(AdminRole.class, new JsonSerializer<AdminRole>() { |
| | | |
| | | @Override |
| | | public JsonElement serialize(AdminRole role, Type type, JsonSerializationContext jsonSerializationContext) { |
| | | return role == null ? new JsonPrimitive("") : new JsonPrimitive(role.getName()); |
| | | } |
| | | }).create(); |
| | | |
| | | data.put("list", gson.toJson(list)); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("delete") |
| | | public String delete(String ids) { |
| | | Type type = new TypeToken<List<String>>() { |
| | | }.getType(); |
| | | List<String> idList = new Gson().fromJson(ids, type); |
| | | adminRoleRuleService.delete(idList); |
| | | return JsonUtil.loadTrueResult(""); |
| | | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("add") |
| | | public String add(@RequestBody AdminRoleRuleAdminVO vo, AcceptAdminData acceptAdminData) { |
| | | try { |
| | | for (String path : vo.getPaths()) { |
| | | vo.setPath(path.trim()); |
| | | adminRoleRuleService.add(vo.toEntity(acceptAdminData.getSystem())); |
| | | } |
| | | return JsonUtil.loadTrueResult(""); |
| | | } catch (Exception e) { |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("get") |
| | | public String get(String id, AcceptAdminData acceptAdminData) { |
| | | Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | |
| | | @Override |
| | | public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) { |
| | | return date == null ? new JsonPrimitive("") : new JsonPrimitive(TimeUtil.getGernalTime(date.getTime(), "yyyy.MM.dd HH:mm")); |
| | | } |
| | | }).registerTypeAdapter(AdminRole.class, new JsonSerializer<AdminRole>() { |
| | | |
| | | @Override |
| | | public JsonElement serialize(AdminRole role, Type type, JsonSerializationContext jsonSerializationContext) { |
| | | return role == null ? new JsonPrimitive("") : new JsonPrimitive(role.getName()); |
| | | } |
| | | }).create(); |
| | | |
| | | |
| | | AdminRoleRule entity = adminRoleRuleService.get(id); |
| | | if (entity != null) { |
| | | return JsonUtil.loadTrueResult(gson.toJson(entity)); |
| | | } else { |
| | | return JsonUtil.loadFalseResult("ID不存在"); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("update") |
| | | |
| | | public String update(AdminRoleRuleAdminVO vo, AcceptAdminData acceptAdminData) { |
| | | if (vo.getId() == null) { |
| | | return JsonUtil.loadFalseResult("ID不能为空"); |
| | | |
| | | } |
| | | try { |
| | | adminRoleRuleService.update(vo.toEntity(null)); |
| | | } catch (Exception e) { |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | |
| | | } |
| | | return JsonUtil.loadTrueResult(""); |
| | | |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("listRoles") |
| | | public String listRoles(AdminRoleRuleAdminVO vo, AcceptAdminData acceptAdminData) { |
| | | JSONArray array = new JSONArray(); |
| | | for (AdminRole role : AdminRole.values()) { |
| | | JSONObject item = new JSONObject(); |
| | | item.put("key", role.name()); |
| | | item.put("value", role.getName()); |
| | | array.add(item); |
| | | } |
| | | return JsonUtil.loadTrueResult(array); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.ks.app.controller.admin; |
| | | |
| | | import com.ks.app.entity.AdminUser; |
| | | import com.google.gson.*; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.ks.app.entity.admin.AdminRole; |
| | | import com.ks.app.entity.admin.AdminUser; |
| | | import com.ks.app.service.inter.AdminUserService; |
| | | import com.ks.app.service.inter.admin.AdminUserRolesService; |
| | | import com.ks.app.vo.AcceptAdminData; |
| | | import com.ks.app.vo.AdminUserVO; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.StringUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpSession; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.lang.reflect.Type; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | | @RequestMapping("/admin/api/user") |
| | | @RequestMapping("/admin/api/adminuser") |
| | | public class AdminUserController { |
| | | |
| | | @Resource |
| | | private AdminUserService adminUserService; |
| | | |
| | | @Resource |
| | | private AdminUserRolesService adminUserRolesService; |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("login") |
| | |
| | | } |
| | | |
| | | AdminUser adminUser = adminUserService.selectByAccount(account); |
| | | if (adminUser == null) { |
| | | if (adminUser == null || !adminUser.getAccount().equals(account)) { |
| | | return JsonUtil.loadFalseResult("账号不存在"); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("list") |
| | | public String list(AcceptAdminData acceptAdminData, int page, int limit) { |
| | | List<AdminUser> list = adminUserService.list(page, limit); |
| | | long count = adminUserService.count(); |
| | | Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | @Override |
| | | public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) { |
| | | return date == null ? new JsonPrimitive("") : new JsonPrimitive(TimeUtil.getGernalTime(date.getTime(), "yyyy.MM.dd HH:mm")); |
| | | } |
| | | }).registerTypeAdapter(AdminRole.class, new JsonSerializer<AdminRole>() { |
| | | @Override |
| | | public JsonElement serialize(AdminRole role, Type type, JsonSerializationContext jsonSerializationContext) { |
| | | return role == null ? new JsonPrimitive("") : new JsonPrimitive(role.getName()); |
| | | } |
| | | }).create(); |
| | | |
| | | List<AdminUserVO> voList = new ArrayList<>(); |
| | | //查询角色 |
| | | for (AdminUser adminUser : list) { |
| | | adminUser.setPwd(null); |
| | | List<AdminRole> roleList = adminUserRolesService.listRoleByAdminId(adminUser.getAccount()); |
| | | voList.add(AdminUserVO.create(adminUser, roleList)); |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("list", gson.toJson(voList)); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getLoginAdminInfo") |
| | | public String getLoginAdminInfo(AcceptAdminData acceptAdminData) { |
| | | |
| | | if (acceptAdminData.getAdminUser() == null) { |
| | | return JsonUtil.loadFalseResult("尚未登录"); |
| | | } |
| | | |
| | | return JsonUtil.loadTrueResult(AdminUserVO.create(acceptAdminData.getAdminUser())); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("get") |
| | | public String get(AcceptAdminData acceptAdminData, String id) { |
| | | AdminUser adminUser = adminUserService.selectByAccount(id); |
| | | if (adminUser == null) { |
| | | return JsonUtil.loadFalseResult("id不存在"); |
| | | } |
| | | adminUser.setPwd(null); |
| | | List<AdminRole> roleList = adminUserRolesService.listRoleByAdminId(adminUser.getAccount()); |
| | | AdminUserVO vo = AdminUserVO.create(adminUser, roleList); |
| | | Gson gson = new GsonBuilder().registerTypeAdapter(AdminRole.class, new JsonSerializer<AdminRole>() { |
| | | @Override |
| | | public JsonElement serialize(AdminRole role, Type type, JsonSerializationContext jsonSerializationContext) { |
| | | JSONObject json = new JSONObject(); |
| | | json.put("key", role.name()); |
| | | json.put("value", role.getName()); |
| | | return role == null ? new JsonPrimitive("") : new JsonPrimitive(json.toString()); |
| | | } |
| | | }).create(); |
| | | return JsonUtil.loadTrueResult(gson.toJson(vo)); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("add") |
| | | public String add(@RequestBody AdminUserVO vo) { |
| | | AdminUser adminUser = vo.toEntity(); |
| | | try { |
| | | adminUserService.add(adminUser); |
| | | } catch (Exception e) { |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | } |
| | | //更新权限 |
| | | adminUserRolesService.setRoles(adminUser.getAccount(), vo.getRoleList()); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("update") |
| | | public String update(@RequestBody AdminUserVO vo) { |
| | | AdminUser adminUser = vo.toEntity(); |
| | | adminUserService.update(adminUser); |
| | | //更新权限 |
| | | adminUserRolesService.setRoles(adminUser.getAccount(), vo.getRoleList()); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("delete") |
| | | public String delete(String ids) { |
| | | Type type = new TypeToken<List<String>>() { |
| | | }.getType(); |
| | | List<String> idList = new Gson().fromJson(ids, type); |
| | | adminUserService.delete(idList); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.app.dao.admin; |
| | | |
| | | import com.ks.app.entity.admin.AdminRole; |
| | | import com.ks.app.entity.admin.AdminRoleRule; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | import org.yeshi.utils.mongo.MongodbBaseDao; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | @Repository |
| | | public class AdminRoleRuleDao extends MongodbBaseDao<AdminRoleRule> { |
| | | |
| | | public void updateSelective(AdminRoleRule bean) { |
| | | Query query = new Query(); |
| | | Update update = new Update(); |
| | | query.addCriteria(Criteria.where("id").is(bean.getId())); |
| | | if (bean.getRole() != null) { |
| | | update.set("role", bean.getRole()); |
| | | } |
| | | if (bean.getPath() != null) { |
| | | update.set("path", bean.getPath()); |
| | | } |
| | | |
| | | if (bean.getNavPage() != null) { |
| | | update.set("navPage", bean.getNavPage()); |
| | | } |
| | | |
| | | if (bean.getCreateTime() != null) { |
| | | update.set("createTime", bean.getCreateTime()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | |
| | | |
| | | public List<AdminRoleRule> list(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | if (daoQuery.sortList != null && daoQuery.sortList.size() > 0) { |
| | | query.with(Sort.by(daoQuery.sortList)); |
| | | } |
| | | query.skip(daoQuery.start); |
| | | query.limit(daoQuery.count); |
| | | return findList(query); |
| | | } |
| | | |
| | | public long count(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | return count(query); |
| | | } |
| | | |
| | | private Query getQuery(DaoQuery daoQuery) { |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | if (daoQuery.role != null) { |
| | | andList.add(Criteria.where("role").is(daoQuery.role)); |
| | | } |
| | | if (daoQuery.roles != null && daoQuery.roles.size() > 0) { |
| | | Criteria[] ors = new Criteria[daoQuery.roles.size()]; |
| | | for (int i = 0; i < ors.length; i++) { |
| | | ors[i] =new Criteria("role").is(daoQuery.roles.get(i)); |
| | | } |
| | | |
| | | |
| | | andList.add(new Criteria().orOperator(ors)); |
| | | } |
| | | if (daoQuery.path != null) { |
| | | andList.add(Criteria.where("path").regex(daoQuery.path)); |
| | | } |
| | | if (daoQuery.navPage != null) { |
| | | andList.add(Criteria.where("navPage").is(daoQuery.navPage)); |
| | | } |
| | | Query query = new Query(); |
| | | Criteria[] ands = new Criteria[andList.size()]; |
| | | andList.toArray(ands); |
| | | if (ands.length > 0) { |
| | | query.addCriteria(new Criteria().andOperator(ands)); |
| | | } |
| | | return query; |
| | | } |
| | | |
| | | public static class DaoQuery { |
| | | public AdminRole role; |
| | | public String path; |
| | | public Boolean navPage; |
| | | public List<AdminRole> roles; |
| | | public int start; |
| | | public int count; |
| | | public List<Sort.Order> sortList; |
| | | } |
| | | } |
| | |
| | | package com.ks.app.dao.admin; |
| | | |
| | | import com.ks.app.entity.AdminUser; |
| | | import com.ks.app.entity.admin.AdminUser; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | import org.yeshi.utils.mongo.MongodbBaseDao; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: AdminUserDao |
| | | * @description: TODO |
| | | * @description: 管理员 |
| | | * @date 2021/11/13 13:08 |
| | | */ |
| | | @Repository |
| | | public class AdminUserDao extends MongodbBaseDao<AdminUser> { |
| | | |
| | | /** |
| | | * @return AdminUser |
| | | * @return com.yeshi.makemoney.app.entity.AdminUser |
| | | * @author hxh |
| | | * @description 根据账号查询 |
| | | * @date 13:10 2021/11/13 |
| | |
| | | return findOne(query); |
| | | } |
| | | |
| | | public List<AdminUser> list(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | if (daoQuery.sortList != null && daoQuery.sortList.size() > 0) { |
| | | query.with(Sort.by(daoQuery.sortList)); |
| | | } |
| | | query.skip(daoQuery.start); |
| | | query.limit(daoQuery.count); |
| | | return findList(query); |
| | | } |
| | | |
| | | public long count(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | return count(query); |
| | | } |
| | | |
| | | private Query getQuery(DaoQuery daoQuery) { |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | Query query = new Query(); |
| | | Criteria[] ands = new Criteria[andList.size()]; |
| | | andList.toArray(ands); |
| | | if (ands.length > 0) { |
| | | query.addCriteria(new Criteria().andOperator(ands)); |
| | | } |
| | | return query; |
| | | } |
| | | |
| | | |
| | | public void updateSelective(AdminUser bean) { |
| | | Query query = new Query(); |
| | | Update update = new Update(); |
| | | query.addCriteria(Criteria.where("_id").is(bean.getAccount())); |
| | | if (bean.getName() != null) { |
| | | update.set("name", bean.getName()); |
| | | } |
| | | if (bean.getEmail() != null) { |
| | | update.set("email", bean.getEmail()); |
| | | } |
| | | if (bean.getPwd() != null) { |
| | | update.set("pwd", bean.getPwd()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | |
| | | public static class DaoQuery { |
| | | public int start; |
| | | public int count; |
| | | public List<Sort.Order> sortList; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.app.dao.admin; |
| | | |
| | | import com.ks.app.entity.admin.AdminRole; |
| | | import com.ks.app.entity.admin.AdminUserRoles; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | import org.yeshi.utils.mongo.MongodbBaseDao; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | @Repository |
| | | public class AdminUserRolesDao extends MongodbBaseDao<AdminUserRoles>{ |
| | | |
| | | public void updateSelective(AdminUserRoles bean) { |
| | | Query query = new Query(); |
| | | Update update=new Update(); |
| | | query.addCriteria(Criteria.where("id").is(bean.getId())); |
| | | if(bean.getAdminId() != null) { |
| | | update.set("adminId", bean.getAdminId()); |
| | | } |
| | | if(bean.getRole() != null) { |
| | | update.set("role", bean.getRole()); |
| | | } |
| | | if(bean.getCreateTime() != null) { |
| | | update.set("createTime", bean.getCreateTime()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | |
| | | |
| | | public List<AdminUserRoles> list(DaoQuery daoQuery){ |
| | | Query query = getQuery(daoQuery); |
| | | if (daoQuery.sortList!=null && daoQuery.sortList.size()>0){ |
| | | query.with(Sort.by(daoQuery.sortList)); |
| | | } |
| | | query.skip(daoQuery.start); |
| | | query.limit(daoQuery.count); |
| | | return findList(query); |
| | | } |
| | | |
| | | public long count(DaoQuery daoQuery){ |
| | | Query query=getQuery(daoQuery); |
| | | return count(query); |
| | | } |
| | | |
| | | private Query getQuery(DaoQuery daoQuery){ |
| | | List<Criteria> andList=new ArrayList<>(); |
| | | if(daoQuery.adminId!=null){ |
| | | andList.add(Criteria.where("adminId").is(daoQuery.adminId)); |
| | | } |
| | | if(daoQuery.role!=null){ |
| | | andList.add(Criteria.where("role").is(daoQuery.role)); |
| | | } |
| | | Query query=new Query(); |
| | | Criteria[] ands=new Criteria[andList.size()]; |
| | | andList.toArray(ands); |
| | | if(ands.length>0){ |
| | | query.addCriteria(new Criteria().andOperator(ands)); |
| | | } |
| | | return query; |
| | | } |
| | | |
| | | public static class DaoQuery{ |
| | | public String adminId; |
| | | public AdminRole role; |
| | | public int start; |
| | | public int count; |
| | | public List<Sort.Order> sortList; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.app.dto.admin; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: PageNav |
| | | * @description: 页面导航 |
| | | * @date 2022/5/18 16:33 |
| | | */ |
| | | public class PageNav { |
| | | |
| | | private String name; |
| | | private String path; |
| | | private String icon; |
| | | private List<PageNav> children; |
| | | |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getPath() { |
| | | return path; |
| | | } |
| | | |
| | | public void setPath(String path) { |
| | | this.path = path; |
| | | } |
| | | |
| | | public String getIcon() { |
| | | return icon; |
| | | } |
| | | |
| | | public void setIcon(String icon) { |
| | | this.icon = icon; |
| | | } |
| | | |
| | | public List<PageNav> getChildren() { |
| | | return children; |
| | | } |
| | | |
| | | public void setChildren(List<PageNav> children) { |
| | | this.children = children; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.app.entity.admin; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: AdminRule |
| | | * @description: 管理员角色 |
| | | * @date 2022/5/16 10:03 |
| | | */ |
| | | public enum AdminRole { |
| | | base("基础权限"), |
| | | contentManager("内容管理员"), |
| | | reviewer("审核人员"), |
| | | systemManager("系统管理员"); |
| | | |
| | | private String name; |
| | | |
| | | private AdminRole(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.app.entity.admin; |
| | | |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.mongodb.core.index.Indexed; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: AdminRoleRule |
| | | * @description: 角色规则 |
| | | * @date 2022/5/16 10:12 |
| | | */ |
| | | @Document(collection = "adminRoleRule") |
| | | public class AdminRoleRule { |
| | | |
| | | @Id |
| | | private String id; |
| | | @Indexed |
| | | private AdminRole role; |
| | | |
| | | /** |
| | | * 是否为导航页面 |
| | | **/ |
| | | @Indexed |
| | | private Boolean navPage; |
| | | |
| | | @Indexed |
| | | private String path; |
| | | |
| | | private String remarks; |
| | | |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | public String toId() { |
| | | return role.name() + "-" + StringUtil.Md5(path); |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public AdminRole getRole() { |
| | | return role; |
| | | } |
| | | |
| | | public void setRole(AdminRole role) { |
| | | this.role = role; |
| | | } |
| | | |
| | | public String getPath() { |
| | | return path; |
| | | } |
| | | |
| | | public void setPath(String path) { |
| | | this.path = path; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public String getRemarks() { |
| | | return remarks; |
| | | } |
| | | |
| | | public void setRemarks(String remarks) { |
| | | this.remarks = remarks; |
| | | } |
| | | |
| | | public Boolean getNavPage() { |
| | | return navPage; |
| | | } |
| | | |
| | | public void setNavPage(Boolean navPage) { |
| | | this.navPage = navPage; |
| | | } |
| | | } |
File was renamed from src/main/resources/code/service/app/src/main/java/com/ks/app/entity/AdminUser.java |
| | |
| | | package com.ks.app.entity; |
| | | package com.ks.app.entity.admin; |
| | | |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.annotation.Transient; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | import org.springframework.security.core.GrantedAuthority; |
| | | import org.springframework.security.core.userdetails.UserDetails; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Document(collection = "adminUser") |
| | | public class AdminUser implements UserDetails { |
| | |
| | | private String email; |
| | | |
| | | private Date createTime; |
| | | |
| | | private Date updateTime; |
| | | |
| | | @Transient |
| | | private List<String> rules; |
| | | |
| | | |
| | | public String getEmail() { |
| | |
| | | public boolean isEnabled() { |
| | | return true; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public List<String> getRules() { |
| | | return rules; |
| | | } |
| | | |
| | | public void setRules(List<String> rules) { |
| | | this.rules = rules; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.app.entity.admin; |
| | | |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.mongodb.core.index.Indexed; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: AdminUserRules |
| | | * @description: 管理员角色分配 |
| | | * @date 2022/5/16 10:09 |
| | | */ |
| | | @Document(collection = "adminUserRoles") |
| | | public class AdminUserRoles { |
| | | @Id |
| | | private String id; |
| | | @Indexed |
| | | private String adminId; |
| | | @Indexed |
| | | private AdminRole role; |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | public String toId() { |
| | | return adminId + "-" + role.name(); |
| | | } |
| | | |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getAdminId() { |
| | | return adminId; |
| | | } |
| | | |
| | | public AdminRole getRole() { |
| | | return role; |
| | | } |
| | | |
| | | public void setRole(AdminRole role) { |
| | | this.role = role; |
| | | } |
| | | |
| | | public void setAdminId(String adminId) { |
| | | this.adminId = adminId; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | } |
| | |
| | | package com.ks.app.entity.config; |
| | | |
| | | import com.yeshi.makemoney.app.entity.SystemEnum; |
| | | import com.ks.app.entity.SystemEnum; |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.mongodb.core.index.Indexed; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | |
| | | package com.ks.app.service.impl; |
| | | |
| | | import com.ks.app.dao.admin.AdminUserDao; |
| | | import com.ks.app.entity.AdminUser; |
| | | import com.ks.app.entity.admin.AdminUser; |
| | | import com.ks.app.service.inter.AdminUserService; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | |
| | | if (selectByAccount(adminUser.getAccount()) != null) { |
| | | throw new Exception("账号已存在"); |
| | | } |
| | | |
| | | if (adminUser.getCreateTime() == null) { |
| | | adminUser.setCreateTime(new Date()); |
| | | } |
| | | |
| | | adminUserDao.save(adminUser); |
| | | } |
| | | |
| | | @Override |
| | | public void update(AdminUser adminUser) { |
| | | if (adminUser.getAccount() == null) { |
| | | return; |
| | | } |
| | | adminUserDao.updateSelective(adminUser); |
| | | } |
| | | |
| | | @Override |
| | | public List<AdminUser> list(int page, int pageSize) { |
| | | AdminUserDao.DaoQuery daoQuery = new AdminUserDao.DaoQuery(); |
| | | daoQuery.start = (page - 1) * pageSize; |
| | | daoQuery.count = pageSize; |
| | | return adminUserDao.list(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public long count() { |
| | | AdminUserDao.DaoQuery daoQuery = new AdminUserDao.DaoQuery(); |
| | | return adminUserDao.count(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(List<String> ids) { |
| | | Query query = new Query(); |
| | | Criteria[] ors = new Criteria[ids.size()]; |
| | | for (int i = 0; i < ids.size(); i++) { |
| | | ors[i] = Criteria.where("_id").is(ids.get(i)); |
| | | } |
| | | query.addCriteria(new Criteria().orOperator(ors)); |
| | | adminUserDao.delete(query); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.app.service.impl.admin; |
| | | |
| | | import com.ks.app.dao.admin.AdminRoleRuleDao; |
| | | import com.ks.app.entity.admin.AdminRole; |
| | | import com.ks.app.entity.admin.AdminRoleRule; |
| | | import com.ks.app.service.inter.admin.AdminRoleRuleService; |
| | | import com.ks.app.service.inter.admin.AdminUserRolesService; |
| | | import com.ks.app.service.query.admin.AdminRoleRuleQuery; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class AdminRoleRuleServiceImpl implements AdminRoleRuleService { |
| | | |
| | | @Resource |
| | | private AdminRoleRuleDao adminRoleRuleDao; |
| | | |
| | | @Resource |
| | | private AdminUserRolesService adminUserRolesService; |
| | | |
| | | @Override |
| | | public List<AdminRoleRule> list(AdminRoleRuleQuery adminRoleRuleQuery, int page, int pageSize) { |
| | | AdminRoleRuleDao.DaoQuery daoQuery = new AdminRoleRuleDao.DaoQuery(); |
| | | daoQuery.role = adminRoleRuleQuery.getRole(); |
| | | daoQuery.path = adminRoleRuleQuery.getPath(); |
| | | daoQuery.navPage = adminRoleRuleQuery.getNavPage(); |
| | | daoQuery.roles = adminRoleRuleQuery.getRoles(); |
| | | daoQuery.sortList = Arrays.asList(new Sort.Order[]{Sort.Order.desc("createTime")}); |
| | | |
| | | |
| | | daoQuery.start = (page - 1) * pageSize; |
| | | daoQuery.count = pageSize; |
| | | return adminRoleRuleDao.list(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public long count(AdminRoleRuleQuery adminRoleRuleQuery) { |
| | | AdminRoleRuleDao.DaoQuery daoQuery = new AdminRoleRuleDao.DaoQuery(); |
| | | daoQuery.role = adminRoleRuleQuery.getRole(); |
| | | daoQuery.path = adminRoleRuleQuery.getPath(); |
| | | daoQuery.navPage = adminRoleRuleQuery.getNavPage(); |
| | | daoQuery.roles = adminRoleRuleQuery.getRoles(); |
| | | |
| | | return adminRoleRuleDao.count(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public AdminRoleRule get(String id) { |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("_id").is(id)); |
| | | return adminRoleRuleDao.findOne(query); |
| | | } |
| | | |
| | | @Override |
| | | public void add(AdminRoleRule adminRoleRule) throws Exception { |
| | | |
| | | if (adminRoleRule.getId() == null) { |
| | | adminRoleRule.setId(adminRoleRule.toId()); |
| | | } |
| | | |
| | | if (adminRoleRule.getNavPage() == null) { |
| | | adminRoleRule.setNavPage(false); |
| | | } |
| | | |
| | | //查询主键ID是否存在 |
| | | if (adminRoleRuleDao.get(adminRoleRule.getId()) != null) { |
| | | throw new Exception("已存在"); |
| | | } |
| | | |
| | | if (adminRoleRule.getCreateTime() == null) { |
| | | adminRoleRule.setCreateTime(new Date()); |
| | | } |
| | | //保存 |
| | | adminRoleRuleDao.save(adminRoleRule); |
| | | } |
| | | |
| | | @Override |
| | | public void update(AdminRoleRule adminRoleRule) { |
| | | if (adminRoleRule.getUpdateTime() == null) { |
| | | adminRoleRule.setUpdateTime(new Date()); |
| | | } |
| | | //更新 |
| | | adminRoleRuleDao.updateSelective(adminRoleRule); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(List<String> idList) { |
| | | for (String id : idList) { |
| | | adminRoleRuleDao.delete(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<String> listPaths(String adminId) { |
| | | |
| | | List<AdminRole> list = adminUserRolesService.listRoleByAdminId(adminId); |
| | | if (list == null) { |
| | | return new ArrayList<>(); |
| | | } |
| | | AdminRoleRuleQuery query = new AdminRoleRuleQuery(); |
| | | query.setRoles(list); |
| | | query.setNavPage(false); |
| | | long count = count(query); |
| | | List<AdminRoleRule> ruleList = list(query, 1, (int) count); |
| | | List<String> paths = new ArrayList<>(); |
| | | for (AdminRoleRule roleRule : ruleList) { |
| | | paths.add(roleRule.getPath()); |
| | | } |
| | | return paths; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.app.service.impl.admin; |
| | | |
| | | import com.ks.app.dao.admin.AdminUserRolesDao; |
| | | import com.ks.app.entity.admin.AdminRole; |
| | | import com.ks.app.entity.admin.AdminUserRoles; |
| | | import com.ks.app.service.inter.admin.AdminUserRolesService; |
| | | import com.ks.app.service.query.admin.AdminUserRolesQuery; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | | import org.yeshi.utils.bean.BeanUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class AdminUserRolesServiceImpl implements AdminUserRolesService { |
| | | |
| | | @Resource |
| | | private AdminUserRolesDao adminUserRolesDao; |
| | | |
| | | @Override |
| | | public List<AdminUserRoles> list(AdminUserRolesQuery adminUserRolesQuery, int page, int pageSize) { |
| | | AdminUserRolesDao.DaoQuery daoQuery = new AdminUserRolesDao.DaoQuery(); |
| | | try { |
| | | BeanUtil.copyProperties(adminUserRolesQuery, daoQuery); |
| | | } catch (IllegalAccessException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | daoQuery.start = (page - 1) * pageSize; |
| | | daoQuery.count = pageSize; |
| | | return adminUserRolesDao.list(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public long count(AdminUserRolesQuery adminUserRolesQuery) { |
| | | AdminUserRolesDao.DaoQuery daoQuery = new AdminUserRolesDao.DaoQuery(); |
| | | try { |
| | | BeanUtil.copyProperties(adminUserRolesQuery, daoQuery); |
| | | } catch (IllegalAccessException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return adminUserRolesDao.count(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public AdminUserRoles get(String id) { |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("_id").is(id)); |
| | | return adminUserRolesDao.findOne(query); |
| | | } |
| | | |
| | | @Override |
| | | public void add(AdminUserRoles adminUserRoles) throws Exception { |
| | | //查询主键ID是否存在 |
| | | if (adminUserRolesDao.get(adminUserRoles.getId()) != null) { |
| | | throw new Exception("已存在"); |
| | | } |
| | | |
| | | if (adminUserRoles.getCreateTime() == null) { |
| | | adminUserRoles.setCreateTime(new Date()); |
| | | } |
| | | //保存 |
| | | adminUserRolesDao.save(adminUserRoles); |
| | | } |
| | | |
| | | @Override |
| | | public void update(AdminUserRoles adminUserRoles) { |
| | | if (adminUserRoles.getUpdateTime() == null) { |
| | | adminUserRoles.setUpdateTime(new Date()); |
| | | } |
| | | //更新 |
| | | adminUserRolesDao.updateSelective(adminUserRoles); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(List<String> idList) { |
| | | for (String id : idList) { |
| | | adminUserRolesDao.delete(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<AdminRole> listRoleByAdminId(String adminId) { |
| | | AdminUserRolesDao.DaoQuery daoQuery = new AdminUserRolesDao.DaoQuery(); |
| | | daoQuery.adminId = adminId; |
| | | daoQuery.count = Integer.MAX_VALUE; |
| | | List<AdminUserRoles> adminUserRoles = adminUserRolesDao.list(daoQuery); |
| | | if (adminUserRoles == null) { |
| | | adminUserRoles = new ArrayList<>(); |
| | | } |
| | | return adminUserRoles.stream().map(e -> e.getRole() |
| | | ).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public void setRoles(String adminId, List<AdminRole> roles) { |
| | | if(roles==null){ |
| | | return; |
| | | } |
| | | //删除之前的权限 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("adminId").is(adminId)); |
| | | adminUserRolesDao.delete(query); |
| | | |
| | | //添加新的权限 |
| | | for (AdminRole role : roles) { |
| | | AdminUserRoles adminUserRoles = new AdminUserRoles(); |
| | | adminUserRoles.setAdminId(adminId); |
| | | adminUserRoles.setCreateTime(new Date()); |
| | | adminUserRoles.setRole(role); |
| | | adminUserRoles.setId(adminUserRoles.toId()); |
| | | adminUserRolesDao.save(adminUserRoles); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.ks.app.service.impl.feedback; |
| | | |
| | | import com.yeshi.makemoney.app.dao.feedback.AdviceDao; |
| | | import com.yeshi.makemoney.app.entity.feedback.Advice; |
| | | import com.yeshi.makemoney.app.service.inter.feedback.AdviceService; |
| | | import com.yeshi.makemoney.app.service.query.feedback.AdviceQuery; |
| | | import com.ks.app.dao.feedback.AdviceDao; |
| | | import com.ks.app.entity.feedback.Advice; |
| | | import com.ks.app.service.inter.feedback.AdviceService; |
| | | import com.ks.app.service.query.feedback.AdviceQuery; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | package com.ks.app.service.inter; |
| | | |
| | | import com.ks.app.entity.AdminUser; |
| | | import com.ks.app.entity.admin.AdminUser; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | |
| | | public void add(AdminUser adminUser) throws Exception; |
| | | |
| | | |
| | | public void update(AdminUser adminUser); |
| | | |
| | | public List<AdminUser> list(int page, int pageSize); |
| | | |
| | | public long count(); |
| | | |
| | | public void delete(List<String> ids); |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.app.service.inter.admin; |
| | | |
| | | import com.ks.app.entity.admin.AdminRoleRule; |
| | | import com.ks.app.service.query.admin.AdminRoleRuleQuery; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | public interface AdminRoleRuleService { |
| | | |
| | | /** |
| | | * 获取列表 |
| | | * @param adminRoleRuleQuery |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<AdminRoleRule> list(AdminRoleRuleQuery adminRoleRuleQuery, int page, int pageSize) ; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public long count(AdminRoleRuleQuery adminRoleRuleQuery) ; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public AdminRoleRule get(String id) ; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public void add(AdminRoleRule adminRoleRule) throws Exception; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public void update(AdminRoleRule adminRoleRule) ; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public void delete(List<String> idList) ; |
| | | |
| | | |
| | | public List<String> listPaths(String adminId); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.app.service.inter.admin; |
| | | |
| | | import com.ks.app.entity.admin.AdminRole; |
| | | import com.ks.app.entity.admin.AdminUserRoles; |
| | | import com.ks.app.service.query.admin.AdminUserRolesQuery; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | public interface AdminUserRolesService { |
| | | |
| | | /** |
| | | * 获取列表 |
| | | * |
| | | * @param adminUserRolesQuery |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<AdminUserRoles> list(AdminUserRolesQuery adminUserRolesQuery, int page, int pageSize); |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public long count(AdminUserRolesQuery adminUserRolesQuery); |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public AdminUserRoles get(String id); |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public void add(AdminUserRoles adminUserRoles) throws Exception; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public void update(AdminUserRoles adminUserRoles); |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public void delete(List<String> idList); |
| | | |
| | | /** |
| | | * @return java.util.List<com.yeshi.makemoney.app.entity.admin.AdminRole> |
| | | * @author hxh |
| | | * @description 查询管理员的角色 |
| | | * @date 11:16 2022/5/16 |
| | | * @param: adminId |
| | | **/ |
| | | public List<AdminRole> listRoleByAdminId(String adminId); |
| | | |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @description 设置权限 |
| | | * @date 11:40 2022/5/16 |
| | | * @param: adminId |
| | | * @param: roles |
| | | * @return void |
| | | **/ |
| | | public void setRoles(String adminId, List<AdminRole> roles); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.app.service.query.admin; |
| | | |
| | | import com.ks.app.entity.admin.AdminRole; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class AdminRoleRuleQuery { |
| | | //搜索关键词 |
| | | private AdminRole role; |
| | | |
| | | private List<AdminRole> roles; |
| | | |
| | | private Boolean navPage; |
| | | |
| | | private String path; |
| | | |
| | | public AdminRole getRole() { |
| | | return role; |
| | | } |
| | | |
| | | public void setRole(AdminRole role) { |
| | | this.role = role; |
| | | } |
| | | |
| | | public String getPath() { |
| | | return path; |
| | | } |
| | | |
| | | public void setPath(String path) { |
| | | this.path = path; |
| | | } |
| | | |
| | | public Boolean getNavPage() { |
| | | return navPage; |
| | | } |
| | | |
| | | public void setNavPage(Boolean navPage) { |
| | | this.navPage = navPage; |
| | | } |
| | | |
| | | public List<AdminRole> getRoles() { |
| | | return roles; |
| | | } |
| | | |
| | | public void setRoles(List<AdminRole> roles) { |
| | | this.roles = roles; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.app.service.query.admin; |
| | | |
| | | import com.ks.app.entity.admin.AdminRole; |
| | | |
| | | public class AdminUserRolesQuery { |
| | | //搜索关键词 |
| | | public String adminId; |
| | | public AdminRole role; |
| | | |
| | | public String getAdminId() { |
| | | return adminId; |
| | | } |
| | | |
| | | public void setAdminId(String adminId) { |
| | | this.adminId = adminId; |
| | | } |
| | | |
| | | public AdminRole getRole() { |
| | | return role; |
| | | } |
| | | |
| | | public void setRole(AdminRole role) { |
| | | this.role = role; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.app.utils.xml; |
| | | |
| | | import com.ks.app.dto.admin.PageNav; |
| | | import org.springframework.util.AntPathMatcher; |
| | | import org.w3c.dom.Document; |
| | | import org.w3c.dom.Node; |
| | | import org.w3c.dom.NodeList; |
| | | import org.xml.sax.SAXException; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import javax.xml.parsers.DocumentBuilder; |
| | | import javax.xml.parsers.DocumentBuilderFactory; |
| | | import javax.xml.parsers.ParserConfigurationException; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: PageNavUtil |
| | | * @description: 页面导航帮助类 |
| | | * @date 2022/5/18 16:35 |
| | | */ |
| | | public class PageNavUtil { |
| | | |
| | | /** |
| | | * @return java.util.List<com.yeshi.makemoney.app.dto.admin.PageNav> |
| | | * @author hxh |
| | | * @description 解析导航 |
| | | * @date 16:49 2022/5/18 |
| | | * @param: inputStream |
| | | **/ |
| | | private static List<PageNav> parseNav(InputStream inputStream) throws ParserConfigurationException, IOException, SAXException { |
| | | DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
| | | //2.创建DocumentBuilder对象 |
| | | DocumentBuilder builder = factory.newDocumentBuilder(); |
| | | Document d = builder.parse(inputStream); |
| | | Node root = d.getElementsByTagName("navs").item(0); |
| | | NodeList items = root.getChildNodes(); |
| | | List<PageNav> list = new ArrayList<>(); |
| | | for (int i = 0; i < items.getLength(); i++) { |
| | | if (items.item(i).getNodeName().equalsIgnoreCase("nav")) { |
| | | list.add(parseNav(items.item(i))); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private static PageNav parseNav(Node node) { |
| | | PageNav nav = new PageNav(); |
| | | String name = node.getAttributes().getNamedItem("name") == null ? null : node.getAttributes().getNamedItem("name").getNodeValue(); |
| | | String path = node.getAttributes().getNamedItem("path") == null ? null : node.getAttributes().getNamedItem("path").getNodeValue(); |
| | | String icon = node.getAttributes().getNamedItem("icon") == null ? null : node.getAttributes().getNamedItem("icon").getNodeValue(); |
| | | nav.setName(name); |
| | | nav.setPath(path); |
| | | nav.setIcon(icon); |
| | | if (node.getChildNodes() != null && node.getChildNodes().getLength() > 0) { |
| | | |
| | | List<PageNav> children = new ArrayList<>(); |
| | | for (int i = 0; i < node.getChildNodes().getLength(); i++) { |
| | | if (node.getChildNodes().item(i).getNodeName().equalsIgnoreCase("nav")) { |
| | | children.add(parseNav(node.getChildNodes().item(i))); |
| | | } |
| | | } |
| | | nav.setChildren(children); |
| | | } |
| | | return nav; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @return java.util.List<com.yeshi.makemoney.app.dto.admin.PageNav> |
| | | * @author hxh |
| | | * @description 获取页面导航 |
| | | * @date 18:02 2022/5/18 |
| | | * @param: pathList |
| | | **/ |
| | | public static List<PageNav> getPageNavs(List<String> pathList) { |
| | | List<PageNav> pageNavs = null; |
| | | try { |
| | | pageNavs = PageNavUtil.parseNav(PageNavUtil.class.getClassLoader().getResourceAsStream("admin/nav.xml")); |
| | | } catch (ParserConfigurationException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } catch (SAXException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | for (PageNav nav : pageNavs) { |
| | | filter(nav, pathList); |
| | | } |
| | | |
| | | //删除一级空目录 |
| | | for (int i = 0; i < pageNavs.size(); i++) { |
| | | if (StringUtil.isNullOrEmpty(pageNavs.get(i).getPath()) && pageNavs.get(i).getChildren() == null) { |
| | | pageNavs.remove(i--); |
| | | } |
| | | } |
| | | return pageNavs; |
| | | } |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | | * @description 过滤掉没有在pathList中的导航选项 |
| | | * @date 18:01 2022/5/18 |
| | | * @param: root |
| | | * @param: pathList |
| | | **/ |
| | | public static void filter(PageNav root, List<String> pathList) { |
| | | if (root == null || root.getChildren() == null || root.getChildren().size() == 0) { |
| | | return; |
| | | } else { |
| | | |
| | | for (int i = 0; i < root.getChildren().size(); i++) { |
| | | filter(root.getChildren().get(i), pathList); |
| | | } |
| | | |
| | | for (int i = 0; i < root.getChildren().size(); i++) { |
| | | PageNav child = root.getChildren().get(i); |
| | | if (!StringUtil.isNullOrEmpty(child.getPath()) && !pathMatch(child.getPath(), pathList)) { |
| | | root.getChildren().remove(i--); |
| | | } |
| | | } |
| | | if (root.getChildren().size() == 0) { |
| | | root.setChildren(null); |
| | | } |
| | | return; |
| | | } |
| | | } |
| | | |
| | | private static boolean pathMatch(String path, List<String> pathList) { |
| | | AntPathMatcher matcher = new AntPathMatcher(); |
| | | for (String regex : pathList) { |
| | | if (matcher.match(regex, path)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { |
| | | List<PageNav> result = getPageNavs(Arrays.asList(new String[]{"team/vip.html"})); |
| | | System.out.println(result); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ks.app.vo; |
| | | |
| | | import com.ks.app.entity.APPPlatform; |
| | | import com.ks.app.entity.AdminUser; |
| | | import com.ks.app.entity.SystemEnum; |
| | | import com.ks.app.entity.admin.AdminUser; |
| | | |
| | | /** |
| | | * @author hxh |
New file |
| | |
| | | package com.ks.app.vo; |
| | | |
| | | import com.ks.app.entity.admin.AdminRole; |
| | | import com.ks.app.entity.admin.AdminUser; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: AdminUserVO |
| | | * @description: 管理员输出 |
| | | * @date 2022/5/16 11:06 |
| | | */ |
| | | public class AdminUserVO { |
| | | |
| | | private String account; |
| | | private String pwd; |
| | | private String name; |
| | | /** |
| | | * 邮箱 |
| | | **/ |
| | | private String email; |
| | | |
| | | private Date createTime; |
| | | |
| | | private Date updateTime; |
| | | |
| | | private List<AdminRole> roleList; |
| | | |
| | | private List<AdminRole> allRoleList; |
| | | |
| | | public AdminUser toEntity() { |
| | | AdminUser entity = new AdminUser(); |
| | | entity.setAccount(account); |
| | | entity.setName(name); |
| | | entity.setEmail(email); |
| | | if (!StringUtil.isNullOrEmpty(pwd)) { |
| | | entity.setPwd(StringUtil.Md5(pwd)); |
| | | } |
| | | return entity; |
| | | } |
| | | |
| | | |
| | | public static AdminUserVO create(AdminUser entity, List<AdminRole> roleList) { |
| | | AdminUserVO vo = new AdminUserVO(); |
| | | vo.setAccount(entity.getAccount()); |
| | | vo.setEmail(entity.getEmail()); |
| | | vo.setName(entity.getName()); |
| | | vo.setRoleList(roleList); |
| | | vo.setAllRoleList(Arrays.asList(AdminRole.values())); |
| | | vo.setCreateTime(entity.getCreateTime()); |
| | | vo.setUpdateTime(entity.getUpdateTime()); |
| | | return vo; |
| | | } |
| | | |
| | | public static AdminUserVO create(AdminUser entity) { |
| | | AdminUserVO vo = new AdminUserVO(); |
| | | vo.setAccount(entity.getAccount()); |
| | | vo.setEmail(entity.getEmail()); |
| | | vo.setName(entity.getName()); |
| | | vo.setCreateTime(entity.getCreateTime()); |
| | | vo.setUpdateTime(entity.getUpdateTime()); |
| | | return vo; |
| | | } |
| | | |
| | | |
| | | public String getAccount() { |
| | | return account; |
| | | } |
| | | |
| | | public void setAccount(String account) { |
| | | this.account = account; |
| | | } |
| | | |
| | | public String getPwd() { |
| | | return pwd; |
| | | } |
| | | |
| | | public void setPwd(String pwd) { |
| | | this.pwd = pwd; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getEmail() { |
| | | return email; |
| | | } |
| | | |
| | | public void setEmail(String email) { |
| | | this.email = email; |
| | | } |
| | | |
| | | public List<AdminRole> getRoleList() { |
| | | return roleList; |
| | | } |
| | | |
| | | public void setRoleList(List<AdminRole> roleList) { |
| | | this.roleList = roleList; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public List<AdminRole> getAllRoleList() { |
| | | return allRoleList; |
| | | } |
| | | |
| | | public void setAllRoleList(List<AdminRole> allRoleList) { |
| | | this.allRoleList = allRoleList; |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <navs> |
| | | |
| | | <nav name="管理员" icon="layui-icon-survey"> |
| | | <nav name="管理员列表" path="authority/admin_user_list.html"></nav> |
| | | <nav name="角色权限" path="authority/admin_role_rule_list.html"></nav> |
| | | </nav> |
| | | |
| | | <nav name="内容运营" icon="layui-icon-gift"> |
| | | <nav name="APP页面通知" path="msg/app_page_notify_msg_list.html"></nav> |
| | | </nav> |
| | | |
| | | <nav name="用户管理" icon="layui-icon-user"> |
| | | <nav name="用户列表" path="user/user_info_list.html"></nav> |
| | | <nav name="登录记录" path="user/user_login_record_list.html"></nav> |
| | | <nav name="用户消息列表" path="msg/user_msg_list.html"></nav> |
| | | </nav> |
| | | |
| | | |
| | | <nav name="用户反馈" icon="layui-icon-survey"> |
| | | <nav name="用户建议" path="feedback/advice_list.html"></nav> |
| | | <nav name="隐私投诉" path="feedback/privacy_complain_list.html"></nav> |
| | | </nav> |
| | | |
| | | <nav name="设置" icon="layui-icon-set"> |
| | | <nav name="系统参数" path="config/system_config_list.html?type=system"></nav> |
| | | <nav name="客户端参数" path="config/system_config_list.html?type=common"></nav> |
| | | <nav name="广告配置" path="config/system_config_list.html?type=ad"></nav> |
| | | </nav> |
| | | |
| | | |
| | | </navs> |
| | |
| | | <!--日志展示的格式--> |
| | | <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n"/> |
| | | |
| | | <property name="tencent.log.accesskey" value="AKIDTlpgJhLjOozvd6QI2XnpfGbgV4NQJk25"/> |
| | | <property name="tencent.log.accessKeySecret" value="xhCSUHo55oHUQ6XicFcmfIgspX0EEzWo"/> |
| | | |
| | | <!--appender是为了配置日志信息输出到哪个地方--> |
| | | <!--控制台设置,输出到控制台中--> |
| | | <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
| | |
| | | <!--pattern为配置输出的格式--> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | </appender> |
| | | |
| | | <appender name="tencentLogAppender" class="com.tencentcloudapi.cls.LoghubAppender"> |
| | | <!--必选项--> |
| | | <endpoint>ap-guangzhou.cls.tencentcs.com</endpoint> |
| | | <accessKeyId>${tencent.log.accesskey}</accessKeyId> |
| | | <accessKeySecret>${tencent.log.accessKeySecret}</accessKeySecret> |
| | | <topicId>dsp</topicId> |
| | | |
| | | <!-- 可选项 详见 '参数说明'--> |
| | | <totalSizeInBytes>104857600</totalSizeInBytes> |
| | | <maxBlockMs>0</maxBlockMs> |
| | | <sendThreadCount>8</sendThreadCount> |
| | | <batchSizeThresholdInBytes>524288</batchSizeThresholdInBytes> |
| | | <batchCountThreshold>4096</batchCountThreshold> |
| | | <lingerMs>2000</lingerMs> |
| | | <retries>10</retries> |
| | | <baseRetryBackoffMs>100</baseRetryBackoffMs> |
| | | <maxRetryBackoffMs>50000</maxRetryBackoffMs> |
| | | |
| | | <!-- 可选项 设置时间格式 --> |
| | | <timeFormat>yyyy-MM-dd'T'HH:mm:ssZ</timeFormat> |
| | | <timeZone>Asia/Shanghai</timeZone> |
| | | <encoder> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | <mdcFields>THREAD_ID,MDC_KEY</mdcFields> |
| | | </appender> |
| | | |
| | | |
| | |
| | | info日志会输出到infoAppender指定的文件中 |
| | | error日志会输出到errorAppender指定的文件中--> |
| | | |
| | | <logger name="io.seata" level="ERROR"></logger> |
| | | <logger name="System.out" level="INFO"></logger> |
| | | <!--<logger name="io.seata" level="ERROR"></logger>--> |
| | | <!--<logger name="System.out" level="INFO"></logger>--> |
| | | |
| | | |
| | | <logger name="com.yeshi.makemoney.app.aop.SignValidate" level="ERROR" additivity="false"> |
| | | <appender-ref ref="tencentLogAppender"></appender-ref> |
| | | </logger> |
| | | |
| | | <!-- 一切logger都会继承自root,root默认的层级level为debug --> |
| | | <root level="INFO"> |
| | | <!--在控制台中输出所在层级对应level(以及大于level)的日志信息,因为这里并没有设置LevelFilter--> |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html class="x-admin-sm"> |
| | | |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <title>新增管理员角色管理</title> |
| | | <meta name="renderer" content="webkit"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" |
| | | content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
| | | |
| | | |
| | | <link rel="stylesheet" href="/admin/css/font.css"> |
| | | <link rel="stylesheet" href="/admin/css/xadmin.css"> |
| | | <link rel="stylesheet" href="/admin/css/theme3049.min.css"> |
| | | |
| | | <script src="/admin/lib/layui/layui.js" charset="utf-8"></script> |
| | | <script src="/admin/js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/xadmin.js" type="text/javascript"></script> |
| | | <script src="/admin/js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/jquery.min.js" type="text/javascript"></script> |
| | | <script src="/admin/js/utils.js"></script> |
| | | |
| | | <style> |
| | | .path { |
| | | display: flex; |
| | | margin: 5px 0; |
| | | } |
| | | |
| | | .path a { |
| | | margin-left: 10px; |
| | | } |
| | | |
| | | |
| | | </style> |
| | | |
| | | |
| | | <!-- 让IE8/9支持媒体查询,从而兼容栅格 --> |
| | | <!--[if lt IE 9]> |
| | | <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script> |
| | | <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> |
| | | <![endif]--> |
| | | </head> |
| | | <body> |
| | | <div class="layui-fluid"> |
| | | <div class="layui-row"> |
| | | <form class="layui-form" lay-filter="add"> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | <span class="x-red">*</span> |
| | | 角色</label> |
| | | <div class="layui-input-block"> |
| | | <select class="layui-select" name="role" lay-verify="required"></select> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | <span class="x-red">*</span> |
| | | 是否为导航路径</label> |
| | | <div class="layui-input-block"> |
| | | <input type="checkbox" name="navPage" autocomplete="off" lay-skin="switch" |
| | | class="layui-form-switch" value="true"> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | <span class="x-red">*</span> |
| | | 访问路径</label> |
| | | <div class="layui-input-block"> |
| | | |
| | | <div class="path"> |
| | | <input type="text" name="path[]" lay-verify="required" placeholder="请输入访问路径表达式" |
| | | autocomplete="off" |
| | | class="layui-input"> |
| | | |
| | | <a class="layui-btn layui-btn-sm layui-btn-primary" onclick="deletePath()" href="javascript:"> |
| | | <i class="layui-icon"></i> |
| | | </a> |
| | | </div> |
| | | <a class="layui-btn layui-btn-primary" onclick="addPath()" href="javascript:"><i |
| | | class="layui-icon"></i>添加</a> |
| | | |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | 备注</label> |
| | | <div class="layui-input-block"> |
| | | <textarea class="layui-textarea" name="remarks"></textarea> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_remarks" class="layui-form-label"></label> |
| | | <button class="layui-btn" lay-filter="add" lay-submit="">确定</button> |
| | | </div> |
| | | </form> |
| | | </div> |
| | | </div> |
| | | <script> |
| | | //初始化上传控件 |
| | | var uploadTool = { |
| | | callback: null, |
| | | chooseImage: {}, |
| | | uploadArray: new Array(), |
| | | init: function (upload) { |
| | | this.uploadArray = new Array(); |
| | | |
| | | }, |
| | | upload: function (result) { |
| | | if (this.uploadArray.length > 0 && Object.keys(this.chooseImage).length > 0) { |
| | | this.callback = result; |
| | | //同时上传 |
| | | for (var i = 0; i < this.uploadArray.length; i++) { |
| | | this.uploadArray[i].upload(); |
| | | } |
| | | } else { |
| | | result(); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | |
| | | </script> |
| | | <script> |
| | | function addPath() { |
| | | var html = $(".path").eq(0).prop("outerHTML"); |
| | | console.log(html); |
| | | $(".path:last").after(html) |
| | | $(".path:last").find("input[type=text]").eq(0).val(); |
| | | |
| | | $(".path:last").find("a").click(function () { |
| | | $(this).parent().remove(); |
| | | }); |
| | | } |
| | | |
| | | function deletePath() { |
| | | if ($(".path").length <= 1) { |
| | | layer.msg("最低保留一个"); |
| | | return; |
| | | } |
| | | console.log(this); |
| | | console.log($(this)) |
| | | } |
| | | |
| | | |
| | | </script> |
| | | |
| | | <script> |
| | | |
| | | layui.use(['form', 'layer', 'jquery', 'upload', 'laydate'], function () { |
| | | $ = layui.jquery; |
| | | var form = layui.form, |
| | | layer = layui.layer, |
| | | upload = layui.upload, |
| | | laydate = layui.laydate; |
| | | |
| | | var verify = {}; |
| | | //自定义验证规则 |
| | | form.verify(verify); |
| | | |
| | | //渲染上传控件 |
| | | uploadTool.init(upload); |
| | | |
| | | laydate.render({ |
| | | elem: "input[name=name]", //指定元素 |
| | | type: 'date' |
| | | }); |
| | | |
| | | |
| | | ksapp.postJSON('/admin/api/authority/listRoles', {}, function (res) { |
| | | if (res.code == 0) { |
| | | //填充数据 |
| | | $("select[name=role]").empty(); |
| | | for (var i = 0; i < res.data.length; i++) { |
| | | var html = "<option value='" + res.data[i].key + "'>"; |
| | | html += res.data[i].value + "</option>"; |
| | | $("select[name=role]").append(html); |
| | | } |
| | | //重新渲染表单 |
| | | form.render(); |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | |
| | | }, function (res) { |
| | | }); |
| | | |
| | | //监听提交 |
| | | form.on('submit(add)', |
| | | function (data) { |
| | | |
| | | //转换json对象 |
| | | var paths = []; |
| | | for (key in data.field) { |
| | | if (key.indexOf("path[") > -1) { |
| | | var value = data.field[key]; |
| | | delete data.field[key]; |
| | | if (value.length > 0) |
| | | paths.push(value); |
| | | } |
| | | } |
| | | |
| | | if (paths.length == 0) { |
| | | layer.msg("未填写任何路径表达式"); |
| | | return false; |
| | | } |
| | | |
| | | data.field.paths=paths; |
| | | |
| | | uploadTool.upload(function (hasFile) { |
| | | if (hasFile) { |
| | | //从新提交表单 |
| | | $("button[lay-filter=add]").click(); |
| | | return; |
| | | } |
| | | //发异步,把数据提交给php |
| | | ksapp.postJSON('/admin/api/authority/add', data.field, function (res) { |
| | | if (res.code == 0) { |
| | | layer.alert("增加成功", { |
| | | icon: 6 |
| | | }, |
| | | function () { |
| | | //关闭当前frame |
| | | xadmin.close(); |
| | | // 可以对父窗口进行刷新 |
| | | // xadmin.father_reload(); |
| | | }); |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | |
| | | }, function (res) { |
| | | }); |
| | | }); |
| | | return false; |
| | | }); |
| | | //请求select的数据API |
| | | }) |
| | | ; |
| | | </script> |
| | | </body> |
| | | |
| | | </html> |
copy from src/main/resources/code/service/app/src/main/resources/static/config/system_config_list.html
copy to src/main/resources/code/service/app/src/main/resources/static/admin/pages/authority/admin_role_rule_list.html
File was copied from src/main/resources/code/service/app/src/main/resources/static/config/system_config_list.html |
| | |
| | | |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <title>系统配置信息列表</title> |
| | | <title>管理员角色管理列表</title> |
| | | <meta name="renderer" content="webkit"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" |
| | | content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
| | | <link rel="stylesheet" href="../css/font.css"> |
| | | <link rel="stylesheet" href="../css/xadmin.css"> |
| | | <script src="../lib/layui/layui.js" charset="utf-8"></script> |
| | | <link rel="stylesheet" href="../css/theme3049.min.css"> |
| | | <script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../js/xadmin.js"></script> |
| | | <script src="../js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> |
| | | |
| | | <link rel="stylesheet" href="/admin/css/font.css"> |
| | | <link rel="stylesheet" href="/admin/css/xadmin.css"> |
| | | <link rel="stylesheet" href="/admin/css/theme3049.min.css"> |
| | | |
| | | <script src="/admin/lib/layui/layui.js" charset="utf-8"></script> |
| | | <script src="/admin/js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/xadmin.js" type="text/javascript"></script> |
| | | <script src="/admin/js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/jquery.min.js" type="text/javascript"></script> |
| | | <script src="/admin/js/utils.js"></script> |
| | | <!--[if lt IE 9]> |
| | | <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script> |
| | | <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> |
| | | <![endif]--> |
| | | <script src="../js/utils.js"></script> |
| | | |
| | | </head> |
| | | |
| | | <body> |
| | |
| | | <div class="layui-card"> |
| | | <div class="layui-card-body"> |
| | | <form class="layui-form layui-col-space5"> |
| | | <div class="layui-inline layui-show-xs-block"> |
| | | <select name="role"> |
| | | </select></div> |
| | | |
| | | <div class="layui-inline layui-show-xs-block"> |
| | | <input type="text" name="kw" lay-verify="" placeholder="请输入名称" autocomplete="off" |
| | | <select name="navPage" lay-verify="" autocomplete="off" |
| | | class="layui-select"> |
| | | <option value="">请选择页面类型</option> |
| | | <option value="true">导航页</option> |
| | | <option value="false">非导航页</option> |
| | | </select> |
| | | </div> |
| | | <div class="layui-inline layui-show-xs-block"> |
| | | <input type="text" name="path" lay-verify="" placeholder="路径" autocomplete="off" |
| | | class="layui-input"> |
| | | </div> |
| | | |
| | | |
| | | |
| | | <div class="layui-inline layui-show-xs-block"> |
| | | <button id="search" class="layui-btn" lay-submit="" lay-filter="search"> |
| | |
| | | </body> |
| | | <script type="text/html" id="toolbar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn" onclick="xadmin.open('添加系统配置信息','system_config_add.html?type='+ ksapp.getQueryParam('type'),500,580)"><i |
| | | <button class="layui-btn" onclick="xadmin.open('添加管理员角色管理','admin_role_rule_add.html',500,580)"><i |
| | | class="layui-icon"></i>添加 |
| | | </button> |
| | | <button class="layui-btn layui-btn-danger" lay-event="delete"> |
| | | <i class="layui-icon"></i> |
| | | 删除 |
| | | </button> |
| | | </div> |
| | | </script> |
| | | |
| | | <script type="text/html" id="optContainer"> |
| | | <div class="layui-btn-container"> |
| | | <a title="修改" onclick="xadmin.open('修改系统配置信息','system_config_update.html?id={{d.id}}',500,580)" |
| | | <a title="修改" onclick="xadmin.open('修改管理员角色管理','admin_role_rule_update.html?id={{d.id}}',500,580)" |
| | | href="javascript:;"> |
| | | <i class="layui-icon"></i> |
| | | </a> |
| | | <a title="删除" onclick="member_del(this,{{d.LAY_INDEX }},'{{d.id}}')" href="javascript:;"> |
| | | <i class="layui-icon"></i> |
| | | </a> |
| | | </div> |
| | | </script> |
| | |
| | | |
| | | <script> |
| | | var tableIns = null; |
| | | var app = null; |
| | | $(function () { |
| | | |
| | | var app = new Vue({ |
| | | app = new Vue({ |
| | | el: "#app", |
| | | data: { |
| | | key: '', |
| | |
| | | |
| | | tableIns = table.render({ |
| | | elem: '#table_list', |
| | | url: "/admin/api/config/list", |
| | | url: "/admin/api/authority/list", |
| | | toolbar: "#toolbar", |
| | | totalRow: true, |
| | | cols: [[{type: 'checkbox', title: "ID"}, |
| | | {field: 'name', width: 200, sort: false, title: "名称"}, |
| | | {field: 'key', width: 120, sort: false, title: "关键字"}, |
| | | {field: 'id', width: 120, sort: false, title: "ID"}, |
| | | {field: 'role', width: 120, sort: false, title: "角色"}, |
| | | {field: 'path', width: 300, sort: false, title: "路径表达式"}, |
| | | { |
| | | field: 'value', width: 400, sort: false, title: "内容", templet: function (res) { |
| | | if ("object" == typeof res.value) { |
| | | return JSON.stringify(res.value); |
| | | field: 'navPage', |
| | | width: 120, |
| | | sort: false, |
| | | title: "是否为导航页面", |
| | | templet: function (res) { |
| | | if (res.navPage) { |
| | | return "<input class='layui-disabled' disabled='disabled' type='checkbox' lay-skin='switch' checked='checked'>"; |
| | | } else { |
| | | return res.value; |
| | | return "<input class='layui-disabled' disabled='disabled' type='checkbox' lay-skin='switch'>"; |
| | | } |
| | | |
| | | } |
| | | }, |
| | | {field: 'remarks', width: 120, sort: false, title: "备注"}, |
| | | {field: 'createTime', width: 120, sort: false, title: "创建时间"}, |
| | | {field: 'updateTime', width: 120, sort: false, title: "修改时间"}, |
| | | {field: 'createTime', width: 150, sort: false, title: "创建时间"}, |
| | | {field: 'updateTime', width: 150, sort: false, title: "修改时间"}, |
| | | {fixed: 'right', width: 80, title: "操作", toolbar: '#optContainer'}]], |
| | | page: true, |
| | | parseData: function (res) { //res 即为原始返回的数据 |
| | |
| | | ; |
| | | }); |
| | | //请求搜索表单中需要的数据 |
| | | |
| | | var requestCount = 0; |
| | | requestCount++; |
| | | var params = {}; |
| | | |
| | | ksapp.postJSON('/admin/api/authority/listRoles', params, function (res) { |
| | | if (res.code == 0) { |
| | | //填充数据 |
| | | $("select[name=role]").empty(); |
| | | $("select[name=role]").append("<option value=''>请选择</option>"); |
| | | for (var i = 0; i < res.data.length; i++) { |
| | | var html = "<option value='" + res.data[i].key + "'>"; |
| | | html += res.data[i].value + "</option>"; |
| | | $("select[name=role]").append(html); |
| | | } |
| | | //重新渲染表单 |
| | | form.render(); |
| | | |
| | | requestCount--; |
| | | if (requestCount <= 0) { |
| | | //搜索 |
| | | $('#search').trigger("click"); |
| | | } |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | |
| | | }, function (res) { |
| | | }); |
| | | }); |
| | | |
| | | }, |
| | |
| | | }); |
| | | }, |
| | | deleteList: function (ids, success) { |
| | | ksapp.post("/admin/api/config/delete", {ids: JSON.stringify(ids)}, function (e) { |
| | | ksapp.post("/admin/api/authority/delete", {ids: JSON.stringify(ids)}, function (e) { |
| | | if (e.code == 0) { |
| | | success(); |
| | | } else { |
| | |
| | | }); |
| | | }, |
| | | search: function (params) { |
| | | params["type"] = ksapp.getQueryParam("type"); |
| | | |
| | | var ps = {}; |
| | | for (var key in params) { |
| | | if (params[key] != null && params[key].length > 0) { |
| | | if (params[key].length > 0) { |
| | | ps[key] = params[key]; |
| | | } |
| | | } |
| | | |
| | | |
| | | //数据重载 |
| | | tableIns.reload({ |
| | | where: params, |
| | | where: ps, |
| | | page: { |
| | | curr: 1 //重新从第 1 页开始 |
| | | } |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html class="x-admin-sm"> |
| | | |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <title>修改管理员角色管理</title> |
| | | <meta name="renderer" content="webkit"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" |
| | | content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
| | | |
| | | <link rel="stylesheet" href="/admin/css/font.css"> |
| | | <link rel="stylesheet" href="/admin/css/xadmin.css"> |
| | | <link rel="stylesheet" href="/admin/css/theme3049.min.css"> |
| | | |
| | | <script src="/admin/lib/layui/layui.js" charset="utf-8"></script> |
| | | <script src="/admin/js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/xadmin.js" type="text/javascript"></script> |
| | | <script src="/admin/js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/jquery.min.js" type="text/javascript"></script> |
| | | <script src="/admin/js/utils.js"></script> |
| | | <!-- 让IE8/9支持媒体查询,从而兼容栅格 --> |
| | | <!--[if lt IE 9]> |
| | | <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script> |
| | | <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> |
| | | <![endif]--> |
| | | </head> |
| | | <body> |
| | | <div class="layui-fluid"> |
| | | <div class="layui-row"> |
| | | <form class="layui-form" lay-filter="update"> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | 角色</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="role" lay-verify="" placeholder="" autocomplete="off" disabled="disabled" |
| | | class="layui-input layui-disabled"> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | <span class="x-red">*</span> |
| | | 是否为导航路径</label> |
| | | <div class="layui-input-block"> |
| | | <input type="checkbox" name="navPage" autocomplete="off" lay-skin="switch" |
| | | class="layui-form-switch" value="true"> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | 路径表达式</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="path" lay-verify="required" placeholder="" autocomplete="off" |
| | | class="layui-input"> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_remarks" class="layui-form-label"></label> |
| | | <button class="layui-btn" lay-filter="update" lay-submit="">确定修改</button> |
| | | </div> |
| | | </form> |
| | | </div> |
| | | </div> |
| | | <script> |
| | | //初始化上传控件 |
| | | var uploadTool = { |
| | | callback: null, |
| | | chooseImage: {}, |
| | | uploadArray: new Array(), |
| | | init: function (upload) { |
| | | this.uploadArray = new Array(); |
| | | |
| | | }, |
| | | upload: function (result) { |
| | | if (this.uploadArray.length > 0 && Object.keys(this.chooseImage).length > 0) { |
| | | this.callback = result; |
| | | //同时上传 |
| | | for (var i = 0; i < this.uploadArray.length; i++) { |
| | | this.uploadArray[i].upload(); |
| | | } |
| | | } else { |
| | | result(); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | |
| | | </script> |
| | | |
| | | <script> |
| | | //填充数据 |
| | | function fillData(form) { |
| | | var id = ksapp.getQueryParam("id"); |
| | | if (id) { |
| | | } else { |
| | | layer.msg("id为空"); |
| | | return; |
| | | } |
| | | |
| | | ksapp.post('/admin/api/authority/get', {id: id}, function (res) { |
| | | if (res.code == 0) { |
| | | form.val("update", res.data); |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | }, function (res) { |
| | | layer.msg("详情获取失败"); |
| | | }); |
| | | } |
| | | </script> |
| | | |
| | | <script> |
| | | layui.use(['form', 'layer', 'jquery', 'upload', 'laydate'], function () { |
| | | $ = layui.jquery; |
| | | var form = layui.form, |
| | | layer = layui.layer, |
| | | upload = layui.upload, |
| | | laydate = layui.laydate; |
| | | |
| | | var verify = {}; |
| | | //自定义验证规则 |
| | | form.verify(verify); |
| | | |
| | | |
| | | //渲染上传控件 |
| | | uploadTool.init(upload); |
| | | |
| | | //填充表单数据 |
| | | //请求数据 |
| | | //form.data(); |
| | | |
| | | |
| | | //监听提交 |
| | | form.on('submit(update)', |
| | | function (data) { |
| | | console.log(data.field); |
| | | //转换json对象 |
| | | for (key in data.field) { |
| | | if (key.indexOf(".") > -1) { |
| | | var value = data.field[key]; |
| | | delete data.field[key]; |
| | | var onkeys = key.split("."); |
| | | //创建对象 |
| | | if (data.field[onkeys[0]] == undefined) { |
| | | data.field[onkeys[0]] = {}; |
| | | } |
| | | data.field[onkeys[0]][onkeys[1]] = value; |
| | | } |
| | | } |
| | | uploadTool.upload(function (hasFile) { |
| | | if (hasFile) { |
| | | //从新提交表单 |
| | | $("button[lay-filter=update]").click(); |
| | | return; |
| | | } |
| | | //发异步,把数据提交给php |
| | | var params = data.field; |
| | | params.id = ksapp.getQueryParam("id"); |
| | | delete params["role"]; |
| | | |
| | | if (!params.navPage) { |
| | | params.navPage = false; |
| | | } |
| | | ksapp.post('/admin/api/authority/update', data.field, function (res) { |
| | | if (res.code == 0) { |
| | | layer.alert("修改成功", { |
| | | icon: 6 |
| | | }, |
| | | function () { |
| | | //关闭当前frame |
| | | xadmin.close(); |
| | | // 可以对父窗口进行刷新 |
| | | // xadmin.father_reload(); |
| | | }); |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | |
| | | }, function (res) { |
| | | }); |
| | | }); |
| | | return false; |
| | | }); |
| | | //请求select的数据API |
| | | |
| | | fillData(form) |
| | | }) |
| | | ; |
| | | </script> |
| | | </body> |
| | | |
| | | </html> |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html class="x-admin-sm"> |
| | | |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <title>新增管理员角色管理</title> |
| | | <meta name="renderer" content="webkit"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" |
| | | content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
| | | |
| | | <link rel="stylesheet" href="/admin/css/font.css"> |
| | | <link rel="stylesheet" href="/admin/css/xadmin.css"> |
| | | <link rel="stylesheet" href="/admin/css/theme3049.min.css"> |
| | | |
| | | <script src="/admin/lib/layui/layui.js" charset="utf-8"></script> |
| | | <script src="/admin/js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/xadmin.js" type="text/javascript"></script> |
| | | <script src="/admin/js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/jquery.min.js" type="text/javascript"></script> |
| | | <script src="/admin/js/utils.js"></script> |
| | | <!-- 让IE8/9支持媒体查询,从而兼容栅格 --> |
| | | <!--[if lt IE 9]> |
| | | <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script> |
| | | <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> |
| | | <![endif]--> |
| | | </head> |
| | | <body> |
| | | <div class="layui-fluid"> |
| | | <div class="layui-row"> |
| | | <form class="layui-form" lay-filter="add"> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | <span class="x-red">*</span> |
| | | 账号</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="account" lay-verify="required" placeholder="" autocomplete="off" |
| | | class="layui-input"> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | <span class="x-red">*</span> |
| | | 密码</label> |
| | | <div class="layui-input-block"> |
| | | <input type="password" name="pwd" lay-verify="required" placeholder="" autocomplete="off" |
| | | class="layui-input"> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | <span class="x-red">*</span> |
| | | 昵称</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="name" lay-verify="required" placeholder="" autocomplete="off" |
| | | class="layui-input"> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | <span class="x-red">*</span> |
| | | 邮件</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="email" lay-verify="required" placeholder="" autocomplete="off" |
| | | class="layui-input"> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | 角色</label> |
| | | <div class="layui-input-block" id="roles-container"> |
| | | |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | 备注</label> |
| | | <div class="layui-input-block"> |
| | | <textarea class="layui-textarea" name="remarks"></textarea> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_remarks" class="layui-form-label"></label> |
| | | <button class="layui-btn" lay-filter="add" lay-submit="">确定</button> |
| | | </div> |
| | | </form> |
| | | </div> |
| | | </div> |
| | | <script> |
| | | //初始化上传控件 |
| | | var uploadTool = { |
| | | callback: null, |
| | | chooseImage: {}, |
| | | uploadArray: new Array(), |
| | | init: function (upload) { |
| | | this.uploadArray = new Array(); |
| | | |
| | | }, |
| | | upload: function (result) { |
| | | if (this.uploadArray.length > 0 && Object.keys(this.chooseImage).length > 0) { |
| | | this.callback = result; |
| | | //同时上传 |
| | | for (var i = 0; i < this.uploadArray.length; i++) { |
| | | this.uploadArray[i].upload(); |
| | | } |
| | | } else { |
| | | result(); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | |
| | | </script> |
| | | |
| | | <script> |
| | | layui.use(['form', 'layer', 'jquery', 'upload', 'laydate'], function () { |
| | | $ = layui.jquery; |
| | | var form = layui.form, |
| | | layer = layui.layer, |
| | | upload = layui.upload, |
| | | laydate = layui.laydate; |
| | | |
| | | var verify = {}; |
| | | //自定义验证规则 |
| | | form.verify(verify); |
| | | |
| | | //渲染上传控件 |
| | | uploadTool.init(upload); |
| | | |
| | | ksapp.postJSON('/admin/api/authority/listRoles', {}, function (res) { |
| | | if (res.code == 0) { |
| | | res.data.forEach(function (role) { |
| | | $("#roles-container").append("<input type='checkbox' name='roles." + role.key + "' title='" + role.value + "' value='1'>"); |
| | | }); |
| | | form.render(); |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | |
| | | }, function (res) { |
| | | }); |
| | | |
| | | //监听提交 |
| | | form.on('submit(add)', |
| | | function (data) { |
| | | console.log(data.field); |
| | | uploadTool.upload(function (hasFile) { |
| | | if (hasFile) { |
| | | //从新提交表单 |
| | | $("button[lay-filter=add]").click(); |
| | | return; |
| | | } |
| | | |
| | | var params = data.field; |
| | | var keys = Object.keys(params); |
| | | var roles = []; |
| | | for (var i = 0; i < keys.length; i++) { |
| | | if (keys[i].indexOf("roles.") == 0) { |
| | | delete params[keys[i]]; |
| | | roles.push(keys[i].replace("roles.", "")); |
| | | } |
| | | } |
| | | |
| | | console.log(roles); |
| | | |
| | | params.roleList = roles; |
| | | |
| | | |
| | | //发异步,把数据提交给php |
| | | ksapp.postJSON('/admin/api/adminuser/add', params, function (res) { |
| | | if (res.code == 0) { |
| | | layer.alert("增加成功", { |
| | | icon: 6 |
| | | }, |
| | | function () { |
| | | //关闭当前frame |
| | | xadmin.close(); |
| | | // 可以对父窗口进行刷新 |
| | | // xadmin.father_reload(); |
| | | }); |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | |
| | | }, function (res) { |
| | | }); |
| | | }); |
| | | return false; |
| | | }); |
| | | //请求select的数据API |
| | | }) |
| | | ; |
| | | </script> |
| | | </body> |
| | | |
| | | </html> |
File was renamed from src/main/resources/code/service/app/src/main/resources/static/config/system_config_list.html |
| | |
| | | |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <title>系统配置信息列表</title> |
| | | <title>管理员角色管理列表</title> |
| | | <meta name="renderer" content="webkit"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" |
| | | content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
| | | <link rel="stylesheet" href="../css/font.css"> |
| | | <link rel="stylesheet" href="../css/xadmin.css"> |
| | | <script src="../lib/layui/layui.js" charset="utf-8"></script> |
| | | <link rel="stylesheet" href="../css/theme3049.min.css"> |
| | | <script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../js/xadmin.js"></script> |
| | | <script src="../js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> |
| | | |
| | | <link rel="stylesheet" href="/admin/css/font.css"> |
| | | <link rel="stylesheet" href="/admin/css/xadmin.css"> |
| | | <link rel="stylesheet" href="/admin/css/theme3049.min.css"> |
| | | |
| | | <script src="/admin/lib/layui/layui.js" charset="utf-8"></script> |
| | | <script src="/admin/js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/xadmin.js" type="text/javascript"></script> |
| | | <script src="/admin/js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/jquery.min.js" type="text/javascript"></script> |
| | | <script src="/admin/js/utils.js"></script> |
| | | <!--[if lt IE 9]> |
| | | <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script> |
| | | <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> |
| | |
| | | <div class="layui-card"> |
| | | <div class="layui-card-body"> |
| | | <form class="layui-form layui-col-space5"> |
| | | |
| | | <div class="layui-inline layui-show-xs-block"> |
| | | <input type="text" name="kw" lay-verify="" placeholder="请输入名称" autocomplete="off" |
| | | <input type="text" name="kw" lay-verify="" placeholder="输入关键字" autocomplete="off" |
| | | class="layui-input"> |
| | | </div> |
| | | |
| | | <div class="layui-inline layui-show-xs-block"> |
| | | <button id="search" class="layui-btn" lay-submit="" lay-filter="search"> |
| | | <i class="layui-icon"></i></button> |
| | |
| | | </body> |
| | | <script type="text/html" id="toolbar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn" onclick="xadmin.open('添加系统配置信息','system_config_add.html?type='+ ksapp.getQueryParam('type'),500,580)"><i |
| | | <button class="layui-btn" onclick="xadmin.open('添加管理员角色管理','admin_user_add.html',500,580)"><i |
| | | class="layui-icon"></i>添加 |
| | | </button> |
| | | <button class="layui-btn layui-btn-danger" lay-event="delete"> |
| | | <i class="layui-icon"></i> |
| | | 删除 |
| | | </button> |
| | | </div> |
| | | </script> |
| | | |
| | | <script type="text/html" id="optContainer"> |
| | | <div class="layui-btn-container"> |
| | | <a title="修改" onclick="xadmin.open('修改系统配置信息','system_config_update.html?id={{d.id}}',500,580)" |
| | | <a title="修改" onclick="xadmin.open('修改管理员角色管理','admin_user_update.html?id={{d.account}}',500,580)" |
| | | href="javascript:;"> |
| | | <i class="layui-icon"></i> |
| | | </a> |
| | | <a title="删除" onclick="member_del(this,{{d.LAY_INDEX }},'{{d.account}}')" href="javascript:;"> |
| | | <i class="layui-icon"></i> |
| | | </a> |
| | | </div> |
| | | </script> |
| | |
| | | |
| | | <script> |
| | | var tableIns = null; |
| | | var app = null; |
| | | $(function () { |
| | | |
| | | var app = new Vue({ |
| | | app = new Vue({ |
| | | el: "#app", |
| | | data: { |
| | | key: '', |
| | |
| | | |
| | | tableIns = table.render({ |
| | | elem: '#table_list', |
| | | url: "/admin/api/config/list", |
| | | url: "/admin/api/adminuser/list", |
| | | toolbar: "#toolbar", |
| | | totalRow: true, |
| | | cols: [[{type: 'checkbox', title: "ID"}, |
| | | {field: 'name', width: 200, sort: false, title: "名称"}, |
| | | {field: 'key', width: 120, sort: false, title: "关键字"}, |
| | | {field: 'account', width: 120, sort: false, title: "账号"}, |
| | | {field: 'name', width: 120, sort: false, title: "昵称"}, |
| | | {field: 'email', width: 200, sort: false, title: "邮件"}, |
| | | { |
| | | field: 'value', width: 400, sort: false, title: "内容", templet: function (res) { |
| | | if ("object" == typeof res.value) { |
| | | return JSON.stringify(res.value); |
| | | } else { |
| | | return res.value; |
| | | field: 'roleList', width: 250, sort: false, title: "角色", templet: function (res) { |
| | | var roles = ""; |
| | | res.roleList.forEach(function (role) { |
| | | roles += role + ","; |
| | | }); |
| | | if (roles.length > 0) { |
| | | roles = roles.substring(0, roles.length - 1); |
| | | } |
| | | |
| | | return roles; |
| | | } |
| | | }, |
| | | {field: 'remarks', width: 120, sort: false, title: "备注"}, |
| | | {field: 'createTime', width: 120, sort: false, title: "创建时间"}, |
| | | {field: 'updateTime', width: 120, sort: false, title: "修改时间"}, |
| | | {field: 'createTime', width: 150, sort: false, title: "创建时间"}, |
| | | {field: 'updateTime', width: 150, sort: false, title: "修改时间"}, |
| | | {fixed: 'right', width: 80, title: "操作", toolbar: '#optContainer'}]], |
| | | page: true, |
| | | parseData: function (res) { //res 即为原始返回的数据 |
| | |
| | | } |
| | | ; |
| | | }); |
| | | //请求搜索表单中需要的数据 |
| | | $('#search').trigger("click"); |
| | | |
| | | }); |
| | | |
| | | }, |
| | |
| | | }); |
| | | }, |
| | | deleteList: function (ids, success) { |
| | | ksapp.post("/admin/api/config/delete", {ids: JSON.stringify(ids)}, function (e) { |
| | | ksapp.post("/admin/api/adminuser/delete", {ids: JSON.stringify(ids)}, function (e) { |
| | | if (e.code == 0) { |
| | | success(); |
| | | } else { |
| | |
| | | }); |
| | | }, |
| | | search: function (params) { |
| | | params["type"] = ksapp.getQueryParam("type"); |
| | | |
| | | var ps = {}; |
| | | for (var key in params) { |
| | | if (params[key] != null && params[key].length > 0) { |
| | | if (params[key].length > 0) { |
| | | ps[key] = params[key]; |
| | | } |
| | | } |
| | | |
| | | |
| | | //数据重载 |
| | | tableIns.reload({ |
| | | where: params, |
| | | where: ps, |
| | | page: { |
| | | curr: 1 //重新从第 1 页开始 |
| | | } |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html class="x-admin-sm"> |
| | | |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <title>修改管理员角色管理</title> |
| | | <meta name="renderer" content="webkit"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" |
| | | content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
| | | |
| | | <link rel="stylesheet" href="/admin/css/font.css"> |
| | | <link rel="stylesheet" href="/admin/css/xadmin.css"> |
| | | <link rel="stylesheet" href="/admin/css/theme3049.min.css"> |
| | | |
| | | <script src="/admin/lib/layui/layui.js" charset="utf-8"></script> |
| | | <script src="/admin/js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/xadmin.js" type="text/javascript"></script> |
| | | <script src="/admin/js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/jquery.min.js" type="text/javascript"></script> |
| | | <script src="/admin/js/utils.js"></script> |
| | | <!-- 让IE8/9支持媒体查询,从而兼容栅格 --> |
| | | <!--[if lt IE 9]> |
| | | <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script> |
| | | <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> |
| | | <![endif]--> |
| | | </head> |
| | | <body> |
| | | <div class="layui-fluid"> |
| | | <div class="layui-row"> |
| | | <form class="layui-form" lay-filter="update"> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | 账号</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="account" lay-verify="" placeholder="" autocomplete="off" |
| | | disabled="disabled" |
| | | class="layui-input"> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | 昵称</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="name" lay-verify="" placeholder="" autocomplete="off" |
| | | class="layui-input"> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | 密码</label> |
| | | <div class="layui-input-block"> |
| | | <input type="password" name="pwd" lay-verify="" placeholder="点击修改密码" autocomplete="off" |
| | | class="layui-input"> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | 邮件</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="email" lay-verify="" placeholder="" autocomplete="off" |
| | | class="layui-input"> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_appCode" class="layui-form-label"> |
| | | 角色</label> |
| | | <div class="layui-input-block" id="roles-container"> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="L_remarks" class="layui-form-label"></label> |
| | | <button class="layui-btn" lay-filter="update" lay-submit="">确定修改</button> |
| | | </div> |
| | | </form> |
| | | </div> |
| | | </div> |
| | | <script> |
| | | //初始化上传控件 |
| | | var uploadTool = { |
| | | callback: null, |
| | | chooseImage: {}, |
| | | uploadArray: new Array(), |
| | | init: function (upload) { |
| | | this.uploadArray = new Array(); |
| | | }, |
| | | upload: function (result) { |
| | | if (this.uploadArray.length > 0 && Object.keys(this.chooseImage).length > 0) { |
| | | this.callback = result; |
| | | //同时上传 |
| | | for (var i = 0; i < this.uploadArray.length; i++) { |
| | | this.uploadArray[i].upload(); |
| | | } |
| | | } else { |
| | | result(); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | |
| | | </script> |
| | | |
| | | <script> |
| | | //填充数据 |
| | | function fillData(form) { |
| | | var id = ksapp.getQueryParam("id"); |
| | | if (id) { |
| | | } else { |
| | | layer.msg("id为空"); |
| | | return; |
| | | } |
| | | |
| | | ksapp.post('/admin/api/adminuser/get', {id: id}, function (res) { |
| | | if (res.code == 0) { |
| | | form.val("update", res.data); |
| | | |
| | | for (var i = 0; i < res.data.allRoleList.length; i++) { |
| | | var role = res.data.allRoleList[i]; |
| | | var checked = false; |
| | | res.data.roleList.forEach(function (e) { |
| | | if (e.key == role.key) { |
| | | checked = true; |
| | | } |
| | | }); |
| | | |
| | | |
| | | |
| | | if (checked) { |
| | | $("#roles-container").append("<input type='checkbox' name='roles." + role.key + "' title='" + role.value + "' value='1' checked='true'>"); |
| | | } else { |
| | | $("#roles-container").append("<input type='checkbox' name='roles." + role.key + "' title='" + role.value + "' value='1'>"); |
| | | } |
| | | } |
| | | form.render(); |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | }, function (res) { |
| | | layer.msg("详情获取失败"); |
| | | }); |
| | | } |
| | | </script> |
| | | |
| | | <script> |
| | | layui.use(['form', 'layer', 'jquery', 'upload', 'laydate'], function () { |
| | | $ = layui.jquery; |
| | | var form = layui.form, |
| | | layer = layui.layer, |
| | | upload = layui.upload, |
| | | laydate = layui.laydate; |
| | | |
| | | var verify = {}; |
| | | //自定义验证规则 |
| | | form.verify(verify); |
| | | |
| | | |
| | | //渲染上传控件 |
| | | uploadTool.init(upload); |
| | | |
| | | //填充表单数据 |
| | | //请求数据 |
| | | //form.data(); |
| | | |
| | | |
| | | //监听提交 |
| | | form.on('submit(update)', |
| | | function (data) { |
| | | uploadTool.upload(function (hasFile) { |
| | | if (hasFile) { |
| | | //从新提交表单 |
| | | $("button[lay-filter=update]").click(); |
| | | return; |
| | | } |
| | | //发异步,把数据提交给php |
| | | var params = data.field; |
| | | var keys = Object.keys(params); |
| | | var roles = []; |
| | | for (var i = 0; i < keys.length; i++) { |
| | | if (keys[i].indexOf("roles.") == 0) { |
| | | delete params[keys[i]]; |
| | | roles.push(keys[i].replace("roles.", "")); |
| | | } |
| | | } |
| | | |
| | | console.log(roles); |
| | | |
| | | params.roleList = roles; |
| | | //组装数据 |
| | | // for (key in params.keys()) { |
| | | // alert(key); |
| | | // if (key.indexOf("roles[") == 0) { |
| | | // delete params[key]; |
| | | // } |
| | | // } |
| | | |
| | | |
| | | ksapp.postJSON('/admin/api/adminuser/update', data.field, function (res) { |
| | | if (res.code == 0) { |
| | | layer.alert("修改成功", { |
| | | icon: 6 |
| | | }, |
| | | function () { |
| | | //关闭当前frame |
| | | xadmin.close(); |
| | | // 可以对父窗口进行刷新 |
| | | // xadmin.father_reload(); |
| | | }); |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | |
| | | }, function (res) { |
| | | }); |
| | | }); |
| | | return false; |
| | | }); |
| | | //请求select的数据API |
| | | |
| | | fillData(form) |
| | | }) |
| | | ; |
| | | </script> |
| | | </body> |
| | | |
| | | </html> |
New file |
| | |
| | | <!doctype html> |
| | | <html class="x-admin-sm"> |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <title>赚钱小视频系统</title> |
| | | <meta name="renderer" content="webkit|ie-comp|ie-stand"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" |
| | | content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
| | | <meta http-equiv="Cache-Control" content="no-siteapp"/> |
| | | <link rel="stylesheet" href="/admin/css/font.css"> |
| | | <link rel="stylesheet" href="/admin/css/xadmin.css"> |
| | | <link rel="stylesheet" href="/admin/css/theme3049.min.css"> |
| | | <script src="/admin/lib/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="/admin/js/xadmin.js"></script> |
| | | <script src="/admin/js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | |
| | | <script src="/admin/js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <!--<script type="text/javascript" src="/admin/js/jquery.min.js"></script>--> |
| | | <script src="https://cdn.staticfile.org/jquery/3.4.0/jquery.min.js"></script> |
| | | <script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script> |
| | | <!-- 让IE8/9支持媒体查询,从而兼容栅格 --> |
| | | <!--[if lt IE 9]> |
| | | <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script> |
| | | <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> |
| | | <![endif]--> |
| | | <script> |
| | | // 是否开启刷新记忆tab功能 |
| | | // var is_remember = false; |
| | | </script> |
| | | <style> |
| | | body { |
| | | font-size: 0; |
| | | } |
| | | |
| | | .container .layui-nav-more { |
| | | top: 0 !important; |
| | | } |
| | | |
| | | </style> |
| | | </head> |
| | | <body class="index"> |
| | | <!-- 顶部开始 --> |
| | | <div class="container"> |
| | | <div class="logo"> |
| | | <a href="index.html">赚钱小视频系统</a></div> |
| | | <div class="left_open"> |
| | | <a><i title="展开左侧栏" class="iconfont"></i></a> |
| | | </div> |
| | | <ul class="layui-nav left fast-add" lay-filter=""> |
| | | |
| | | </ul> |
| | | <ul class="layui-nav right" lay-filter=""> |
| | | <li class="layui-nav-item" id="system"> |
| | | <a href="javascript:;"> 当前系统:<b></b></a> |
| | | <dl class="layui-nav-child"> |
| | | </dl> |
| | | </li> |
| | | |
| | | |
| | | <li class="layui-nav-item"> |
| | | <a href="javascript:;" id="logined-name">admin</a> |
| | | <dl class="layui-nav-child"> |
| | | <!-- 二级菜单 --> |
| | | <dd> |
| | | <a href="javascript:void();" id="loginExit">退出</a></dd> |
| | | </dl> |
| | | </li> |
| | | <li class="layui-nav-item to-index"> |
| | | <a href="javascript:void();" id="clearCache">清除缓存</a></li> |
| | | </ul> |
| | | </div> |
| | | <!-- 顶部结束 --> |
| | | <!-- 中部开始 --> |
| | | <!-- 左侧菜单开始 --> |
| | | <div class="left-nav"> |
| | | <div id="side-nav"> |
| | | <ul id="nav"> |
| | | |
| | | |
| | | <li th:each="page : ${pages}"> |
| | | <a href="javascript:;"> |
| | | <i class="layui-icon left-nav-li" th:lay-tips="${page.name}" |
| | | th:class="|layui-icon left-nav-li ${page.icon}|"></i> |
| | | <cite th:text="${page.name}"></cite> |
| | | <i class="iconfont nav_right"></i></a> |
| | | <ul class="sub-menu" th:unless="${#lists.isEmpty(page.children)}"> |
| | | <li th:each="page1 : ${page.children}"> |
| | | <a th:attrprepend="onclick =|add_tab('${page1.name}','${page1.path}')|" |
| | | th:if="${page1.path}!=null"> |
| | | <i class="iconfont"></i> |
| | | <cite th:text="${page1.name}"></cite></a> |
| | | |
| | | <a href="javascript:;" th:if="${page1.path}==null"> |
| | | <i class="layui-icon left-nav-li" th:lay-tips="${page1.name}" |
| | | th:class="|layui-icon left-nav-li ${page1.icon}|"></i> |
| | | <cite th:text="${page1.name}"></cite> |
| | | <i class="iconfont nav_right"></i></a> |
| | | </a> |
| | | |
| | | <ul class="sub-menu" th:unless="${#lists.isEmpty(page1.children)}"> |
| | | <li th:each="page2 : ${page1.children}"> |
| | | <a th:attrprepend="onclick =|add_tab('${page2.name}','${page2.path}')|"> |
| | | <i class="iconfont"></i> |
| | | <cite th:text="${page2.name}"></cite></a> |
| | | </li> |
| | | </ul> |
| | | </li> |
| | | </ul> |
| | | </li> |
| | | </ul> |
| | | </div> |
| | | </div> |
| | | <!-- <div class="x-slide_left"></div> --> |
| | | <!-- 左侧菜单结束 --> |
| | | <!-- 右侧主体开始 --> |
| | | <div class="page-content"> |
| | | <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false"> |
| | | <ul class="layui-tab-title"> |
| | | <li class="home"> |
| | | <i class="layui-icon"></i>我的桌面 |
| | | </li> |
| | | </ul> |
| | | <div class="layui-unselect layui-form-select layui-form-selected" id="tab_right"> |
| | | <dl> |
| | | <dd data-type="this">关闭当前</dd> |
| | | <dd data-type="other">关闭其它</dd> |
| | | <dd data-type="all">关闭全部</dd> |
| | | </dl> |
| | | </div> |
| | | <div class="layui-tab-content"> |
| | | <div class="layui-tab-item layui-show"> |
| | | <iframe src='/admin/pages/welcome.html' frameborder="0" scrolling="yes" class="x-iframe"></iframe> |
| | | </div> |
| | | </div> |
| | | <div id="tab_show"></div> |
| | | </div> |
| | | </div> |
| | | <div class="page-content-bg"></div> |
| | | <style id="theme_style"></style> |
| | | <!-- 右侧主体结束 --> |
| | | <!-- 中部结束 --> |
| | | </body> |
| | | |
| | | <script> |
| | | |
| | | window.add_tab = function (name, path) { |
| | | xadmin.add_tab(name, "/admin/pages/" + path) |
| | | } |
| | | |
| | | $(function () { |
| | | // 退出登录事件 |
| | | $("#loginExit").click(function () { |
| | | var myurl = "/admin/api/logout"; |
| | | $.post(myurl, {}, function (e) { |
| | | window.location.replace("login.html"); |
| | | }); |
| | | }); |
| | | |
| | | $("#clearCache").click(function () { |
| | | var myurl = "/admin/api/clearCache"; |
| | | $.post(myurl, {}, function (e) { |
| | | if (e.code == 200) {//成功 |
| | | layer.msg("清除成功"); |
| | | } else { |
| | | layer.msg(e.msg); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | function getSystemList() { |
| | | ksapp.post("/admin/api/system/systemList", {}, function (res) { |
| | | |
| | | if (res.code == 0) { |
| | | $("#system").find("dl").eq(0).empty(); |
| | | var list = res.data.list; |
| | | var selected = false; |
| | | for (var i = 0; i < list.length; i++) { |
| | | $("#system").find("dl").append("<dd key='" + list[i].key + "'><a href='javascript:void();' >" + list[i].name + "</a></dd>"); |
| | | if (list[i].selected) { |
| | | selected = true; |
| | | $("#system").find("b").eq(0).html(list[i].name); |
| | | //保存cookie |
| | | // $.cookie('selectSystem', list[i].key, {expires: 30}); |
| | | } |
| | | } |
| | | |
| | | if (!selected) { |
| | | //获取是否有cookie |
| | | var selectSystem = $.cookie('selectSystem'); |
| | | if (!selectSystem) { |
| | | selectSystem = list[0].key; |
| | | } |
| | | //设置cookie |
| | | ksapp.post("/admin/api/system/selectSystem", {key: selectSystem}, function (res) { |
| | | if (res.code == 0) { |
| | | getSystemList(); |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | }, function (res) { |
| | | |
| | | }) |
| | | |
| | | } |
| | | |
| | | |
| | | $("#system").find("dd").bind("click", function () { |
| | | ksapp.post("/admin/api/system/selectSystem", {key: $(this).attr("key")}, function (res) { |
| | | if (res.code == 0) { |
| | | layer.msg("更改成功"); |
| | | getSystemList(); |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | }, function (res) { |
| | | |
| | | }) |
| | | }) |
| | | } |
| | | }, function (res) { |
| | | |
| | | }) |
| | | } |
| | | |
| | | function getLoginInfo() { |
| | | ksapp.post("/admin/api/adminuser/getLoginAdminInfo", {}, function (res) { |
| | | if (res.code == 0) { |
| | | $("#logined-name").html(res.data.name); |
| | | } |
| | | }, function (res) { |
| | | |
| | | }) |
| | | } |
| | | |
| | | getSystemList(); |
| | | getLoginInfo(); |
| | | |
| | | |
| | | }); |
| | | |
| | | |
| | | </script> |
| | | |
| | | </html> |
File was renamed from src/main/resources/code/service/app/src/main/resources/static/login.html |
| | |
| | | <meta name="viewport" |
| | | content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/> |
| | | <meta http-equiv="Cache-Control" content="no-siteapp"/> |
| | | <link rel="stylesheet" href="css/font.css"> |
| | | <link rel="stylesheet" href="css/login.css"> |
| | | <link rel="stylesheet" href="css/xadmin.css"> |
| | | <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> |
| | | <script src="lib/layui/layui.js" charset="utf-8"></script> |
| | | <script src="js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script type="text/javascript" src="js/xadmin.js"></script> |
| | | <link rel="stylesheet" href="/admin/css/font.css"> |
| | | <link rel="stylesheet" href="/admin/css/login.css"> |
| | | <link rel="stylesheet" href="/admin/css/xadmin.css"> |
| | | <script type="text/javascript" src="/admin/js/jquery.min.js"></script> |
| | | <script src="/admin/lib/layui/layui.js" charset="utf-8"></script> |
| | | <script src="/admin/js/vue.min.js" type="text/javascript" charset="utf-8"></script> |
| | | <script src="/admin/js/http.js" type="text/javascript" charset="utf-8"></script> |
| | | <script type="text/javascript" src="/admin/js/xadmin.js"></script> |
| | | <script type="text/javascript"> |
| | | </script> |
| | | <!--[if lt IE 9]> |
| | |
| | | <version>1.3.1</version> |
| | | </dependency> |
| | | |
| | | <!-- 腾讯云日志采集CLS --> |
| | | <dependency> |
| | | <groupId>com.tencentcloudapi.cls</groupId> |
| | | <artifactId>tencentcloud-cls-logback-appender</artifactId> |
| | | <version>1.0.1</version> |
| | | </dependency> |
| | | |
| | | |
| | | </dependencies> |
| | | |
| | | |