-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
120 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ POST {{base}}/user/create | |
|
||
### | ||
POST {{base}}/user/update | ||
|
||
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
nest-plus-demo/src/main/java/com/zhaofujun/nest/demo/domain/Address.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.zhaofujun.nest.demo.domain; | ||
|
||
import com.zhaofujun.nest.context.model.BaseValueObject; | ||
|
||
public class Address extends BaseValueObject { | ||
private String name; | ||
private Point point; | ||
|
||
public Address(String name, Point point) { | ||
this.name = name; | ||
this.point = point; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Point getPoint() { | ||
return point; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
nest-plus-demo/src/main/java/com/zhaofujun/nest/demo/domain/Point.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.zhaofujun.nest.demo.domain; | ||
|
||
import com.zhaofujun.nest.context.model.BaseValueObject; | ||
|
||
public class Point extends BaseValueObject { | ||
private int x; | ||
private int y; | ||
|
||
public Point(int x, int y) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
public int getX() { | ||
return x; | ||
} | ||
|
||
public int getY() { | ||
return y; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 57 additions & 57 deletions
114
...emo/src/main/java/com/zhaofujun/nest/demo/infrastructure/repositories/UserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,57 @@ | ||
package com.zhaofujun.nest.demo.infrastructure.repositories; | ||
|
||
import com.zhaofujun.automapper.AutoMapper; | ||
import com.zhaofujun.nest.context.model.LongIdentifier; | ||
import com.zhaofujun.nest.demo.domain.User; | ||
import com.zhaofujun.nest.demo.infrastructure.repositories.dao.UserDao; | ||
import com.zhaofujun.nest.demo.infrastructure.repositories.dao.po.UserPO; | ||
import com.zhaofujun.nest.standard.EntityLoader; | ||
import com.zhaofujun.nest.standard.Identifier; | ||
import com.zhaofujun.nest.standard.Repository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class UserRepository implements Repository<User> { | ||
@Autowired | ||
private AutoMapper autoMapper; | ||
|
||
@Autowired | ||
private UserDao userDao; | ||
|
||
@Override | ||
public Class<User> getEntityClass() { | ||
return User.class; | ||
} | ||
|
||
@Override | ||
public User getEntityById(Identifier identifier, EntityLoader<User> entityLoader) { | ||
LongIdentifier id = (LongIdentifier) identifier; | ||
UserPO userPO = userDao.getOne(id.getId()); | ||
if (userPO == null) return null; | ||
User user = entityLoader.create(identifier); | ||
autoMapper.map(userPO, user); | ||
return user; | ||
} | ||
|
||
@Override | ||
public void insert(User user) { | ||
// if (user.getId().getId().equals(101L)) throw new RuntimeException("发生异常"); | ||
if (user == null) return; | ||
UserPO userPO = autoMapper.map(user, UserPO.class); | ||
userDao.save(userPO); | ||
} | ||
|
||
@Override | ||
public void update(User user) { | ||
if (user == null) return; | ||
UserPO userPO = autoMapper.map(user, UserPO.class); | ||
userDao.save(userPO); | ||
} | ||
|
||
@Override | ||
public void delete(User user) { | ||
if (user != null) | ||
userDao.deleteById(user.getId().getId()); | ||
} | ||
} | ||
//package com.zhaofujun.nest.demo.infrastructure.repositories; | ||
// | ||
//import com.zhaofujun.automapper.AutoMapper; | ||
//import com.zhaofujun.nest.context.model.LongIdentifier; | ||
//import com.zhaofujun.nest.demo.domain.User; | ||
//import com.zhaofujun.nest.demo.infrastructure.repositories.dao.UserDao; | ||
//import com.zhaofujun.nest.demo.infrastructure.repositories.dao.po.UserPO; | ||
//import com.zhaofujun.nest.standard.EntityLoader; | ||
//import com.zhaofujun.nest.standard.Identifier; | ||
//import com.zhaofujun.nest.standard.Repository; | ||
//import org.springframework.beans.factory.annotation.Autowired; | ||
//import org.springframework.stereotype.Component; | ||
// | ||
//@Component | ||
//public class UserRepository implements Repository<User> { | ||
// @Autowired | ||
// private AutoMapper autoMapper; | ||
// | ||
// @Autowired | ||
// private UserDao userDao; | ||
// | ||
// @Override | ||
// public Class<User> getEntityClass() { | ||
// return User.class; | ||
// } | ||
// | ||
// @Override | ||
// public User getEntityById(Identifier identifier, EntityLoader<User> entityLoader) { | ||
// LongIdentifier id = (LongIdentifier) identifier; | ||
// UserPO userPO = userDao.getOne(id.getId()); | ||
// if (userPO == null) return null; | ||
// User user = entityLoader.create(identifier); | ||
// autoMapper.map(userPO, user); | ||
// return user; | ||
// } | ||
// | ||
// @Override | ||
// public void insert(User user) { | ||
//// if (user.getId().getId().equals(101L)) throw new RuntimeException("发生异常"); | ||
// if (user == null) return; | ||
// UserPO userPO = autoMapper.map(user, UserPO.class); | ||
// userDao.save(userPO); | ||
// } | ||
// | ||
// @Override | ||
// public void update(User user) { | ||
// if (user == null) return; | ||
// UserPO userPO = autoMapper.map(user, UserPO.class); | ||
// userDao.save(userPO); | ||
// } | ||
// | ||
// @Override | ||
// public void delete(User user) { | ||
// if (user != null) | ||
// userDao.deleteById(user.getId().getId()); | ||
// } | ||
//} |
1 change: 1 addition & 0 deletions
1
...us-spring-boot-starter/src/main/java/com/zhaofujun/nest/spring/NestAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters