Antiloveg лет назад: 8
Родитель
Сommit
b1ed572d66

+ 8 - 0
schema/20170725-lectureUser.sql

@@ -0,0 +1,8 @@
+CREATE TABLE `lecture_user` (
+  `lid` BIGINT NOT NULL COMMENT '讲堂ID',
+  `uid` VARCHAR(36) NOT NULL COMMENT '报名人ID',
+  `create_time` DATETIME NULL COMMENT '创建时间(首次咨询时间)',
+  `last_update_time` DATETIME NULL COMMENT '最近一次咨询时间',
+  PRIMARY KEY (`lid`, `uid`))
+ENGINE = InnoDB DEFAULT CHARSET=utf8mb4
+COMMENT = '科技讲堂报名'

+ 40 - 0
src/main/java/com/goafanti/LectureUser/controller/UserLectureUserApiController.java

@@ -0,0 +1,40 @@
+package com.goafanti.LectureUser.controller;
+
+import javax.annotation.Resource;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.goafanti.LectureUser.service.LectureUserService;
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.controller.BaseApiController;
+import com.goafanti.common.model.LectureUser;
+import com.goafanti.common.model.LectureUserKey;
+import com.goafanti.core.shiro.token.TokenManager;
+@RestController
+@RequestMapping(value = "/api/user/lectureUser")
+public class UserLectureUserApiController extends BaseApiController{
+	@Resource
+	private LectureUserService lectureUserService;
+	
+	/**
+	 * 报名
+	 */
+	@RequestMapping(value = "/signUp", method = RequestMethod.POST)
+	public Result signUp(Long lid){
+		Result res = new Result();
+		if (null == lid) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "科技讲堂ID"));
+			return res;
+		}
+		LectureUser au = lectureUserService.selectByPrimaryKey(new LectureUserKey(lid, TokenManager.getUserId()));
+		if (null == au){
+			lectureUserService.save(lid);
+		} else {
+			lectureUserService.update(au);
+		}
+		return res;
+	}
+}

+ 19 - 0
src/main/java/com/goafanti/LectureUser/service/LectureUserService.java

@@ -0,0 +1,19 @@
+package com.goafanti.LectureUser.service;
+
+import java.util.List;
+
+import com.goafanti.common.model.LectureUser;
+import com.goafanti.common.model.LectureUserKey;
+
+public interface LectureUserService {
+
+
+	void save(Long lid);
+
+	int update(LectureUser au);
+
+	int batchDeleteByPrimaryKey(List<String> asList);
+
+	LectureUser selectByPrimaryKey(LectureUserKey lectureUserKey);
+
+}

+ 49 - 0
src/main/java/com/goafanti/LectureUser/service/impl/LectureUserServiceImpl.java

@@ -0,0 +1,49 @@
+package com.goafanti.LectureUser.service.impl;
+
+import java.util.Calendar;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.goafanti.LectureUser.service.LectureUserService;
+import com.goafanti.common.dao.LectureUserMapper;
+import com.goafanti.common.model.LectureUser;
+import com.goafanti.common.model.LectureUserKey;
+import com.goafanti.core.shiro.token.TokenManager;
+
+@Service
+public class LectureUserServiceImpl implements LectureUserService {
+	@Autowired
+	private LectureUserMapper lectureUserMapper;
+
+	@Override
+	public void save(Long lid) {
+		LectureUser lu = new LectureUser();
+		lu.setLid(lid);
+		lu.setUid(TokenManager.getUserId());
+		Calendar now = Calendar.getInstance();
+		now.set(Calendar.MILLISECOND, 0);
+		lu.setCreateTime(now.getTime());
+		lu.setLastUpdateTime(lu.getCreateTime());
+		lectureUserMapper.insert(lu);
+	}
+
+	@Override
+	public int update(LectureUser lu) {
+		Calendar now = Calendar.getInstance();
+		now.set(Calendar.MILLISECOND, 0);
+		lu.setLastUpdateTime(now.getTime());
+		return lectureUserMapper.updateByPrimaryKeySelective(lu);
+	}
+
+	@Override
+	public int batchDeleteByPrimaryKey(List<String> id) {
+		return lectureUserMapper.batchDeleteByPrimaryKey(id);
+	}
+
+	@Override
+	public LectureUser selectByPrimaryKey(LectureUserKey key) {
+		return lectureUserMapper.selectByPrimaryKey(key);
+	}
+}

+ 2 - 1
src/main/java/com/goafanti/activityUser/controller/UserActivityUserApiController.java

@@ -11,6 +11,7 @@ import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseApiController;
 import com.goafanti.common.model.ActivityUser;
+import com.goafanti.common.model.ActivityUserKey;
 import com.goafanti.core.shiro.token.TokenManager;
 
 @RestController
@@ -29,7 +30,7 @@ public class UserActivityUserApiController extends BaseApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "活动ID"));
 			return res;
 		}
