Skip to content

Commit

Permalink
tk.mybatis替换为mybatisplus
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghuaiGit committed Nov 11, 2019
1 parent 01464d2 commit b8229b7
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion earthsystem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<dependency>
<groupId>com.skrshop</groupId>
<artifactId>skrshop-tkmybatis</artifactId>
<artifactId>skrshop-mybatisplus</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.skrshop.earthsystem;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import tk.mybatis.spring.annotation.MapperScan;


@SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.skrshop.earthsystem.model.po.account;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;

/**
Expand All @@ -18,8 +18,7 @@ public class AccountUser implements Serializable {
/**
* 账号id
*/
@Id
@GeneratedValue(generator = "JDBC")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 账户类型 0:员工,1:用户
Expand Down
2 changes: 1 addition & 1 deletion mall/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<dependency>
<groupId>com.skrshop</groupId>
<artifactId>skrshop-tkmybatis</artifactId>
<artifactId>skrshop-mybatisplus</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>

Expand Down
5 changes: 1 addition & 4 deletions mall/src/main/java/com/skrshop/mall/MallApplication.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.skrshop.mall;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
import tk.mybatis.spring.annotation.MapperScan;

@SpringBootApplication
@EnableDiscoveryClient
Expand Down
8 changes: 3 additions & 5 deletions mall/src/main/java/com/skrshop/mall/model/po/SkrMember.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.skrshop.mall.model.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;


Expand All @@ -14,8 +13,7 @@
@Data
public class SkrMember {

@Id
@GeneratedValue(generator = "JDBC")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private Long uid;
private String nickName;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<module>oauthclient</module>
<module>oauthserver</module>
<module>redis-support</module>
<module>skrshop-tkmybatis</module>
<module>skrshop-mybatisplus</module>
</modules>

<dependencies>
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions skrshop-tkmybatis/pom.xml → skrshop-mybatisplus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.skrshop</groupId>
<artifactId>skrshop-tkmybatis</artifactId>
<artifactId>skrshop-mybatisplus</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>skrshop-tkmybatis</name>
<description>Demo project for Spring Boot</description>
Expand Down Expand Up @@ -46,9 +46,9 @@
</dependency>

<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.1.5</version>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.2.0</version>
</dependency>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.skrshop.skrshoptkmybatis.extensionmapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.skrshop.common.error.ServiceException;
import com.skrshop.common.response.ResultCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tk.mybatis.mapper.common.Mapper;

public interface ExtensionMapper<T> extends Mapper {
public interface ExtensionMapper<T> extends BaseMapper {
Logger LOGGER = LoggerFactory.getLogger(ExtensionMapper.class);

default void createSuccess(T data, ResultCode resultCode) {
int result = this.insertSelective(data);
int result = this.insert(data);
if (result != 1) {
LOGGER.error("添加 {} 失败,影响行数result {}", data, result);
throw new ServiceException(resultCode);
Expand Down

0 comments on commit b8229b7

Please sign in to comment.