日期不识别bug修复

This commit is contained in:
s2042968 2024-12-24 13:34:25 +08:00
parent a839b0c866
commit d7fc388c55
7 changed files with 67 additions and 12 deletions

View File

@ -4,20 +4,20 @@ import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject; import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.LocalDateTime; import java.util.Date;
@Component @Component
public class EdMetaObjectHandler implements MetaObjectHandler { public class EdMetaObjectHandler implements MetaObjectHandler {
@Override @Override
public void insertFill(MetaObject metaObject) { public void insertFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "gmtCreate", LocalDateTime.class, LocalDateTime.now()); this.strictInsertFill(metaObject, "gmtCreate", Date.class, new Date());
this.strictInsertFill(metaObject, "gmtModified", LocalDateTime.class, LocalDateTime.now()); this.strictInsertFill(metaObject, "gmtModified", Date.class, new Date());
} }
@Override @Override
public void updateFill(MetaObject metaObject) { public void updateFill(MetaObject metaObject) {
this.strictUpdateFill(metaObject, "gmtModified", LocalDateTime.class, LocalDateTime.now()); this.strictUpdateFill(metaObject, "gmtModified", Date.class, new Date());
} }
} }

View File

@ -4,6 +4,8 @@ import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil; import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.manage.pojo.req.RoleDTO; import com.electromagnetic.industry.software.manage.pojo.req.RoleDTO;
import com.electromagnetic.industry.software.manage.service.RoleService; import com.electromagnetic.industry.software.manage.service.RoleService;
import com.electromagnetic.industry.software.manage.service.UserService;
import com.electromagnetic.industry.software.manage.service.serviceimpl.CommonService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -15,10 +17,13 @@ public class RoleController {
@Resource @Resource
private RoleService roleService; private RoleService roleService;
@Resource
private CommonService commonService;
@ApiOperation(value = "新建角色", notes = "") @ApiOperation(value = "新建角色", notes = "")
@RequestMapping(value = "/createRole", method = RequestMethod.POST) @RequestMapping(value = "/createRole", method = RequestMethod.POST)
public ElectromagneticResult<?> createRole(@RequestBody RoleDTO roleDTO) { public ElectromagneticResult<?> createRole(@RequestBody RoleDTO roleDTO) {
commonService.queryAllPrjInfo();
return ElectromagneticResultUtil.success(roleService.createRole(roleDTO)); return ElectromagneticResultUtil.success(roleService.createRole(roleDTO));
} }
@ -33,4 +38,10 @@ public class RoleController {
public ElectromagneticResult<?> deleteRole(@PathVariable("roleId") String roleId) { public ElectromagneticResult<?> deleteRole(@PathVariable("roleId") String roleId) {
return ElectromagneticResultUtil.success(roleService.deleteRole(roleId)); return ElectromagneticResultUtil.success(roleService.deleteRole(roleId));
} }
@ApiOperation(value="查看角色", notes = "")
@GetMapping(value="/{roleId}")
public ElectromagneticResult<?> getRole(@PathVariable("roleId") String roleId) {
return ElectromagneticResultUtil.success(roleService.getRole(roleId));
}
} }

View File

@ -2,6 +2,7 @@ package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
@Data @Data

View File

@ -22,6 +22,16 @@ public class RoleDTO {
*/ */
private String roleDesc; private String roleDesc;
/**
* 数据权限
*/
private String dataScope;
/**
* 功能权限
*/
private String allowedActions;
/** /**
* 权限数据 * 权限数据
*/ */

View File

@ -3,6 +3,7 @@ package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
import java.util.Map;
@Data @Data
public class RolePermissionDTO { public class RolePermissionDTO {
@ -18,9 +19,14 @@ public class RolePermissionDTO {
private String fileName; private String fileName;
/** /**
* 权限列表 * 数据权限
*/ */
private List<String> permission; private Map<String,Boolean> dataAuth;
/**
* 权限哈希
*/
private Map<String,Boolean> permission;
/** /**
* 子目录 * 子目录

View File

@ -27,5 +27,12 @@ public interface RoleService extends IService<Role> {
* @return * @return
*/ */
Boolean deleteRole(String roleId); Boolean deleteRole(String roleId);
/**
* 查看角色
* @param roleId
* @return
*/
RoleDTO getRole(String roleId);
} }

View File

@ -16,7 +16,6 @@ import com.electromagnetic.industry.software.manage.pojo.req.RolePermissionDTO;
import com.electromagnetic.industry.software.manage.service.RolePermissionService; import com.electromagnetic.industry.software.manage.service.RolePermissionService;
import com.electromagnetic.industry.software.manage.service.RoleService; import com.electromagnetic.industry.software.manage.service.RoleService;
import com.electromagnetic.industry.software.manage.service.UserRoleService; import com.electromagnetic.industry.software.manage.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -31,8 +30,6 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
private RolePermissionService rolePermissionService; private RolePermissionService rolePermissionService;
@Resource @Resource
private UserRoleService userRoleService; private UserRoleService userRoleService;
@Autowired
private RoleMapper roleMapper;
private EleLog log = new EleLog(RoleServiceImpl.class); private EleLog log = new EleLog(RoleServiceImpl.class);
@ -120,6 +117,26 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
return true; return true;
} }
/**
* 查看角色
* @param roleId
* @return
*/
@Transactional
@Override
public RoleDTO getRole(String roleId){
RoleDTO roleDTO = new RoleDTO();
QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("role_id", roleId);
Role role = this.getOne(queryWrapper);
roleDTO.setRoleId(role.getRoleId());
roleDTO.setRoleName(role.getRoleName());
roleDTO.setRoleDesc(role.getRoleDesc());
return roleDTO;
}
/** /**
* 校验当前角色名称是否唯一 * 校验当前角色名称是否唯一
* *
@ -152,9 +169,12 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
} }
private void flattenNode(RolePermissionDTO node, List<RolePermission> flatList, String roleId) { private void flattenNode(RolePermissionDTO node, List<RolePermission> flatList, String roleId) {
node.getPermission().forEach(code ->
flatList.add(new RolePermission(roleId, node.getFileId(), code)) node.getPermission().forEach((code, hasPermission) -> {
); if (Boolean.TRUE.equals(hasPermission)) { // 检查权限值是否为 true
flatList.add(new RolePermission(roleId, node.getFileId(), code));
}
});
// 添加当前节点 // 添加当前节点
if (node.getChildren() != null && !node.getChildren().isEmpty()) { if (node.getChildren() != null && !node.getChildren().isEmpty()) {
for (RolePermissionDTO child : node.getChildren()) { for (RolePermissionDTO child : node.getChildren()) {