一个好的SpringCloud+SpringBoot b2b2c 电子商务平台涉及哪些技术、运营方案?以下是我结合公司的产品做的总结,希望可以帮助到大家!
搜索体验小程序:海哇
1. 涉及平台
平台管理、商家端(PC端、手机端)、买家平台(H5/公众号、小程序、APP端(IOS/Android)、微服务平台(业务服务)
2. 核心架构
Spring Cloud、Spring Boot、Mybatis、Redis
3. 前端框架
VUE、Uniapp、Bootstrap/H5/CSS3、IOS、Android、小程序
4. 核心思想
分布式、微服务、云架构、模块化、原子化、持续集成、集群部署、前后端分离、支持阿里Docker
5. 开发模式
前后端分离、微服务开发
6. 社交模式
VR全景虚拟现实、直播带货、短视频带货、分销分润、代跑腿配送、内容营销、社交种草、社交电商、秒杀、积分商城、限时折扣、活动商品、拼团活动等
7. 营销模式
通用版本(标准多商户入驻+二级分销体系+满减、满送、优惠券、组合销售、平台礼包等营销活动)
直播、短视频带货版本(标准多商户入驻+直播、短视频带货+二级分销体系+满减、满送、优惠券、组合销售、平台礼包等营销活动)
特殊营销方案(一):一县一特(一个县城,一个特色,集本地特产、特色、名胜、小吃、文化为一体的营销方案)
特殊营销方案(二):短距离配送(外卖、生鲜水果配送,解决1.5公里配送问题,接入第三方代跑腿服务)
特殊营销方案(三):酒店行业(酒店商家入驻,根据定位,可针对附近酒店,不同城酒店进行线上预定、下线核销等,参考去哪儿网酒店业务)
特殊营销方案(四):VR全景(商家入驻后,可以进行VR全景拍摄,VR店铺体验,全新购物方式,通过虚拟现实技术,线上线下打通,实现全新O2O,深度场景体验,感受另一个大千世界,让用户足不出户完美购物。通过VR让您的店铺曝光率更高,让天下没有难销的商品)
特殊营销方案(五):线下套餐体验(针对于实体行业,用户线上消费后生成核销码,用户到实体店铺体验套餐,可凭借核销码进行体验项目)
特殊营销方案(六):旅游业(周边游、本地游、异地游等,旅游景区和VR全景结合,用户足不出户先感受一下旅游项目、旅游攻略等,可线上订票、预定等)
特殊营销方案(七):供应求购(简易供应链供应、求购模式)
特殊营销方案(八):社交资讯(用户发布文章,可进行带货)
特殊营销方案(九):社交动态(个人信息、动态、视频,如:文字+图片、文字+视频,可进行带货;粉丝、关注、分享等)
活动商品(平台发布活动商品,如:可以进行0元领取,领取需要进行用户拉新,拉新后可进行现金奖励等)
特殊营销方案(十):异业联盟(不同行业的联盟销售,如:在某餐饮店面消费后可送附近健身卡优惠券,凭借优惠券可进行线下体验)
特殊营销方案(十一):一键代发营销(商家选择平台商品后放入自己店面销售,用户购买后商家可获取特殊分润提成,商家不需要发货,由平台厂家直接发货,并支持本店面自提)
package com.honghu.cloud.controller;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.honghu.cloud.bean.Social;
import com.honghu.cloud.bean.SocialStatistics;
import com.honghu.cloud.code.ResponseCode;
import com.honghu.cloud.service.ISocialService;
import com.honghu.cloud.service.ISocialStatisticsService;
import com.honghu.cloud.tools.QueryTools;
import com.honghu.cloud.tools.SecurityUserHolder;
import com.honghu.cloud.utils.CommUtil;
import com.honghu.cloud.common.page.Page;
/**
* 社交电商内容Controller
* @author admin
* @version 2019-04-25
*/
@RestController
@RequestMapping(value = "/social")
/*@CrossOrigin(origins = "*", maxAge = 3600, methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE,
RequestMethod.PUT })*/
public class SocialController {
@Value("${gateway.url}")
private String gatewayUrl;
@Autowired
private ISocialService socialService;
@Autowired
private QueryTools queryTools;
@Autowired
private ISocialStatisticsService socialStatisticsService;
/**
* 获取社交电商的列表
* @param social 社交电商
* @param request
* @param response
* @param currentPage 当前页
* @param pageSize 每页显示条数
* @return
*/
@RequestMapping(value = {"/getSocialList","/apiPc/getSocialList"}, method = RequestMethod.POST)
public Map<String, Object> getSocialList(HttpServletRequest request, HttpServletResponse response,
String title, Long socialClassId, Integer status, Integer recommend,
String currentPage, Integer pageSize) {
//封装分页参数
Map<String, Object> maps = queryTools.getParams(currentPage, pageSize,null,null);
if(null != socialClassId){
maps.put("currentPage", 0);
maps.put("socialClassId", socialClassId);
}
if(StringUtils.isNotEmpty(title)){
maps.put("currentPage", 0);
maps.put("title", title);
}
if(status != null){
maps.put("currentPage", 0);
maps.put("status", status);
}
if(recommend != null){
maps.put("currentPage", 0);
maps.put("recommend", recommend);
}
Page<Social> pageList=socialService.list(maps);
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("currentPage", pageList.getCurrentPage());
resultMap.put("pages", pageList.getPages());
resultMap.put("result", pageList.getResult());
resultMap.put("rowCount", pageList.getRowCount());
resultMap.put("gotoPageAjaxHTML", CommUtil.showPageAjaxHtml(gatewayUrl+"honghu-social-service"+"/social/apiPc/getSocialList",
"", pageList.getCurrentPage(),pageList.getPages(),pageList.getPageSize()));
return ResponseCode.buildSuccessMap(resultMap);
}
@RequestMapping(value = {"/form","/apiPc/form"},method = RequestMethod.POST)
public Map<String, Object> form(Long id, HttpServletRequest request, HttpServletResponse response) {
Social social = null;
if(id != null){
social = socialService.selectByPrimaryKey(id);
}
return ResponseCode.buildSuccessMap(social);
}
/**
* 发布社交电商
* @param social 社交电商
* @param request
* @param response
* @return
*/
@RequestMapping(value = {"/save","/apiPc/save"}, method = RequestMethod.POST)
public Map<String, Object> save(Social social, HttpServletRequest request,
HttpServletResponse response) {
SocialStatistics socialStatistics = null;
Long userId = SecurityUserHolder.getCurrentUserId(request);
if(social.getId() == null){
social.setAddTime(new Date());
social.setPublishDate(new Date());
social.setDeleteStatus(0);
social.setCreateUserId(userId);
social.setStatus(0);
social.setCreateDate(new Date());
social.setUpdateUserId(userId);
social.setUpdateDate(new Date());
socialStatistics = new SocialStatistics();
socialStatistics.setLikeCount(0L);
socialStatistics.setCommentCount(0L);
socialStatistics.setBrowseCount(0L);
socialStatistics.setForwardCount(0L);
socialStatistics.setFavoriteCount(0L);
socialStatistics.setDeleteStatus(0);
socialStatistics.setCreateUserId(userId);
socialStatistics.setCreateDate(new Date());
socialStatistics.setUpdateUserId(userId);
socialStatistics.setUpdateDate(new Date());
social.setSocialStatistics(socialStatistics);
}
social.setUpdateUserId(userId);
social.setUpdateDate(new Date());
socialService.addOrUpdate(social, socialStatistics);
return ResponseCode.buildSuccessMap(social);
}
/**
* 社交电商的删除
* @param id 社交电商id
* @param request
* @return
*/
@RequestMapping(value = {"/delete","/apiPc/delete"}, method = RequestMethod.POST)
public Map<String, Object> delete(String ids, HttpServletRequest request) {
Map<String, Object> resultMap = new HashMap<String, Object>();
if(StringUtils.isEmpty(ids)){
return ResponseCode.buildCodeMap("20001", "社交电商id为空", null);
}
String [] idArray = ids.split(",");
for(String id : idArray){
if(StringUtils.isEmpty(id)){
continue;
}
Social social = socialService.selectByPrimaryKey(CommUtil.null2Long(id));
if(social != null){
social.setDeleteStatus(1);
socialService.updateById(social);
}
}
resultMap.put("url", CommUtil.getURL(request) + "/social/social_list");
return ResponseCode.buildSuccessMap(resultMap);
}
/**
* 查看社交电商的详情页
* @param id
* @param request
* @param response
* @param currentPage
* @param pageSize
* @return
*/
@RequestMapping(value = {"/detail","/apiPc/detail"},method = RequestMethod.POST)
public Map<String, Object> detail(Long id, HttpServletRequest request, HttpServletResponse response, String currentPage, Integer pageSize) {
Map<String, Object> resultMap = new HashMap<String, Object>();
if(id != null){
Social social = socialService.selectByPrimaryKey(id);
SocialStatistics socialStatistics = socialStatisticsService.selectByPrimaryKey(id);
social.setSocialStatistics(socialStatistics);
resultMap.put("social", social);
}
//遍历不包含第一个id的社交电商列表
Map<String, Object> maps = queryTools.getParams(currentPage, pageSize,null,null);
if(id !=null){
maps.put("id", id);
}
Page<Social> socialPageList=socialService.list(maps);
resultMap.put("currentPage", socialPageList.getCurrentPage());
resultMap.put("pages", socialPageList.getPages());
resultMap.put("rowCount", socialPageList.getRowCount());
//resultMap.put("result", socialPageList.getResult());
List<Social> socialList =socialPageList.getResult();
for(Social sc : socialList){
if(sc.getId()!= null){
SocialStatistics socialStatistics = socialStatisticsService.selectByPrimaryKey(sc.getId());
sc.setSocialStatistics(socialStatistics);
}
}
resultMap.put("result", socialList);
return ResponseCode.buildSuccessMap(resultMap);
}
/**
* 添加喜欢社交电商
* @param request
* @param response
* @param socialCommentId
* @return
*/
@RequestMapping(value = {"/likeSocial","/apiPc/likeSocial"})
public Map<String, Object> likeComment(HttpServletRequest request,
HttpServletResponse response, Long socialId) {
if(socialId == null){
return ResponseCode.buildCodeMap("20001", "社交电商id不能为空", null);
}
Long userId = SecurityUserHolder.getCurrentUserId(request);
socialService.likeSocial(socialId, userId);
return ResponseCode.buildSuccessMap(null);
}
/**
* 取消喜欢
* @param request
* @param response
* @param socialCommentId
* @return
*/
@RequestMapping(value = {"/deleteSocialLike","/apiPc/deleteSocialLike"})
public Map<String, Object> deleteCommentLike(HttpServletRequest request,
HttpServletResponse response, Long socialId) {
if(socialId == null){
return ResponseCode.buildCodeMap("20001", "社交电商id不能为空", null);
}
Long userId = SecurityUserHolder.getCurrentUserId(request);
socialService.deleteSocialLike(socialId, userId);
return ResponseCode.buildSuccessMap(null);
}
}
/**
* Copyright © 2012-2017 <a href="http://minglisoft.cn">HongHu</a> All rights reserved.
*/
package com.honghu.cloud.controller;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.google.common.collect.Maps;
import com.honghu.cloud.bean.SocialComment;
import com.honghu.cloud.code.ResponseCode;
import com.honghu.cloud.service.ISocialClassService;
import com.honghu.cloud.service.ISocialCommentService;
import com.honghu.cloud.tools.QueryTools;
import com.honghu.cloud.tools.SecurityUserHolder;
import com.honghu.cloud.utils.CommUtil;
import com.honghu.cloud.common.page.Page;
/**
* 社交电商评论Controller
*
* @author admin
* @version 2019-04-25
*/
@RestController
@RequestMapping(value = "socialComment")
/*@CrossOrigin(origins = "*", maxAge = 3600, methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE, RequestMethod.PUT })*/
public class SocialCommentController {
@Value("${gateway.url}")
private String gatewayUrl;
@Autowired
private ISocialCommentService socialCommentService;
@Autowired
private ISocialClassService socialClassService;
@Autowired
private QueryTools queryTools;
/**
* 查询社交电商评论分页
* @param socialId 社交id
* @param currentPage 当前页
* @param pageSize 每页多少条
* @return
*/
@RequestMapping(value = {"/list", "/apiPc/list"}, method = RequestMethod.POST)
public Map<String, Object> list(HttpServletRequest request, HttpServletResponse response,
Long socialId, String currentPage,Integer pageSize) {
if(socialId == null){
return ResponseCode.buildCodeMap("20002", "社交id不能为空", null);
}
//获取用户id
Long userId = SecurityUserHolder.getCurrentUserId(request);
HashMap<String, Object> result = Maps.newHashMap();
//查询社交评论分页
Map<String, Object> maps = queryTools.getParams(currentPage, pageSize, "a.update_date", "desc");
maps.put("social_status", 0);
maps.put("socialId", socialId);
maps.put("userId", userId);
Page<SocialComment> pageList = this.socialCommentService.list(maps);
result.put("currentPage", pageList.getCurrentPage());
result.put("pages", pageList.getPages());
result.put("result", pageList.getResult());
result.put("RowCount", pageList.getRowCount());
return ResponseCode.buildSuccessMap(result);
}
/**
* 查询社交电商top评论分页
* @param socialId 社交id
* @param topId 评论id
* @param currentPage 当前页
* @param pageSize 每页多少条
* @return
*/
@RequestMapping(value = {"/commentList", "/apiPc/commentList"}, method = RequestMethod.POST)
public Map<String, Object> commentList(HttpServletRequest request, HttpServletResponse response,
Long socialId, Long topId, String currentPage,Integer pageSize) {
if(socialId == null){
return ResponseCode.buildCodeMap("20002", "社交id不能为空", null);
}
if(topId == null){
return ResponseCode.buildCodeMap("20002", "评论id不能为空", null);
}
// 查询当前评论
SocialComment socialComment = socialCommentService.selectByPrimaryKey(topId);
if(socialComment == null){
return ResponseCode.buildCodeMap("20001", "评论已删除,请刷新后再试", null);
}
HashMap<String, Object> result = Maps.newHashMap();
result.put("socialComment", socialComment);
//获取登录用户id
Long userId = SecurityUserHolder.getCurrentUserId(request);
Map<String, Object> maps = queryTools.getParams(currentPage, pageSize, "a.update_date", "desc");
maps.put("social_status", 0);
maps.put("socialId", socialId);
maps.put("topId", topId);
maps.put("userId", userId);
Page<SocialComment> pageList = this.socialCommentService.commentList(maps);
result.put("currentPage", pageList.getCurrentPage());
result.put("pages", pageList.getPages());
result.put("result", pageList.getResult());
result.put("rowCount", pageList.getRowCount());
return ResponseCode.buildSuccessMap(result);
}
/**
* 查询单个评论()
* @param request
* @param response
* @param id
* @return
*/
@RequestMapping(value = {"/form", "/apiPc/form"}, method = RequestMethod.POST)
public Map<String, Object> form(HttpServletRequest request, HttpServletResponse response,
Long id) {
SocialComment socialComment = null;
if(id != null){
socialComment = socialCommentService.selectByPrimaryKey(id);
}
return ResponseCode.buildSuccessMap(socialComment);
}
/**
* 保存或者修改评论
* @param socialComment
* @param request
* @param response
* @return
*/
@RequestMapping(value = {"addOrUpdate", "/apiPc/addOrUpdate"}, method = RequestMethod.POST)
public Map<String, Object> addOrUpdate(SocialComment socialComment, HttpServletRequest request,
HttpServletResponse response) {
//获取登录用户id
Long userId = SecurityUserHolder.getCurrentUserId(request);
// 若id为空则添加评论, 不为空则修改(待处理)
if (socialComment.getId() == null) {
if (socialComment.getReppayUserId() == null) {
return ResponseCode.buildCodeMap("20002", "评论用户id不能为空", null);
}
socialComment.setCommentUserId(userId);
socialComment.setReppayUserId(socialComment.getReppayUserId());
socialComment.setCreateDate(new Date());
socialComment.setCreateUserId(userId);
socialComment.setDeletestatus(0);
} else {
SocialComment sComment = socialCommentService.selectByPrimaryKey(socialComment.getId());
if (sComment!=null && userId.longValue() != 1) {
return ResponseCode.buildCodeMap("20003", "非管理员不能修改", null);
}
}
//修改更新信息
socialComment.setUpdateDate(new Date());
socialComment.setUpdateUserId(userId);
socialCommentService.addOrUpdate(socialComment);
return ResponseCode.buildSuccessMap(socialComment);
}
/**
* 删除评论(微服务)
* @param socialComment
* @param request
* @param response
* @param id 社交评论id
* @return
*/
@RequestMapping(value = {"/delete"}, method = RequestMethod.POST)
public Map<String, Object> delete(HttpServletRequest request,
HttpServletResponse response,Long id) {
Long userId = SecurityUserHolder.getCurrentUserId(request);
SocialComment comment = socialCommentService.selectByPrimaryKey(id);
if (comment != null) {
if(!comment.getCreateUserId().equals(userId)){
return ResponseCode.buildCodeMap("20003", "不能删除他人的评论", null);
}
comment.setDeletestatus(1);
socialCommentService.updateById(comment);
}
return ResponseCode.buildSuccessMap(null);
}
/**
* 删除评论(后台管理)
* @param socialComment
* @param request
* @param response
* @param id
* @return
*/
@RequestMapping(value = {"/apiPc/delete"}, method = RequestMethod.POST)
public Map<String, Object> apiPcDelete(HttpServletRequest request,
HttpServletResponse response,String ids) {
if (StringUtils.isEmpty(ids)) {
return ResponseCode.buildCodeMap("20001", "id不能为空", null);
}
String [] idArray = ids.split(",");
for(String id : idArray){
if(StringUtils.isEmpty(id)){
continue;
}
SocialComment socialId = socialCommentService.selectByPrimaryKey(CommUtil.null2Long(id));
if (socialId!=null) {
socialId.setDeletestatus(1);
socialCommentService.updateById(socialId);
}
}
return ResponseCode.buildSuccessMap(null);
}
/**
* 添加喜欢评论
* @param request
* @param response
* @param socialCommentId
* @return
*/
@RequestMapping(value = "/likeComment", method = RequestMethod.POST)
public Map<String, Object> likeComment(HttpServletRequest request,
HttpServletResponse response, Long socialCommentId) {
if(socialCommentId == null){
return ResponseCode.buildCodeMap("20001", "评论id不能为空", null);
}
Long userId = SecurityUserHolder.getCurrentUserId(request);
socialCommentService.likeComment(socialCommentId, userId);
return ResponseCode.buildSuccessMap(null);
}
/**
* 取消喜欢
* @param request
* @param response
* @param socialCommentId
* @return
*/
@RequestMapping(value = "/deleteCommentLike", method = RequestMethod.POST)
public Map<String, Object> deleteCommentLike(HttpServletRequest request,
HttpServletResponse response, Long socialCommentId) {
if(socialCommentId == null){
return ResponseCode.buildCodeMap("20001", "评论id不能为空", null);
}
Long userId = SecurityUserHolder.getCurrentUserId(request);
socialCommentService.deleteCommentLike(socialCommentId, userId);
return ResponseCode.buildSuccessMap(null);
}
/**
* 查询社交电商评论分页后台管理 查询分页
* @param socialId 社交id
* @param currentPage 当前页
* @param pageSize 每页多少条
* @return
*/
@RequestMapping(value = "/apiPc/adminList", method = RequestMethod.POST)
public Map<String, Object> adminList(HttpServletRequest request, HttpServletResponse response,
String title, String commentUserName, String reppayUserName, String currentPage,Integer pageSize,String id) {
//获取用户id
HashMap<String, Object> result = Maps.newHashMap();
//查询社交评论分页
Map<String, Object> maps = queryTools.getParams(currentPage, pageSize, "a.update_date", "desc");
if(StringUtils.isNotEmpty(title)){
maps.put("currentPage", 0);
maps.put("title", title);
}
if(StringUtils.isNotEmpty(commentUserName)){
maps.put("currentPage", 0);
maps.put("commentUserName", commentUserName);
}
if(StringUtils.isNotEmpty(reppayUserName)){
maps.put("currentPage", 0);
maps.put("reppayUserName", reppayUserName);
}
if(StringUtils.isNotEmpty(id)){
maps.put("currentPage", 0);
maps.put("socialId", CommUtil.null2Long(id));
}
Page<SocialComment> pageList = this.socialCommentService.adminList(maps);
result.put("currentPage", pageList.getCurrentPage());
result.put("pages", pageList.getPages());
result.put("result", pageList.getResult());
result.put("gotoPageAjaxHTML", CommUtil.showPageAjaxHtml(gatewayUrl+"honghu-social-service"+"/socialComment/apiPc/adminList",
"", pageList.getCurrentPage(),pageList.getPages(),pageList.getPageSize()));
return ResponseCode.buildSuccessMap(result);
}
/**
* 查询社交电商评论分页详情
* @param id 评论id
* @return
*/
@RequestMapping(value = "/apiPc/adminComment", method = RequestMethod.POST)
public Map<String, Object> adminComment(HttpServletRequest request, HttpServletResponse response,Long id) {
SocialComment socialComment = socialCommentService.adminComment(id);
if(socialComment != null && socialComment.getSocial() != null &&
socialComment.getSocial().getSocialClassId() != null){
socialComment.getSocial().setSocialClass(socialClassService.selectByPrimaryKey(id));
}
return ResponseCode.buildSuccessMap(socialComment);
}
}
/**
* Copyright © 2012-2017 <a href="http://minglisoft.cn">HongHu</a> All rights reserved.
*/
package com.honghu.cloud.controller;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.google.common.collect.Maps;
import com.honghu.cloud.bean.SocialClass;
import com.honghu.cloud.code.ResponseCode;
import com.honghu.cloud.service.ISocialClassService;
import com.honghu.cloud.tools.QueryTools;
import com.honghu.cloud.tools.SecurityUserHolder;
import com.honghu.cloud.utils.CommUtil;
import com.honghu.cloud.common.page.Page;
/**
* 社交电商分类Controller
* @author admin
* @version 2019-04-25
*/
@RestController
@RequestMapping(value = "socialClass")
/*@CrossOrigin(origins = "*", maxAge = 3600, methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE,
RequestMethod.PUT })*/
public class SocialClassController {
@Value("${gateway.url}")
private String gatewayUrl;
@Autowired
private ISocialClassService socialClassService;
@Autowired
private QueryTools queryTools;
/**
* 查询社交电商分类分页
* @param socialClass 社交分类
* @param currentPage 当前页
* @param pageSize 每页多少条
* @return
*/
@RequestMapping(value = {"/list","/apiPc/list"}, method = RequestMethod.POST)
public Map<String, Object> list(HttpServletRequest request, HttpServletResponse response,
String name, String currentPage,Integer pageSize) {
HashMap<String,Object> result = Maps.newHashMap();
//工具类进行分页排序
Map<String, Object> params = queryTools.getParams(currentPage, pageSize, "squence", "asc");
if(StringUtils.isNotEmpty(name)){
params.put("currentPage", 0);
params.put("name", name);
}
Page<SocialClass> pageList = socialClassService.list(params);
result.put("currentPage", pageList.getCurrentPage());
result.put("pages", pageList.getPages());
result.put("result", pageList.getResult());
result.put("gotoPageAjaxHTML", CommUtil.showPageAjaxHtml(gatewayUrl+"honghu-social-service"+"/socialClass/apiPc/list",
"", pageList.getCurrentPage(),pageList.getPages(),pageList.getPageSize()));
return ResponseCode.buildSuccessMap(result);
}
/**
* 查询单个分类信息
* @param id社交分类id
* @param request
* @param response
* @return
*/
@RequestMapping(value = {"/form","/apiPc/form"}, method = RequestMethod.POST)
public Map<String, Object> form(Long id, HttpServletRequest request, HttpServletResponse response) {
SocialClass socialClass = null;
if(id != null){
//通过社交分类id查询社交分类
socialClass = socialClassService.selectByPrimaryKey(id);
}
return ResponseCode.buildSuccessMap(socialClass);
}
/**
* 保存或者修改分类
* @param socialComment
* @param request
* @param response
* @return
*/
@RequestMapping(value = {"/save","/apiPc/save"}, method = RequestMethod.POST)
public Map<String, Object> addOrUpdate(SocialClass socialClass, HttpServletRequest request,
HttpServletResponse response) {
//判断id是否为空,若为空则创建
if(socialClass.getId() == null){
if (socialClass.getName()==null) {
return ResponseCode.buildCodeMap("20001", "分类名称不能为空", null);
}
if (socialClass.getSequence()==null) {
return ResponseCode.buildCodeMap("20001", "分类排序不能为空", null);
}
socialClass.setDeleteStatus(0);
socialClass.setCreateUserId(SecurityUserHolder.getCurrentUserId(request));
socialClass.setCreateDate(new Date());
}
//更新修改改记录
socialClass.setUpdateUserId(SecurityUserHolder.getCurrentUserId(request));
socialClass.setUpdateTime(new Date());
socialClassService.addOrUpdate(socialClass);
return ResponseCode.buildSuccessMap(null);
}
/**
* 删除社交分类
* @param id 社交分类id
* @return
*/
@RequestMapping(value = {"/delete","/apiPc/delete"}, method = RequestMethod.POST)
public Map<String, Object> delete(String ids, HttpServletRequest request,
HttpServletResponse response) {
if (StringUtils.isEmpty(ids)) {
return ResponseCode.buildCodeMap("20001", "id不能为空", null);
}
String [] idArray = ids.split(",");
for(String id : idArray){
if(StringUtils.isEmpty(id)){
continue;
}
SocialClass socialClass = socialClassService.selectByPrimaryKey(CommUtil.null2Long(id));
if(socialClass != null){
socialClass.setDeleteStatus(1);
socialClassService.updateById(socialClass);
}
}
return ResponseCode.buildSuccessMap(null);
}
}