Antiloveg 8 years ago
parent
commit
1459ef80ff

+ 21 - 0
src/main/java/com/goafanti/admin/controller/AdminLectureApiController.java

@@ -3,6 +3,7 @@ package com.goafanti.admin.controller;
 import java.util.Arrays;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import javax.validation.Valid;
 
 import org.apache.commons.lang3.StringUtils;
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseApiController;
+import com.goafanti.common.enums.AttachmentType;
 import com.goafanti.common.enums.PatentInfoFields;
 import com.goafanti.common.model.Lecture;
 import com.goafanti.lecture.bo.InputLecture;
@@ -132,4 +134,23 @@ public class AdminLectureApiController extends BaseApiController {
 		res.setData(lectureService.listLecture(uid, username, name, startLectureTime, endLectureTime, pNo, pSize));
 		return res;
 	}
+
+	/**
+	 * 科技讲堂图片上传
+	 */
+	@RequestMapping(value = "/upload", method = RequestMethod.POST)
+	public Result upload(HttpServletRequest req, String sign, String uid) {
+		Result res = new Result();
+		if (StringUtils.isBlank(uid)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "讲堂开展人ID"));
+			return res;
+		}
+		AttachmentType attachmentType = AttachmentType.getField(sign);
+		if (attachmentType == AttachmentType.LECTURE_PICTURE) {
+			res.setData(handleFiles(res, "/lecture/", false, req, sign, uid));
+		} else {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
+		}
+		return res;
+	}
 }

+ 1 - 1
src/main/java/com/goafanti/common/enums/AttachmentType.java

