Commit 0f507251 by 魏文甫

Merge branch 'wei_master' into '105'

init

See merge request !3
2 parents cb29f19e 40b6c3ee
package com.server.utils;
import java.util.HashMap;
import java.util.Map;
/**
* Created by weiwenfu@163.com on 2019/5/17 上午 11:28.
*/
public class ResultMapUtil {
public static Map<String,Object> returnMap(String status, String message, Object object){
Map<String,Object> resultMap = new HashMap<>();
resultMap.put("status",status);
resultMap.put("message",message);
resultMap.put("data",object);
return resultMap;
}
}
package com.server.web.common.mapping;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Created by weiwenfu@163.com on 2020/3/12 下午 4:41.
*/
public interface InformationMapper {
List<Map<String, Object>> categoryDetail(@Param("firstId") Long id);
List<Map<String, Object>> secondClassDetailInformation(Map<String,Object> param);
List<Map<String, Object>> secondClassDetailCourse(Map<String,Object> param);
}
package com.server.web.common.service.Impl;
import com.server.web.common.mapper.TBaseBannerMapper;
import com.server.web.common.mapper.TBaseFirstClassMapper;
import com.server.web.common.mapping.InformationMapper;
import com.server.web.common.model.TBaseBanner;
import com.server.web.common.model.TBaseBannerExample;
import com.server.web.common.model.TBaseFirstClass;
import com.server.web.common.model.TBaseFirstClassExample;
import com.server.web.common.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.server.utils.ResultMapUtil.returnMap;
/**
* Created by weiwenfu@163.com on 2018/12/12 下午 3:05.
*/
......@@ -19,6 +26,10 @@ public class IndexServiceImpl implements IndexService {
@Autowired
private TBaseBannerMapper tBaseBannerMapper;
@Autowired
private TBaseFirstClassMapper tBaseFirstClassMapper;
@Autowired
private InformationMapper informationMapper;
@Override
public Map<String, Object> banner() {
......@@ -26,10 +37,45 @@ public class IndexServiceImpl implements IndexService {
tBaseBannerExample.createCriteria().andIsUpEqualTo(1).andIsDeleteEqualTo(0);
tBaseBannerExample.setOrderByClause(" weight desc ");
List<TBaseBanner> list = tBaseBannerMapper.selectByExample(tBaseBannerExample);
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("status", "1");
resultMap.put("message", "");
resultMap.put("data", list);
return resultMap;
return returnMap("1", "", list);
}
/**
* 首页分类
*
* @return
*/
@Override
public Map<String, Object> categoryList() {
TBaseFirstClassExample tBaseFirstClassExample = new TBaseFirstClassExample();
tBaseFirstClassExample.setOrderByClause(" weight desc");
tBaseFirstClassExample.createCriteria().andStatusEqualTo(1);
List<TBaseFirstClass> list = tBaseFirstClassMapper.selectByExample(tBaseFirstClassExample);
return returnMap("1", "", list);
}
/**
* 首页分类+两条资讯
*
* @return
*/
@Override
public Map<String, Object> categoryDetail() {
TBaseFirstClassExample tBaseFirstClassExample = new TBaseFirstClassExample();
tBaseFirstClassExample.setOrderByClause(" weight desc");
tBaseFirstClassExample.createCriteria().andStatusEqualTo(1);
List<TBaseFirstClass> list = tBaseFirstClassMapper.selectByExample(tBaseFirstClassExample);
List<Map<String, Object>> resultList = new ArrayList<>();
Map<String, Object> flagMap = null;
for (TBaseFirstClass tBaseFirstClass : list) {
flagMap = new HashMap<String, Object>();
flagMap.put("className", tBaseFirstClass.getClassName());
List<Map<String, Object>> list2 = informationMapper.categoryDetail(tBaseFirstClass.getId());
flagMap.put("informationList", list2);
resultList.add(flagMap);
}
return returnMap("1", "", resultList);
}
}
package com.server.web.common.service.Impl;
import com.server.utils.ResultMapUtil;
import com.server.web.common.mapper.TBaseSecondClassMapper;
import com.server.web.common.mapper.TKzyInformationMapper;
import com.server.web.common.mapping.InformationMapper;
import com.server.web.common.model.TBaseSecondClass;
import com.server.web.common.model.TBaseSecondClassExample;
import com.server.web.common.model.TKzyInformation;
import com.server.web.common.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by weiwenfu@163.com on 2020/3/12 下午 4:54.
*/
@Service
public class InformationServiceImpl implements InformationService {
@Autowired
private InformationMapper informationMapper;
@Autowired
private TKzyInformationMapper tKzyInformationMapper;
@Autowired
private TBaseSecondClassMapper tBaseSecondClassMapper;
@Override
public Map<String, Object> secondClassList(Long firstId) {
TBaseSecondClassExample tBaseSecondClassExample = new TBaseSecondClassExample();
tBaseSecondClassExample.createCriteria().andFirstIdEqualTo(firstId).andStatusEqualTo(1);
List<TBaseSecondClass> list = tBaseSecondClassMapper.selectByExample(tBaseSecondClassExample);
return ResultMapUtil.returnMap("1", "", list);
}
/**
* 二级分类详情
*
* @param secondId
* @return
*/
@Override
public Map<String, Object> secondClassDetail(Long secondId, Integer pageNo, Integer pageSize) {
TBaseSecondClass tBaseSecondClass = tBaseSecondClassMapper.selectByPrimaryKey(secondId);
List<Map<String, Object>> list = null;
Map<String, Object> param = new HashMap<String, Object>();
param.put("start", (pageNo - 1) * pageSize);
param.put("pageSize", pageSize);
param.put("secondId", secondId);
if (tBaseSecondClass.getType() == 1) {
list = informationMapper.secondClassDetailInformation(param);
} else {
list = informationMapper.secondClassDetailCourse(param);
}
return ResultMapUtil.returnMap("1", "", list);
}
/**
* 详情
*
* @param informationId
* @return
*/
@Override
public Map<String, Object> informationDetail(Long informationId) {
TKzyInformation tKzyInformation = tKzyInformationMapper.selectByPrimaryKey(informationId);
return ResultMapUtil.returnMap("1", "", tKzyInformation);
}
}
......@@ -235,20 +235,6 @@ public class TKzyCourseServiceImpl implements TKzyCourseService {
}
}
public static void main(String[] args) {
/*Map<String,Object> courseMap = new HashMap<>();
courseMap.put("startTime",new Date());
courseMap.put("courseName","韌帶撕裂韌帶撕裂韌帶撕裂韌帶撕裂韌帶撕裂韌帶撕裂韌帶撕裂韌帶撕裂韌帶撕裂韌帶撕裂");
Map<String,Object> _UserMap = new HashMap<>();
_UserMap.put("headPhoto","http://thirdwx.qlogo.cn/mmopen/vi_32/H8OKNDmtqnWeV59hyuExZkun00eQJa07YvS6aCmpXhoCrYlcTtCOBY4iaSsKccAF6J2qJaz2Q2zrLAdtdZUBhag/132");
String courseUrl = "http://yxvzb.b0.upaiyun.com/images/1544683416876.PNG";//generateQrCodeByUrl("http://wx.yxvzb.com/html/newWechat.html#/liveDetail/"+12+"?visiterId="+10);
String posterUrl = generateCourseInvitePoseterNew(TEMPLATE_RRKDB_COURSE_TEMPLATE,courseUrl,courseMap,_UserMap);
System.out.println("||||"+posterUrl);*/
}
/**
* 评论
*
......
......@@ -7,4 +7,8 @@ import java.util.Map;
*/
public interface IndexService {
Map<String,Object> banner();
Map<String,Object> categoryList();
Map<String,Object> categoryDetail();
}
package com.server.web.common.service;
import java.util.Map;
/**
* Created by weiwenfu@163.com on 2020/3/12 下午 4:53.
*/
public interface InformationService {
Map<String,Object> secondClassList(Long firstId);
Map<String,Object> secondClassDetail(Long secondId, Integer pageNo, Integer pageSize);
Map<String,Object> informationDetail(Long informationId);
}
package com.server.web.controller;
import com.server.web.common.mapper.TKzyUserMapper;
import com.server.web.common.model.TKzyCourse;
import com.server.web.common.model.TKzyUser;
import com.server.web.common.service.TKzyCourseService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -20,10 +14,8 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* 课程相关action
......@@ -138,64 +130,6 @@ public class CourseController extends BaseController{
return tKzyCourseService.courseType();
}
/**
* 送花(此处只是调用前端的服务)
* @return
*/
@RequestMapping("/sendFlower")
public Map<String,Object> sendFlower(HttpServletRequest request,@RequestParam(value = "courseId") Long courseId){
Map<String,Object> resultMap = new HashMap<String,Object>();
resultMap.put("status","0");
resultMap.put("message","");
String giftUrl = "http://cdn.yxvzb.com/WEB/wx-master/images/gift1.png";
TKzyUser tKzyUser = getLoginUser(request);
if(tKzyUser==null){
resultMap.put("message","请先登录~");
resultMap.put("status","-1");
return resultMap;
}
TKzyCourse tKzyCourse = tKzyCourseService.selectByPrimaryKey(courseId);
if(tKzyCourse==null){
resultMap.put("message","课程信息有误,请确认~");
return resultMap;
}
//每分钟可赠送五次礼物,超出则吐丝提示:礼物赠送频繁,请稍后赠送
ValueOperations vv = redisTemplate.opsForValue();
Integer count = (Integer) vv.get("WX_FLOWER_COURSE_"+tKzyUser.getId()+"_"+courseId);
if(count!=null && count>=5){
resultMap.put("message","礼物赠送频繁,请稍后赠送~");
return resultMap;
}
try {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, Object> valueMap = new LinkedMultiValueMap<>();
valueMap.add("type",2+"");
valueMap.add("courseId", courseId+"");
valueMap.add("giftType", 2+"");
valueMap.add("userId",tKzyUser.getId()+"");
valueMap.add("giftCount",1+"");
valueMap.add("giftImg",giftUrl);
valueMap.add("giftName","鲜花");
valueMap.add("channelId","Kzy"+courseId+"");
if (StringUtils.isEmpty(tKzyUser.getFullName())) {
valueMap.add("userName",tKzyUser.getFullName());
}else {
valueMap.add("userName",tKzyUser.getFullName());
}
Date liveEndTime = tKzyCourse.getEndDt();
valueMap.add("liveEndTime",liveEndTime.getTime()+"");
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(valueMap, headers);
ResponseEntity<String> response = restTemplate.exchange(danmuUrl + "/sendGift", HttpMethod.POST, requestEntity, String.class);
System.out.println(tKzyUser.getId()+"送花返回:"+response);
vv.set("WX_FLOWER_COURSE_"+tKzyUser.getId()+"_"+courseId,(count==null?1:count+1),1, TimeUnit.MINUTES);
} catch (Exception e) {
e.printStackTrace();
}
resultMap.put("status","1");
return resultMap;
}
/**
* 临时设置登录信息
......
......@@ -12,7 +12,7 @@ import java.util.Map;
* Created by weiwenfu@163.com on 2018/12/12 下午 3:03.
*/
@RestController
@RequestMapping(value = BaseController.WX_NAMESPACE + "/index",produces = "application/json")
@RequestMapping(value = BaseController.WX_NAMESPACE + "/index", produces = "application/json")
public class IndexController {
@Autowired
......@@ -20,11 +20,33 @@ public class IndexController {
/**
* banner
*
* @return
*/
@RequestMapping("/banner")
public Map<String,Object> banner(){
public Map<String, Object> banner() {
return indexService.banner();
}
/**
* 首页分类
*
* @return
*/
@RequestMapping("/categoryList")
public Map<String, Object> categoryList() {
return indexService.categoryList();
}
/**
* 首页分类-两条数据
*
* @return
*/
@RequestMapping("/categoryDetail")
public Map<String, Object> categoryDetail() {
return indexService.categoryDetail();
}
}
package com.server.web.controller;
import com.server.web.common.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
* Created by weiwenfu@163.com on 2020/3/12 下午 4:53.
*/
@RestController
@RequestMapping(value = BaseController.WX_NAMESPACE + "/information", produces = "application/json")
public class InformationController {
@Autowired
private InformationService informationService;
/**
* 二级分类
*
* @return
*/
@RequestMapping("/secondClassList")
public Map<String, Object> secondClassList(HttpServletRequest request, @RequestParam(value = "firstId") Long firstId) {
return informationService.secondClassList(firstId);
}
/**
* 二级分类详情
*
* @return
*/
@RequestMapping("/secondClassDetail")
public Map<String, Object> secondClassDetail(HttpServletRequest request, @RequestParam(value = "secondId") Long secondId,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize) {
return informationService.secondClassDetail(secondId, pageNo, pageSize);
}
/**
* 资讯详情
*
* @param request
* @param informationId
* @return
*/
@RequestMapping("/informationDetail")
public Map<String, Object> informationDetail(HttpServletRequest request, @RequestParam(value = "informationId") Long informationId) {
return informationService.informationDetail(informationId);
}
}
......@@ -89,11 +89,13 @@ public class UserController extends BaseController {
String wxOpenId = request.getParameter("wxOpenId");
String fullName = request.getParameter("fullName");
String userCategory = request.getParameter("userCategory");
String duty = request.getParameter("duty");
loginUser.setWxOpenid(wxOpenId);
loginUser.setDuty(duty);
loginUser.setUserCategory(Integer.valueOf(userCategory));
loginUser.setFullName(fullName);
loginUser.setDuty(duty);
userMapper.updateByPrimaryKeySelective(loginUser);
request.getSession().setAttribute(WX_USER_SESSION_KEY, loginUser);
......
<?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.server.web.common.mapping.CourseMapper" >
<select id="livingCourse" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT
t.`pic_url` as picUrl,
t.`course_name` as courseName,
t.`start_dt` AS startDt,
t.`end_dt` AS endDt,
t.id
FROM
t_kzy_course t
WHERE t.`is_delete` = 0
AND t.`is_up` = 1
AND t.`course_type`=1
AND (t.end_dt is null or t.end_dt &gt; NOW())
ORDER BY t.`start_dt`
</select>
</mapper>
\ No newline at end of file
<?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.server.web.common.mapping.InformationMapper">
<select id="livingCourse" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT
t.`pic_url` as picUrl,
t.`course_name` as courseName,
t.`start_dt` AS startDt,
t.`end_dt` AS endDt,
t.id
FROM
t_kzy_course t
WHERE t.`is_delete` = 0
AND t.`is_up` = 1
AND t.`course_type`=1
AND (t.end_dt is null or t.end_dt &gt; NOW())
ORDER BY t.`start_dt`
</select>
<select id="categoryDetail" resultType="java.util.HashMap">
SELECT
i.id,
i.title,
i.icon_url AS iconUrl
FROM
t_kzy_relation_class rc
LEFT JOIN t_kzy_information i ON rc.relation_id = i.id
WHERE
i.is_delete = 0
AND rc.first_class_id = #{firstId,jdbcType=BIGINT}
ORDER BY
i.id DESC
LIMIT 0,
2
</select>
<select id="secondClassDetailInformation" resultType="java.util.HashMap">
SELECT
i.id,
i.title,
i.icon_url AS iconUrl,
i.create_dt AS createDt,
1 AS classType
FROM
t_kzy_relation_class rc
LEFT JOIN t_kzy_information i ON rc.relation_id = i.id
LEFT JOIN t_base_second_class sc ON rc.second_class_id = sc.id AND sc.type = 1
WHERE
i.is_delete = 0
AND sc.type = 2
AND rc.second_class_id = #{secondId,jdbcType=BIGINT}
ORDER BY
i.id DESC
LIMIT ${start},${pageSize}
</select>
<select id="secondClassDetailCourse" resultType="java.util.HashMap">
SELECT
c.id,
c.course_name AS title,
c.pic_url AS iconUrl,
c.create_dt AS createDt,
2 AS classType
FROM
t_kzy_relation_class rc
LEFT JOIN t_kzy_course c ON rc.relation_id = c.id
LEFT JOIN t_base_second_class sc ON rc.second_class_id = sc.id AND sc.type = 2
WHERE
c.is_delete = 0
AND sc.type = 2
AND rc.second_class_id = #{secondId,jdbcType=BIGINT}
ORDER BY
c.id DESC
LIMIT ${start},${pageSize}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!