优化条件判断

dep_wangsr
RuoYi 6 years ago committed by Limy
parent f3229805b1
commit ad322f6948

@ -6,6 +6,7 @@ import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
import com.ruoyi.project.monitor.online.domain.UserOnline;
import com.ruoyi.project.monitor.online.mapper.UserOnlineMapper;
@ -46,7 +47,7 @@ public class UserOnlineServiceImpl implements IUserOnlineService
public void deleteOnlineById(String sessionId)
{
UserOnline userOnline = selectOnlineById(sessionId);
if (userOnline != null)
if (StringUtils.isNotNull(userOnline))
{
userOnlineDao.deleteOnlineById(sessionId);
}
@ -64,7 +65,7 @@ public class UserOnlineServiceImpl implements IUserOnlineService
for (String sessionId : sessions)
{
UserOnline userOnline = selectOnlineById(sessionId);
if (userOnline != null)
if (StringUtils.isNotNull(userOnline))
{
userOnlineDao.deleteOnlineById(sessionId);
}

@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
@ -134,7 +135,7 @@ public class ConfigController extends BaseController
public String checkConfigKeyUnique(Config config)
{
String uniqueFlag = "0";
if (config != null)
if (StringUtils.isNotNull(config))
{
uniqueFlag = configService.checkConfigKeyUnique(config);
}

@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
@ -120,7 +121,7 @@ public class DeptController extends BaseController
public String checkDeptNameUnique(Dept dept)
{
String uniqueFlag = "0";
if (dept != null)
if (StringUtils.isNotNull(dept))
{
uniqueFlag = deptService.checkDeptNameUnique(dept);
}

@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
@ -147,7 +148,7 @@ public class DictTypeController extends BaseController
public String checkDictTypeUnique(DictType dictType)
{
String uniqueFlag = "0";
if (dictType != null)
if (StringUtils.isNotNull(dictType))
{
uniqueFlag = dictTypeService.checkDictTypeUnique(dictType);
}

@ -133,7 +133,7 @@ public class DictTypeServiceImpl implements IDictTypeService
{
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
DictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
if (StringUtils.isNotNull(dictType) && dictType.getDictId() != dictId)
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue())
{
return UserConstants.DICT_TYPE_NOT_UNIQUE;
}

@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
@ -142,7 +143,7 @@ public class MenuController extends BaseController
public String checkMenuNameUnique(Menu menu)
{
String uniqueFlag = "0";
if (menu != null)
if (StringUtils.isNotNull(menu))
{
uniqueFlag = menuService.checkMenuNameUnique(menu);
}

@ -61,7 +61,7 @@ public class PostServiceImpl implements IPostService
{
for (Post userRole : userPosts)
{
if (post.getPostId() == userRole.getPostId())
if (post.getPostId().longValue() == userRole.getPostId().longValue())
{
post.setFlag(true);
break;

@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
@ -140,7 +141,7 @@ public class RoleController extends BaseController
public String checkRoleNameUnique(Role role)
{
String uniqueFlag = "0";
if (role != null)
if (StringUtils.isNotNull(role))
{
uniqueFlag = roleService.checkRoleNameUnique(role);
}
@ -155,7 +156,7 @@ public class RoleController extends BaseController
public String checkRoleKeyUnique(Role role)
{
String uniqueFlag = "0";
if (role != null)
if (StringUtils.isNotNull(role))
{
uniqueFlag = roleService.checkRoleKeyUnique(role);
}

@ -83,7 +83,7 @@ public class RoleServiceImpl implements IRoleService
{
for (Role userRole : userRoles)
{
if (role.getRoleId() == userRole.getRoleId())
if (role.getRoleId().longValue() == userRole.getRoleId().longValue())
{
role.setFlag(true);
break;

@ -28,7 +28,7 @@ public class LoginController extends BaseController
public String login(HttpServletRequest request, HttpServletResponse response)
{
// 如果是Ajax请求返回Json字符串。
if (ServletUtils.isAjaxRequest((HttpServletRequest) request))
if (ServletUtils.isAjaxRequest(request))
{
return ServletUtils.renderString(response, "{\"code\":\"1\",\"msg\":\"未登录或登录超时。请重新登录\"}");
}

@ -177,7 +177,7 @@ public class UserController extends BaseController
public String checkLoginNameUnique(User user)
{
String uniqueFlag = "0";
if (user != null)
if (StringUtils.isNotNull(user))
{
uniqueFlag = userService.checkLoginNameUnique(user.getLoginName());
}
@ -192,7 +192,7 @@ public class UserController extends BaseController
public String checkPhoneUnique(User user)
{
String uniqueFlag = "0";
if (user != null)
if (StringUtils.isNotNull(user))
{
uniqueFlag = userService.checkPhoneUnique(user);
}
@ -207,7 +207,7 @@ public class UserController extends BaseController
public String checkEmailUnique(User user)
{
String uniqueFlag = "0";
if (user != null)
if (StringUtils.isNotNull(user))
{
uniqueFlag = userService.checkEmailUnique(user);
}

Loading…
Cancel
Save