Python 官方文档:入门教程 => 点击学习
目录☣基于java疫情防控管理系统1、登录模块(注册)2、今日疫情模块3、防疫管理模块4、系统管理模块5、用户模块☣基于java疫情防控管理系统 ☣
☣项目介绍:通过对依社区为单位进行人群的管理,以及疫苗的情况,包括小区状况,通过RBAC进行角色与用户之间的权限管理。
☣项目:环境-idea、Mysql数据库,Tomcat服务器,springMVC,SpringBoot,aop,拦截器,过滤器,全局异常,RBAC权限控制等。
核心代码:service层
@Service
public class UserService extends BaseService<User,Integer> {
@Resource
//引入dao层
private UserMapper userMapper;
@Resource
private UserRoleMapper userRoleMapper;
@Resource
private CommUnityMapper communityMapper;
//用户登录
public UserModel userLogin(String userName,String userPwd){
//对输入的账号密码进行判断,是否符合格式
checkUserLoginParam(userName,userPwd);
//通过对数据库的查询,查看用户是否存在
User temp = userMapper.queryUserByUserName(userName);
AssertUtil.isTrue(temp == null,"用户不存在");
//判断用户的密码是否正确,拿数据库查询到的用户密码和用户输入的用户密码进行equest比较
checkUserPwd(userPwd,temp.getUserPwd());
//返回目标对象 对密码进行加密
return builderUserInfo(temp);
}
//对输入的账号密码进行判断,是否符合格式
private void checkUserLoginParam(String userName, String userPwd) {
//用户非空
AssertUtil.isTrue(StringUtils.isBlank(userName),"用户名不能为空");
//密码非空
AssertUtil.isTrue(StringUtils.isBlank(userPwd),"密码不能为空");
}
//判断用户的密码是否正确,拿数据库查询到的用户密码和用户输入的用户密码进行equest比较
private void checkUserPwd(String userPwd, String userPwd1) {
//对用户输入的密码进行加密
userPwd = Md5Util.encode(userPwd);
AssertUtil.isTrue(!(userPwd.equals(userPwd1)),"密码不正确");
}
//对密码进行加密 返回目标对象
private UserModel builderUserInfo(User temp) {
UserModel userModel = new UserModel();
//为用户密码进行加密
userModel.setUserIdStr(UserIDBase64.encoderUserID(temp.getId()));
userModel.setUserName(temp.getUserName());
userModel.setTrueName(temp.getTrueName());
return userModel;
}
//修改密码
@Transactional(propagation = Propagation.REQUIRED)
public void updateUserPassword(Integer userId, String oldPassWord, String newPassword, String confirmPassword) {
//通过Id获取user对象
User user = userMapper.selectByPrimaryKey(userId);
//参数校验 (用户,旧密码,新密码,确认密码)
checkPasswordParams(user,oldPassword,newPassword,confirmPassword);
//默认参数设置,把用户输入的新密码 加密 添加进去
user.setUserPwd(Md5Util.encode(newPassword));
//执行更新操作
AssertUtil.isTrue(userMapper.updateByPrimaryKeySelective(user)<1,"修改密码失败");
}
//修改密码的参数校验
private void checkPasswordParams(User user, String oldPassword, String newPassword, String confirmPwd) {
//用户不能为空 (不存在)
AssertUtil.isTrue(null == user,"用户不存在");
//原始密码 非空
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
AssertUtil.isTrue(StringUtils.isBlank(oldPassword),"原始密码不能为空");
//原始密码是否和数据库查询到的密码一致
AssertUtil.isTrue(!(Md5Util.encode(oldPassword).equals(user.getUserPwd())),"原始密码不正确");
//新密码不能为空
AssertUtil.isTrue(StringUtils.isBlank(newPassword),"新密码不能为空");
//新密码和原始密码不能相同
AssertUtil.isTrue(oldPassword.equals(newPassword),"新密码不能和原始密码相同");
//确认密码非空
AssertUtil.isTrue(StringUtils.isBlank(confirmPwd),"确认密码不能为空");
//确认密码需要和新密码一致
AssertUtil.isTrue(!(newPassword.equals(confirmPwd)),"新密码和确认密码不一致");
}
public Map<String, Object> queryUserByParams (UserQuery query) {
Map<String, Object> map = new HashMap<>();
PageHelper.startPage(query.getPage(), query.getLimit());
PageInfo<User> pageInfo = new PageInfo<>(userMapper.selectByParams(query));
map.put("code",0);
map.put("msg", "");
map.put("count", pageInfo.getTotal());
map.put("data", pageInfo.getList());
System.out.println("执行完毕");
return map;
}
@Transactional(propagation = Propagation.REQUIRED)
public void saveUser(User user){
//参数校验
checkParams(user.getUserName(),user.getComId(),user.getVc());
//设置默认参数
user.setCreateDate(new Date());
user.setUpdateDate(new Date());
user.setUserPwd(Md5Util.encode("123456"));
//执行添加,判断结果
AssertUtil.isTrue(userMapper.insertSelective(user)==null,"用户添加失败!");
relaionUserRole(user.getId(),user.getRoleIds());
AssertUtil.isTrue(communityMapper.addNumByComId(user.getComId())<1, "社区用户添加失败");
}
@Transactional(propagation = Propagation.REQUIRED)
public void updateUser(User user){
//1.参数校验
//通过用户id获取用户对象
User temp=userMapper.selectByPrimaryKey(user.getId());
//判断对象是否存在
AssertUtil.isTrue(temp==null,"待更新记录不存在");
//验证参数
checkParams1(user.getUserName(),user.getComId(),user.getVc());
//2.设置默认参数
user.setUpdateDate(new Date());
//3.执行更新,返回结果
AssertUtil.isTrue(userMapper.updateByPrimaryKeySelective(user)<1,"用户更新失败!");
relaionUserRole(user.getId(),user.getRoleIds());
}
private void checkParams(String userName, Integer comId, Integer vc) {
AssertUtil.isTrue(StringUtils.isBlank(userName),"用户名不能为空");
//验证用户是否存在
User temp=userMapper.queryUserByUserName(userName);
AssertUtil.isTrue(temp!=null,"用户名已存在");
AssertUtil.isTrue(comId==null,"请输入所在社区");
AssertUtil.isTrue(vc==null,"请选择疫苗接种状况");
}
private void checkParams1(String userName, Integer comId, Integer vc) {
AssertUtil.isTrue(StringUtils.isBlank(userName),"用户名不能为空");
//验证用户是否存在
AssertUtil.isTrue(comId==null,"请输入所在社区");
AssertUtil.isTrue(vc==null,"请选择疫苗接种状况");
}
@Transactional(propagation = Propagation.REQUIRED)
public void deleteUser(Integer[] ids){
AssertUtil.isTrue(ids==null||ids.length==0,"请选择您要删除的记录");
for (int id:ids){
User user=userMapper.selectByPrimaryKey(id);
AssertUtil.isTrue(communityMapper.subNumByComId(user.getComId())!=ids.length, "社区用户删除失败");
}
AssertUtil.isTrue(deleteBatch(ids) != ids.length,"用户角色删除失败");
}
public void reGISterUser(String userName, String password1, String password2, String icon) {
// 参数校验
checkRegister(userName, password1, password2, icon);
// 实例化user
User user = new User();
//设置默认参数
user.setUserName(userName);
user.setUserPwd(Md5Util.encode(password1));
user.setUserPhone(icon);
user.setCreateDate(new Date());
user.setUpdateDate(new Date());
// 执行方法
AssertUtil.isTrue(userMapper.insertSelective(user)<1, "用户添加失败");
}
private void checkRegister(String userName, String password1, String password2, String icon) {
// 用户名不为空
AssertUtil.isTrue(StringUtils.isBlank(userName), "请输入用户名");
// 判断用户名是否存在
User user1 = userMapper.selectByName(userName);
AssertUtil.isTrue(user1!=null, "该用户已存在");
// 判断手机号是否存在
User user2 = userMapper.selectByPhone(icon);
AssertUtil.isTrue(user2!=null, "该手机号已注册过账号");
// 密码不为空
AssertUtil.isTrue(StringUtils.isBlank(password1), "请输入密码");
// 确认密码不为空
AssertUtil.isTrue(StringUtils.isBlank(password2), "请输入确认密码");
// 密码长度校验
AssertUtil.isTrue(password1.length()<6 || password1.length()>12, "密码长度为6-12位");
// 密码和确认密码相等
AssertUtil.isTrue(!password1.equals(password2), "确认密码与密码不一致");
// 手机号合法
AssertUtil.isTrue(!PhoneUtil.isMobile(icon), "请输入正确的手机号");
}
private void relaionUserRole(int userId, String roleIds) {
// 通过id获取用户的角色数量
int count = userRoleMapper.countUserRoleByUserId(userId);
// count>0 说明用户原先有角色 先删除所有的角色
if (count>0) {
AssertUtil.isTrue(userRoleMapper.deleteUserRoleByUserId(userId)!=count, "用户角色删除失败");
}
// 传入的角色信息不为空 添加新的角色
if (StringUtils.isNoneBlank(roleIds)) {
// 将传入的roleIds转成字符串数组
String[] roleStrIds = roleIds.split(",");
// 用来存放用户的角色信息
List<UserRole> roleList = new ArrayList<>();
// 遍历roleIds
for (String rid : roleStrIds) {
// 准备对象
UserRole userRole = new UserRole();
userRole.setUserId(userId);
userRole.setRoleId(Integer.parseInt(rid));
userRole.setCreateDate(new Date());
userRole.setUpdateDate(new Date());
roleList.add(userRole);
}
AssertUtil.isTrue(userRoleMapper.insertBatch(roleList) != roleList.size(), "用户角色分配失败");
}
}
}
核心代码Service
@Service
public class ConfirmedService extends BaseService<Confirmed,Integer> {
@Resource
//引入ConfirmedMapper
private ConfirmedMapper confirmedMapper;
@Resource
//引入user表
private UserMapper userMapper;
@Resource
//引入user表
private CommunityMapper communityMapper;
//角色的条件查询以及 分页
public Map<String,Object> findRoleByParam(ConfirmedQuery confirmedQuery){
//实例化对象
Map<String,Object> map = new HashMap<>();
//实例化分页单位
PageHelper.startPage(confirmedQuery.getPage(), confirmedQuery.getLimit());
//开始分页
PageInfo<Confirmed> rlist = new PageInfo<>(selectByParams(confirmedQuery));
map.put("code",0);
map.put("msg","success");
map.put("count",rlist.getTotal());
map.put("data",rlist.getList());
//返回Map
return map;
}
@Transactional(propagation = Propagation.REQUIRED) //涉及到事务 就需要此注解
//用户模块的添加
public void addUser(Confirmed user) {
//1、参数校验
checkConfirmed(user.getTrueName(),user.getState());
if (user.getComId().equals("浦东区")){
user.setComId(1);
}
if (user.getComId().equals("黄浦区")){
user.setComId(2);
}
if (user.getComId().equals("松江区")){
user.setComId(3);
}
if (user.getComId().equals("徐汇区")){
user.setComId(4);
}
if (user.getComId().equals("虹口区")){
user.setComId(5);
}
//查询user表中是否存在此人 不存在 添加上去 设置默认值
User temp = userMapper.selectByPhone(user.gettcphone());
// 手机号查询用户
if (temp != null){
//健康状态改成2 如果user表里面已经有了的情况下
userMapper.updateUserHealthById(temp.getUserPhone());
//默认值 确诊表中的userId字段
user.setUserId(temp.getId());
}else { //表里没有这个人的时候 添加 这个用户 新建一个user对象
User u = new User();
//真实姓名
u.setTrueName(user.getTrueName());
//名字
u.setUserName(user.getTrueName());
//设置密码 默认值 :123456
u.setUserPwd(Md5Util.encode("123456"));
//设置社区ID
u.setComId(user.getComId());
//手机号 唯一
u.setUserPhone(user.getTcPhone());
u.setEcPhone(user.getTcPhone());
u.setHealth("2");
//创建时间
u.setCreateDate(new Date());
//修改时间
u.setUpdateDate(new Date());
//添加用户是否成功
AssertUtil.isTrue(userMapper.insertSelective(u)<1,"插入用户失败");
//给确诊人员添加其 userId
Integer userId = userMapper.selectById(user.getTcPhone());
user.setUserId(userId);
}
//2、默认值设置
//确诊日期
user.setCreateDate(new Date());
//添加是否成功
AssertUtil.isTrue(insertSelective(user)<1,"添加失败");
//relaionUserRole(user.getId(),user.getComId());
}
@Transactional(propagation = Propagation.REQUIRED) //涉及到事务 就需要此注解
//用户模块的修改
public void changeUser(Confirmed user) {
//通过id获取用户信息
Confirmed temp = confirmedMapper.selectByPrimaryKey(user.getId());
//判断用户信息是否存在
AssertUtil.isTrue(temp == null,"当前用户不存在");
//校验参数
changeConfirmed(user.getTrueName(),user.getTcPhone(),user.getState());
//修改是否成功 完整版
//AssertUtil.isTrue(updateByPrimaryKeySelective(user)<1,"修改失败了");
//修改是否成功 完整版
AssertUtil.isTrue(confirmedMapper.uBPKS(user)<1,"修改失败了");
}
//修改的参数校验
private void changeConfirmed(String trueName, String tcPhone, Integer state) {
//1、用户名不能为空
AssertUtil.isTrue(StringUtils.isBlank(trueName),"姓名不能为空");
//2、当前状态不能为空
AssertUtil.isTrue(StringUtils.isBlank(tcPhone),"请输入手机号");
//3、当前状态不能为空
AssertUtil.isTrue(state<1 || state>4,"请选择正确的状态码");
}
//用户模块的添加的参数校验
private void checkConfirmed(String trueName, Integer state) {
//1、用户名不能为空
AssertUtil.isTrue(StringUtils.isBlank(trueName),"姓名不能为空");
//2、当前状态不能为空
AssertUtil.isTrue(state<1 || state>3,"请选择正确的状态码");
}
//添加社区时的校验
private void relaionUserRole(Integer id, Integer comId) {
//准备集合 存储对象
List<Community> urlist = new ArrayList<>();
//userId,roleId
//判断是否选择了角色信息
//只能选择一个社区
AssertUtil.isTrue(comId>1 || comId<1,"只能选择一个社区");
//通过社区表的 com_id 查询到社区表的对应社区名
communityMapper.selectaddresComId(comId);
//添加
}
@Transactional(propagation = Propagation.REQUIRED) //涉及到事务 就需要此注解
//确诊人员的批量删除
public void deleteUserByIds(Integer[] ids) {
//要删除记录不能为空
AssertUtil.isTrue(ids == null || ids.length==0,"请选择要删除的记录");
//修改user表的状态码
for(Integer id: ids){
Confirmed confirmed = confirmedMapper.selectId(id);
System.out.println(id+ " -----------------" );
System.out.println(confirmed.getTrueName());
AssertUtil.isTrue(userMapper.updateById(confirmed.getUserId())<1,"修改失败");
}
//删除确诊表的个人信息记录
AssertUtil.isTrue(deleteBatch(ids)!=ids.length,"删除失败");
}
//查询所有社区
public List<Map<String, Object>> queryComs() {
return confirmedMapper.selectComs();
}
}
核心代码Service:
@Service
public class CommunityService extends BaseService<Community,Integer> {
@Resource
private CommunityMapper communityMapper;
public Map<String,Object> queryComByParams(CommunityQuery query){
Map<String,Object> map=new HashMap<>();
//初始化分页
PageHelper.startPage(query.getPage(), query.getLimit());
//开始分页
PageInfo<Community> pageInfo=new PageInfo<>(communityMapper.selectByParams(query));
//准备数据
map.put("code",0);
map.put("msg","");
map.put("count",pageInfo.getTotal());
map.put("data",pageInfo.getList());
return map;
}
//查询所有角色信息
public List<Map<String, Object>> findRoles(Integer userId) {
return communityMapper.selectRoles(userId);
}
}
//============================================================
@Service
public class VaccinationService {
@Resource
VaccinationMapper vaccinationMapper;
public Map<String,Object> selectAll(VaccinationQuery vaccinationQuery) {
//创建map
Map<String,Object> map =new HashMap<String,Object>();
//查数据并分页
PageHelper.startPage(vaccinationQuery.getPage(),vaccinationQuery.getLimit());
PageInfo<Vaccination> pageInfo=new PageInfo<>(vaccinationMapper.selectByParams(vaccinationQuery));
map.put("code",0);
map.put("msg","success");
map.put("data",pageInfo.getList());
map.put("count",pageInfo.getTotal());
return map;
}
public Vaccination selectId(Integer id) {
return vaccinationMapper.selectById(id);
}
@Transactional(propagation = Propagation.REQUIRED)
public void insertVaccination(Vaccination vaccination) {
//审核
checkOK(vaccination);
vaccination.setFirstDate(new Date());
vaccination.setSecondDate(new Date());
//插入
AssertUtil.isTrue(vaccinationMapper.insertSelective(vaccination)<1,"插入失败");
}
private void checkOK(Vaccination vaccinatio){
AssertUtil.isTrue(vaccinatio==null,"请输入添加的角色");
AssertUtil.isTrue(StringUtils.isBlank(vaccinatio.getTrueName()),"用户名不能为空");
AssertUtil.isTrue(StringUtils.isBlank(vaccinatio.getFirst()),"请填写(是/否)");
AssertUtil.isTrue(StringUtils.isBlank(vaccinatio.getSecond()),"请填写(是/否)");
}
public void delete(Integer[] ids) {
AssertUtil.isTrue(ids==null||ids.length==0,"请选择要删除的用户");
AssertUtil.isTrue(vaccinationMapper.deleteVa(ids)!=ids.length,"删除失败~~~");
}
public void updateVa(Vaccination vaccination) {
checkOK(vaccination);
if(vaccination.getFirst()==null||"否".equals(vaccination.getFirst())){
vaccination.setFirstDate(null);
}
if(vaccination.getSecond()==null||"否".equals(vaccination.getSecond())){
vaccination.setSecondDate(null);
}
if("是".equals(vaccination.getFirst())){
vaccination.setFirstDate(new Date());
}
if("是".equals(vaccination.getSecond())){
vaccination.setSecondDate(new Date());
}
AssertUtil.isTrue(vaccinationMapper.updateByPrimaryKeySelective(vaccination)<1,"修改失败~");
}
}
核心代码:Service:
@Service
public class RoleService extends BaseService<Role,Integer> {
@Autowired(required = false)
RoleMapper roleMapper;
@Autowired(required = false)
RoleQuery roleQuery;
@Resource
private ModuleMapper moduleMapper;
@Resource
private PermissionMapper permissionMapper;
public Map<String,Object> selectRole(RoleQuery roleQuery){
//创建map
Map<String,Object> map =new HashMap<String,Object>();
//查数据并分页
PageHelper.startPage(roleQuery.getPage(),roleQuery.getLimit());
PageInfo<Role> pageInfo=new PageInfo<>(roleMapper.selectByParams(roleQuery));
map.put("code",0);
map.put("msg","success");
map.put("data",pageInfo.getList());
map.put("count",pageInfo.getTotal());
return map;
}
@Transactional(propagation = Propagation.REQUIRED)
public void insertRole(Role role) {
//审核
checkRole(role);
//添加
role.setCreateDate(new Date());
role.setUpdateDate(new Date());
System.out.println("就差一点!!!!");
AssertUtil.isTrue(insertSelective(role)<1,"添加失败了呢~");
}
private void checkRole(Role role) {
//是否为空
AssertUtil.isTrue(role==null,"请输入角色信息~");
//判断是否已经重复
System.out.println("判断");
Role role1= roleMapper.selectByName(role.getRoleName());
System.out.println("判断结束");
System.out.println(role1!=null);
AssertUtil.isTrue(role1!=null,"已添加过啦~");
System.out.println("退出@");
}
@Transactional(propagation = Propagation.REQUIRED)
public void updateRole(Role role) {
role.setUpdateDate(new Date());
AssertUtil.isTrue(updateByPrimaryKeySelective(role)<1,"编辑失败啦~");
}
@Transactional(propagation = Propagation.REQUIRED)
public void deleteRole(Role role) {
// 验证
AssertUtil.isTrue(role.getId()==null || selectByPrimaryKey(role.getId())==null, "待删除角色不存在");
// 设定默认值
role.setUpdateDate(new Date());
// 删除角色绑定的权限资源
int count = roleMapper.countPermissionByRoleId(role.getId());
if (count>0) {
int i = roleMapper.deletePermissionsByRoleId(role.getId());
AssertUtil.isTrue(i!=count, "角色绑定的权限资源删除失败");
}
// 判断是否成功
AssertUtil.isTrue(roleMapper.updateRoleById(role.getId())<1, "角色删除失败");
}
public List<Map<String, Object>> seleceAllRole(Integer userId) {
return roleMapper.seleceAllRole(userId);
}
@Transactional(propagation = Propagation.REQUIRED)
public void addGrant(Integer[] mids, Integer roleId) {
// 判断roleId是否存在
AssertUtil.isTrue(roleId==null || roleMapper.selectByPrimaryKey(roleId)==null, "待授权的角色不存在");
// 统计当前角色的权限资源数量
int count = roleMapper.countPermissionByRoleId(roleId);
if (count>0) {
// 如果角色存在权限资源,就全部删除
int num = roleMapper.deletePermissionsByRoleId(roleId);
AssertUtil.isTrue(count!=num, "资源删除失败");
}
List<Permission> plist = new ArrayList<>();
if (mids!=null && mids.length!=0) {
// 遍历mids
for (Integer mid : mids) {
// 实例化对象
Permission permission = new Permission();
// 设置数据
permission.setRoleId(roleId);
permission.setModuleId(mid);
// 权限码
permission.setAclValue(moduleMapper.selectByPrimaryKey(mid).getOptValue());
permission.setCreateDate(new Date());
permission.setUpdateDate(new Date());
// 添加到list
plist.add(permission);
}
}
AssertUtil.isTrue(permissionMapper.insertBatch(plist)!=plist.size(), "角色权限更新失败");
}
}
核心代码Service:
@Service
public class RoleService extends BaseService<Role,Integer> {
@Autowired(required = false)
RoleMapper roleMapper;
@Autowired(required = false)
RoleQuery roleQuery;
@Resource
private ModuleMapper moduleMapper;
@Resource
private PermissionMapper permissionMapper;
public Map<String,Object> selectRole(RoleQuery roleQuery){
//创建map
Map<String,Object> map =new HashMap<String,Object>();
//查数据并分页
PageHelper.startPage(roleQuery.getPage(),roleQuery.getLimit());
PageInfo<Role> pageInfo=new PageInfo<>(roleMapper.selectByParams(roleQuery));
map.put("code",0);
map.put("msg","success");
map.put("data",pageInfo.getList());
map.put("count",pageInfo.getTotal());
return map;
}
@Transactional(propagation = Propagation.REQUIRED)
public void insertRole(Role role) {
//审核
checkRole(role);
//添加
role.setCreateDate(new Date());
role.setUpdateDate(new Date());
System.out.println("就差一点!!!!");
AssertUtil.isTrue(insertSelective(role)<1,"添加失败了呢~");
}
private void checkRole(Role role) {
//是否为空
AssertUtil.isTrue(role==null,"请输入角色信息~");
//判断是否已经重复
System.out.println("判断");
Role role1= roleMapper.selectByName(role.getRoleName());
System.out.println("判断结束");
System.out.println(role1!=null);
AssertUtil.isTrue(role1!=null,"已添加过啦~");
System.out.println("退出@");
}
@Transactional(propagation = Propagation.REQUIRED)
public void updateRole(Role role) {
role.setUpdateDate(new Date());
AssertUtil.isTrue(updateByPrimaryKeySelective(role)<1,"编辑失败啦~");
}
@Transactional(propagation = Propagation.REQUIRED)
public void deleteRole(Role role) {
// 验证
AssertUtil.isTrue(role.getId()==null || selectByPrimaryKey(role.getId())==null, "待删除角色不存在");
// 设定默认值
role.setUpdateDate(new Date());
// 删除角色绑定的权限资源
int count = roleMapper.countPermissionByRoleId(role.getId());
if (count>0) {
int i = roleMapper.deletePermissionsByRoleId(role.getId());
AssertUtil.isTrue(i!=count, "角色绑定的权限资源删除失败");
}
// 判断是否成功
AssertUtil.isTrue(roleMapper.updateRoleById(role.getId())<1, "角色删除失败");
}
public List<Map<String, Object>> seleceAllRole(Integer userId) {
return roleMapper.seleceAllRole(userId);
}
@Transactional(propagation = Propagation.REQUIRED)
public void addGrant(Integer[] mids, Integer roleId) {
// 判断roleId是否存在
AssertUtil.isTrue(roleId==null || roleMapper.selectByPrimaryKey(roleId)==null, "待授权的角色不存在");
// 统计当前角色的权限资源数量
int count = roleMapper.countPermissionByRoleId(roleId);
if (count>0) {
// 如果角色存在权限资源,就全部删除
int num = roleMapper.deletePermissionsByRoleId(roleId);
AssertUtil.isTrue(count!=num, "资源删除失败");
}
List<Permission> plist = new ArrayList<>();
if (mids!=null && mids.length!=0) {
// 遍历mids
for (Integer mid : mids) {
// 实例化对象
Permission permission = new Permission();
// 设置数据
permission.setRoleId(roleId);
permission.setModuleId(mid);
// 权限码
permission.setAclValue(moduleMapper.selectByPrimaryKey(mid).getOptValue());
permission.setCreateDate(new Date());
permission.setUpdateDate(new Date());
// 添加到list
plist.add(permission);
}
}
AssertUtil.isTrue(permissionMapper.insertBatch(plist)!=plist.size(), "角色权限更新失败");
}
}
大概就是这样,管理系统,基本都差不多,比如图书管理,CRM等,详细源码见文件上传~
到此这篇关于Java 实战项目之疫情防控管理系统详解的文章就介绍到这了,更多相关Java 疫情防控管理系统内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: Java 实战项目之疫情防控管理系统详解
本文链接: https://lsjlt.com/news/156333.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0