哈哈哈哈哈哈哈👌话嘿嘿👌h
      
      springBoot开发

      
      <resultMap id="Areas" type="com.imooc.demo.entyti.Area"> <id column="area_id" jdbcType="INTEGER" property="areaId" /> <result column="area_name" jdbcType="VARCHAR" property="areaName" /> <result column="priority" jdbcType="INTEGER" property="priority" /> <result column="create_time" jdbcType="DATE" property="createTime" /> <result column="last_edit_time" jdbcType="DATE" property="lastEditTime" /> </resultMap> <select id="queryArea" resultMap="Areas"> SELECT area_id, area_name, priority, create_time, last_edit_time FROM td_area ORDER BY priority DESC </select>
    绑定代码,忽略下划线改成大写
      
      server层为了复查dao层中的操作,与事务有关
将增删改查整合到一起
      
      gitignore配置需要git管理的文件
      
      test失败????????
java.lang.IllegalStateException: Failed to load ApplicationContext
      
      我的
      
      
      
      1111
      
      配置类
      
      dataSource.return = return dataSource;
      
      springboot项目,除了mybatis的配置,其他配置一般都不用xml。mybatis的配置也可用java类,但是xml的方式是主流。
      
      @controllerAdvice统一异常处理
      
      Junit单元测试
      
      springboot集成mybatise,mapper.xml的编写
      
      MenuDao层:
package com.example.demo.dao;
import com.example.demo.bean.MainMenu;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface MenuDao {
    public List<MainMenu> getMenus();
}MenuController层:
package com.example.demo.logincontroller;
import com.alibaba.fastjson.JSON;
import com.example.demo.bean.MainMenu;
import com.example.demo.dao.MenuDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
@RestController
public class MenuController {
    @Autowired
    MenuDao menuDao;
    @RequestMapping(value="/menus")
    public String getAllMenus(){
        System.out.println("访问成功!!!");
        HashMap<String, Object> data = new HashMap<>();
        List<MainMenu> menus = menuDao.getMenus();
        if (menus != null){
            data.put("menus", menus);
            data.put("flag", 200);
        }else{
            data.put("flag", 404);
        }
        String s = JSON.toJSONString(data);
        return s;
    }
}
      
      MenuMainMapper。xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.example.demo.dao.MenuDao"> <!-- 关系映射--> <resultMap id="menuMap" type="com.example.demo.bean.MainMenu"> <id column="id" property="id"></id> <result column="title" property="title"></result> <result column="path" property="path"></result> <collection property="sList" ofType="com.example.demo.bean.SubMenu"> <id column="sid" property="id"></id> <result column="stitle" property="title"></result> <result column="spath" property="path"></result> </collection> </resultMap> <select id="getMenus" resultMap="menuMap"> select mm.*,sm.id as sid ,sm.title as stitle ,sm.path as spath from vue_mainmenu mm ,vue_submenu sm where mm.id = mid; </select> </mapper>
      
      Controller层:
package com.example.demo.logincontroller;
import com.alibaba.fastjson.JSON;
import com.example.demo.bean.UserName;
import com.example.demo.dao.UserNameDao;
//import jdk.nashorn.internal.parser.JSONParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
@RestController
public class LoginController {
    @Autowired
    UserNameDao userNameDao;
    @RequestMapping(value="/Login")
    public String login(@RequestBody UserName username){
        String flag = "error";
        UserName userName = userNameDao.getUserNameByMassage(username.getUsername(), username.getPassword());
        HashMap<String, Object> res = new HashMap<>();
        if(userName != null){
            flag = "hello world!!!";
        }
        res.put("flag", flag);
        res.put("username", username);
        String res_json = JSON.toJSONString(res);
//        System.out.println(userName);
        return res_json;
    }
}UserNameDao层:
package com.example.demo.dao;
import com.example.demo.bean.UserName;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface UserNameDao {
    public UserName getUserNameByMassage(@Param("username") String username, @Param("password") String password);
}解决跨域:
package com.example.demo.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
 * 解决跨域问题
 */
@Configuration
public class Config extends WebMvcConfigurerAdapter {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedMethods("*")
                .allowCredentials(true)
                .maxAge(3600);
    }
}实体层bean:
package com.example.demo.bean;
public class UserName {
    private int id;
    private String username;
    private String password;
    public UserName(){
    }
    public UserName(String username, String password){
        this.username = username;
        this.password = password;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    @Override
    public String toString() {
        return "UserName{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
      
      草他个妈耶,真鸡儿难
      
      
      
      
      
      formSubmit:function(e){
var that = this;
var formData = e.detail.value;
var url = that.data.addUrl;
if(that.data.areaId != undefined){
formData.areaId = that.data.areaId;
url = that.data.modifyUrl;
}
wx.request({
url: url,
data: JSON.stringify(formData),
method:"GET",
header: {'Content-Type':'application/json'},
success: function(res){
var result = res.data.success;
var toastText = "操作成功!";
if(result != true){
toastText = "操作失败"+res.data.errMsg;
}
wx.showToast({
title: toastText,
})
}
})
}
      
      operation.wxml
      
      onShow
      
      目录结构……
      
      创建小程序项目
      
      小程序介绍
      
      jsonView 插件
      
      IDEA:自动导包
      
      实战项目页面