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

自己做商业网站网站推广seo优化

自己做商业网站,网站推广seo优化,动态网站留言板怎么做,ps做的网页怎么导入网站SpringBootWeb项目 TILAS智能学习辅助系统 需求 部门管理 查询部门列表 删除部门 新增部门 修改部门 员工管理 查询员工列表(分页) 删除员工 新增员工 修改员工 准备工作 导入依赖 web(2.7.6) mybatis mysql驱动 lombok 准备好包结构 Controller->Servi…

SpringBootWeb项目

TILAS智能学习辅助系统

需求

部门管理

查询部门列表
删除部门
新增部门
修改部门

员工管理

查询员工列表(分页)
删除员工
新增员工
修改员工

准备工作

导入依赖

web(2.7.6)

mybatis

mysql驱动

lombok

准备好包结构

Controller->Service->Mapper->Pojo

controller

@Controller
public interface DeptController{
}@Controller
public interface EmpController {
}

mapper

@Mapper
public interface DeptMapper {
}
@Mapper
public interface EmpMapper {
}

service/serviceImpl

@Service
public interface DeptService {
}
@Service
public interface EmpService {
}
@Slf4j
@Service
public class DeptServiceImpl {
}
@Slf4j
@Service
public class EmpServiceImpl {
}
创建数据库表和对应的实体类
@Data
public class Dept {private Integer id;private String username;private String password;private String name;private Short gender;private String image;private Short job;private LocalDate entrydate;private Integer deptId;private LocalDateTime createTime;private LocalDateTime updateTime;
}@Data
public class Emp {private Integer id;private String name;private LocalDateTime createTime;private LocalDateTime updateTime;
}
在配置文件中引入数据库连接
server.port=8080
#下面这些内容是为了让MyBatis映射
#指定Mybatis的Mapper文件
mybatis.mapper-locations=classpath:mappers/*xml
#指定Mybatis的实体目录
mybatis.type-aliases-package=com.example.tlias.mybatis.entityspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/Tlias_db
spring.datasource.username=root
spring.datasource.password=ljymysqlpwd
#开启日志
mybatis.configuration.logimpl=org.apache.ibatis.logging.stdout.StdOutImpl
#开启字段到实体类的驼峰映射
mybatis.configuration.map-underscore-to-camel-case=true

开发规范

基于前后端分离模式进行开发

定义主流的REST风格API接口进行交互

REST:(Representational State Transfer)表现形式状态转换,一种软件架构风格
url/aaa/1 GET:查询
url/aaa   POST:新增
url/aaa	  PUT:修改
url/aaa/1 DELETE

通过请求方式的不同进行不同操作

在@RequestMapping()中设置method = {RequestMethod.请求方式} RequestMethod是一个枚举类型

或者直接使用

@GetMapping

@PostMapping

@PutMapping

@DeleteMapping

开发流程

根据如下流程进行开发

查看页面原型明确需求

阅读接口文档

思路分析

接口开发:开发后台业务功能(功能按接口划分)

接口测试;通过Postman进行接口测试

前后端联调:和前端工程一起进行测试

功能实现

1,部门管理

查询部门

无需分页

请求路径:/depts

请求方式:GET

//控制层
@GetMapping("/depts")Result getDept();@AutowiredDeptService deptService;@Overridepublic Result getDept() {return Result.success(deptService.selectDept());}//业务层
List<Dept> selectDept();@Autowiredprivate DeptMapper deptMapper;@Overridepublic List<Dept> selectDept(){List<Dept> deptList = deptMapper.selectDept();return deptList;}//持久层
@Select("select * from dept")List<Dept> selectDept();
删除部门

前端传递ID,后端删除对应数据

请求路径:/depts/{id}

请求方式:DELETE

//控制层
//接收路径参数
@DeleteMapping("/depts/{id}")Result DeleteDept(@PathVariable Integer id);@AutowiredDeptService deptService;@Overridepublic Result DeleteDept(Integer id) {deptService.deleteDept(id);return Result.success();}//业务层
void deleteDept(Integer id);@Autowiredprivate DeptMapper deptMapper;@Overridepublic void deleteDept(Integer id) {deptMapper.deleteDept(id);}//持久层
@Delete("delete from dept where id = #{id}")void deleteDept(@Param("id") Integer id);
新增部门

前端输入部门名称,后端创建部门保存到数据库

请求路径:/depts

请求方式:POST

//控制层
//接收JSON参数,使用@RequestBody进行映射
@PostMapping("/depts")Result PostDept(@RequestBody Dept dept);@AutowiredDeptService deptService;@Overridepublic Result PostDept(@RequestBody Dept dept) {deptService.insertDept(dept);return Result.success();}//业务层
void insertDept(Dept dept);@Autowiredprivate DeptMapper deptMapper;@Overridepublic void insertDept(Dept dept) {dept.setCreateTime(LocalDateTime.now());dept.setUpdateTime(LocalDateTime.now());deptMapper.insertDept(dept);}//持久层
@Insert("insert into dept (id, name, create_time, update_time) values (null,#{name},#{createTime},#{updateTime})")void insertDept(Dept dept);
修改部门

先通过selectById进行数据回填,再通过updateDept进行数据修改

//控制层@PutMapping("/depts")Result PutDept(@RequestBody Dept dept);@GetMapping("/depts/{id}")Result getDeptByID(@PathVariable Integer id);@AutowiredDeptService deptService;@Overridepublic Result PutDept(Dept dept) {deptService.putDept(dept);return Result.success();}@Overridepublic Result getDeptByID(Integer id) {return Result.success(deptService.selectDeptByID(id));}//业务层void putDept(Dept dept);Dept selectDeptByID(Integer id);@Autowiredprivate DeptMapper deptMapper;@Overridepublic void putDept(Dept dept) {dept.setUpdateTime(LocalDateTime.now());deptMapper.putDept(dept);}@Overridepublic Dept selectDeptByID(Integer id) {return deptMapper.selectDeptByID(id);}//持久层//修改部门@Update("update dept set name = #{name} where id = #{id}")void putDept(Dept dept);//查询部门数据byID@Select("select * from dept where id = #{id}")Dept selectDeptByID(Integer id);

员工管理

分页查询

使用sql中的LIMIT语句

前端发送查询第几页,后端根据前端返回的页码进行计算对应显示的数据

参数传递:页码page,每页展示数pageSize

后端响应:当前页展示的数据,总共的记录数,封装到对象中以json格式数据进行响应回复

//控制层
@GetMapping("/emps")
Result pageSelect(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer num);@Override
public Result pageSelect(@RequestParam(defaultValue = "1") Integer 		page, @RequestParam(defaultValue = "10") Integer num) {PageBean bean = empService.selectPage(page,num);return Result.success(bean);
}//服务层
PageBean selectPage(Integer page, Integer num);
//返回一个pagebean对象,封装了数据总条数和数据列表@Overridepublic PageBean page(String name, Short gender, LocalDate begin, LocalDate end, Integer page, Integer num) {List<Emp> empList = empMapper.selectEmp();List<Emp> empList = empMapper.selectEmi(name,gender,begin,end);return new pageBean(count,emplist);//在持久层中计算总数据条数}//持久层
@Select("select * from emp limit #{index},#{num}")List<Emp> selectPage(@Param("index") Integer index, @Param("num") Integer num);
分页插件

PageHelper,Mybatis的一款分页插件,简化了在Mapper层手动分页的操作,直接使用列表查询,在Service层调用mapper方法设置分页参数.在查询之后解析分页结果,最后封装到PageBean对象中返回即可.

仅在服务层中不同,可以

//服务层
PageBean selectPage(Integer page, Integer num);
//返回一个pagebean对象,封装了数据总条数和数据列表@Overridepublic PageBean page(String name, Short gender, LocalDate begin, LocalDate end, Integer page, Integer num) {PageHelper.startPage(page,num);
//        List<Emp> empList = empMapper.selectEmp();List<Emp> empList = empMapper.selectEmi(name,gender,begin,end);Page<Emp> p = (Page<Emp>) empList;PageBean pageBean = new PageBean(p.getTotal(),p.getResult());return pageBean;}
条件分页查询

使用动态SQL

请求路径/emps

请求方式:GET

<select id="selectEmi" resultType="com.example.tlias.pojo.Emp">select * from emp<where><if test="name != null and name != ''">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></select>

删除员工

请求路径:/emps/{ids}

请求方式:DELETE

在路径参数中传递多个id,在后端springboot中对其封装到集合中,在Mybatis中通过动态sql来完成批量删除操作

//控制层@DeleteMapping("/emps/{ids}")Result delete(@PathVariable List<Integer> ids);@Overridepublic Result delete(List<Integer> ids) {empService.delete(ids);return Result.success();}//业务层void delete(List<Integer> id);@Overridepublic void delete(List<Integer> id) {empMapper.delete(id);System.out.println(id);}//持久层void delete(@Param("id") List<Integer> id);
<delete id="delete">delete from emp where id in<foreach collection="id"item = "item"open = "("separator=","close=")">#{item}</foreach></delete>

遍历集合进行sql判断

http://www.hrbkazy.com/news/29447.html

相关文章:

  • app客户端网站建设方案百度长尾关键词挖掘工具
  • seo企业网站源码5118关键词挖掘工具
  • 淘宝客手机网站搭建企业宣传推广方案
  • 网站空间在哪申请企业文化标语
  • 百度统计会对原网站产生影响吗可以引流推广的app
  • 广州设计网站公司近一周的新闻大事热点
  • 腾讯网站建设专家竞价推广渠道
  • wordpress 导航栏登录扬州seo博客
  • 自己做的网站怎么样把里面的内容下载下来开发网站的流程是
  • 公司关键词排名优化南京seo外包平台
  • 网站关键词堆砌bt磁力猫
  • wordpress 微博模板丽水网站seo
  • 学校网站建设发展概况分析百度信息流推广是什么意思
  • ps免抠素材网站大全在线视频用什么网址
  • 我需要把网站做数据分析培训班
  • 石家庄高端网站建设网络平台的推广方法
  • 服务器怎么做看视频的网站产品线上推广渠道
  • 多用户商城系统的服务商关键词优化排名
  • 政府集约化网站群建设上海百度推广电话
  • 简单网站建设流程图宁波seo外包推广
  • 权威做网站的公司网站推广要点
  • 企业网站的功能什么是网站外链
  • 做外贸的要有自己的网站吗网络营销理论包括哪些
  • 黄色色调 网站沈阳seo公司
  • 重庆企业建站系统模板域名解析查询站长工具
  • 做阿里巴巴网站可以贷款吗百度推广开户联系方式
  • wordpress打开越来越慢扬州seo优化
  • 北京市劳动人民文化宫东莞营销网站建设优化
  • 网站做跳转微信打开互联网推广是做什么的
  • 建设五证在那个网站可以查网店网络营销策划方案