当前位置: 首页 > news >正文

深圳地质建设网站网站页面设计尺寸

深圳地质建设网站,网站页面设计尺寸,监利网站,做网站需要的执照Mapper接口 使用注解执行SQL语句操作和相应的Java抽象类#xff08;对于简单的增删改查使用注解#xff09; Mapper public interface EmpMapper {// 根据id删除员工信息Delete(delete from mybatis.emp where id#{id})public int EmpDelete(Integer id);// 查…Mapper接口 使用注解执行SQL语句操作和相应的Java抽象类对于简单的增删改查使用注解 Mapper public interface EmpMapper {// 根据id删除员工信息Delete(delete from mybatis.emp where id#{id})public int EmpDelete(Integer id);// 查询所有员工信息Select(select * from emp)public ListEmp EmpSelect();//将自动增长的id封装到emp对象的id属性中Options(useGeneratedKeys true, keyPropertyid)//向emp表中插入一条数据Insert(insert into emp(username, name, gender, image, job, entrydate, dept_id, create_time, update_time) values (#{username}, #{name}, #{gender}, #{image}, #{job}, #{entrydate}, #{deptId}, #{createTime}, #{updateTime}))public void EmpInsert(Emp emp);//更新emp表中的数据Update(update emp set username#{username},name#{name},gender#{gender},image #{image},job#{job},entrydate#{entrydate},dept_id #{deptId},update_time#{updateTime} where id#{id})public void update(Emp emp);//方案一为字段起别名让MySQL中的字段和java类中的字段名一致这样mybatis 就能获取MySQL中相对应的字段数据了 // Select(select id, username, password, name, gender, image, job, entrydate, dept_id as deptId, create_time as createTime, // update_time as updateTime from emp where id #{id}) // public Emp Search(Integer id);// // 方案二在Results注解中将数据库表中的dept_id列映射到Java对象中的deptId属性 // Results({ // //MySQL中的字段名和Java类中对应的属性名 // Result(column dept_id,property deptId), // Result(column create_time,property createTime), // Result(column update_time,property updateTime) // // }) // Select(select * from emp where id #{id}) // public Emp Search(Integer id);//方案三在配置文件中开启mybatis的驼峰命名自动映射开关mybatis.camel无需动原代码自动映射// 根据id查询员工信息Select(select * from emp where id #{id})public Emp Search(Integer id);Select(select * from emp where name like concat(%,#{name},%) and gender #{gender} and entrydate between #{begin} and #{end} order by update_time desc)//条件查询public ListEmp conditionSearch(String name , Short gender , LocalDate begin , LocalDate end); }使用xml配置映射语句对于复杂的SQL语句建议使用xml配置映射语句 接收MySQL数据的Java类 Data NoArgsConstructor AllArgsConstructor public class Emp {private Integer id;private String username;private String password;private String name;private Short gender;private String image;private Short job;private LocalDate entrydate; //LocalDate类型对应数据表中的date类型private Integer deptId;private LocalDateTime createTime;//LocalDateTime类型对应数据表中的datetime类型private LocalDateTime updateTime; } 连接数据库和引入mybatis的配置文件 spring.application.namemybatis-idus #连接数据库 spring.datasource.driver-class-namecom.mysql.cj.jdbc.Driver spring.datasource.urljdbc:mysql://localhost:3306/mybatis spring.datasource.usernameroot spring.datasource.passwordroot #配置mybatis.log日志指定输出到控制台 mybatis.configuration.log-implorg.apache.ibatis.logging.stdout.StdOutImpl #开启mybatis的驼峰命名自动映射开关mybatis.camel mybatis.configuration.map-underscore-to-camel-casetrue 执行相关操作的测试类 SpringBootTest class MybatisCdusApplicationTests {Autowiredprivate EmpMapper emp;Testvoid contextLoads() {// //删除id为17的员工 // int n emp.EmpDelete(17); // System.out.println(n); // //创建一个新的员工对象 // Emp emp2 new Emp(); // //设置员工对象的属性 // emp2.setUsername(Tom3); // emp2.setName(汤姆3); // emp2.setGender((short)1); // emp2.setImage(https://img-home.csdnimg.cn/images/20240218021830.png); // emp2.setJob((short)2); // emp2.setDeptId(1); // emp2.setEntrydate(LocalDate.now()); // emp2.setCreateTime(LocalDateTime.now()); // emp2.setUpdateTime(LocalDateTime.now()); // //插入新的员工对象 // emp.EmpInsert(emp2); // //使用了 Options(useGeneratedKeys true, keyPropertyid) 就可以获取主键值了 // System.out.println(emp2.getId()); // // System.out.println(n); // // //创建一个新的员工对象 // Emp emp3 new Emp(); // //设置员工对象的属性 // emp3.setUsername(Tom4); // emp3.setName(汤姆4); // emp3.setGender((short)1); // emp3.setImage(https://img-home.csdnimg.cn/images/20240218021830.png); // emp3.setJob((short)2); // emp3.setDeptId(1); // emp3.setEntrydate(LocalDate.of(2001,12,12)); // emp3.setCreateTime(LocalDateTime.now()); // emp3.setUpdateTime(LocalDateTime.now()); // emp3.setId(21); // //更新员工对象 // emp.update(emp3); // // //根据id查询员工对象 // Emp employee emp.Search(21); // System.out.println(employee.toString());// 根据姓名、性别、入职日期和当前日期进行条件查询emp.conditionSearch(汤, (short) 1, LocalDate.of(2010,1,1),LocalDate.now());}}MySQL相关数据 create table emp (id int unsigned auto_increment comment IDprimary key,username varchar(20) not null comment 用户名,password varchar(32) default 123456 null comment 密码,name varchar(10) not null comment 姓名,gender tinyint unsigned not null comment 性别, 说明: 1 男, 2 女,image varchar(300) null comment 图像,job tinyint unsigned null comment 职位, 说明: 1 班主任,2 讲师, 3 学工主管, 4 教研主管, 5 咨询师,entrydate date null comment 入职时间,dept_id int unsigned null comment 部门ID,create_time datetime not null comment 创建时间,update_time datetime not null comment 修改时间,constraint usernameunique (username) )comment 员工表;
http://www.w-s-a.com/news/337999/

