Parcourir la source

店铺增加ip记录

Hu Jie il y a 7 ans
Parent
commit
84e6cba416

+ 3 - 2
src/main/java/com/uas/platform/b2c/prod/store/controller/StoreApplyController.java

@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.servlet.ModelAndView;
 
+import javax.servlet.http.HttpServletRequest;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
@@ -58,9 +59,9 @@ public class StoreApplyController {
 	 * @param shop 店铺信息
 	 */
 	@RequestMapping(value = "/applications", method = RequestMethod.POST)
-	public ResultMap applyShop(@RequestBody StoreApply shop) {
+	public ResultMap applyShop(@RequestBody StoreApply shop, HttpServletRequest request) {
 		logger.info("Someone supporter apply for to open one store.");
-		return storeApplyService.applyShop(shop);
+		return storeApplyService.applyShop(request, shop);
 	}
 
 	/**

+ 11 - 0
src/main/java/com/uas/platform/b2c/prod/store/model/StoreApply.java

@@ -181,6 +181,9 @@ public class StoreApply {
 	@Column(name = "apply_qualifications", length = 4000,columnDefinition="TEXT")
 	private String qualificationsJson;
 
+	@Column(name = "apply_ip_address")
+	private String ipAddress;
+
 	/**
 	 * 资质信息列表
 	 */
@@ -203,6 +206,14 @@ public class StoreApply {
 	public StoreApply() {
 	}
 
+	public String getIpAddress() {
+		return ipAddress;
+	}
+
+	public void setIpAddress(String ipAddress) {
+		this.ipAddress = ipAddress;
+	}
+
 	public String getFinalPerson() {
 		return finalPerson;
 	}

+ 2 - 1
src/main/java/com/uas/platform/b2c/prod/store/service/StoreApplyService.java

@@ -9,6 +9,7 @@ import com.uas.platform.core.model.PageInfo;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.Date;
 import java.util.List;
 
@@ -25,7 +26,7 @@ public interface StoreApplyService {
 	 *
 	 * @param storeApply	店铺信息
 	 */
-	ResultMap applyShop(StoreApply storeApply);
+	ResultMap applyShop(HttpServletRequest request, StoreApply storeApply);
 
 	/**
 	 * 获取所有待审批的店铺申请信息

+ 7 - 1
src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreApplyServiceImpl.java

@@ -26,6 +26,7 @@ import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.persistence.criteria.CriterionExpression;
 import com.uas.platform.core.persistence.criteria.LogicalExpression;
 import com.uas.platform.core.persistence.criteria.SimpleExpression;
+import com.uas.platform.core.util.AgentUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
@@ -39,6 +40,7 @@ import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
+import javax.servlet.http.HttpServletRequest;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
@@ -62,6 +64,7 @@ public class StoreApplyServiceImpl implements StoreApplyService {
 
 	private final CommonDao commonDao;
 
+
 	@Autowired
 	public StoreApplyServiceImpl(StoreApplyDao storeApplyDao, EnterpriseDao enterpriseDao, StoreInService storeInService,
 								 StoreBrandInfoDao brandInfoDao, CommonDao commonDao) {
@@ -74,7 +77,7 @@ public class StoreApplyServiceImpl implements StoreApplyService {
 
 	@Override
 	@Transactional
-	public ResultMap applyShop(StoreApply storeApply) {
+	public ResultMap applyShop(HttpServletRequest request, StoreApply storeApply) {
 		// 验证开铺申请信息
 		if (storeApply == null || storeApply.getType() == null || CollectionUtils.isEmpty(storeApply.getQualifications())) {
 			return new ResultMap(CodeType.NO_INFO, "请提交完整开铺申请信息");
@@ -147,6 +150,9 @@ public class StoreApplyServiceImpl implements StoreApplyService {
 		EnterpriseSimple enterpriseSimple = EnterpriseSimple.translateSimple(enterprise);
 		storeApply.setEnterprise(enterpriseSimple);
 
+		String ip = AgentUtils.getIp(request);
+		storeApply.setIpAddress(ip);
+
 		// 更新资质信息
 		List<Qualification> qualifications = storeApply.getQualifications();
 		for (Qualification qualification : qualifications) {