albertshaw 8 anni fa
parent
commit
2592f567be

+ 1 - 1
pom.xml

@@ -170,7 +170,7 @@
 		<dependency>
 			<groupId>mysql</groupId>
 			<artifactId>mysql-connector-java</artifactId>
-			<version>5.1.39</version>
+			<version>5.1.40</version>
 		</dependency>
 
 		<!-- Logging -->

+ 3 - 2
schema/2017-06-09.sql

@@ -6,7 +6,8 @@ CREATE TABLE `value_evaluation` (
   `value` BIGINT(18) NULL COMMENT '评估值',
   `step` INT(2) NULL COMMENT '当前步骤',
   `log` JSON NULL COMMENT '步骤记录',
-  PRIMARY KEY (`id`));
+  PRIMARY KEY (`id`)
+);
 
-ALTER TABLE `aft_dev`.`value_evaluation` 
+ALTER TABLE `value_evaluation` 
 ADD INDEX `uid_index` (`uid` ASC);

File diff suppressed because it is too large
+ 7 - 0
schema/2017-06-12.sql


+ 17 - 0
src/main/java/com/goafanti/common/dao/HtmlFragmentMapper.java

@@ -0,0 +1,17 @@
+package com.goafanti.common.dao;
+
+import com.goafanti.common.model.HtmlFragment;
+
+public interface HtmlFragmentMapper {
+    int deleteByPrimaryKey(String id);
+
+    int insert(HtmlFragment record);
+
+    int insertSelective(HtmlFragment record);
+
+    HtmlFragment selectByPrimaryKey(String id);
+
+    int updateByPrimaryKeySelective(HtmlFragment record);
+
+    int updateByPrimaryKeyWithBLOBs(HtmlFragment record);
+}

+ 65 - 0
src/main/java/com/goafanti/common/mapper/HtmlFragmentMapper.xml

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.goafanti.common.dao.HtmlFragmentMapper">
+  <resultMap id="BaseResultMap" type="com.goafanti.common.model.HtmlFragment">
+    <id column="id" jdbcType="VARCHAR" property="id" />
+  </resultMap>
+  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.goafanti.common.model.HtmlFragment">
+    <result column="content" jdbcType="LONGVARCHAR" property="content" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id
+  </sql>
+  <sql id="Blob_Column_List">
+    content
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
+    select 
+    <include refid="Base_Column_List" />
+    ,
+    <include refid="Blob_Column_List" />
+    from html_fragment
+    where id = #{id,jdbcType=VARCHAR}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+    delete from html_fragment
+    where id = #{id,jdbcType=VARCHAR}
+  </delete>
+  <insert id="insert" parameterType="com.goafanti.common.model.HtmlFragment">
+    insert into html_fragment (id, content)
+    values (#{id,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR})
+  </insert>
+  <insert id="insertSelective" parameterType="com.goafanti.common.model.HtmlFragment">
+    insert into html_fragment
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="content != null">
+        content,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=VARCHAR},
+      </if>
+      <if test="content != null">
+        #{content,jdbcType=LONGVARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.HtmlFragment">
+    update html_fragment
+    <set>
+      <if test="content != null">
+        content = #{content,jdbcType=LONGVARCHAR},
+      </if>
+    </set>
+    where id = #{id,jdbcType=VARCHAR}
+  </update>
+  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.goafanti.common.model.HtmlFragment">
+    update html_fragment
+    set content = #{content,jdbcType=LONGVARCHAR}
+    where id = #{id,jdbcType=VARCHAR}
+  </update>
+</mapper>

+ 0 - 3
src/main/java/com/goafanti/common/mapper/ValueEvaluationMapper.xml

@@ -148,9 +148,6 @@
     <if test="name != null">
       and name = #{name,jdbcType=VARCHAR},
     </if>
-    <if test="page_sql!=null">
-		${page_sql}
-	</if>
   </select>
   
 </mapper>

+ 23 - 0
src/main/java/com/goafanti/common/model/HtmlFragment.java

@@ -0,0 +1,23 @@
+package com.goafanti.common.model;
+
+public class HtmlFragment {
+    private String id;
+
+    private String content;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+}

