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

网站做外链好嘛百度搜索历史记录

网站做外链好嘛,百度搜索历史记录,大兴模版网站建设哪家好,网站更新怎么做黑马程序员JavaWeb开发教程 文章目录 一、准备工作1. 准备数据库表1.1 新建数据库mytlias1.2 新建部门表dept1.3 新建员工表emp 2. 准备一个Springboot工程2.1 新建一个项目 3. 配置文件application.properties中引入mybatis的配置信息,准备对应的实体类3.1 引入myb…

黑马程序员JavaWeb开发教程

文章目录

  • 一、准备工作
    • 1. 准备数据库表
      • 1.1 新建数据库mytlias
      • 1.2 新建部门表dept
      • 1.3 新建员工表emp
    • 2. 准备一个Springboot工程
      • 2.1 新建一个项目
    • 3. 配置文件application.properties中引入mybatis的配置信息,准备对应的实体类
      • 3.1 引入mybatis的配置信息
      • 3.2 准备对应的实体类
    • 4. 准备对应的mapper、service、controller基础结构
      • 4.1 创建结构
      • 4.2 controller
      • 4.3 service
      • 4.4 Mapper
    • 5. 统一响应结果
  • 二、部门管理-查询
    • 1. 需求说明
    • 2. 接口文档
    • 3. 代码实现
      • 3.1 controller层
      • 3.2 service层
      • 3.3 mapper层
    • 4. postman测试
  • 三、部门管理-删除
    • 1. 需求说明
    • 2. 接口文档
    • 3. 代码实现
      • 3.1 controller层
      • 3.2 service层
      • 3.3 mapper层
    • 4. postman测试
  • 四、部门管理-新增
    • 1. 需求说明
    • 2. 接口文档
    • 3. 代码实现
      • 3.1 controller层
      • 3.2 service层
      • 3.3 mapper层
    • 4. postman测试
  • 五、员工管理-分页查询
    • 1. 需求说明
    • 2. 接口文档
    • 3. 代码实现
      • 3.1 controller层
      • 3.2 service层
      • 3.3 mapper层
    • 4. postman测试
  • 六、员工管理-删除员工
    • 1. 需求说明
    • 2. 接口文档
    • 3. 代码实现
      • 3.1 controller层
      • 3.2 service层
      • 3.3 mapper层
    • 4. postman测试
  • 七、员工管理-新增员工
    • 1. 需求说明
    • 2. 接口文档
    • 3. 代码实现
      • 3.1 controller层
      • 3.2 service层
      • 3.3 mapper层
    • 4. postman测试
  • 八、员工管理-修改
    • 1. 根据id 查询员工
      • 1.1 需求说明
      • 1.2 接口文档
      • 1.3 代码实现
        • 1.3.1 controller层
        • 1.3.2 service层
        • 1.3.3 mapper层
      • 1.4 postman测试
    • 2. 修改员工数据
      • 1.1 需求说明
      • 1.2 接口文档
      • 1.3 代码实现
        • 1.3.1 controller层
        • 1.3.2 service层
        • 1.3.3 mapper层
      • 1.4 postman测试

在这里插入图片描述

一、准备工作

1. 准备数据库表

1.1 新建数据库mytlias

# 新建数据库 mytlias
create database mytlias;
# 使用数据库 mytlias
use mytlias;

1.2 新建部门表dept

  1. 新建部门表
-- 部门管理
create table dept(id int unsigned primary key auto_increment comment '主键ID',name varchar(10) not null unique comment '部门名称',create_time datetime not null comment '创建时间',update_time datetime not null comment '修改时间'
) comment '部门表';
  1. 向部门表中插入数据
insert into dept (id, name, create_time, update_time)
values(1,'学工部',now(),now()),(2,'教研部',now(),now()),(3,'咨询部',now(),now()),(4,'就业部',now(),now()),(5,'人事部',now(),now());

1.3 新建员工表emp

  1. 新建员工表
-- 员工管理(带约束)
create table emp (id int unsigned primary key auto_increment comment 'ID',username varchar(20) not null unique comment '用户名',password varchar(32) default '123456' comment '密码',name varchar(10) not null comment '姓名',gender tinyint unsigned not null comment '性别, 说明: 1 男, 2 女',image varchar(300) comment '图像',job tinyint unsigned comment '职位, 说明: 1 班主任,2 讲师, 3 学工主管, 4 教研主管, 5 咨询师',entrydate date comment '入职时间',dept_id int unsigned comment '部门ID',create_time datetime not null comment '创建时间',update_time datetime not null comment '修改时间',foreign key (dept_id) references dept(id) # 部门表的主键id 是员工表的一个外键
) comment '员工表';
  1. 向员工表中插入数据
INSERT INTO emp
(id, username, password, name, gender, image, job, entrydate,dept_id, create_time, update_time)
VALUES  (1,'jinyong','123456','金庸',1,'1.jpg',4,'2000-01-01',2,now(),now()),(2,'zhangwuji','123456','张无忌',1,'2.jpg',2,'2015-01-01',2,now(),now()),(3,'yangxiao','123456','杨逍',1,'3.jpg',2,'2008-05-01',2,now(),now()),(4,'weiyixiao','123456','韦一笑',1,'4.jpg',2,'2007-01-01',2,now(),now()),(5,'changyuchun','123456','常遇春',1,'5.jpg',2,'2012-12-05',2,now(),now()),(6,'xiaozhao','123456','小昭',2,'6.jpg',3,'2013-09-05',1,now(),now()),(7,'jixiaofu','123456','纪晓芙',2,'7.jpg',1,'2005-08-01',1,now(),now()),(8,'zhouzhiruo','123456','周芷若',2,'8.jpg',1,'2014-11-09',1,now(),now()),(9,'dingminjun','123456','丁敏君',2,'9.jpg',1,'2011-03-11',1,now(),now()),(10,'zhaomin','123456','赵敏',2,'10.jpg',1,'2013-09-05',1,now(),now()),(11,'luzhangke','123456','鹿杖客',1,'11.jpg',5,'2007-02-01',3,now(),now()),(12,'hebiweng','123456','鹤笔翁',1,'12.jpg',5,'2008-08-18',3,now(),now()),(13,'fangdongbai','123456','方东白',1,'13.jpg',5,'2012-11-01',3,now(),now()),(14,'zhangsanfeng','123456','张三丰',1,'14.jpg',2,'2002-08-01',2,now(),now()),(15,'yulianzhou','123456','俞莲舟',1,'15.jpg',2,'2011-05-01',2,now(),now()),(16,'songyuanqiao','123456','宋远桥',1,'16.jpg',2,'2007-01-01',2,now(),now()),(17,'chenyouliang','123456','陈友谅',1,'17.jpg',NULL,'2015-03-21',NULL,now(),now());

2. 准备一个Springboot工程

2.1 新建一个项目

在这里插入图片描述
在这里插入图片描述

  • 引入对应的起步依赖(web、mybatis、mysql驱动、lombok)

在这里插入图片描述

3. 配置文件application.properties中引入mybatis的配置信息,准备对应的实体类

3.1 引入mybatis的配置信息

  • 在application.properties中添加以下代码
    在这里插入图片描述
# MyBatis配置信息
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# 改成你自己要连接的数据库的名字(mytlias)
spring.datasource.url=jdbc:mysql://localhost:3306/mytlias
# 自己数据库用户名(root)
spring.datasource.username=root
# 自己数据库密码(123456)
spring.datasource.password=123456#开启驼峰命名
mybatis.configuration.map-underscore-to-camel-case=true 

3.2 准备对应的实体类

  • 创建一个文件夹pojo,并在其下创建两个类Dept、Emp
    在这里插入图片描述
  1. 实体类Dept
package com.itheima.mytlias.pojo;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;import java.time.LocalDateTime;@Data//生成getter、setter、tostring等
@AllArgsConstructor//全参构造函数
@NoArgsConstructor//无参构造函数
public class Dept {private Integer id; // 部门idprivate String name; // 部门名称private LocalDateTime createTime; // 创建时间private LocalDateTime updateTime; // 更新时间}
  1. 实体类Emp
package com.itheima.mytlias.pojo;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;import java.time.LocalDate;
import java.time.LocalDateTime;@Data
@AllArgsConstructor
@NoArgsConstructor
public class Emp {private Integer id;//用户idprivate String username;//用户名private String password;//用户密码private String name;//用户姓名private Short gender;//用户新别private String image;//图像地址private Short job;//职位private LocalDate entrydate;//日志日期private Integer deptId;//部门idprivate LocalDateTime createTime;//创建时间private LocalDateTime updateTime;//更新时间
}

4. 准备对应的mapper、service、controller基础结构

4.1 创建结构

在这里插入图片描述

4.2 controller

