Commit eb4e2865 authored by 廖旭伟's avatar 廖旭伟

客户保存设计

parent da3320f2
...@@ -6,8 +6,15 @@ import com.mortals.framework.model.PageInfo; ...@@ -6,8 +6,15 @@ import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.customer.dao.CustomerWorkCollectDao; import com.mortals.xhx.module.customer.dao.CustomerWorkCollectDao;
import com.mortals.xhx.module.customer.model.CustomerWorkCollectEntity; import com.mortals.xhx.module.customer.model.CustomerWorkCollectEntity;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity;
import com.mortals.xhx.module.customer.service.CustomerWorkCollectService; import com.mortals.xhx.module.customer.service.CustomerWorkCollectService;
import com.mortals.xhx.module.masterplate.model.MasterplateUseInfoEntity;
import com.mortals.xhx.module.masterplate.service.MasterplateUseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* CustomerWorkCollectService * CustomerWorkCollectService
* 客户收藏信息 service实现 * 客户收藏信息 service实现
......
package com.mortals.xhx.module.customer.service.impl; package com.mortals.xhx.module.customer.service.impl;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.customer.model.CustomerWorkCollectEntity;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.customer.dao.CustomerWorkDesignDao; import com.mortals.xhx.module.customer.dao.CustomerWorkDesignDao;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity; import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignStatEntity;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignStatQuery;
import com.mortals.xhx.module.customer.service.CustomerWorkDesignService; import com.mortals.xhx.module.customer.service.CustomerWorkDesignService;
import com.mortals.xhx.module.customer.service.CustomerWorkDesignStatService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/** /**
* CustomerWorkDesignService * CustomerWorkDesignService
* 客户作品信息 service实现 * 客户作品信息 service实现
...@@ -18,6 +27,9 @@ import com.mortals.xhx.module.customer.service.CustomerWorkDesignService; ...@@ -18,6 +27,9 @@ import com.mortals.xhx.module.customer.service.CustomerWorkDesignService;
@Service("customerWorkDesignService") @Service("customerWorkDesignService")
public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<CustomerWorkDesignDao, CustomerWorkDesignEntity, Long> implements CustomerWorkDesignService { public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<CustomerWorkDesignDao, CustomerWorkDesignEntity, Long> implements CustomerWorkDesignService {
@Autowired
private CustomerWorkDesignStatService customerWorkDesignStatService;
@Override @Override
protected CustomerWorkDesignEntity findBefore(CustomerWorkDesignEntity params, PageInfo pageInfo, Context context) throws AppException { protected CustomerWorkDesignEntity findBefore(CustomerWorkDesignEntity params, PageInfo pageInfo, Context context) throws AppException {
pageInfo.setPrePageResult(-1); pageInfo.setPrePageResult(-1);
...@@ -30,4 +42,27 @@ public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<Custo ...@@ -30,4 +42,27 @@ public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<Custo
this.validData(entity, context); this.validData(entity, context);
entity.setCustomerId(this.getContextUserId(context)); entity.setCustomerId(this.getContextUserId(context));
} }
@Override
protected void saveAfter(CustomerWorkDesignEntity entity, Context context) throws AppException {
CustomerWorkDesignStatEntity cQuery = new CustomerWorkDesignStatEntity();
cQuery.setCustomerId(entity.getCustomerId());
List<CustomerWorkDesignStatEntity> cwdList = customerWorkDesignStatService.find(cQuery);
if(CollectionUtils.isEmpty(cwdList)){
CustomerWorkDesignStatEntity cwdEntity = new CustomerWorkDesignStatEntity();
cwdEntity.setCustomerId(entity.getCustomerId());
cwdEntity.setCustomerDesignPictures(1);
cwdEntity.setCustomerDesignVideos(0);
cwdEntity.setCreateTime(new Date());
cwdEntity.setUpdateTime(new Date());
customerWorkDesignStatService.save(cwdEntity);
}else {
CustomerWorkDesignStatEntity cwdEntity = cwdList.get(0);
CustomerWorkDesignStatQuery updateEntity = new CustomerWorkDesignStatQuery();
updateEntity.setId(cwdEntity.getId());
updateEntity.setCustomerDesignPicturesIncrement(1);
updateEntity.setUpdateTime(new Date());
customerWorkDesignStatService.update(updateEntity);
}
}
} }
\ No newline at end of file
...@@ -72,6 +72,14 @@ public class CustomerWorkDesignController extends BaseCRUDJsonBodyMappingControl ...@@ -72,6 +72,14 @@ public class CustomerWorkDesignController extends BaseCRUDJsonBodyMappingControl
query.setCustomerId(this.getCurUser().getId()); query.setCustomerId(this.getCurUser().getId());
} }
@Override
protected void saveBefore(CustomerWorkDesignEntity entity, Map<String, Object> model, Context context) throws AppException {
if(this.getCurUser()==null||this.getCurUser().getUserType()!= Constant.CUSTOMER_USER){
throw new AppException("非法用户,不可访问");
}
entity.setCustomerId(this.getCurUser().getId());
}
@PostMapping({"picture/list"}) @PostMapping({"picture/list"})
@UnAuth @UnAuth
......
...@@ -2,6 +2,10 @@ package com.mortals.xhx.module.masterplate.service.impl; ...@@ -2,6 +2,10 @@ package com.mortals.xhx.module.masterplate.service.impl;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.design.model.DesignMasterplateEntity;
import com.mortals.xhx.module.design.model.DesignMasterplateQuery;
import com.mortals.xhx.module.design.service.DesignMasterplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.masterplate.dao.MasterplateUseInfoDao; import com.mortals.xhx.module.masterplate.dao.MasterplateUseInfoDao;
...@@ -17,8 +21,19 @@ import com.mortals.xhx.module.masterplate.service.MasterplateUseInfoService; ...@@ -17,8 +21,19 @@ import com.mortals.xhx.module.masterplate.service.MasterplateUseInfoService;
@Service("masterplateUseInfoService") @Service("masterplateUseInfoService")
public class MasterplateUseInfoServiceImpl extends AbstractCRUDServiceImpl<MasterplateUseInfoDao, MasterplateUseInfoEntity, Long> implements MasterplateUseInfoService { public class MasterplateUseInfoServiceImpl extends AbstractCRUDServiceImpl<MasterplateUseInfoDao, MasterplateUseInfoEntity, Long> implements MasterplateUseInfoService {
@Autowired
private DesignMasterplateService designMasterplateService;
@Override @Override
protected MasterplateUseInfoEntity findBefore(MasterplateUseInfoEntity entity, PageInfo pageInfo, Context context) throws AppException { protected MasterplateUseInfoEntity findBefore(MasterplateUseInfoEntity entity, PageInfo pageInfo, Context context) throws AppException {
return entity; return entity;
} }
@Override
protected void saveAfter(MasterplateUseInfoEntity entity, Context context) throws AppException {
DesignMasterplateQuery update = new DesignMasterplateQuery();
update.setId(entity.getMasterplateId());
update.setMasterplateUseNumIncrement(1);
designMasterplateService.update(update);
}
} }
\ No newline at end of file
package com.mortals.xhx.module.masterplate.web; package com.mortals.xhx.module.masterplate.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.module.customer.model.CustomerEntity;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity;
import com.mortals.xhx.module.customer.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -36,6 +41,8 @@ public class MasterplateUseInfoController extends BaseCRUDJsonBodyMappingControl ...@@ -36,6 +41,8 @@ public class MasterplateUseInfoController extends BaseCRUDJsonBodyMappingControl
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
@Autowired
private CustomerService customerService;
public MasterplateUseInfoController(){ public MasterplateUseInfoController(){
super.setModuleDesc( "模版使用信息"); super.setModuleDesc( "模版使用信息");
...@@ -46,5 +53,15 @@ public class MasterplateUseInfoController extends BaseCRUDJsonBodyMappingControl ...@@ -46,5 +53,15 @@ public class MasterplateUseInfoController extends BaseCRUDJsonBodyMappingControl
super.init(model, context); super.init(model, context);
} }
@Override
protected void saveBefore(MasterplateUseInfoEntity entity, Map<String, Object> model, Context context) throws AppException {
if(this.getCurUser()==null||this.getCurUser().getUserType()!= Constant.CUSTOMER_USER){
throw new AppException("非法用户,不可访问");
}
CustomerEntity customerEntity = customerService.get(this.getCurUser().getId());
entity.setCustomerId(this.getCurUser().getId());
entity.setCustomerName(customerEntity.getCustName());
entity.setCustomerTelphone(customerEntity.getContactTelphone());
entity.setCustomerOrganization(customerEntity.getOrganization());
}
} }
\ No newline at end of file
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