基于javaweb+mysql的springboot在线游戏商城系统(java+springboot+mybatis+mysql+maven+layui+thymeleaf+html)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot在线游戏商城系统(java+springboot+mybatis+mysql+maven+layui+thymeleaf+html)
一、项目简述功能包括: 用户管理,游戏商品管理,在线购买,上传,售卖记录,商品审核等等。
二、项目运行环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Spring + SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等
// System.out.println("===o1大于等于o2===");
// i = 1;
// } else if (o1.getThinkmoney().compareTo(o2.getThinkmoney()) < 1) {
// i = -1;
// System.out.println("===o1小于等于o2===");
// }
// return i;
// }
/**降序*/
@Override
public int compare(Commodity o1, Commodity o2) {
if (o1.getThinkmoney().compareTo(o2.getThinkmoney()) > -1) {
System.out.println("===o1大于等于o2===");
i = -1;
} else if (o1.getThinkmoney().compareTo(o2.getThinkmoney()) < 1) {
System.out.println("===o1小于等于o2===");
i = 1;
}
return i;
}
});
System.out.println("排序后的商品为:");
for (Commodity commodity : commodityList) {
System.out.println(commodity);
}
System.out.println("查询的服务器为:" + server);
System.out.println("查询的商品分页为:" + pages);
System.out.println("查询的商品数量为:" + dataNumber);
}
}
package com.controller;
/**
* <p>
* 登录注册 控制器
* </p>
*
*/
@Controller
public class LoginController {
@Autowired
private LoginService loginService;
@Autowired
private UserInfoService userInfoService;
@Autowired
private UserRoleService userRoleService;
/**手机号和注册验证码map集合*/
private static Map<String, String> phonecodemap1 = new HashMap<>();
/**手机号和重置密码验证码map集合*/
private static Map<String, String> phonecodemap2 = new HashMap<>();
/**
*图片验证码
* */
@RequestMapping(value = "/images", method = {RequestMethod.GET, RequestMethod.POST})
public void images(HttpServletResponse response) throws IOException {
response.setContentType("image/jpeg");
//禁止图像缓存。
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
ValidateCode vCode = new ValidateCode(820, 200, 5, 80);
vCode.write(response.getOutputStream());
}
/**注册时发送短信验证码
* 1.判断是否为注册类型验证码
* 2.判断手机号格式是否正确
* 3.判断手机号是否已经注册过
* 4.发送注册验证码并存入map集合
* */
@ResponseBody
}
}, 5 * 60 * 1000);
*/
//执行定时任务
ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1,
new BasicThreadFactory.Builder().namingPattern("example-schedule-pool-%d").daemon(true).build());
executorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
phonecodemap.remove(mobilephone);
((ScheduledThreadPoolExecutor) executorService).remove(this::run);
}
},5 * 60 * 1000,5 * 60 * 1000, TimeUnit.HOURS);
return new ResultVo(true,StatusCode.SMS,"验证码发送成功");
}else if(result == 2){
return new ResultVo(false,StatusCode.ERROR,"请输入正确格式的手机号");
}
return new ResultVo(false,StatusCode.REMOTEERROR,"验证码发送失败");
}
/**
* 修改绑定手机号
* 1.获取session中userid
* 2.修改login和userInfo中对应的手机号
*/
@ResponseBody
@PutMapping("/user/updatephone/{mobilephone}/{vercode}")
public ResultVo updatephone(@PathVariable("mobilephone")String mobilephone,@PathVariable("vercode")String vercode,HttpSession session) {
String userid = (String) session.getAttribute("userid");
String rel = phonecodemap.get(mobilephone);
if (StringUtils.isEmpty(rel)) {//验证码到期 或者 没发送短信验证码
return new ResultVo(false,StatusCode.ERROR,"请重新获取验证码");
}
if (rel.equalsIgnoreCase(vercode)) {//验证码正确
Login login = new Login().setUserid(userid).setMobilephone(mobilephone);
UserInfo userInfo = new UserInfo().setUserid(userid).setMobilephone(mobilephone);
return new ResultVo(false,StatusCode.ERROR,"取消失败");
}
return new ResultVo(false,StatusCode.ACCESSERROR,"禁止操作");
}
}
/**
* 收藏列表界面取消收藏
* 1.前端传入收藏id(id)
* 2.判断是否本人取消收藏
* 3.进行取消收藏操作
*/
@ResponseBody
@PutMapping("/collect/delete/{id}")
public ResultVo deletecollect(@PathVariable("id") String id,HttpSession session){
String couserid = (String) session.getAttribute("userid");
Collect collect = new Collect().setId(id).setCouserid(couserid);
Collect collect1 = collectService.queryCollectStatus(collect);
/**判断是否为本人操作*/
if (collect1.getCouserid().equals(couserid)){
collect.setColloperate(2);
Integer i = collectService.updateCollect(collect);
if (i == 1){
return new ResultVo(true, StatusCode.OK,"取消成功");
}
return new ResultVo(false,StatusCode.ERROR,"取消失败");
}
return new ResultVo(false,StatusCode.ACCESSERROR,"禁止操作");
}
/**
* 分页查看用户所有收藏内容
* 前端传入页码、分页数量
* 查询分页数据
*/
@ResponseBody
@GetMapping("/user/collect/queryall")
public LayuiPageVo usercollect(int limit, int page, HttpSession session) {
String couserid = (String) session.getAttribute("userid");
List<Collect> collectList = collectService.queryAllCollect((page - 1) * limit, limit, couserid);
Integer dataNumber = collectService.queryCollectCount(couserid);
return new LayuiPageVo("",0,dataNumber,collectList);
}
}
@RequiresPermissions("user:userinfo")
@GetMapping("/user/pass")
public String userinfo(){
return "/user/updatepass";
}
/**
* 用户更换手机号
* */
@RequiresPermissions("user:userinfo")
@GetMapping("/user/phone")
public String userphone(){
return "/user/updatephone";
}
/**
* 用户商品列表
* */
@GetMapping("/user/product")
public String userproduct(){
return "/user/product/productlist";
}
/**
* 通知消息
* */
@GetMapping("/user/message")
public String commonmessage(){
return "/user/message/message";
}
/**
* 弹出式通知消息
* */
@GetMapping("/user/alertmessage")
public String alertmessage(){
return "/user/message/alertmessage";
}
/**
* 跳转到产品清单界面
* */
@GetMapping("/product-listing")
public String toproductlisting() {
/**
* <p>
* 个人中心 控制器
* </p>
*
*/
@Controller
public class UserController {
@Autowired
private LoginService loginService;
@Autowired
private UserInfoService userInfoService;
/**手机号和更换手机号验证码map集合*/
private static Map<String, String> phonecodemap = new HashMap<>();
/**
* 修改密码
* 1.前端传入旧密码(oldpwd)、新密码(newpwd)
* 2.判断输入旧密码和系统旧密码是否相等
* 4.修改密码
*/
@ResponseBody
@PutMapping("/user/updatepwd")
public ResultVo updatepwd(HttpSession session, HttpServletRequest request) throws IOException {
JSONObject json = JsonReader.receivePost(request);
String oldpwd = json.getString("oldpwd");
String newpwd = json.getString("newpwd");
String userid = (String) session.getAttribute("userid");
Login login = new Login();
UserInfo userInfo = new UserInfo();
login.setUserid(userid);
Login login1 = loginService.userLogin(login);
String oldpwds = new Md5Hash(oldpwd, "Game-shops").toString();
//如果旧密码相等
if (oldpwds.equals(login1.getPassword())){
//盐加密
String passwords = new Md5Hash(newpwd, "Game-shops").toString();
login.setPassword(passwords);
userInfo.setPassword(passwords).setUserid(login1.getUserid());
Integer integer = loginService.updateLogin(login);
Integer integer1 = userInfoService.UpdateUserInfo(userInfo);
JSONObject resUrl = new JSONObject();
List<String> imageurls=new ArrayList<>();
for (MultipartFile files:file){
String filename = UUID.randomUUID().toString().replaceAll("-", "");
String ext = FilenameUtils.getExtension(files.getOriginalFilename());
String filenames = filename + "." + ext;
String pathname = "D:/file/" + filenames;
files.transferTo(new File(pathname));
imageurls.add("/pic/"+filenames);
res.put("msg", "");
res.put("code", 0);
}
resUrl.put("src", imageurls);
res.put("data", resUrl);
return res;
}
/**
* 商品详情
* 根据商品id(commid)查询商品信息、用户昵称及头像
* 用户可以查看正常的商品
* 商品发布者和管理员可以查看
* */
@GetMapping("/product-detail/{commid}")
public String product_detail(@PathVariable("commid") String commid, ModelMap modelMap,HttpSession session){
String couserid = (String) session.getAttribute("userid");
System.out.println("commid = "+commid);
System.out.println("commodity = " + commodityService.LookCommodity(new Commodity().setCommid(commid).setCommstatus(1)).getImage());
Commodity commodity = commodityService.LookCommodity(new Commodity().setCommid(commid).setCommstatus(1));
int i = 0;
if (commodity.getCommstatus().equals(1)){//如果商品正常
i=1;
}else if (!StringUtils.isEmpty(couserid)){//如果用户已登录
Login login = loginService.userLogin(new Login().setUserid(couserid));
/**商品为违规状态时:本人和管理员可查看*/
if (commodity.getCommstatus().equals(0) && (commodity.getUserid().equals(couserid) || (login.getRoleid().equals(2) || login.getRoleid().equals(3)))){
i=1;
/**商品为待审核状态时:本人和管理员可查看*/
}else if (commodity.getCommstatus().equals(3) && (commodity.getUserid().equals(couserid) || (login.getRoleid().equals(2) || login.getRoleid().equals(3)))){
i=1;
/**商品为已售出状态时:本人和管理员可查看*/
}else if (commodity.getCommstatus().equals(4) && (commodity.getUserid().equals(couserid) || (login.getRoleid().equals(2) || login.getRoleid().equals(3)))){
i=1;
}
}
if(i==1){
/**
* 修改个人信息
* 1.前端传入用户昵称(username)、用户邮箱(email)、性别(sex)、游戏(server
* 2.前端传入变更后的字段,未变更的不传入后台
* 3.判断更改的用户名是否已存在
* 4.修改个人信息
*/
@ResponseBody
@PostMapping("/user/updateinfo")
public ResultVo updateInfo(@RequestBody UserInfo userInfo, HttpSession session) {
String username = userInfo.getUsername();
String sessionname = (String) session.getAttribute("username");
String userid = (String) session.getAttribute("userid");
Login login = new Login();
//如果传入用户名不为空
if (!StringUtils.isEmpty(username)){
login.setUsername(username);
Login login1 = loginService.userLogin(login);
//如果用户名未修改
if (sessionname.equals(username)){
UserInfo userInfo2 = userInfoService.LookUserinfo(login1.getUserid());
if (userInfo.getUsername().equals(userInfo2.getUsername())
&& userInfo.getEmail().equals(userInfo2.getEmail())
&& userInfo.getSex().equals(userInfo2.getSex())
&& userInfo.getServer().equals(userInfo2.getServer())
){
return new ResultVo(false, StatusCode.ERROR, "1.尚未修改信息");
}
} else {
//如果用户名已存在
if (!StringUtils.isEmpty(login1)) {
return new ResultVo(false, StatusCode.ERROR, "2.用户名已存在");
}
}
login.setUserid(userid);
//修改登录表中用户名
loginService.updateLogin(login);
}
userInfo.setUserid(userid);
Integer integer1 = userInfoService.UpdateUserInfo(userInfo);
if (integer1 == 1) {
session.setAttribute("username",username);
return new ResultVo(true, StatusCode.OK, "修改成功");
}
return new ResultVo(false, StatusCode.ERROR, "修改失败");
}
/**更换手机号时发送短信验证码
* 1.判断是否为更换手机号类型验证码
* 2.判断手机号格式是否正确
* 3.查询账号是否存在
* 4.发送验证码
* </p>
*
*/
@Controller
public class CommentReplyController {
@Autowired
private CommodityService commodityService;
@Autowired
private CommentService commentService;
@Autowired
private ReplyService replyService;
@Autowired
private UserInfoService userInfoService;
@Autowired
private NoticesService noticesService;
/**
* 查询商品下的评论和回复
* */
@ResponseBody
@GetMapping("/comment/query/{commid}")
public ResultVo queryCommentReply(@PathVariable("commid") String commid){
System.out.println("DJLdebug:查询商品下的评论和回复");
/**查询评论*/
List<Comment> commentsList = commentService.queryComments(commid);
for (Comment comment : commentsList) {
/**查询对应评论下的回复*/
List<Reply> repliesList = replyService.queryReply(comment.getCid());
for (Reply reply : repliesList) {
/**查询回复者的昵称和头像信息*/
UserInfo ruser = userInfoService.queryPartInfo(reply.getRuserid());
/**查询被回复者的昵称信息*/
UserInfo cuser = userInfoService.queryPartInfo(reply.getCuserid());
/**添加回复中涉及到的用户昵称及头像信息*/
reply.setRusername(ruser.getUsername()).setRuimage(ruser.getUimage()).setCusername(cuser.getUsername());
}
/**查询评论者的昵称和头像信息*/
System.out.println("评论者ID:" + comment.getCuserid());
UserInfo userInfo = userInfoService.queryPartInfo(comment.getCuserid());
/**添加评论下的回复及评论者昵称和头像信息*/
comment.setReplyLsit(repliesList).setCusername(userInfo.getUsername()).setCuimage(userInfo.getUimage());
}
System.out.println("DJLdebug:查询评论结束");
return new ResultVo(true, StatusCode.OK,"查询评论回复成功",commentsList);
}
/**
resUrl.put("src", "/pic/"+filenames);
res.put("msg", "");
res.put("code", 0);
res.put("data", resUrl);
return res;
}
/**
* 上传其他图片
*/
@PostMapping(value="/relgoods/images")
@ResponseBody
public JSONObject relgoodsimages(@RequestParam(value = "file", required = false) MultipartFile[] file) throws IOException {
JSONObject res = new JSONObject();
JSONObject resUrl = new JSONObject();
List<String> imageurls=new ArrayList<>();
for (MultipartFile files:file){
String filename = UUID.randomUUID().toString().replaceAll("-", "");
String ext = FilenameUtils.getExtension(files.getOriginalFilename());
String filenames = filename + "." + ext;
String pathname = "D:/file/" + filenames;
files.transferTo(new File(pathname));
imageurls.add("/pic/"+filenames);
res.put("msg", "");
res.put("code", 0);
}
resUrl.put("src", imageurls);
res.put("data", resUrl);
return res;
}
/**
* 商品详情
* 根据商品id(commid)查询商品信息、用户昵称及头像
* 用户可以查看正常的商品
* 商品发布者和管理员可以查看
* */
@GetMapping("/product-detail/{commid}")
public String product_detail(@PathVariable("commid") String commid, ModelMap modelMap,HttpSession session){
String couserid = (String) session.getAttribute("userid");
System.out.println("commid = "+commid);
System.out.println("commodity = " + commodityService.LookCommodity(new Commodity().setCommid(commid).setCommstatus(1)).getImage());
Commodity commodity = commodityService.LookCommodity(new Commodity().setCommid(commid).setCommstatus(1));
int i = 0;
if (commodity.getCommstatus().equals(1)){//如果商品正常
i=1;
}else if (!StringUtils.isEmpty(couserid)){//如果用户已登录
InitImVo initImVo=new InitImVo();
//个人信息
UserInfo mine=friendsService.LookUserMine(userid);
//好友列表
List<UserInfo> list=friendsService.LookUserFriend(userid);
Friend friend=new Friend().setId("2").setGroupname("分组").setList(list);
List<Friend> friendList=new ArrayList<>();
friendList.add(friend);
//群组信息
List<Groups> groupList=new ArrayList<>();
//Data数据
ImData imData=new ImData().setMine(mine).setFriend(friendList).setGroup(groupList);
initImVo.setCode(0).setMsg("").setData(imData);
return initImVo;
}
}
package com.controller;
@Controller
public class IndexController {
/**
* 网站首页
* */
@GetMapping("/")
public String index(){
return "/index";
}
/**
* 联系我们
* */
@GetMapping("/contacts")
public String contacts(){
return "/common/contacts";
/**
* <p>
* 登录注册 控制器
* </p>
*
*/
@Controller
public class LoginController {
@Autowired
private LoginService loginService;
@Autowired
private UserInfoService userInfoService;
@Autowired
private UserRoleService userRoleService;
/**手机号和注册验证码map集合*/
private static Map<String, String> phonecodemap1 = new HashMap<>();
/**手机号和重置密码验证码map集合*/
private static Map<String, String> phonecodemap2 = new HashMap<>();
/**
noticesService.insertNotices(notices);
return new ResultVo(true, StatusCode.OK, "设置管理员成功");
}
return new ResultVo(true, StatusCode.ERROR, "设置管理员失败");
}else if (roleid == 1){
Integer i = loginService.updateLogin(new Login().setUserid(userid).setRoleid(roleid));
if (i == 1){
userRoleService.UpdateUserRole(new UserRole().setUserid(userid).setRoleid(1).setIdentity("网站用户"));
/**发出设置为网站用户的系统通知*/
Notices notices = new Notices().setId(KeyUtil.genUniqueKey()).setUserid(userid).setTpname("系统通知")
.setWhys("您已被设置为网站用户,希望您再接再厉。");
noticesService.insertNotices(notices);
return new ResultVo(true, StatusCode.OK, "设置成员成功");
}
return new ResultVo(true, StatusCode.ERROR, "设置成员失败");
}
return new ResultVo(false,StatusCode.ACCESSERROR,"违规操作");
}
/**
* 将用户封号或解封(userstatus)
* 0:封号 1:解封
*/
@PutMapping("/admin/user/forbid/{userid}/{userstatus}")
@ResponseBody
public ResultVo adminuserlist(@PathVariable("userid") String userid,@PathVariable("userstatus") Integer userstatus) {
if (userstatus == 0){
Integer i = loginService.updateLogin(new Login().setUserid(userid).setUserstatus(userstatus));
Integer j = userInfoService.UpdateUserInfo(new UserInfo().setUserid(userid).setUserstatus(userstatus));
if (i ==1 && j == 1){
/**发出封号的系统通知*/
Notices notices = new Notices().setId(KeyUtil.genUniqueKey()).setUserid(userid).setTpname("系统通知")
.setWhys("因为您的不良行为,您在该网站的账号已被封号。");
noticesService.insertNotices(notices);
return new ResultVo(true, StatusCode.OK, "封号成功");
}
return new ResultVo(true, StatusCode.ERROR, "封号失败");
}else if (userstatus == 1){
Integer i = loginService.updateLogin(new Login().setUserid(userid).setUserstatus(userstatus));
Integer j = userInfoService.UpdateUserInfo(new UserInfo().setUserid(userid).setUserstatus(userstatus));
if (i ==1 && j == 1){
/**发出解封的系统通知*/
Notices notices = new Notices().setId(KeyUtil.genUniqueKey()).setUserid(userid).setTpname("系统通知")
.setWhys("您在该网站的账号已被解封,希望您保持良好的行为。");
noticesService.insertNotices(notices);
return new ResultVo(true, StatusCode.OK, "解封成功");
}
return new ResultVo(true, StatusCode.ERROR, "解封失败");
* 1.前端传入:商品id(commid)、商品发布者id(spuserid)、评论内容(content)
* 2.session获取:评论者id(cuserid)
* 3.过滤评论内容后,插入评论
*/
@ResponseBody
@PostMapping("/comment/insert")
public ResultVo insertcomment(@RequestBody Comment comment,HttpSession session) {
String cuserid = (String) session.getAttribute("userid");
String content = comment.getContent();
if (StringUtils.isEmpty(cuserid)) {
return new ResultVo(false,StatusCode.ACCESSERROR,"请登录后再评论");
}
content = content.replace("<", "<");
content = content.replace(">", ">");
content = content.replace("'", "\"");
comment.setCid(KeyUtil.genUniqueKey()).setCuserid(cuserid).setContent(content);
/**插入评论*/
Integer i = commentService.insertComment(comment);
if (i == 1){
/**发出评论通知消息*/
Commodity commodity = commodityService.LookCommodity(new Commodity().setCommid(comment.getCommid()));
Notices notices = new Notices().setId(KeyUtil.genUniqueKey()).setUserid(comment.getSpuserid()).setTpname("评论")
.setWhys("您的商品 <a href=/product-detail/"+comment.getCommid()+" style=\"color:#08bf91\" target=\"_blank\" >"+commodity.getCommname()+"</a> 被评论了,快去看看吧。");
noticesService.insertNotices(notices);
return new ResultVo(true, StatusCode.OK,"评论成功");
}
return new ResultVo(false,StatusCode.ERROR,"评论失败");
}
/**
* 评论回复
* 1.前端传入:商品id(commid)、评论id(cid)、被回复用户id(cuserid)、商品发布者id(spuserid)、评论内容(recontent)
* 2.session获取:回复者id(ruserid)
* 3.过滤评论回复内容后,插入评论回复
*/
@ResponseBody
@PostMapping("/reply/insert")
public ResultVo insertreply(@RequestBody Reply reply,HttpSession session) {
String ruserid = (String) session.getAttribute("userid");
String recontent = reply.getRecontent();
/**
* 发布商品
* 1、插入商品信息
* 2、插入商品其他图
*/
@PostMapping("/relgoods/rel")
@ResponseBody
public String relgoods(@RequestBody Commodity commodity, HttpSession session){
String userid = (String) session.getAttribute("userid");
UserInfo userInfo = userInfoService.LookUserinfo(userid);
String commid = KeyUtil.genUniqueKey();
commodity.setCommid(commid).setUserid(userid).setServer(userInfo.getServer());//商品id
//commodity.setCommon(commodity.getCommon()+"、"+commodity.getCommon2());//常用选项拼接
commodityService.InsertCommodity(commodity);
List<Commimages> commimagesList=new ArrayList<>();
for (String list:commodity.getOtherimg()) {
commimagesList.add(new Commimages().setId(KeyUtil.genUniqueKey()).setCommid(commid).setImage(list));
}
commimagesService.InsertGoodImages(commimagesList);
/**发出待审核系统通知*/
Notices notices = new Notices().setId(KeyUtil.genUniqueKey()).setUserid(userid).setTpname("商品审核")
.setWhys("您的商品 <a href=/product-detail/"+commid+" style=\"color:#08bf91\" target=\"_blank\" >"+commodity.getCommname()+"</a> 进入待审核队列,请您耐心等待。");
noticesService.insertNotices(notices);
return "0";
}
/**
* 上传视频和主图
*/
@PostMapping("/relgoods/video")
@ResponseBody
public JSONObject relgoodsvideo(@RequestParam(value = "file", required = false) MultipartFile file) throws IOException {
JSONObject res = new JSONObject();
JSONObject resUrl = new JSONObject();
String filename = UUID.randomUUID().toString().replaceAll("-", "");
String ext = FilenameUtils.getExtension(file.getOriginalFilename());
String filenames = filename + "." + ext;
String pathname = "D:/file/" + filenames;
file.transferTo(new File(pathname));
resUrl.put("src", "/pic/"+filenames);
if (webSocketSet.get(reviceUserid) != null) {
webSocketSet.get(reviceUserid).sendMessage(JSONObject.toJSONString(message));//转成json形式发送出去
}else{
webSocketSet.get(userno).sendMessage("0");
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 给群组中的所有人发消息
*
* @param message
*/
private void sendAll(UserInfo message) {
}
/**
* 发生错误时调用
*
* @param session
* @param error
*/
@OnError
public void onError(Session session, Throwable error) {
error.printStackTrace();
}
/**
* 这个方法与上面几个方法不一样。没有用注解,是根据自己需要添加的方法。
*
* @param message
* @throws IOException
*/
public void sendMessage(String message) throws IOException {
this.WebSocketsession.getBasicRemote().sendText(message);
//this.session.getAsyncRemote().sendText(message);
}
public static synchronized int getOnlineCount() {
return onlineCount;
}
public static synchronized void addOnlineCount() {
ChatWebSocket.onlineCount++;
}
@RunWith(SpringRunner.class)
@SpringBootTest
public class StartApplicationTests {
@Autowired
private CommodityService commodityService;
@Autowired
private CommimagesService commimagesService;
@Autowired
private CommentService commentService;
@Autowired
private ReplyService replyService;
@Autowired
private UserInfoService userInfoService;
/**
* 查询商品下的评论和回复
*/
@Test
@Transactional
public void queryCommentReply() {
/**查询评论*/
List<Comment> commentsList = commentService.queryComments("1577792919764240135");
for (Comment comment : commentsList) {
/**查询对应评论下的回复*/
if (i == 1){
return new ResultVo(true, StatusCode.OK,"取消成功");
}
return new ResultVo(false,StatusCode.ERROR,"取消失败");
}
return new ResultVo(false,StatusCode.ACCESSERROR,"禁止操作");
}
/**
* 分页查看用户所有收藏内容
* 前端传入页码、分页数量
* 查询分页数据
*/
@ResponseBody
@GetMapping("/user/collect/queryall")
public LayuiPageVo usercollect(int limit, int page, HttpSession session) {
String couserid = (String) session.getAttribute("userid");
List<Collect> collectList = collectService.queryAllCollect((page - 1) * limit, limit, couserid);
Integer dataNumber = collectService.queryCollectCount(couserid);
return new LayuiPageVo("",0,dataNumber,collectList);
}
}
package com.controller;
@Controller
public class ChatCtrl {
@Autowired
FriendsService friendsService;
@Autowired
UserInfoService mineService;
@Autowired