  1. DeptController
package com.itheima.mytlias.controller;import org.springframework.web.bind.annotation.RestController;@RestController
public class DeptController {
}
  1. EmpController
package com.itheima.mytlias.controller;import org.springframework.web.bind.annotation.RestController;@RestController
public class EmpController {
}

4.3 service

  1. deptService
package com.itheima.mytlias.service;public interface DeptService {
}
  1. EmpService
package com.itheima.mytlias.service;public interface EmpService {
}
  1. DeptServiceImpl
package com.itheima.mytlias.service.impl;import com.itheima.mytlias.service.DeptService;
import org.springframework.stereotype.Service;@Service
public class DeptServiceImpl implements DeptService {
}
  1. EmpServiceImpl
package com.itheima.mytlias.service.impl;import com.itheima.mytlias.service.EmpService;
import org.springframework.stereotype.Service;@Service
public class EmpServiceImpl implements EmpService {
}

4.4 Mapper

  1. DeptMapper
package com.itheima.mytlias.mapper;import org.apache.ibatis.annotations.Mapper;@Mapper
public interfaceDeptMapper {
}
  1. EmpMapper
package com.itheima.mytlias.mapper;import org.apache.ibatis.annotations.Mapper;@Mapper
public interfaceEmpMapper {
}

5. 统一响应结果

  • 为了统一响应结果,需要在pojo包下创建Result类
package com.itheima.mytlias.pojo;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {private Integer code;//响应码,1 代表成功; 0 代表失败private String msg;  //响应信息 描述字符串private Object data; //返回的数据//增删改 成功响应public static Result success() {return new Result(1, "success", null);}//查询 成功响应public static Result success(Object data) {return new Result(1, "success", data);}//失败响应public static Result error(String msg) {return new Result(0, msg, null);}
}

二、部门管理-查询

1. 需求说明

在这里插入图片描述

2. 接口文档

在这里插入图片描述

3. 代码实现

3.1 controller层

package com.itheima.mytlias.controller;import com.itheima.mytlias.pojo.Dept;
import com.itheima.mytlias.pojo.Result;
import com.itheima.mytlias.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.awt.*;
import java.util.List;@Slf4j//打印日志使用
@RestController
@RequestMapping("/depts")//本例下所有的请求都会以/dept开头,所以可以使用这个注解,提取出来
public class DeptController {//注入@Autowiredprivate DeptService deptService;/*** 查询所有部门数据* 请求方式为 Get* 请求路径为/dept* 无参数* 返回统一响应结果* @return*/@GetMappingpublic Result list(){//打印日志log.info("查询所有部门数据");//调用service,查询所有部门数据List<Dept> deptList = deptService.list();//返回结果return Result.success(deptList);}
}

3.2 service层

  1. service
package com.itheima.mytlias.service;import com.itheima.mytlias.pojo.Dept;import java.util.List;public interface DeptService {/*** 查询部门所有数据* @return*/List<Dept> list();
}
  1. impl
package com.itheima.mytlias.service.impl;import com.itheima.mytlias.mapper.DeptMapper;
import com.itheima.mytlias.pojo.Dept;
import com.itheima.mytlias.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;@Service
public class DeptServiceImpl implements DeptService {//注入@Autowiredprivate DeptMapper deptMapper;/*** 查询所有部门数据* @return*/@Overridepublic List<Dept> list() {//调用mapper查询所有部门数据List<Dept> deptList=deptMapper.list();return deptList;}
}

3.3 mapper层

package com.itheima.mytlias.mapper;import com.itheima.mytlias.pojo.Dept;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;import java.util.List;@Mapper
public interface DeptMapper {/*** 查询部门全部数据* @return*/@Select("select * from dept")public List<Dept> list();
}

4. postman测试

在这里插入图片描述

三、部门管理-删除

1. 需求说明

在这里插入图片描述

  • 也就是根据部门id删除部门

2. 接口文档

在这里插入图片描述

3. 代码实现

3.1 controller层

