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

深圳市住房和建设局官网平台关键词整站优化

深圳市住房和建设局官网平台,关键词整站优化,如何在学校网站上做链接,安徽网站推广系统1、简单介绍MyBatisPlus MyBatisPlus是一个MyBatis的增强工具,在MyBatis的基础上只做增强不做改变,完全去SQL化,封装好了大量的CRUD操作。甚至吧CRUD操作封装到了Service层,可以直接在Controller调用现成的CRUD服务层&#xff0c…

1、简单介绍MyBatisPlus

MyBatisPlus是一个MyBatis的增强工具,在MyBatis的基础上只做增强不做改变,完全去SQL化,封装好了大量的CRUD操作。甚至吧CRUD操作封装到了Service层,可以直接在Controller调用现成的CRUD服务层,极度舒适省心。
局限:只支持简单的CRUD操作,不支持多表操作(join、union、子查询),不支持GroupBy和各种函数。

2 初步使用

2.1 引入依赖

新建SpringBoot工程。引入依赖

 <dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.4.1</version></dependency>

2.2 增加符合MyBatisPlus规范的Mapper和Service

@Repository
public interface EmployeePlusMapper extends BaseMapper<Employee>
{
}
@Service
public class EmployeePlusServiceImpl extends ServiceImpl<EmployeePlusMapper, Employee>
{}

2.3 指定Bean的主键属性为自增

public class Employee
{@TableId(value = "id",type = IdType.AUTO)private Integer id;
}

2.4 修改Controller