-		ActivityUser au = activityUserService.selectByUid(TokenManager.getUserId());
+		ActivityUser au = activityUserService.selectByPrimaryKey(new ActivityUserKey(aid, TokenManager.getUserId()));
 		if (null == au){
 			activityUserService.save(aid);
 		} else {

+ 3 - 0
src/main/java/com/goafanti/activityUser/service/ActivityUserService.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.goafanti.activityUser.bo.ActivityUserListBo;
 import com.goafanti.common.model.ActivityUser;
+import com.goafanti.common.model.ActivityUserKey;
 import com.goafanti.core.mybatis.page.Pagination;
 
 public interface ActivityUserService {
@@ -22,4 +23,6 @@ public interface ActivityUserService {
 
 	int batchDeleteByPrimaryKey(List<String> asList);
 
+	ActivityUser selectByPrimaryKey(ActivityUserKey key);
+
 }

+ 6 - 0
src/main/java/com/goafanti/activityUser/service/impl/ActivityUserServiceImpl.java

@@ -12,6 +12,7 @@ import com.goafanti.activityUser.bo.ActivityUserListBo;
 import com.goafanti.activityUser.service.ActivityUserService;
 import com.goafanti.common.dao.ActivityUserMapper;
 import com.goafanti.common.model.ActivityUser;
+import com.goafanti.common.model.ActivityUserKey;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
@@ -111,4 +112,9 @@ public class ActivityUserServiceImpl extends BaseMybatisDao<ActivityUserMapper>
 		return activityUserMapper.batchDeleteByPrimaryKey(id);
 	}
 
+	@Override
+	public ActivityUser selectByPrimaryKey(ActivityUserKey key) {
+		return activityUserMapper.selectByPrimaryKey(key);
+	}
+
 }

+ 77 - 0
src/main/java/com/goafanti/admin/controller/AdminLectureUserApiController.java

@@ -0,0 +1,77 @@
+package com.goafanti.admin.controller;
+
+import java.util.Arrays;
+
+import javax.annotation.Resource;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.goafanti.LectureUser.service.LectureUserService;
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.controller.BaseApiController;
+import com.goafanti.common.utils.StringUtils;
+
+@RestController
+@RequestMapping(value = "/api/admin/lectureUser")
+public class AdminLectureUserApiController extends BaseApiController{
+	@Resource
+	private LectureUserService lectureUserService;
+
+	/**
+	 * 科技讲堂个人用户报名列表
+	 */
+	@RequestMapping(value = "/userList", method = RequestMethod.GET)
+	public Result activityUserList(String lectureName, String mobile, String username, Integer number, String pageSize,
+			String pageNo) {
+		Result res = new Result();
+		res.setData(lectureUserService.listLectureUser(lectureName, mobile, username, number, getPSize(pageSize),
+				getPNo(pageNo)));
+		return res;
+	}
+
+	/**
+	 * 科技讲堂组织用户报名列表
+	 */
+	@RequestMapping(value = "/orgList", method = RequestMethod.GET)
+	public Result activityOrgList(String lectureName, String mobile, String unitName, Integer number, String pageSize,
+			String pageNo) {
+		Result res = new Result();
+		res.setData(lectureUserService.listLectureOrg(lectureName, mobile, unitName, number, getPSize(pageSize),
+				getPNo(pageNo)));
+		return res;
+	}
+
+	/**
+	 * 批量删除活动报名记录
+	 */
+	@RequestMapping(value = "/delete", method = RequestMethod.POST)
+	public Result delete(@RequestParam(name = "ids[]", required = false) String[] ids) {
+		Result res = new Result();
+		if (ids == null || ids.length < 1) {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
+		} else {
+			res.setData(lectureUserService.batchDeleteByPrimaryKey(Arrays.asList(ids)));
+		}
+		return res;
+	}
+
+	private Integer getPNo(String pageNo) {
+		Integer pNo = 1;
+		if (StringUtils.isNumeric(pageNo)) {
+			pNo = Integer.parseInt(pageNo);
+		}
+		return pNo;
+	}
+
+	private Integer getPSize(String pageSize) {
+		Integer pSize = 10;
+		if (StringUtils.isNumeric(pageSize)) {
+			pSize = Integer.parseInt(pageSize);
+		}
+		return pSize;
+	}
+}

+ 24 - 0
src/main/java/com/goafanti/common/dao/LectureUserMapper.java

@@ -0,0 +1,24 @@
+package com.goafanti.common.dao;
+
+import java.util.List;
+
+import com.goafanti.common.model.LectureUser;
+import com.goafanti.common.model.LectureUserKey;
+
+public interface LectureUserMapper {
+    int deleteByPrimaryKey(LectureUserKey key);
+
+    int insert(LectureUser record);
+
+    int insertSelective(LectureUser record);
+
+    LectureUser selectByPrimaryKey(LectureUserKey key);
+
+    int updateByPrimaryKeySelective(LectureUser record);
+
+    int updateByPrimaryKey(LectureUser record);
+
+	LectureUser selectByUid(String uid);
+
+	int batchDeleteByPrimaryKey(List<String> id);
+}