  • 从这里向后,只给出新增的代码
 /*** 根据部门id删除部门* 请求方式为 Delete* 请求路径为/depts/{id}* 参数为部门id,路径参数,需要加上注解 @PathVariable* 返回统一响应结果* @param id* @return*/@DeleteMapping("/{id}")public Result deleteById(@PathVariable Integer id){//打印日志log.info("根据部门id删除部门");//调用service,根据部门id删除部门deptService.deleteById(id);//返回结果return Result.success();}

3.2 service层

  1. service
 /*** 根据部门id删除部门* @param id*/void deleteById(Integer id);
  1. impl
/*** 根据部门id删除部门* @param id*/@Overridepublic void deleteById(Integer id) {//调用mapper,根据部门id删除部门deptMapper.deleteById(id);}

3.3 mapper层

 /*** 根据部门id删除部门* @param id*/@Delete("delete from dept where id=#{id}")void deleteById(Integer id);

4. postman测试

在这里插入图片描述

四、部门管理-新增

1. 需求说明

在这里插入图片描述

  • 根据部门名称新增部门

2. 接口文档

在这里插入图片描述

3. 代码实现

3.1 controller层

/*** 根据部门名称添加部门* 请求方式为 POST* 请求路径为/depts* 参数为JSON格式数据,因此需要加上注解 @RequestBody* 返回统一响应结果* @param dept* @return*/@PostMappingpublic Result insertByName(@RequestBody Dept dept){//打印日志log.info("根据部门名称添加部门");//调用service,根据部门名称添加部门deptService.insertByName(dept);//返回结果return Result.success();}

3.2 service层

  1. service
/*** 根据部门名称添加部门* @param dept*/void insertByName(Dept dept);
  1. impl
/*** 根据部门名称添加部门* @param dept*/@Overridepublic void insertByName(Dept dept) {//修改基础信息dept.setCreateTime(LocalDateTime.now());dept.setUpdateTime(LocalDateTime.now());//调用mapper,根据部门名称添加部门deptMapper.insertByName(dept);}

3.3 mapper层

/*** 根据部门名称添加部门* @param dept*/@Insert("insert into dept (id, name, create_time, update_time) values (#{id},#{name},#{createTime},#{updateTime})")void insertByName(Dept dept);

4. postman测试

在这里插入图片描述

{"name":"人事部"
}

五、员工管理-分页查询

  • PageHelper和xml映射文件的使用参考分页查询PageHelper插件&分页条件查询(xml映射文件,动态SQL)

1. 需求说明

在这里插入图片描述

2. 接口文档

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3. 代码实现

3.1 controller层

package com.itheima.mytlias.controller;import com.itheima.mytlias.pojo.PageBean;
import com.itheima.mytlias.pojo.Result;
import com.itheima.mytlias.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;import java.time.LocalDate;@Slf4j
@RestController
@RequestMapping("/emps")
public class EmpController {@Autowiredprivate EmpService empService;@GetMapping//@RequestParam:为了给形参指定默认值//@DateTimeFormat:日期时间类型的参数,需要使用该注解指定格式public Result page(String name, Short gender,@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end,@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "2") Integer pageSize) {//打印日志log.info("参数 {},{},{},{},{},{}", name, gender, begin, end, page, pageSize);//调用servicePageBean pageBean = empService.page(name, gender, begin, end, page, pageSize);//返回结果return Result.success(pageBean);}
}

3.2 service层

  1. service
package com.itheima.mytlias.service;import com.itheima.mytlias.pojo.PageBean;import java.time.LocalDate;public interface EmpService {/*** 分页查询** @return*/PageBean page(String name, Short gender, LocalDate begin, LocalDate end, Integer page, Integer pageSize);
}
  1. impl
package com.itheima.mytlias.service.impl;import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.mytlias.mapper.EmpMapper;
import com.itheima.mytlias.pojo.Emp;
import com.itheima.mytlias.pojo.PageBean;
import com.itheima.mytlias.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.time.LocalDate;
import java.util.List;@Service
public class EmpServiceImpl implements EmpService {@Autowiredprivate EmpMapper empMapper;/*** 分页查询** @return*/@Overridepublic PageBean page(String name, Short gender, LocalDate begin, LocalDate end, Integer page, Integer pageSize) {//使用pagehelper指定查询页码,和每页查询数据PageHelper.startPage(page, pageSize);//执行查询List<Emp> empList = empMapper.list(name, gender, begin, end);Page<Emp> p = (Page<Emp>) empList;//强制转换成Page类型Long count = p.getTotal();List<Emp> result = p.getResult();//封装为 PageBeanPageBean pageBean = new PageBean(count, result);return pageBean;}
}

3.3 mapper层

  1. mapper
package com.itheima.mytlias.mapper;import com.itheima.mytlias.pojo.Emp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.PathVariable;import java.time.LocalDate;
import java.util.List;@Mapper
public interface EmpMapper {/*** 使用pageHelper的话,只需要定义一个简单的查询就可以** @return*/public List<Emp> list(@Param("name") String name, @Param("gender") Short gender, @Param("begin") LocalDate begin, @Param("end") LocalDate end);
}
  1. EmpMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--        namespace:EmpMapper的全类名-->
<mapper namespace="com.itheima.mytlias.mapper.EmpMapper"><!--    带条件的分页查询-动态查询--><!--    id:与方法名一致resultType:返回单条记录的全类名--><select id="list" resultType="com.itheima.mytlias.pojo.Emp">select * from emp<where><if test="name!=null">name like concat('%',#{name},'%')</if><if test="gender!=null">and gender=#{gender}</if><if test="begin!=null and end!=null">and entrydate between #{begin} and #{end}</if></where>order by update_time desc</select>
</mapper>

4. postman测试

在这里插入图片描述

http://localhost:8080/emps?name=张&gender=1&begin=2000-01-01&end=2010-01-01

六、员工管理-删除员工

1. 需求说明

在这里插入图片描述

2. 接口文档

在这里插入图片描述

3. 代码实现

3.1 controller层

/*** 根据员工id,删除员工* 请求方式为 DELETE* 请求路径为/emps* 返回统一响应结果* 参数:* @param ids  @PathVariable 路径参数需要加这个注解* @return*/@DeleteMapping("/{ids}")public Result DeleteById(@PathVariable List<Integer> ids){//打印日志log.info("参数:{}",ids);//调用serviceempService.deleteById(ids);//返回结果return Result.success();}

3.2 service层

  1. service
 /*** 根据员工 id删除员工* @param ids*/void deleteById(List<Integer> ids);
  1. impl
 /*** 根据员工 id删除员工* @param ids*/@Overridepublic void deleteById(List<Integer> ids) {//调用mapper 删除员工empMapper.deleteById(ids);}

3.3 mapper层

  1. EmpMapper
/*** 根据id删除员工* @param ids*/void deleteById(@Param("ids") List<Integer> ids);
  1. EmpMApper.xml
<!--    根据员工删除id--><!--    collection:要遍历的数组close:结束之后的SQL片段open:遍历之前的左侧separator:以什么为分割item遍历后得到的单个元素--><delete id="deleteById">delete from emp where id in<foreach collection="ids" close=")" open="(" separator="," item="id">#{id}</foreach></delete>

4. postman测试

在这里插入图片描述

七、员工管理-新增员工

1. 需求说明

在这里插入图片描述
在这里插入图片描述

2. 接口文档

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

3. 代码实现

3.1 controller层

/*** 新增员工* 请求方式为 POST* 请求路径为/emps* 返回统一响应结果* 参数:* @param emp @RequestBody 如果参数是JSON格式的数据,需要加这个注解* @return*/@PostMappingpublic Result insert(@RequestBody Emp emp){//打印日志log.info("新增员工");//调用servicceempService.insert(emp);//返回结果return Result.success();}

3.2 service层

  1. service
/*** 新增员工*/void insert(Emp emp);
  1. impl
/*** 新增员工*/@Overridepublic void insert(Emp emp) {//处理基本数据emp.setCreateTime(LocalDateTime.now());emp.setUpdateTime(LocalDateTime.now());//调用mapperempMapper.insert(emp);}

3.3 mapper层

 /*** 新增员工*/@Insert("insert into emp(id,username,password,name,gender,image,dept_id,entrydate,job,create_time,update_time) values(null,#{username},#{password},#{name},#{gender},#{image},#{deptId},#{entrydate},#{job},#{createTime},#{updateTime})")void insert(Emp emp);

4. postman测试

在这里插入图片描述

八、员工管理-修改

– 修改可以分为两个步骤:根据id查询员工;修改员工信息

1. 根据id 查询员工

1.1 需求说明

在这里插入图片描述

1.2 接口文档

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

1.3 代码实现

1.3.1 controller层
/*** 该接口用于根据主键ID查询员工的信息* 请求方式为 GET* 请求路径为/emps/{id}* 返回统一响应结果-Emp* 参数:** @param id @PathVariable 路径参数,添加此注解* @return*/@GetMapping("/{id}")public Result getById(@PathVariable Integer id) {//打印日志log.info("参数 {}", id);//调用service,根据主键ID查询员工的信息Emp emp = empService.getById(id);//返回结果return Result.success(emp);}
1.3.2 service层
  1. service
/*** 根据主键ID查询员工的信息* @param id* @return*/Emp getById(Integer id);
  1. impl
 /*** 根据主键ID查询员工的信息* @param id* @return*/@Overridepublic Emp getById(Integer id) {//调用mapper,根据主键ID查询员工的信息Emp emp=empMapper.getById(id);return emp;}
1.3.3 mapper层
/*** 根据主键ID查询员工的信息* @return*/@Select("select * from emp where id=#{id}")Emp getById(@Param("id") Integer id);

1.4 postman测试

在这里插入图片描述

2. 修改员工数据

1.1 需求说明

  • 同上

1.2 接口文档

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

1.3 代码实现

1.3.1 controller层
/*** 该接口用于修改员工的数据信息* 请求方式为 PUT* 请求路径为/emps* 返回统一响应结果* 参数:* @param emp  @RequestBody 若参数是JSON格式的数据的话,需要加上该注解* @return*/@PutMappingpublic Result update(@RequestBody Emp emp){//打印日志log.info("修改员工的数据信息");//调用serviceempService.update(emp);//返回结果return Result.success();}
1.3.2 service层
  1. service
/*** 修改员工的数据信息* @param emp*/void update(Emp emp);
  1. impl
/*** 修改员工的数据信息* @param emp*/@Overridepublic void update(Emp emp) {//设置基本值emp.setUpdateTime(LocalDateTime.now());//调用mapper,修改员工的数据信息empMapper.update(emp);}
1.3.3 mapper层
  1. EmpMapper
 /*** 修改员工的数据信息*/void update(Emp emp);
  1. EmpMapper.xml
<!--    修改员工的数据信息--><update id="update">update emp<set><if test="username !=null and username!=' '">username =#{username},</if><if test="name !=null and name!=' '">name=#{name},</if><if test="gender !=null and gender!=' '">gender=#{gender},</if><if test="image !=null and image!=' '">image=#{image},</if><if test="deptId !=null and deptId!=' '">dept_id=#{deptId},</if><if test="entrydate !=null and entrydate!=' '">entrydate=#{entrydate},</if><if test="job !=null and job!=' '">job=#{job}</if></set>where id=#{id}</update>

1.4 postman测试

在这里插入图片描述

{"id":1,"username":"jinyongnew","name":"金庸","gender":1,"image":"1.jpg","job":4,"entrydate":"2000-01-01","deptId":2
}
http://www.khdw.cn/news/19966.html

相关文章:

  • appcms程序怎么做网站百度推广登录入口官网网址
  • 保定专门做网站的公司如何网络推广新产品
  • 黑龙江省建设局网站首页知名的seo快速排名多少钱
  • 成都网站建设新闻网站关键字优化软件
  • 做网站欢迎页什么意思搜索引擎优化策略
  • 建站有哪些需求百度应用商店下载
  • 广西网站建设哪家有seo外包服务
  • 简约网站建设公司google seo 优化招聘
  • 家具网站怎么做广告最多的网站
  • 市场营销考试题目及答案2022杭州百度seo优化
  • ps ui做响应式网站要求百度应用商店下载
  • 广州网站建设集团长沙本地推广
  • 关于企业网站建设的请示推广平台都有哪些
  • 集团网站cms近三天的国内新闻
  • web前端做网站网站流量统计工具
  • 怎么让网站快速收录百度推广怎么优化排名
  • 深圳网站建设制作视频软件媒体代发网站
  • 怎么做关于花的网站全网营销方案
  • 免备案网站建站外贸网站优化推广
  • 百度 手机网站收录淘宝关键词挖掘工具
  • 餐饮类网站模板重庆网站网络推广
  • 网站服务器租一个月seo推广的全称是
  • 市民留言常德论坛常德政府网站百度天眼查公司
  • 服务质量好的网站设计制作山西百度查关键词排名
  • 高端网网站建设推广营销网络
  • 大连网站推广公司最新nba排名
  • 如何介绍网站模板下载地址怎么网络推广
  • 在百度做推广需要网站cdq百度指数
  • dw怎么做网站教程seo快速排名软件品牌
  • 做展厅 参考什么网站口碑营销案例ppt