相关文章:

  • 襄阳 网站建设管理系统网站
  • 重庆工程建设招标投标交易信息网广州外贸seo优化
  • 一个一起做网站东莞设计兼职网站建设
  • 杭州网站程序开发公司在哪个公司建设网站好
  • 网店的网站设计方案济南手机建站价格
  • 网站做了301重定向域名会自动跳转吗唐山地方志网站建设
  • 学校网站建设说明书海南省建设执业资格注册管理中心网站
  • 东莞哪家网站建设好网站风格设定
  • 自驾游网站模板搭建wordpress步骤
  • wordpress视频网站上传视频提升学历是什么意思
  • 江西省城乡建设厅建设网站浙江建设
  • 网站联系我们页面临平做网站
  • 如何用网站做cpa交互比较好的网站
  • 一家只做特卖的网站wordpress修改模板教程
  • 与恶魔做交易的网站成都到西安高铁票价
  • 太原网站制作哪家便宜长春昆仑建设股份有限公司网站
  • 优质做网站价格设计手机商城网站建设
  • 高校网站建设制度无锡网站建设排名
  • 做网站的软件wd的叫啥无锡公司网站建设服务
  • 网站建设一般需要多久网站服务器基本要素有哪些
  • 大连开发区网站开发公司免费网站建设哪个好?
  • 关于建设门户网站的通知海曙区建设局网站
  • 韩国建设部网站温州企业网站制作
  • 苏州网站建设优化贵州网站建设lonwone
  • 网站建设与推广方案模板网站建设教程搭建浊贝湖南岚鸿给力
  • 网站建设内部下单流程图昆明网站制作公司
  • 手机网站焦点图在线外链推广
  • 做静态页面的网站中国建设银行河南省分行网站
  • 镇平县两学一做专题网站佛山家居网站全网营销
  • 做网站的需求wordpress图片怎么居中