Commit 593ee9ca authored by JiangSN's avatar JiangSN

集成mybatis-plus

parent a53a3e57
......@@ -30,7 +30,8 @@ import router from './router/routers'
import './assets/icons' // icon
import './router/index' // permission control
import 'echarts-gl'
import VueResource from 'vue-resource';
Vue.use(VueResource);
Vue.use(checkPer)
Vue.use(VueHighlightJS)
Vue.use(mavonEditor)
......
......@@ -34,22 +34,12 @@
<version>3.1.2</version>
</dependency>-->
<!-- MybatisPlus -->
<!--<dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>me.zhengjie</groupId>
<artifactId>eladmin-common</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>-->
<dependency>
<groupId>me.zhengjie</groupId>
<artifactId>eladmin-common</artifactId>
......@@ -61,4 +51,22 @@
<version>2.3.1</version>
</dependency>
</dependencies>
<build>
<resources>
<!-- maven项目中src源代码下的xml等资源文件编译进classes文件夹,
注意:如果没有这个,它会自动搜索resources下是否有mapper.xml文件,
如果没有就会报org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.pet.mapper.PetMapper.selectByPrimaryKey-->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<!--将resources目录下的配置文件编译进classes文件 -->
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>
package me.zhengjie.config;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author JiangHeJia
* @version V1.0
* @Title: MybatisPlusConfig
* @Package el-admin
* @Description: TODO(配置分页插件)
* @date 2021/10/12 21:20
*/
@Configuration
public class MybatisPlusConfig {
/**
* 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
/*
* Copyright (c) 2019-2020, 冷冷 (wangiegie@gmail.com).
* <p>
* Licensed under the GNU Lesser General Public License 3.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.constant;
/**
* @author lengleng
* @date 2019/2/1
*/
public interface CommonConstants {
/**
* 删除
*/
String STATUS_DEL = "1";
/**
* 正常
*/
String STATUS_NORMAL = "0";
/**
* 锁定
*/
String STATUS_LOCK = "9";
/**
* 菜单
*/
String MENU = "0";
/**
* 编码
*/
String UTF8 = "UTF-8";
/**
* JSON 资源
*/
String CONTENT_TYPE = "application/json; charset=utf-8";
/**
* 前端工程名
*/
String FRONT_END_PROJECT = "pig-ui";
/**
* 后端工程名
*/
String BACK_END_PROJECT = "pig";
/**
* 成功标记
*/
Integer SUCCESS = 0;
/**
* 失败标记
*/
Integer FAIL = 1;
/**
* 验证码前缀
*/
String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY_";
}
package me.zhengjie.controller;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.service.IndexService;
import me.zhengjie.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author JiangHeJia
* @version V1.0
* @Title: IndexController
* @Package el-admin
* @Description: TODO(首页展示信息查询控制器)
* @date 2021/10/12 21:28
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("api/IndexController")
@Api(tags = "查询:首页展示信息查询控制器")
public class IndexController {
@Autowired
private IndexService indexService;
@AnonymousAccess
@RequestMapping("/selectDemo")
public R selectDemo() {
return new R<>(indexService.selectDemo());
}
}
package me.zhengjie.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
import java.util.Map;
public interface IndexMapper extends BaseMapper<Map> {
List<Map> selectDemo();
}
package me.zhengjie.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public interface IndexService extends IService<Map> {
/**
* 领导-管理部贷款逾期情况
* @return
*/
List<Map> selectDemo();
}
package me.zhengjie.serviceimpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import me.zhengjie.mapper.IndexMapper;
import me.zhengjie.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @author JiangHeJia
* @version V1.0
* @Title: IndexServiceImpl
* @Package el-admin
* @Description: TODO()
* @date 2021/10/12 21:30
*/
@Service
public class IndexServiceImpl extends ServiceImpl<IndexMapper, Map> implements IndexService {
@Autowired
private IndexMapper indexMapper;
@Override
public List<Map> selectDemo() {
return indexMapper.selectDemo();
}
}
/*
* Copyright (c) 2019-2020, 冷冷 (wangiegie@gmail.com).
* <p>
* Licensed under the GNU Lesser General Public License 3.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.util;
import lombok.*;
import lombok.experimental.Accessors;
import me.zhengjie.constant.CommonConstants;
import java.io.Serializable;
/**
* 响应信息主体
*
* @param <T>
* @author lengleng
*/
@Builder
@ToString
@Accessors(chain = true)
@AllArgsConstructor
public class R<T> implements Serializable {
private static final long serialVersionUID = 1L;
@Getter
@Setter
private int code = CommonConstants.SUCCESS;
@Getter
@Setter
private String msg = "success";
@Getter
@Setter
private T data;
public R() {
super();
}
public R(T data) {
super();
this.data = data;
}
public R(T data, String msg) {
super();
this.data = data;
this.msg = msg;
}
public R(Throwable e) {
super();
this.msg = e.getMessage();
this.code = CommonConstants.FAIL;
}
}
<?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="me.zhengjie.mapper.IndexMapper">
<!-- 领导-贷款逾期-->
<select id="selectDemo" resultType="java.util.Map">
<![CDATA[
select * from sjgx_sys_log
]]>
</select>
</mapper>
......@@ -18,6 +18,7 @@ package me.zhengjie;
import io.swagger.annotations.Api;
import me.zhengjie.annotation.rest.AnonymousGetMapping;
import me.zhengjie.utils.SpringContextHolder;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
......@@ -44,6 +45,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@EnableTransactionManagement
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
@ComponentScan(basePackages={"me.zhengjie.*"})
@MapperScan(basePackages = "me.zhengjie.mapper")
public class AppRun {
public static void main(String[] args) {
......
......@@ -35,6 +35,7 @@ spring:
password: ${REDIS_PWD:}
#连接超时时间
timeout: 5000
logging:
level:
org.springframework.security:
......@@ -45,6 +46,21 @@ logging:
org.hibernate.engine.QueryParameters: debug
org.hibernate.engine.query.HQLQueryPlan: debug
org.hibernate.type.descriptor.sql.BasicBinder: trace
me.zhengjie.mapper: debug
# mybaits-plus配置
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
global-config:
banner: false
id-type: 1
field-strategy: 1
table-underline: true
logic-delete-value: 1
logic-not-delete-value: 0
configuration:
map-underscore-to-camel-case: true
jdbc-type-for-null: 'null'
task:
pool:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment