| | |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | int list_count = xxlJobUserDao.pageListCount(start, length, username, role); |
| | | |
| | | // filter |
| | | if (list!=null && list.size()>0) { |
| | | for (XxlJobUser item: list) { |
| | | if (list != null && list.size() > 0) { |
| | | for (XxlJobUser item : list) { |
| | | item.setPassword(null); |
| | | } |
| | | } |
| | | |
| | | // package result |
| | | Map<String, Object> maps = new HashMap<String, Object>(); |
| | | maps.put("recordsTotal", list_count); // 总记录数 |
| | | maps.put("recordsFiltered", list_count); // 过滤后的总记录数 |
| | | maps.put("data", list); // 分页列表 |
| | | maps.put("recordsTotal", list_count); // 总记录数 |
| | | maps.put("recordsFiltered", list_count); // 过滤后的总记录数 |
| | | maps.put("data", list); // 分页列表 |
| | | return maps; |
| | | } |
| | | |
| | |
| | | |
| | | // valid username |
| | | if (!StringUtils.hasText(xxlJobUser.getUsername())) { |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input")+I18nUtil.getString("user_username") ); |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input") + I18nUtil.getString("user_username")); |
| | | } |
| | | xxlJobUser.setUsername(xxlJobUser.getUsername().trim()); |
| | | if (!(xxlJobUser.getUsername().length()>=4 && xxlJobUser.getUsername().length()<=20)) { |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" ); |
| | | if (!(xxlJobUser.getUsername().length() >= 4 && xxlJobUser.getUsername().length() <= 20)) { |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit") + "[4-20]"); |
| | | } |
| | | // valid password |
| | | if (!StringUtils.hasText(xxlJobUser.getPassword())) { |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input")+I18nUtil.getString("user_password") ); |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input") + I18nUtil.getString("user_password")); |
| | | } |
| | | xxlJobUser.setPassword(xxlJobUser.getPassword().trim()); |
| | | if (!(xxlJobUser.getPassword().length()>=4 && xxlJobUser.getPassword().length()<=20)) { |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" ); |
| | | if (!(xxlJobUser.getPassword().length() >= 4 && xxlJobUser.getPassword().length() <= 20)) { |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit") + "[4-20]"); |
| | | } |
| | | // md5 password |
| | | xxlJobUser.setPassword(DigestUtils.md5DigestAsHex(xxlJobUser.getPassword().getBytes())); |
| | |
| | | // check repeat |
| | | XxlJobUser existUser = xxlJobUserDao.loadByUserName(xxlJobUser.getUsername()); |
| | | if (existUser != null) { |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("user_username_repeat") ); |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("user_username_repeat")); |
| | | } |
| | | |
| | | // write |
| | |
| | | // valid password |
| | | if (StringUtils.hasText(xxlJobUser.getPassword())) { |
| | | xxlJobUser.setPassword(xxlJobUser.getPassword().trim()); |
| | | if (!(xxlJobUser.getPassword().length()>=4 && xxlJobUser.getPassword().length()<=20)) { |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" ); |
| | | if (!(xxlJobUser.getPassword().length() >= 4 && xxlJobUser.getPassword().length() <= 20)) { |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit") + "[4-20]"); |
| | | } |
| | | // md5 password |
| | | xxlJobUser.setPassword(DigestUtils.md5DigestAsHex(xxlJobUser.getPassword().getBytes())); |
| | |
| | | |
| | | @RequestMapping("/updatePwd") |
| | | @ResponseBody |
| | | public ReturnT<String> updatePwd(HttpServletRequest request, String password){ |
| | | public ReturnT<String> updatePwd(HttpServletRequest request, String password) { |
| | | |
| | | // valid password |
| | | if (password==null || password.trim().length()==0){ |
| | | if (password == null || password.trim().length() == 0) { |
| | | return new ReturnT<String>(ReturnT.FAIL.getCode(), "密码不可为空"); |
| | | } |
| | | password = password.trim(); |
| | | if (!(password.length()>=4 && password.length()<=20)) { |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" ); |
| | | if (!(password.length() >= 4 && password.length() <= 20)) { |
| | | return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit") + "[4-20]"); |
| | | } |
| | | |
| | | // md5 password |