记得上下班打卡 | git大法好,push需谨慎

Commit 53050cb3 authored by 张国柄's avatar 张国柄

fix:+shardkey操作MDB.VO;

parent 6ca32790
...@@ -145,13 +145,14 @@ public class AdamAddressesServiceImpl implements IAdamAddressesService { ...@@ -145,13 +145,14 @@ public class AdamAddressesServiceImpl implements IAdamAddressesService {
@Override @Override
// @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) // @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void edit(AdamAddressesParam parameter) { public void edit(AdamAddressesParam parameter) {
String currentUid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
AdamAddressesVo updateVo = AdamAddressesVo.getNew(); AdamAddressesVo updateVo = AdamAddressesVo.getNew();
BeanUtils.copyProperties(parameter, updateVo); BeanUtils.copyProperties(parameter, updateVo);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
Document doc = mongoTemplate.getCollection(AdamAddressesVo.class.getSimpleName()).findOneAndUpdate( Document doc = mongoTemplate.getCollection(AdamAddressesVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("addressesId").is(parameter.getAddressesId())).getQueryObject(), Query.query(Criteria.where("uid").is(currentUid).and("addressesId").is(parameter.getAddressesId())).getQueryObject(),
new Document("$set", Document.parse(JsonUtils.toJson(updateVo)).append("updatedAt", now)), new Document("$set", Document.parse(JsonUtils.toJson(updateVo)).append("updatedAt", now)),
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER) new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
); );
...@@ -159,7 +160,6 @@ public class AdamAddressesServiceImpl implements IAdamAddressesService { ...@@ -159,7 +160,6 @@ public class AdamAddressesServiceImpl implements IAdamAddressesService {
if (null != doc) { if (null != doc) {
updateVo = BsonUtil.toBean(doc, AdamAddressesVo.class); updateVo = BsonUtil.toBean(doc, AdamAddressesVo.class);
String currentUid = CurrentUtil.getCurrentUid();
List<AdamAddressesVo> vos = adamRdmService.getAddressesVoByUid(currentUid); List<AdamAddressesVo> vos = adamRdmService.getAddressesVoByUid(currentUid);
s = System.currentTimeMillis(); s = System.currentTimeMillis();
adamRdmService.setAddressesVoByUid(updateVo.getUid(), this.collectionProcess(vos, parameter.getAddressesId(), updateVo)); adamRdmService.setAddressesVoByUid(updateVo.getUid(), this.collectionProcess(vos, parameter.getAddressesId(), updateVo));
...@@ -178,6 +178,7 @@ public class AdamAddressesServiceImpl implements IAdamAddressesService { ...@@ -178,6 +178,7 @@ public class AdamAddressesServiceImpl implements IAdamAddressesService {
@Override @Override
// @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) // @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void remove(String uid, String addressesId) { public void remove(String uid, String addressesId) {
String currentUid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
// AdamAddressesVo removeVo = AdamAddressesVo.getNew(); // AdamAddressesVo removeVo = AdamAddressesVo.getNew();
...@@ -188,7 +189,7 @@ public class AdamAddressesServiceImpl implements IAdamAddressesService { ...@@ -188,7 +189,7 @@ public class AdamAddressesServiceImpl implements IAdamAddressesService {
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
DeleteResult deleteResult = mongoTemplate.remove( DeleteResult deleteResult = mongoTemplate.remove(
Query.query(Criteria.where("addressesId").is(addressesId)), AdamAddressesVo.class.getSimpleName() Query.query(Criteria.where("uid").is(currentUid).and("addressesId").is(addressesId)), AdamAddressesVo.class.getSimpleName()
); );
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
List<AdamAddressesVo> vos = adamRdmService.getAddressesVoByUid(uid); List<AdamAddressesVo> vos = adamRdmService.getAddressesVoByUid(uid);
......
...@@ -163,9 +163,8 @@ public class AdamEntersServiceImpl implements IAdamEntersService { ...@@ -163,9 +163,8 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
@Override @Override
// @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) // @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void edit(AdamEntersParam parameter) { public void edit(AdamEntersParam parameter) {
LocalDateTime now = LocalDateTime.now();
String currentUid = CurrentUtil.getCurrentUid(); String currentUid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now();
if (1 == parameter.getType()) { if (1 == parameter.getType()) {
if (!adamRdmService.isCertification(1, parameter.getIdCard(), parameter.getName())) { if (!adamRdmService.isCertification(1, parameter.getIdCard(), parameter.getName())) {
...@@ -173,12 +172,11 @@ public class AdamEntersServiceImpl implements IAdamEntersService { ...@@ -173,12 +172,11 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
} }
} }
AdamEntersVo updateVo = AdamEntersVo.getNew(); AdamEntersVo updateVo = AdamEntersVo.getNew();
BeanUtils.copyProperties(parameter, updateVo); BeanUtils.copyProperties(parameter, updateVo);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
Document doc = mongoTemplate.getCollection(AdamEntersVo.class.getSimpleName()).findOneAndUpdate( Document doc = mongoTemplate.getCollection(AdamEntersVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("entersId").is(parameter.getEntersId())).getQueryObject(), Query.query(Criteria.where("uid").is(currentUid).and("entersId").is(parameter.getEntersId())).getQueryObject(),
new Document("$set", Document.parse(JsonUtils.toJson(updateVo)).append("updatedAt", now)), new Document("$set", Document.parse(JsonUtils.toJson(updateVo)).append("updatedAt", now)),
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER) new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
); );
...@@ -207,10 +205,11 @@ public class AdamEntersServiceImpl implements IAdamEntersService { ...@@ -207,10 +205,11 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
@Override @Override
// @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) // @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void remove(String uid, String entersId) { public void remove(String uid, String entersId) {
String currentUid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
DeleteResult deleteResult = mongoTemplate.remove( DeleteResult deleteResult = mongoTemplate.remove(
Query.query(Criteria.where("entersId").is(entersId)), AdamEntersVo.class.getSimpleName() Query.query(Criteria.where("uid").is(currentUid).and("entersId").is(entersId)), AdamEntersVo.class.getSimpleName()
); );
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
List<AdamEntersVo> vos = adamRdmService.getEntersVoByUid(uid); List<AdamEntersVo> vos = adamRdmService.getEntersVoByUid(uid);
......
...@@ -340,7 +340,7 @@ public class AdamUserServiceImpl implements IAdamUserService { ...@@ -340,7 +340,7 @@ public class AdamUserServiceImpl implements IAdamUserService {
/* ---------------------- 收货地址信息 */ /* ---------------------- 收货地址信息 */
s = System.currentTimeMillis(); s = System.currentTimeMillis();
deleteResult = mongoTemplate.remove(Query.query(Criteria.where("uid").is(uid).and("state").is(1)), AdamAddressesVo.class.getSimpleName()); deleteResult = mongoTemplate.remove(Query.query(Criteria.where("uid").is(uid)), AdamAddressesVo.class.getSimpleName());
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
if (deleteResult.getDeletedCount() > 0) { if (deleteResult.getDeletedCount() > 0) {
toMqSqls.add(SqlMapping.get("adam_addresses.close")); toMqSqls.add(SqlMapping.get("adam_addresses.close"));
......
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