This commit is contained in:
water 2020-03-11 15:10:13 +08:00
parent aeb916dbf8
commit e6aa86f2b9
5 changed files with 34 additions and 29 deletions

View File

@ -66,8 +66,7 @@ public class BaseForm {
* @return
*/
public Long getPageNo() {
String pageNum = StrUtil.emptyToDefault(StrUtil.toString(this.get("pageNum")), StrUtil.toString(this.get("page")));
String pageNum = StrUtil.toString(this.get("current"));
if (!StrUtil.isEmpty(pageNum) && NumberUtil.isNumber(pageNum)) {
this.current = Long.parseLong(pageNum);
}
@ -80,9 +79,9 @@ public class BaseForm {
* @return
*/
public Long getPageSize() {
String pageSize = StrUtil.emptyToDefault(StrUtil.toString(this.get("pageSize")), StrUtil.toString(this.get("rows")));
String pageSize = StrUtil.toString(this.get("size"));
if (!StrUtil.isEmpty(pageSize) || NumberUtil.isNumber(pageSize)) {
if (StrUtil.isNotEmpty(pageSize) && NumberUtil.isNumber(pageSize) && !"null".equalsIgnoreCase(pageSize)) {
this.size = Long.parseLong(pageSize);
}
return this.size;

View File

@ -63,7 +63,7 @@ public class JobLogController {
int list_count = jobLogMapper.pageListCount((current-1)*size, size, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
// package result
Map<String, Object> maps = new HashMap<String, Object>();
Map<String, Object> maps = new HashMap<>();
maps.put("recordsTotal", list_count); // 总记录数
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
maps.put("data", list); // 分页列表

View File

@ -38,12 +38,12 @@ public class UserController {
// page list
List<JobUser> list = jobUserMapper.pageList((current-1)*size, size, username);
int list_count = jobUserMapper.pageListCount((current-1)*size, size, username);
int recordsTotal = jobUserMapper.pageListCount((current-1)*size, size, username);
// package result
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("recordsTotal", list_count); // 总记录数
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
Map<String, Object> maps = new HashMap<>();
maps.put("recordsTotal", recordsTotal); // 总记录数
maps.put("recordsFiltered", recordsTotal); // 过滤后的总记录数
maps.put("data", list); // 分页列表
return new ReturnT<>(maps);
}
@ -54,26 +54,26 @@ public class UserController {
// valid username
if (!StringUtils.hasText(jobUser.getUsername())) {
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input")+I18nUtil.getString("user_username") );
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input") + I18nUtil.getString("user_username"));
}
jobUser.setUsername(jobUser.getUsername().trim());
if (!(jobUser.getUsername().length()>=4 && jobUser.getUsername().length()<=20)) {
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" );
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit") + "[4-20]");
}
// valid password
if (!StringUtils.hasText(jobUser.getPassword())) {
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input")+I18nUtil.getString("user_password") );
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("system_please_input") + I18nUtil.getString("user_password"));
}
jobUser.setPassword(jobUser.getPassword().trim());
if (!(jobUser.getPassword().length()>=4 && jobUser.getPassword().length()<=20)) {
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" );
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit") + "[4-20]");
}
jobUser.setPassword(bCryptPasswordEncoder.encode(jobUser.getPassword()));
// check repeat
JobUser existUser = jobUserMapper.loadByUserName(jobUser.getUsername());
if (existUser != null) {
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("user_username_repeat") );
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("user_username_repeat"));
}
// write
@ -88,7 +88,7 @@ public class UserController {
if (StringUtils.hasText(jobUser.getPassword())) {
jobUser.setPassword(jobUser.getPassword().trim());
if (!(jobUser.getPassword().length()>=4 && jobUser.getPassword().length()<=20)) {
return new ReturnT<String>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit")+"[4-20]" );
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit") + "[4-20]");
}
jobUser.setPassword(bCryptPasswordEncoder.encode(jobUser.getPassword()));
} else {
@ -112,11 +112,11 @@ public class UserController {
String password=jobUser.getPassword();
// valid password
if (password==null || password.trim().length()==0){
return new ReturnT<String>(ReturnT.FAIL.getCode(), "密码不可为空");
return new ReturnT<>(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]" );
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("system_lengh_limit") + "[4-20]");
}
// do write
JobUser existUser = jobUserMapper.loadByUserName(jobUser.getUsername());

View File

@ -14,19 +14,20 @@ import java.util.List;
@Repository
public interface JobUserMapper {
public List<JobUser> pageList(@Param("offset") int offset,
@Param("pagesize") int pagesize,
@Param("username") String username);
public int pageListCount(@Param("offset") int offset,
@Param("pagesize") int pagesize,
@Param("username") String username);
List<JobUser> pageList(@Param("offset") int offset,
@Param("pagesize") int pagesize,
@Param("username") String username);
public JobUser loadByUserName(@Param("username") String username);
int pageListCount(@Param("offset") int offset,
@Param("pagesize") int pagesize,
@Param("username") String username);
public int save(JobUser xxlJobUser);
JobUser loadByUserName(@Param("username") String username);
public int update(JobUser xxlJobUser);
public int delete(@Param("id") int id);
int save(JobUser xxlJobUser);
int update(JobUser xxlJobUser);
int delete(@Param("id") int id);
}

View File

@ -20,7 +20,12 @@
</sql>
<select id="pageList" parameterType="java.util.HashMap" resultMap="JobUser">
SELECT <include refid="Base_Column_List" />
<!--SELECT <include refid="Base_Column_List" />--> /*不返回密码(前端密码置空)*/
SELECT
t.id,
t.username,
t.role,
t.permission
FROM job_user AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="username != null and username != ''">