更新优化
This commit is contained in:
parent
ab49c986d7
commit
5599f89863
|
@ -144,4 +144,14 @@ public class MathUtils {
|
||||||
}
|
}
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean equals(Integer a, Integer b) {
|
||||||
|
if (a == null) {
|
||||||
|
a = 0;
|
||||||
|
}
|
||||||
|
if (b == null) {
|
||||||
|
b = 0;
|
||||||
|
}
|
||||||
|
return a.equals(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,13 @@ import com.ruoyi.bst.areaJoin.domain.AreaJoinVO;
|
||||||
import com.ruoyi.bst.areaJoin.mapper.AreaJoinMapper;
|
import com.ruoyi.bst.areaJoin.mapper.AreaJoinMapper;
|
||||||
import com.ruoyi.bst.areaJoin.service.AreaJoinService;
|
import com.ruoyi.bst.areaJoin.service.AreaJoinService;
|
||||||
import com.ruoyi.bst.areaJoin.service.AreaJoinValidator;
|
import com.ruoyi.bst.areaJoin.service.AreaJoinValidator;
|
||||||
|
import com.ruoyi.common.constant.RoleConstants;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||||
|
import com.ruoyi.system.role.service.RoleService;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运营加盟Service业务层处理
|
* 运营加盟Service业务层处理
|
||||||
|
@ -25,6 +29,7 @@ import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||||
* @date 2025-03-25
|
* @date 2025-03-25
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class AreaJoinServiceImpl implements AreaJoinService
|
public class AreaJoinServiceImpl implements AreaJoinService
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -36,6 +41,9 @@ public class AreaJoinServiceImpl implements AreaJoinService
|
||||||
@Autowired
|
@Autowired
|
||||||
private TransactionTemplate transactionTemplate;
|
private TransactionTemplate transactionTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RoleService roleService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询运营加盟
|
* 查询运营加盟
|
||||||
*
|
*
|
||||||
|
@ -110,6 +118,9 @@ public class AreaJoinServiceImpl implements AreaJoinService
|
||||||
int rows = areaJoinMapper.insertAreaJoin(areaJoin);
|
int rows = areaJoinMapper.insertAreaJoin(areaJoin);
|
||||||
|
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
|
// 尝试修改用户角色
|
||||||
|
this.tryUpdateUserRole(areaJoin);
|
||||||
|
|
||||||
// 后校验
|
// 后校验
|
||||||
areaJoinValidator.afterCheck(areaJoin.getId());
|
areaJoinValidator.afterCheck(areaJoin.getId());
|
||||||
}
|
}
|
||||||
|
@ -133,6 +144,9 @@ public class AreaJoinServiceImpl implements AreaJoinService
|
||||||
int rows = areaJoinMapper.updateAreaJoin(areaJoin);
|
int rows = areaJoinMapper.updateAreaJoin(areaJoin);
|
||||||
|
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
|
// 尝试修改用户角色
|
||||||
|
this.tryUpdateUserRole(areaJoin);
|
||||||
|
|
||||||
// 后校验
|
// 后校验
|
||||||
areaJoinValidator.afterCheck(areaJoin.getId());
|
areaJoinValidator.afterCheck(areaJoin.getId());
|
||||||
}
|
}
|
||||||
|
@ -143,6 +157,18 @@ public class AreaJoinServiceImpl implements AreaJoinService
|
||||||
return result == null ? 0 : result;
|
return result == null ? 0 : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 尝试修改用户角色
|
||||||
|
*
|
||||||
|
* @param areaJoin
|
||||||
|
*/
|
||||||
|
private void tryUpdateUserRole(AreaJoin areaJoin) {
|
||||||
|
try {
|
||||||
|
roleService.insertAuthUsers(RoleConstants.JOIN, Collections.singletonList(areaJoin.getUserId()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("尝试修改ID为{}的用户角色失败:{}", areaJoin.getUserId(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 批量删除运营加盟
|
* 批量删除运营加盟
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.common.utils.MathUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@ public class SuitValidatorImpl implements SuitValidator {
|
||||||
SuitIntervalFeeRule nextRule = intervalRules.get(i + 1);
|
SuitIntervalFeeRule nextRule = intervalRules.get(i + 1);
|
||||||
ServiceUtil.assertion(rule.getEnd() == null, "区间结束时间不能为空");
|
ServiceUtil.assertion(rule.getEnd() == null, "区间结束时间不能为空");
|
||||||
ServiceUtil.assertion(rule.getStart() > rule.getEnd(), "区间的结束时间不允许小于开始时间");
|
ServiceUtil.assertion(rule.getStart() > rule.getEnd(), "区间的结束时间不允许小于开始时间");
|
||||||
ServiceUtil.assertion(rule.getEnd() != nextRule.getStart(), "区间的结束时间必须等于下一个区间的开始时间");
|
ServiceUtil.assertion(!MathUtils.equals(rule.getEnd(), nextRule.getStart()), "区间的结束时间必须等于下一个区间的开始时间");
|
||||||
int eachUnit = rule.getEachUnit();
|
int eachUnit = rule.getEachUnit();
|
||||||
int duration = rule.getEnd() - rule.getStart();
|
int duration = rule.getEnd() - rule.getStart();
|
||||||
ServiceUtil.assertion(duration % eachUnit != 0, "区间间隔必须能够被区间整除");
|
ServiceUtil.assertion(duration % eachUnit != 0, "区间间隔必须能够被区间整除");
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.iot.service.impl;
|
package com.ruoyi.iot.service.impl;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -69,10 +70,10 @@ public class IotConverterImpl implements IotConverter {
|
||||||
if (sys == null) {
|
if (sys == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO 部分硬件版本,电压除以10
|
// 旧版硬件BUG,电压超过100V的需要除以10
|
||||||
// if (sys.getBat() != null) {
|
if (sys.getBat() != null && sys.getBat().compareTo(BigDecimal.valueOf(100)) >= 0) {
|
||||||
// sys.setBat(sys.getBat().divide(new BigDecimal(10), 2, BigDecimal.ROUND_HALF_UP));
|
sys.setBat(sys.getBat().divide(BigDecimal.valueOf(10), 2, BigDecimal.ROUND_HALF_UP));
|
||||||
// }
|
}
|
||||||
device.setSys(sys);
|
device.setSys(sys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package com.ruoyi.system.role.mapper;
|
package com.ruoyi.system.role.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.entity.Role;
|
import com.ruoyi.common.core.domain.entity.Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,4 +107,11 @@ public interface RoleMapper
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteRoleByIds(Long[] roleIds);
|
public int deleteRoleByIds(Long[] roleIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据角色编码查询角色
|
||||||
|
* @param roleKey
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Role selectRoleByKey(@Param("roleKey") String roleKey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
WHERE r.del_flag = '0' and ur.user_id = #{userId}
|
WHERE r.del_flag = '0' and ur.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- selectRoleByKey -->
|
||||||
|
|
||||||
|
<select id="selectRoleByKey" parameterType="String" resultMap="SysRoleResult">
|
||||||
|
<include refid="selectRoleVo"/>
|
||||||
|
WHERE r.del_flag = '0' and r.role_key = #{roleKey}
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectRoleAll" resultMap="SysRoleResult">
|
<select id="selectRoleAll" resultMap="SysRoleResult">
|
||||||
<include refid="selectRoleVo"/>
|
<include refid="selectRoleVo"/>
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.ruoyi.system.role.service;
|
package com.ruoyi.system.role.service;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.entity.Role;
|
|
||||||
import com.ruoyi.system.userRole.domain.UserRole;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.Role;
|
||||||
|
import com.ruoyi.system.userRole.domain.UserRole;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色业务层
|
* 角色业务层
|
||||||
*
|
*
|
||||||
|
@ -170,5 +170,13 @@ public interface RoleService
|
||||||
* @param userIds 需要删除的用户数据ID
|
* @param userIds 需要删除的用户数据ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertAuthUsers(Long roleId, Long[] userIds);
|
public int insertAuthUsers(Long roleId, List<Long> userIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量选择授权用户角色(根据角色编码)
|
||||||
|
* @param code
|
||||||
|
* @param userIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int insertAuthUsers(String code, List<Long> userIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,14 @@ import com.ruoyi.common.core.domain.entity.User;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.roleDept.domain.RoleDept;
|
|
||||||
import com.ruoyi.system.roleMenu.domain.RoleMenu;
|
|
||||||
import com.ruoyi.system.userRole.domain.UserRole;
|
|
||||||
import com.ruoyi.system.roleDept.mapper.RoleDeptMapper;
|
|
||||||
import com.ruoyi.system.role.mapper.RoleMapper;
|
import com.ruoyi.system.role.mapper.RoleMapper;
|
||||||
import com.ruoyi.system.roleMenu.mapper.RoleMenuMapper;
|
|
||||||
import com.ruoyi.system.userRole.mapper.UserRoleMapper;
|
|
||||||
import com.ruoyi.system.role.service.RoleService;
|
import com.ruoyi.system.role.service.RoleService;
|
||||||
|
import com.ruoyi.system.roleDept.domain.RoleDept;
|
||||||
|
import com.ruoyi.system.roleDept.mapper.RoleDeptMapper;
|
||||||
|
import com.ruoyi.system.roleMenu.domain.RoleMenu;
|
||||||
|
import com.ruoyi.system.roleMenu.mapper.RoleMenuMapper;
|
||||||
|
import com.ruoyi.system.userRole.domain.UserRole;
|
||||||
|
import com.ruoyi.system.userRole.mapper.UserRoleMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色 业务层处理
|
* 角色 业务层处理
|
||||||
|
@ -410,7 +410,7 @@ public class RoleServiceImpl implements RoleService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertAuthUsers(Long roleId, Long[] userIds)
|
public int insertAuthUsers(Long roleId, List<Long> userIds)
|
||||||
{
|
{
|
||||||
// 新增用户与角色管理
|
// 新增用户与角色管理
|
||||||
List<UserRole> list = new ArrayList<UserRole>();
|
List<UserRole> list = new ArrayList<UserRole>();
|
||||||
|
@ -423,4 +423,22 @@ public class RoleServiceImpl implements RoleService
|
||||||
}
|
}
|
||||||
return userRoleMapper.batchUserRole(list);
|
return userRoleMapper.batchUserRole(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertAuthUsers(String key, List<Long> userIds) {
|
||||||
|
Role role = this.selectRoleByKey(key);
|
||||||
|
if (role == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return this.insertAuthUsers(role.getRoleId(), userIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据角色编码查询角色
|
||||||
|
* @param key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Role selectRoleByKey(String key) {
|
||||||
|
return roleMapper.selectRoleByKey(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,4 +56,7 @@ public class UserQuery extends UserVO {
|
||||||
@ApiModelProperty("创建日期范围")
|
@ApiModelProperty("创建日期范围")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
private List<LocalDate> createDateRange;
|
private List<LocalDate> createDateRange;
|
||||||
|
|
||||||
|
@ApiModelProperty("角色ID")
|
||||||
|
private Long roleId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,6 +177,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
<if test="nickName != null and nickName != ''">
|
||||||
|
and u.nick_name like concat('%', #{nickName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="roleId != null">
|
||||||
|
and u.user_id in (
|
||||||
|
select sur.user_id from sys_user_role sur where sur.role_id = #{roleId}
|
||||||
|
)
|
||||||
|
</if>
|
||||||
<if test="deptIds != null and deptIds.size() > 0">
|
<if test="deptIds != null and deptIds.size() > 0">
|
||||||
AND u.dept_id IN
|
AND u.dept_id IN
|
||||||
<foreach collection="deptIds" item="item" open="(" separator="," close=")">
|
<foreach collection="deptIds" item="item" open="(" separator="," close=")">
|
||||||
|
|
|
@ -24,8 +24,6 @@ public class AppDeviceController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceService deviceService;
|
private DeviceService deviceService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("获取附近可用车辆列表")
|
@ApiOperation("获取附近可用车辆列表")
|
||||||
@GetMapping("/listNearBy")
|
@GetMapping("/listNearBy")
|
||||||
@Anonymous
|
@Anonymous
|
||||||
|
|
|
@ -4,7 +4,6 @@ import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.vo.UserVO;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
@ -23,6 +22,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.Role;
|
import com.ruoyi.common.core.domain.entity.Role;
|
||||||
import com.ruoyi.common.core.domain.entity.User;
|
import com.ruoyi.common.core.domain.entity.User;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
|
import com.ruoyi.common.core.domain.vo.UserVO;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
@ -31,9 +31,9 @@ import com.ruoyi.framework.web.service.SysPermissionService;
|
||||||
import com.ruoyi.framework.web.service.TokenService;
|
import com.ruoyi.framework.web.service.TokenService;
|
||||||
import com.ruoyi.system.dept.domain.DeptQuery;
|
import com.ruoyi.system.dept.domain.DeptQuery;
|
||||||
import com.ruoyi.system.dept.service.DeptService;
|
import com.ruoyi.system.dept.service.DeptService;
|
||||||
import com.ruoyi.system.userRole.domain.UserRole;
|
|
||||||
import com.ruoyi.system.role.service.RoleService;
|
import com.ruoyi.system.role.service.RoleService;
|
||||||
import com.ruoyi.system.user.service.UserService;
|
import com.ruoyi.system.user.service.UserService;
|
||||||
|
import com.ruoyi.system.userRole.domain.UserRole;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色信息
|
* 角色信息
|
||||||
|
@ -245,7 +245,7 @@ public class SysRoleController extends BaseController
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authUser/selectAll")
|
@PutMapping("/authUser/selectAll")
|
||||||
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
|
public AjaxResult selectAuthUserAll(Long roleId, List<Long> userIds)
|
||||||
{
|
{
|
||||||
roleService.checkRoleDataScope(roleId);
|
roleService.checkRoleDataScope(roleId);
|
||||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user