+ 92 - 0
src/main/java/com/goafanti/common/mapper/LectureUserMapper.xml

@@ -0,0 +1,92 @@
+<?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.LectureUserMapper" >
+  <resultMap id="BaseResultMap" type="com.goafanti.common.model.LectureUser" >
+    <id column="lid" property="lid" jdbcType="BIGINT" />
+    <id column="uid" property="uid" jdbcType="VARCHAR" />
+    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
+    <result column="last_update_time" property="lastUpdateTime" jdbcType="TIMESTAMP" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    lid, uid, create_time, last_update_time
+  </sql>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="com.goafanti.common.model.LectureUserKey" >
+    select 
+    <include refid="Base_Column_List" />
+    from lecture_user
+    where lid = #{lid,jdbcType=BIGINT}
+      and uid = #{uid,jdbcType=VARCHAR}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="com.goafanti.common.model.LectureUserKey" >
+    delete from lecture_user
+    where lid = #{lid,jdbcType=BIGINT}
+      and uid = #{uid,jdbcType=VARCHAR}
+  </delete>
+  <insert id="insert" parameterType="com.goafanti.common.model.LectureUser" >
+    insert into lecture_user (lid, uid, create_time, 
+      last_update_time)
+    values (#{lid,jdbcType=BIGINT}, #{uid,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{lastUpdateTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.goafanti.common.model.LectureUser" >
+    insert into lecture_user
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="lid != null" >
+        lid,
+      </if>
+      <if test="uid != null" >
+        uid,
+      </if>
+      <if test="createTime != null" >
+        create_time,
+      </if>
+      <if test="lastUpdateTime != null" >
+        last_update_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="lid != null" >
+        #{lid,jdbcType=BIGINT},
+      </if>
+      <if test="uid != null" >
+        #{uid,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="lastUpdateTime != null" >
+        #{lastUpdateTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.LectureUser" >
+    update lecture_user
+    <set >
+      <if test="createTime != null" >
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="lastUpdateTime != null" >
+        last_update_time = #{lastUpdateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where lid = #{lid,jdbcType=BIGINT}
+      and uid = #{uid,jdbcType=VARCHAR}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.LectureUser" >
+    update lecture_user
+    set create_time = #{createTime,jdbcType=TIMESTAMP},
+      last_update_time = #{lastUpdateTime,jdbcType=TIMESTAMP}
+    where lid = #{lid,jdbcType=BIGINT}
+      and uid = #{uid,jdbcType=VARCHAR}
+  </update>
+  
+   <delete id="batchDeleteByPrimaryKey" parameterType="java.util.List">
+  	delete
+  		from activity_user
+  	where id in
+  	<foreach item="item" index="index" collection="list" open="("
+			separator="," close=")">
+			#{item}
+	</foreach>
+  </delete>
+</mapper>

+ 9 - 0
src/main/java/com/goafanti/common/model/ActivityUserKey.java

@@ -10,6 +10,15 @@ public class ActivityUserKey {
     * 用户ID
     */
     private String uid;
+    
+    public ActivityUserKey(){
+    	
+    }
+    
+    public ActivityUserKey(Long aid, String uid){
+    	this.aid = aid;
+    	this.uid = uid;
+    }
 
     public Long getAid() {
         return aid;

+ 31 - 0
src/main/java/com/goafanti/common/model/LectureUser.java

@@ -0,0 +1,31 @@
+package com.goafanti.common.model;
+
+import java.util.Date;
+
+public class LectureUser extends LectureUserKey {
+    /**
+    * 创建时间(首次咨询时间)
+    */
+    private Date createTime;
+
+    /**
+    * 最近一次咨询时间
+    */
+    private Date lastUpdateTime;
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getLastUpdateTime() {
+        return lastUpdateTime;
+    }
+
+    public void setLastUpdateTime(Date lastUpdateTime) {
+        this.lastUpdateTime = lastUpdateTime;
+    }
+}

+ 38 - 0
src/main/java/com/goafanti/common/model/LectureUserKey.java

@@ -0,0 +1,38 @@
+package com.goafanti.common.model;
+
+public class LectureUserKey {
+	/**
+	 * 讲堂ID
+	 */
+	private Long	lid;
+
+	/**
+	 * 报名人ID
+	 */
+	private String	uid;
+
+	public LectureUserKey() {
+
+	}
+
+	public LectureUserKey(Long lid, String uid) {
+		this.lid = lid;
+		this.uid = uid;
+	}
+
+	public Long getLid() {
+		return lid;
+	}
+
+	public void setLid(Long lid) {
+		this.lid = lid;
+	}
+
+	public String getUid() {
+		return uid;
+	}
+
+	public void setUid(String uid) {
+		this.uid = uid;
+	}
+}