|
|
@@ -1,8 +1,10 @@
|
|
|
package com.jpsoft.employment.modules.base.api;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.employment.modules.base.entity.AddressInfo;
|
|
|
import com.jpsoft.employment.modules.base.entity.WishInfo;
|
|
|
import com.jpsoft.employment.modules.base.entity.WishInfoUserRecord;
|
|
|
+import com.jpsoft.employment.modules.base.service.AddressInfoService;
|
|
|
import com.jpsoft.employment.modules.base.service.StudentAspirationsService;
|
|
|
import com.jpsoft.employment.modules.base.service.WishInfoService;
|
|
|
import com.jpsoft.employment.modules.base.service.WishInfoUserRecordService;
|
|
|
@@ -22,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
@@ -31,6 +34,8 @@ import java.util.*;
|
|
|
public class WishApi {
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AddressInfoService addressInfoService;
|
|
|
@Autowired
|
|
|
private WishInfoService wishInfoService;
|
|
|
@Autowired
|
|
|
@@ -100,18 +105,20 @@ public class WishApi {
|
|
|
|
|
|
@ApiOperation(value="提交心愿单")
|
|
|
@RequestMapping(value = "add",method = RequestMethod.POST)
|
|
|
-// @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name="wishInfoId", value="心愿信息ID", required=true, paramType="query"),
|
|
|
@ApiImplicitParam(name="isSpot", value="是否现场互换心愿", required=true, paramType="query"),
|
|
|
@ApiImplicitParam(name="recipients", value="收件人", required=false, paramType="query"),
|
|
|
@ApiImplicitParam(name="recipientsPhone", value="收件人电话", required=false, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="recipientsRegion", value="收件人区域", required=false, paramType="query"),
|
|
|
@ApiImplicitParam(name="recipientsAddress", value="收件人地址", required=false, paramType="query"),
|
|
|
})
|
|
|
public MessageResult<WishInfoUserRecord> add(String wishInfoId, Boolean isSpot,
|
|
|
- String recipients, String recipientsPhone, String recipientsAddress,
|
|
|
- @RequestAttribute String subject){
|
|
|
+ String recipients, String recipientsPhone, String recipientsRegion, String recipientsAddress,
|
|
|
+ HttpServletRequest request){
|
|
|
MessageResult<WishInfoUserRecord> msgResult = new MessageResult<>();
|
|
|
+ String subject = (String)request.getAttribute("subject");
|
|
|
|
|
|
try {
|
|
|
WishInfoUserRecord wishInfoUserRecord = new WishInfoUserRecord();
|
|
|
@@ -123,20 +130,36 @@ public class WishApi {
|
|
|
wishInfoUserRecord.setNum(getSerialNumber());
|
|
|
wishInfoUserRecord.setRecipients (recipients);
|
|
|
wishInfoUserRecord.setRecipientsPhone(recipientsPhone);
|
|
|
- wishInfoUserRecord.setRecipientsAddress(recipientsAddress);
|
|
|
+ wishInfoUserRecord.setRecipientsAddress(recipientsRegion + recipientsAddress);
|
|
|
wishInfoUserRecord.setDelFlag(false);
|
|
|
wishInfoUserRecord.setCreateBy(subject);
|
|
|
wishInfoUserRecord.setCreateTime(new Date());
|
|
|
-
|
|
|
- int affectCount = wishInfoUserRecordService.insert(wishInfoUserRecord);
|
|
|
-
|
|
|
- if (affectCount > 0) {
|
|
|
- msgResult.setResult(true);
|
|
|
- msgResult.setData(wishInfoUserRecord);
|
|
|
- } else {
|
|
|
- msgResult.setResult(false);
|
|
|
- msgResult.setMessage("数据库添加失败");
|
|
|
+ wishInfoUserRecordService.insert(wishInfoUserRecord);
|
|
|
+
|
|
|
+ AddressInfo addressInfo = addressInfoService.getByUser(subject);
|
|
|
+ if(addressInfo == null) {
|
|
|
+ addressInfo = new AddressInfo();
|
|
|
+ addressInfo.setRecipients(recipients);
|
|
|
+ addressInfo.setPhone(recipientsPhone);
|
|
|
+ addressInfo.setRegion(recipientsRegion);
|
|
|
+ addressInfo.setDetailAddress(recipientsAddress);
|
|
|
+ addressInfo.setRegUserId(subject);
|
|
|
+ addressInfo.setDelFlag(false);
|
|
|
+ addressInfo.setCreateBy(subject);
|
|
|
+ addressInfo.setCreateTime(new Date());
|
|
|
+ addressInfoService.insert(addressInfo);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ addressInfo.setRecipients(recipients);
|
|
|
+ addressInfo.setPhone(recipientsPhone);
|
|
|
+ addressInfo.setRegion(recipientsRegion);
|
|
|
+ addressInfo.setDetailAddress(recipientsAddress);
|
|
|
+ addressInfo.setUpdateBy(subject);
|
|
|
+ addressInfo.setUpdateTime(new Date());
|
|
|
+ addressInfoService.update(addressInfo);
|
|
|
}
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
}
|
|
|
catch(Exception ex){
|
|
|
logger.error(ex.getMessage(),ex);
|
|
|
@@ -167,6 +190,33 @@ public class WishApi {
|
|
|
return messageResult;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value="地址详情")
|
|
|
+ @RequestMapping(value = "getAddress",method = RequestMethod.POST)
|
|
|
+ public MessageResult<AddressInfo> getAddress(HttpServletRequest request){
|
|
|
+ MessageResult<AddressInfo> msgResult = new MessageResult<>();
|
|
|
+ String subject = (String)request.getAttribute("subject");
|
|
|
+
|
|
|
+ try {
|
|
|
+ AddressInfo addressInfo = addressInfoService.getByUser(subject);
|
|
|
+
|
|
|
+ if (addressInfo != null) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(addressInfo);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("数据库不存在该记录!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
private String getSerialNumber() {
|
|
|
String serialNumber = "";
|
|
|
|