2026-01-07
1.优化代码
This commit is contained in:
@@ -5,7 +5,6 @@ import cn.lailab.toolbox.mapper.ParameterMapper;
|
||||
import cn.lailab.toolbox.service.ParameterService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
||||
@@ -12,39 +12,41 @@ public class ResultServiceImpl implements ResultService {
|
||||
Result result = new Result();
|
||||
result.setCode(code);
|
||||
result.setMessage(message);
|
||||
if(data == null) result.setData("");
|
||||
if (data == null)
|
||||
result.setData("");
|
||||
result.setData(data);
|
||||
result.setTimestamp(System.currentTimeMillis());
|
||||
//return JSONUtil.toJsonPrettyStr(result);
|
||||
// return JSONUtil.toJsonPrettyStr(result);
|
||||
return JSONUtil.toJsonStr(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String success() {
|
||||
return other(0,"success","");
|
||||
return other(0, "success", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String success(String message) {
|
||||
return other(0,message,"");
|
||||
return other(0, message, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String success(String message, Object data) {
|
||||
return other(0,message,data);
|
||||
return other(0, message, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String error() {
|
||||
return other(-1,"error","");
|
||||
return other(-1, "error", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String error(String message) {
|
||||
return other(-1,message,"");
|
||||
return other(-1, message, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String error(String message, Object data) {
|
||||
return other(-1,message,data);
|
||||
return other(-1, message, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import cn.lailab.toolbox.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,15 +26,15 @@ public class UserServiceImpl implements UserService {
|
||||
public int addUser(User user) {
|
||||
int maxId;
|
||||
maxId = userMapper.getMaxId();
|
||||
maxId +=1;
|
||||
maxId += 1;
|
||||
// 自动生成用户名
|
||||
if(user.getUsername().isEmpty()){
|
||||
user.setUsername(String.format("%05d",maxId));
|
||||
if (user.getUsername().isEmpty()) {
|
||||
user.setUsername(String.format("%05d", maxId));
|
||||
}
|
||||
// 对用户输入的密码进行MD5加密
|
||||
if(user.getPassword().isEmpty()) {
|
||||
if (user.getPassword().isEmpty()) {
|
||||
user.setPassword(SecureUtil.md5(defaultPassword).toUpperCase());
|
||||
}else{
|
||||
} else {
|
||||
user.setPassword(SecureUtil.md5(user.getPassword()).toUpperCase());
|
||||
}
|
||||
// 创建时间赋值
|
||||
@@ -71,9 +70,9 @@ public class UserServiceImpl implements UserService {
|
||||
@Override
|
||||
public int updateUser(User user) {
|
||||
// 对用户输入的密码进行MD5加密
|
||||
if(user.getPassword().isEmpty()) {
|
||||
if (user.getPassword().isEmpty()) {
|
||||
user.setPassword(SecureUtil.md5(defaultPassword).toUpperCase());
|
||||
}else{
|
||||
} else {
|
||||
user.setPassword(SecureUtil.md5(user.getPassword()).toUpperCase());
|
||||
}
|
||||
return userMapper.updateUser(user);
|
||||
@@ -103,5 +102,4 @@ public class UserServiceImpl implements UserService {
|
||||
return userMapper.getMaxId();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user