@@ -21,7 +21,7 @@ public enum AttachmentType {
 	ACHIEVEMENT_TECH_PLAN("achievement_tech_plan", "科技成果技术方案文件"),
 	ACHIEVEMENT_BUSINESS_PLAN("achievement_business_plan", "科技成果商业计划书"),
 	DEMAND_TEMPLATE("demand_template", "科技需求批量导入模板"), ACHIEVEMENT_TEMPLATE("achievement_template", "科技成果批量导入模板"), 
-	DEMAND_ORDER_FILE("demand_order_file", "科技需求意向单/交易单附件")
+	DEMAND_ORDER_FILE("demand_order_file", "科技需求意向单/交易单附件"), LECTURE_PICTURE("lecture_picture","科技讲堂展示图片")
 	;
 
 	private AttachmentType(String code, String desc) {

+ 16 - 4
src/main/java/com/goafanti/common/mapper/LectureMapper.xml

@@ -10,9 +10,10 @@
     <result column="name" property="name" jdbcType="VARCHAR" />
     <result column="summary" property="summary" jdbcType="VARCHAR" />
     <result column="deleted_sign" property="deletedSign" jdbcType="INTEGER" />
+    <result column="lecture_url" property="lectureUrl" jdbcType="VARCHAR" />
   </resultMap>
   <sql id="Base_Column_List" >
-    id, uid, lecture_time, create_time, last_update_time, name, summary, deleted_sign
+    id, uid, lecture_time, create_time, last_update_time, name, summary, deleted_sign, lecture_url
   </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
     select 
@@ -27,10 +28,10 @@
   <insert id="insert" parameterType="com.goafanti.common.model.Lecture" >
     insert into lecture (id, uid, lecture_time, 
       create_time, last_update_time, name, 
-      summary, deleted_sign)
+      summary, deleted_sign, lecture_url)
     values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{lectureTime,jdbcType=TIMESTAMP}, 
       #{createTime,jdbcType=TIMESTAMP}, #{lastUpdateTime,jdbcType=TIMESTAMP}, #{name,jdbcType=VARCHAR}, 
-      #{summary,jdbcType=VARCHAR}, #{deletedSign,jdbcType=INTEGER})
+      #{summary,jdbcType=VARCHAR}, #{deletedSign,jdbcType=INTEGER}, #{lectureUrl,jdbcType=VARCHAR})
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.Lecture" >
     insert into lecture
@@ -59,6 +60,9 @@
       <if test="deletedSign != null" >
         deleted_sign,
       </if>
+       <if test="lectureUrl != null" >
+        lecture_url,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides="," >
       <if test="id != null" >
@@ -85,6 +89,9 @@
       <if test="deletedSign != null" >
         #{deletedSign,jdbcType=INTEGER},
       </if>
+       <if test="lectureUrl != null" >
+        #{lectureUrl,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Lecture" >
@@ -111,6 +118,9 @@
       <if test="deletedSign != null" >
         deleted_sign = #{deletedSign,jdbcType=INTEGER},
       </if>
+       <if test="lectureUrl != null" >
+        lecture_url = #{lectureUrl,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -122,7 +132,8 @@
       last_update_time = #{lastUpdateTime,jdbcType=TIMESTAMP},
       name = #{name,jdbcType=VARCHAR},
       summary = #{summary,jdbcType=VARCHAR},
-      deleted_sign = #{deletedSign,jdbcType=INTEGER}
+      deleted_sign = #{deletedSign,jdbcType=INTEGER},
+      lecture_url = #{lectureUrl,jdbcType=VARCHAR}
     where id = #{id,jdbcType=VARCHAR}
   </update>
   
@@ -142,6 +153,7 @@
 	  		l.name,
 	  		l.lecture_time as lectureTime,
 	  		l.summary,
+	  		l.lecture_url as lectureUrl,
 	  		ui.username 
 	  	from lecture l
 	  	left join  user_identity ui on ui.uid = l.uid

+ 13 - 0
src/main/java/com/goafanti/common/model/Lecture.java

@@ -45,6 +45,11 @@ public class Lecture {
 	 */
 	private Integer	deletedSign;
 
+	/**
+	 * 展示图URL
+	 */
+	private String	lectureUrl;
+
 	public String getId() {
 		return id;
 	}
@@ -112,6 +117,14 @@ public class Lecture {
 		this.deletedSign = deletedSign;
 	}
 
+	public String getLectureUrl() {
+		return lectureUrl;
+	}
+
+	public void setLectureUrl(String lectureUrl) {
+		this.lectureUrl = lectureUrl;
+	}
+
 	public String getLectureTimeFormattedDate() {
 		if (this.lectureTime == null) {
 			return null;

+ 2 - 1
src/main/java/com/goafanti/common/utils/FileUtils.java

@@ -104,7 +104,8 @@ public class FileUtils {
 				|| sign.indexOf("patent_certificate") != -1 || sign.indexOf("standard") != -1
 				|| sign.indexOf("demand_picture") != -1 || sign.indexOf("demand_text_file") != -1
 				|| sign.indexOf("achievement_technical_picture") != -1
-				|| sign.indexOf("achievement_maturity_picture") != -1 || sign.indexOf("demand_order_file") != -1) {
+				|| sign.indexOf("achievement_maturity_picture") != -1 || sign.indexOf("demand_order_file") != -1
+				|| sign.indexOf("lecture_picture") != -1) {
 			uniq = true;
 		}
 		String fileName = "";

+ 13 - 0
src/main/java/com/goafanti/lecture/bo/InputLecture.java

@@ -7,14 +7,19 @@ import com.goafanti.common.constant.ErrorConstants;
 public class InputLecture {
 	@Size(min = 0, max = 36, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	id;
+
 	@Size(min = 0, max = 36, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	uid;
 
 	@Size(min = 0, max = 45, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	name;
+
 	@Size(min = 0, max = 128, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	describe;
 
+	@Size(min = 0, max = 255, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	lectureUrl;
+
 	public String getId() {
 		return id;
 	}
@@ -47,4 +52,12 @@ public class InputLecture {
 		this.describe = describe;
 	}
 
+	public String getLectureUrl() {
+		return lectureUrl;
+	}
+
+	public void setLectureUrl(String lectureUrl) {
+		this.lectureUrl = lectureUrl;
+	}
+
 }