dao

简单的权限管理php

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 06:29:43
转发自https://www.cnblogs.com/shenzikun1314/p/6604867.html#4262295 首先,要明白的基础理论是用户,角色,权限之间的关系是一对多,还是多对多。据此来建立表。 一个用户可以属于多个角色,比如邓超。他是孙俪的丈夫,同时是他小孩的父亲,还是他老爸的儿子。那么这里他一共有丈夫,父亲,儿子3个角色。 一个角色可以有多个用户。比如学生(角色),张三,李四,王五等。 所以用户跟角色是多对多的关系。 一个角色可以多个权限。比如把文章模块分为查看,修改,添加,删除这4个权限。普通用户只有查看的权限,但管理员他可以同时有这4个权限。 一个权限也可以被多个角色同时拥有。普通用户和管理员都有查看权限。 所以权限跟角色也是多对多的关系。 下面开始建表 第一张用户表 第二张角色表 第三张权限表 接下来是2张中间表。 用户-角色表(要设置多对多的外键关联关系) 最后一张角色-权限表(设置多对多的关联关系) 接下来是代码 第一个guanli.php,用到ajax等jquery语法,要引用jquery文件。这个页面是修改用户的角色权限 <?php error_reporting(E_ALL ^ E_DEPRECATED); include("DB.class.php"); $sql = "select * from qx_user"; $arr = $dao

SpringBoot系列: Spring项目异常处理最佳实践

こ雲淡風輕ζ 提交于 2019-12-05 06:26:26
=================================== 自定义异常类 =================================== 稍具规模的项目, 一般都要自定义一组异常类, 这样做的好处是: 1. 可以充分利用异常的中断特性, 简化代码的逻辑控制. 2. 在自定义的异常类, 可以设置 BusinessErrorCode 和 error message, 有了统一的 BusinessErrorCode, 排查和联调沟通就更容易了. Java 异常的 Root 是 Throwable, 其下有 Error 和 Exception. Error 是 JVM 级的致命错误, 应用系统内部一般不用关心这类错误. Exception 是异常的父类, 其下分为两类, 一类是 Runtime Exception, 一类是 Checked Exception. Checked Exception 是那些编译器能检查到的异常, 如果一个函数中抛出了这类异常, 我们要么 catch 它, 要么在函数签名上继续抛出去, 否则程序将不能编译通过. Runtime Exception 有, 包括 RuntimeException 和它的子类. 比如 ArrayIndexOutOfBoundsException/ClassCastException/被 0 除等. Checked

【maven】父子项目的一般姿势

旧街凉风 提交于 2019-12-05 06:16:00
一、为什么需要创建maven父子项目。 一般一个业务较多的项目,如果我们做服务拆分的话,有些公共的模块就只能做成jar包了。你将util、constant、model封装成jar包是比较好的,如果dao呢? 显然封装成jar包是不合适的,如果dao无法做业务拆分,那么就只能被多个模块共用了。比如一个商品表dao,商品查询系统和活动系统都想使用这个dao,这个时候就需要我们考虑建父子项目了。 二、如何创建。 1、父项目 无弄是基于maven还是基于spring-boot,都可以,只要保证建完之后结构和pom是这样的。 2、子项目 未完待续。。。 来源: https://www.cnblogs.com/kbian/p/11909722.html

How to cache information in a DAO in a threadsafe manner

烈酒焚心 提交于 2019-12-05 06:14:13
问题 I often need to implement DAO's for some reference data that doesn't change very often. I sometimes cache this in collection field on the DAO - so that it is only loaded once and explicitly updated when required. However this brings in many concurrency issues - what if another thread attempts to access the data while it is loading or being updated. Obviously this can be handled by making both the getters and setters of the data synchronised - but for a large web application this is quite an

【串线篇】mybatis-config.xml配置事项

蓝咒 提交于 2019-12-05 04:59:47
一、术语 properties 属性 settings 设置 typeAliases 类型命名 typeHandlers 类型处理器 objectFactory 对象工厂 , plugins 插件 , environments 环境 environment 环境变量 transactionManager 事务管理器 dataSource 数据源 databaseIdProvider 数据库厂商标识 mappers 映射器 二、mapper <mappers> <mapper resource= "EmployeeDao.xml" /> </mappers> 1.<mapper/>3个属性 resource=“”指定类路径下找sql映射文件 url=””可以从磁盘或者网络路径引用 class=“”不怎么用 1)引用接口的全类名,但要将EmployeeDao.xml跟dao放在一起而且文件名与接口名一致 2)、引用接口的全类名,另一种用法不需要写EmployeeDao.xml, 然后在dao的每个方法上加注解@Select/@Update/@Delete/@Insert ,将对应的sql语句放进注解中即可。这样就相当于就相当于EmployeeDao.xml了 2.<mapper/>批量注册 <mappers> <package name=“dao所在包名”/> </mappers>

