Explorar el Código

企业双百强功能

xiao547607 hace 4 años
padre
commit
8455e9d30d

+ 2 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/entity/DoubleHundred.java

@@ -44,4 +44,6 @@ public class DoubleHundred {
     private Date updateTime;
         @ApiModelProperty(value = "是否删除")
     private Boolean delFlag;
+    @ApiModelProperty(value = "openId")
+    private String openId;
 }

+ 7 - 1
common/src/main/resources/mapper/base/DoubleHundred.xml

@@ -16,6 +16,7 @@
 			<result property="updateBy" column="update_by" />
 			<result property="updateTime" column="update_time" />
 			<result property="delFlag" column="del_flag" />
+			<result property="openId" column="open_id" />
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.enterprise.modules.base.entity.DoubleHundred">
 	<!--
@@ -25,7 +26,8 @@
 	-->
 	<![CDATA[
 		insert into base_double_hundred
-	    (id_,information_,person_,phone_,introduction_,income_,pay_taxes,create_by,create_time,update_by,update_time,del_flag)
+	    (id_,information_,person_,phone_,introduction_,income_,pay_taxes,create_by,create_time,update_by,update_time,del_flag,
+	    open_id)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -40,6 +42,7 @@
 ,#{updateBy,jdbcType=VARCHAR}
 ,#{updateTime,jdbcType= TIMESTAMP }
 ,#{delFlag,jdbcType= NUMERIC }
+,#{openId,jdbcType=VARCHAR}
 		)
 	]]>
 	</insert>
@@ -82,6 +85,9 @@
 				<if test="delFlag!=null">
 		del_flag=#{delFlag,jdbcType= NUMERIC },
 		</if>
+			<if test="openId!=null">
+				open_id=#{openId,jdbcType=VARCHAR},
+			</if>
 		</set>
 	where id_=#{id}
 	</update>

+ 22 - 3
web/src/main/java/com/jpsoft/enterprise/modules/mobile/controller/DoubleHundredApiController.java

@@ -11,9 +11,11 @@ import lombok.extern.slf4j.Slf4j;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 
 /**
  企业双百强
@@ -28,9 +30,11 @@ public class DoubleHundredApiController {
 
     @Autowired
     private DoubleHundredService doubleHundredService;
+    @Autowired
+    private ValueOperations<String, Object> valueOperations;
 
     @PostMapping("submitInformation")
-    @ApiOperation(value = "个人互助信息提交")
+    @ApiOperation(value = "个人互助信息提交(开放)")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "information", value = "企业信息", required = true, paramType = "form"),
             @ApiImplicitParam(name = "person", value = "联系人", required = true, paramType = "form"),
@@ -38,7 +42,8 @@ public class DoubleHundredApiController {
             @ApiImplicitParam(name = "introduction", value = "企业介绍", required = true, paramType = "form"),
             @ApiImplicitParam(name = "income", value = "收入", required = true, paramType = "form"),
             @ApiImplicitParam(name = "payTaxes", value = "纳税", required = true, paramType = "form"),
-            @ApiImplicitParam(name = "personId", value = "提交用户ID(没有则不传)", paramType = "form")
+            @ApiImplicitParam(name = "personId", value = "提交用户ID(没有则不传)", paramType = "form"),
+            @ApiImplicitParam(name = "openId", value = "openId", paramType = "form"),
     })
     public MessageResult<Map> submitInformation(
             @RequestParam(value="information",defaultValue="") String information,
@@ -47,9 +52,20 @@ public class DoubleHundredApiController {
             @RequestParam(value="introduction",defaultValue="") String introduction,
             @RequestParam(value="income",defaultValue="") String income,
             @RequestParam(value="payTaxes",defaultValue="") String payTaxes,
-            @RequestParam(value="personId",defaultValue="") String personId) {
+            @RequestParam(value="personId",defaultValue="") String personId,
+            @RequestParam(value="openId",defaultValue="") String openId) {
         MessageResult<Map> messageResult = new MessageResult<>();
         try {
+
+            String key = "personInfo_register_" + phone;
+
+            //5秒内不能重复提交
+            boolean lockSuccess = valueOperations.setIfAbsent(key, true, 5, TimeUnit.SECONDS);
+
+            if (!lockSuccess) {
+                throw new Exception("操作过于频繁!");
+            }
+
             DoubleHundred dh = new DoubleHundred();
             dh.setId(UUID.randomUUID().toString());
             dh.setInformation(information);
@@ -61,6 +77,9 @@ public class DoubleHundredApiController {
             if(StringUtils.isNotEmpty(personId)) {
                 dh.setCreateBy(personId);
             }
+            if(StringUtils.isNotEmpty(openId)) {
+                dh.setOpenId(openId);
+            }
             dh.setCreateTime(new Date());
             dh.setDelFlag(false);
             int num = doubleHundredService.insert(dh);