+ 1 - 0
src/main/java/com/goafanti/core/cache/serializer/FastJsonRedisSerializer.java

@@ -12,6 +12,7 @@ public class FastJsonRedisSerializer implements RedisSerializer<Object> {
 		ParserConfig pc = ParserConfig.getGlobalInstance();
 		pc.addAccept("com.goafanti.common.model.IndustryCategory");
 		pc.addAccept("com.goafanti.common.model.DistrictGlossory");
+		pc.addAccept("com.goafanti.common.model.HtmlFragment");
 	}
 
 	@Override

+ 4 - 3
src/main/java/com/goafanti/evaluation/bo/Step1.java

@@ -23,7 +23,8 @@ public class Step1 {
 	private Integer	timeLeft;
 
 	@NotNull
-	private Integer	transferArea;
+	@Size(max = 100)
+	private String	transferArea;
 
 	@NotNull
 	@Size(max = 36)
@@ -69,11 +70,11 @@ public class Step1 {
 		this.timeLeft = timeLeft;
 	}
 
-	public Integer getTransferArea() {
+	public String getTransferArea() {
 		return transferArea;
 	}
 
-	public void setTransferArea(Integer transferArea) {
+	public void setTransferArea(String transferArea) {
 		this.transferArea = transferArea;
 	}
 

+ 79 - 0
src/main/java/com/goafanti/evaluation/bo/Step2.java

@@ -0,0 +1,79 @@
+package com.goafanti.evaluation.bo;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.NotNull;
+
+public class Step2 {
+	@NotNull
+	@Max(value = 5)
+	private Integer	accessMethod;
+	
+	@NotNull
+	@Max(value = 5)
+	private Integer	legalStatus;
+	
+	@NotNull
+	@Max(value = 5)
+	private Integer	patentMaintenance;
+	
+	@NotNull
+	@Max(value = 5)
+	private Integer	confidentiality;
+	
+	@NotNull
+	@Max(value = 5)
+	private Integer	decidability;
+	
+	@NotNull
+	@Max(value = 5)
+	private Integer	hasRightLimitation;
+
+	public Integer getAccessMethod() {
+		return accessMethod;
+	}
+
+	public void setAccessMethod(Integer accessMethod) {
+		this.accessMethod = accessMethod;
+	}
+
+	public Integer getLegalStatus() {
+		return legalStatus;
+	}
+
+	public void setLegalStatus(Integer legalStatus) {
+		this.legalStatus = legalStatus;
+	}
+
+	public Integer getPatentMaintenance() {
+		return patentMaintenance;
+	}
+
+	public void setPatentMaintenance(Integer patentMaintenance) {
+		this.patentMaintenance = patentMaintenance;
+	}
+
+	public Integer getConfidentiality() {
+		return confidentiality;
+	}
+
+	public void setConfidentiality(Integer confidentiality) {
+		this.confidentiality = confidentiality;
+	}
+
+	public Integer getDecidability() {
+		return decidability;
+	}
+
+	public void setDecidability(Integer decidability) {
+		this.decidability = decidability;
+	}
+
+	public Integer getHasRightLimitation() {
+		return hasRightLimitation;
+	}
+
+	public void setHasRightLimitation(Integer hasRightLimitation) {
+		this.hasRightLimitation = hasRightLimitation;
+	}
+
+}

+ 26 - 6
src/main/java/com/goafanti/evaluation/controller/EvaluationController.java

@@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.Assert;
 import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
@@ -21,6 +22,7 @@ import com.goafanti.common.model.ValueEvaluation;
 import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.evaluation.bo.Step1;
+import com.goafanti.evaluation.bo.Step2;
 import com.goafanti.evaluation.service.ValueEvaluationService;
 
 @RestController
@@ -32,14 +34,14 @@ public class EvaluationController extends BaseApiController {
 	@Autowired
 	ValueEvaluationService		valueEvaluationService;
 
-	@RequestMapping(value = "/create", method = RequestMethod.POST)
+	@RequestMapping(value = "/create", method = RequestMethod.GET)
 	public Result create() {
 		ValueEvaluation ve = new ValueEvaluation();
 		ve.setUid(TokenManager.getUserId());
-		ve.setStep(1);
+		ve.setStep(0);
 		ve.setLog("{}");
 		valueEvaluationService.insert(ve);
-		return new Result(ve.getId());
+		return new Result(ve.getId().toString());
 	}
 
 	@RequestMapping(value = "/list", method = RequestMethod.GET)
@@ -47,14 +49,14 @@ public class EvaluationController extends BaseApiController {
 		return new Result().data(valueEvaluationService.list(handlePageNo(pageNo), handlePageSize(pageSize)));
 	}
 
-	@RequestMapping(value = "/info", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
-	public String info(String id) {
+	@RequestMapping(value = "/info/{id}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
+	public String info(@PathVariable String id) {
 		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
 		return valueEvaluationService.getMyEvaluationSteps(Long.valueOf(id));
 	}
 
 	@RequestMapping(value = "/step1", method = RequestMethod.POST)
-	public Result update(String id, @Valid Step1 data, BindingResult bindingResult) {
+	public Result step1(String id, @Valid Step1 data, BindingResult bindingResult) {
 		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
 		Result res = new Result();
 		if (handleBindingError(res, bindingResult)) {
@@ -63,6 +65,24 @@ public class EvaluationController extends BaseApiController {
 		ValueEvaluation ve = valueEvaluationService.getEvaluation(Long.valueOf(id));
 		Assert.notNull(ve, ErrorConstants.EVALUATE_ID);
 		ve.setName(data.getName());
+		ve.setStep(1);
+		JSONObject jo = JSON.parseObject(ve.getLog());
+		jo.put("0", data);
+		ve.setLog(jo.toJSONString());
+		res.data(valueEvaluationService.update(ve));
+		return res;
+	}
+	
+	@RequestMapping(value = "/step2", method = RequestMethod.POST)
+	public Result step2(String id, @Valid Step2 data, BindingResult bindingResult) {
+		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
+		Result res = new Result();
+		if (handleBindingError(res, bindingResult)) {
+			return res;
+		}
+		ValueEvaluation ve = valueEvaluationService.getEvaluation(Long.valueOf(id));
+		Assert.notNull(ve, ErrorConstants.EVALUATE_ID);
+		ve.setStep(2);
 		JSONObject jo = JSON.parseObject(ve.getLog());
 		jo.put("1", data);
 		ve.setLog(jo.toJSONString());

+ 1 - 1
src/main/java/com/goafanti/evaluation/service/ValueEvaluationService.java

@@ -41,7 +41,7 @@ public class ValueEvaluationService extends BaseMybatisDao<ValueEvaluationMapper
 		params.put("uid", TokenManager.getUserId());
 		params.put("id", id);
 		ValueEvaluation ve = valueEvaluationMapper.selectByPrimaryKeyAndUser(params);
-		return ve == null ? null : ve.getLog();
+		return ve == null ? "{}" : ve.getLog();
 	}
 
 	@SuppressWarnings("unchecked")

+ 25 - 0
src/main/java/com/goafanti/fragment/controller/FragmentController.java

@@ -0,0 +1,25 @@
+package com.goafanti.fragment.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.controller.BaseApiController;
+import com.goafanti.fragment.service.FragmentService;
+
+@RestController
+@RequestMapping(value = "/open/html/")
+public class FragmentController extends BaseApiController {
+
+	@Autowired
+	FragmentService fragmentService;
+
+	@RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
+	public Result get(@PathVariable String id) {
+		return new Result(fragmentService.selectById("evaluation_announcement"));
+	}
+
+}

+ 22 - 0
src/main/java/com/goafanti/fragment/service/FragmentService.java

@@ -0,0 +1,22 @@
+package com.goafanti.fragment.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.goafanti.common.dao.HtmlFragmentMapper;
+import com.goafanti.common.model.HtmlFragment;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+
+@Service
+@Transactional
+public class FragmentService extends BaseMybatisDao<HtmlFragmentMapper> {
+	@Autowired
+	HtmlFragmentMapper htmlFragmentMapper;
+
+	@Cacheable(value = "HtmlFragmentCache", key = "'HtmlFragment:'+#id")
+	public HtmlFragment selectById(String id) {
+		return htmlFragmentMapper.selectByPrimaryKey(id);
+	}
+}