为什么在SSM中的dao层不用写@Repository注解

半腔热情 提交于 2019-12-05 04:01:35
1. Mybatis 接口编程中dao 层接口没有注解和 为什么能被实例化为bean? 在Spring配置Mybatis的文件中我们可以看到如下代码: <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="org.tarena.note.dao"> </property> MapperScannerConfigurer,让它扫描特定的包,自动帮我们成批地创建映射器。这样就大大减少了配置的工作量。 参考 https://blog.csdn.net/java280580332/article/details/72123890 来源: https://www.cnblogs.com/sjzxxy/p/11904398.html

spring - how to autowire data source?

假如想象 提交于 2019-12-05 03:16:44
问题 I'm having some problem with autowire and DI in general, so I hope that someone can help cause I've been stuck for days now. This is the code: @Service public class TicketsController implements Controller { private TicketManager ticketManager; @Autowired public void setTicketManager(TicketManager ticketManager) { this.ticketManager = ticketManager; } ... } @Service public class SimpleTicketManager implements TicketManager { private TicketsDao ticketsDao; @Autowired public void setTicketsDao

What is the necessity of DAO Architecture

那年仲夏 提交于 2019-12-05 02:45:59
问题 When programming in Java is it always necessary to code according to the DAO architecture? If so what are advantages of using it? I'm doing a project which has a class diagram like below. what are the disadvantages of this? Entity Class: private void fillSONumber() { try { ZnAlSalesOrder o = new ZnAlSalesOrder(); ArrayList a = o.getPendingSalesOrderIDs(); for (int i = 0; i < a.size(); i++) { cmbSoNo.addItem(a.get(i)); } o.close(); } catch (Terminated ex) { } } EntityTable Class Example:

Spring/Spring-Boot 学习2 入门知识

天涯浪子 提交于 2019-12-05 02:38:27
在Spring/Spring-Boot的入门上我绕了很多弯路,我绕过的一个典型的弯路是: 找一个Spring-Boot的入门案例,下载代码跟着跑了一遍,跑通之后确不能理解代码,尤其是各种配置文件以及注解让我难以理解这个程序究竟是怎么跑起来的。@Autowired, @Controller这些注解到底是什么意思,它的工作流程是怎样的? 我怀疑自己是注解相关的知识没有学好,于是往下挖注解的工作原理-->动态代理机制-->反射-->类加载过程-->类加载器的工作原理。这样一套走下来之后,即使我懵懵懂懂明白了类加载器、反射、动态代理、注解, 我还是不能看懂spring的这些注解是怎么工作的,也不知道怎么去实际使用他们。 很多的入门教程,给出了很多具体的操作,但是并没有告诉我们为什么spring要用这个注解,这个注解用了之后他会有什么作用,以及这些注解的工作流程(我指的是使用流程不是底层的实现原理)。 下面是我自己的一些学习反思。 首先我们从最基本的需求讲起。 java是面向对象的语言,每个对象都可以绑定一定的操作,通过将多个对象组合,我们可以完成一个任务所需要的所有操作。 举个例子,假设我们的任务是接收用户对 localhost:8080/user 这个链接的get请求,返回给用户浏览器一个含有用户数据的json数据串 “{"name":"bob"}”。我们把这个任务分成到多个对象去完成

CurrentDb.RecordsAffected returns 0. Why?

北城余情 提交于 2019-12-05 02:37:16
If I use RecordsAffected with CurrentDb.Execute, it always returns 0. If I first make a instance of a Database object it works properly. Why? Like this: Dim Db As Database Set Db = CurrentDb Db.Execute "DELETE * FROM [Samples] WHERE Sample=5" If Db.RecordsAffected = 0 Then MsgBox "Error" End If Instead of: CurrentDb.Execute "DELETE * FROM [Samples] WHERE Sample=5" If CurrentDb.RecordsAffected = 0 Then MsgBox "Error" End If I'm using Access 2007 and the Microsoft Office 12.0 Access database engine Objects Library. Each time you use CurrentDB, it is a new instance. Use With . Change your code to