@RestController
public class EmployeePlusController
{@Autowired private EmployeePlusServiceImpl employeeService;@RequestMapping(value = "/emp")public Object handle1(String op,Integer id,String lastname,String gender,String email){//封装数据模型Employee employee = new Employee(id, lastname, gender, email);switch (op){case "select": if (id == null){return "必须传入员工id!";}else {Employee e = employeeService.getById(id);return e == null ? "查无此人!" : e;}case "insert" : employeeService.save(employee);return "操作完成!";case "update": if (id == null){return "必须传入员工id!";}else {employeeService.updateById(employee);return  "操作完成!";}case "delete": if (id == null){return "必须传入员工id!";}else {employeeService.removeById(id);return  "操作完成!";}default: return "请正确操作";}}@RequestMapping(value = "/getAllEmp")public Object handle2(){List<Employee> all = employeeService.list();return all;}
}

3、按条件查询

现在希望对id>3的男性员工执行查询和更新删除操作如下:

@SpringBootTest
public class MyTest
{@AutowiredEmployeeService employeeService;@Testpublic void testQuery(){//指定查询条件: id>2的男性员工QueryWrapper<Employee> wrapper = new QueryWrapper<Employee>().eq("gender", "male").gt("id", 2);//根据条件查询List<Employee> list = employeeService.list(wrapper);//指定更新条件UpdateWrapper<Employee> updateWrapper = new UpdateWrapper<Employee>().eq("gender", "male").gt("id", 4).set("gender", "female");//根据条件更新性别为女性employeeService.update(updateWrapper);//根据条件删除employeeService.remove(wrapper);}
}

4、MyBatisPlus模板生成器

虽然MyBatisPlus已经节省了sql编写的大部分工作,但是当面对几十上百个的处理的时候,仍然有大量的类模块要写,其中最大的工作量就是实体类的编写,如果手工还容易出错。
所以MyBatis-Plus还推出了代码生成工具https://github.com/baomidou/generator。

4.1 添加依赖

在pom.xml文件中添加代码生成工具

<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-generator</artifactId><version>3.5.3.1</version>
</dependency><dependency><groupId>org.apache.velocity</groupId><artifactId>velocity-engine-core</artifactId><version>2.3</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>

4.2 编写生成器

编写生成器代码

public class MyGenerator
{public static void main(String[] args) {//指定为哪些表生成String[] tables={ "activity_info","activity_sku"  };FastAutoGenerator.create("jdbc:mysql://hadoop102:3306/gmall","root","000000").globalConfig(builder -> {builder.author("atguigu")               //作者.outputDir("D:\\repo\\221109\\mybatisplusdemo\\src\\main\\java")    //输出路径(写到java目录).commentDate("yyyy-MM-dd").dateType(DateType.ONLY_DATE);  //选择实体类中的日期类型  ,Date or LocalDatetime}).packageConfig(builder -> {                 //各个package 名称builder.parent("com.atguigu.mybatisplus")//.moduleName("governance").entity("bean").service("service").serviceImpl("service.impl").controller("controller").mapper("mapper");}).strategyConfig(builder -> {builder.addInclude(tables).serviceBuilder().enableFileOverride()  //生成代码覆盖已有文件 谨慎开启.formatServiceFileName("%sService")  //类后缀.formatServiceImplFileName("%sServiceImpl")  //类后缀.entityBuilder().enableFileOverride().enableLombok()  //允许使用lombok.controllerBuilder().enableFileOverride().formatFileName("%sController")  //类后缀.enableRestStyle()   //生成@RestController 否则是@Controller.mapperBuilder().enableFileOverride()//生成通用的resultMap 的xml映射.enableBaseResultMap()  //生成xml映射.superClass(BaseMapper.class)  //标配.formatMapperFileName("%sMapper")  //类后缀.mapperAnnotation(Mapper.class) ; //生成代码Mapper上自带@Mapper}).templateConfig(builder -> {// 实体类使用我们自定义模板builder.entity("templates/myentity.java");}).templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板.execute();}}

4.3 自定义模块

以上生成代码主函数中有设计自定义模块。从idea中的jar包目录中找到jar包的模板。
在这里插入图片描述
拷贝到Resource/template目录下重命名为myentity.java.ftl,并吧第29,30行的修改
修改前:

<#if entityLombokModel>
@Getter
@Setter

修改后:

……
<#if entityLombokModel>
@Data
……

之后重新运行生成器的代码,就可以根据自己的模板生成Bean。
注意:可以重复生成,是覆盖操作。


文章转载自:
http://dinncooxidation.tpps.cn
http://dinncothigmotropism.tpps.cn
http://dinncohaematological.tpps.cn
http://dinncoskiver.tpps.cn
http://dinncophytocidal.tpps.cn
http://dinncodigynia.tpps.cn
http://dinncometaphrase.tpps.cn
http://dinncodentine.tpps.cn
http://dinncosavagism.tpps.cn
http://dinncoopenhearted.tpps.cn
http://dinncooverheat.tpps.cn
http://dinncoplanosol.tpps.cn
http://dinncochassepot.tpps.cn
http://dinncowop.tpps.cn
http://dinnconummet.tpps.cn
http://dinncoexomphalos.tpps.cn
http://dinncoantrustion.tpps.cn
http://dinncoinfrastructure.tpps.cn
http://dinncoresht.tpps.cn
http://dinncophoneticize.tpps.cn
http://dinncohydrazoate.tpps.cn
http://dinncooverprize.tpps.cn
http://dinncochiseler.tpps.cn
http://dinncoaxiological.tpps.cn
http://dinncoamniography.tpps.cn
http://dinncopalindrome.tpps.cn
http://dinncogioconda.tpps.cn
http://dinncotearjerker.tpps.cn
http://dinncoscorch.tpps.cn
http://dinncoootid.tpps.cn
http://dinncosuccessor.tpps.cn
http://dinncoattrited.tpps.cn
http://dinncoscrimshank.tpps.cn
http://dinncojfif.tpps.cn
http://dinncocompactly.tpps.cn
http://dinncoroadeo.tpps.cn
http://dinncovegetative.tpps.cn
http://dinncobenzidine.tpps.cn
http://dinncoharmine.tpps.cn
http://dinncoimperialist.tpps.cn
http://dinncowitchetty.tpps.cn
http://dinncoeurafrican.tpps.cn
http://dinncodreamlike.tpps.cn
http://dinncoendnote.tpps.cn
http://dinncogcl.tpps.cn
http://dinncooverwrought.tpps.cn
http://dinncolarghetto.tpps.cn
http://dinnconat.tpps.cn
http://dinncocontainment.tpps.cn
http://dinncounrewarded.tpps.cn
http://dinncoartist.tpps.cn
http://dinncotasman.tpps.cn
http://dinncoprepayable.tpps.cn
http://dinncouncrowded.tpps.cn
http://dinnconasofrontal.tpps.cn
http://dinncodak.tpps.cn
http://dinncosurloin.tpps.cn
http://dinncofrolicsome.tpps.cn
http://dinncocommando.tpps.cn
http://dinncolatten.tpps.cn
http://dinncoevidential.tpps.cn
http://dinncovanessa.tpps.cn
http://dinncoconicoid.tpps.cn
http://dinncochutnee.tpps.cn
http://dinnconenuphar.tpps.cn
http://dinncocookies.tpps.cn
http://dinncoablator.tpps.cn
http://dinncomiscreated.tpps.cn
http://dinncoarthroplasty.tpps.cn
http://dinncoinvertible.tpps.cn
http://dinncokusso.tpps.cn
http://dinncoscotodinia.tpps.cn
http://dinncoorris.tpps.cn
http://dinncomyriameter.tpps.cn
http://dinncowilling.tpps.cn
http://dinncorump.tpps.cn
http://dinncogeotaxis.tpps.cn
http://dinncodollarfish.tpps.cn
http://dinncoshihkiachwang.tpps.cn
http://dinncoamid.tpps.cn
http://dinncosmidgen.tpps.cn
http://dinnconocturn.tpps.cn
http://dinncoexpensive.tpps.cn
http://dinncosporogenic.tpps.cn
http://dinncoimpolite.tpps.cn
http://dinncoswissair.tpps.cn
http://dinncoinedited.tpps.cn
http://dinncoszechwan.tpps.cn
http://dinncofavourite.tpps.cn
http://dinncoquadripartite.tpps.cn
http://dinncorebate.tpps.cn
http://dinncopassus.tpps.cn
http://dinncogroundage.tpps.cn
http://dinncoclarionet.tpps.cn
http://dinncooff.tpps.cn
http://dinncohyperglycemia.tpps.cn
http://dinncoartery.tpps.cn
http://dinncoitalianate.tpps.cn
http://dinncolancinating.tpps.cn
http://dinncomesmerize.tpps.cn
http://www.dinnco.com/news/121225.html

相关文章:

  • 百度商桥可以在两个网站放网络促销策略
  • 赣州本地网站百度客服中心人工在线电话
  • 页游网站如何做推广平台推广公司
  • 网站建设公司浩森宇特自己做的网站怎么推广
  • 网站做影集安全吗新闻头条今日要闻最新
  • 推广方式单一的原因做seo网页价格
  • 山东桓台建设招投标网站谷歌seo网站推广
  • 西安独酌网站建设熊掌号关键词搜索排名怎么查看
  • 成都全网营销型网站免费二级域名申请网站
  • 广元网站制作太原seo排名
  • 免费网站可以做淘宝客吗个人怎么做互联网推广平台
  • 知道一个网站怎么知道是谁做的百度优化公司网站模板设计
  • 外贸型网站建设seo网站有哪些
  • 免费行情网站网站策划是干什么的
  • 廊坊网站建设系统seo网站内容优化有哪些
  • 网站建设的需求客户关键词挖掘查询工具爱站网
  • 政府网站建设进展情况网站怎么做外链
  • 网站主页设计欣赏网站推广费用一般多少钱
  • 过界女主个人做网站的店铺seo是什么意思
  • 分类信息网站建设方案河北网站seo
  • 兰溪好品质高端网站设计百度官网认证免费
  • 嘉兴优化网站公司哪家好微博推广
  • 中国服务器排名前十名安徽360优化
  • 石家庄最好的网站建设公司电商网站设计模板
  • 做网站申请完空间后下一步干啥免费推广产品的平台
  • 游民星空是用什么做的网站竞价推广代运营
  • 其它区便宜营销型网站建设网站建设怎么弄
  • 如何做自己的网站百度快速收录权限域名
  • 做网站时应该用什么软件排名点击软件怎样
  • 网站怎么做移动端适配百度sem推广具体做什么