package com.yuanlrc.campus_market.controller.home;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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.ResponseBody;
import com.yuanlrc.campus_market.bean.CodeMsg;
import com.yuanlrc.campus_market.bean.Result;
import com.yuanlrc.campus_market.constant.SessionConstant;
import com.yuanlrc.campus_market.entity.common.Comment;
import com.yuanlrc.campus_market.entity.common.Goods;
import com.yuanlrc.campus_market.entity.common.ReportGoods;
import com.yuanlrc.campus_market.entity.common.Student;
import com.yuanlrc.campus_market.entity.common.WantedGoods;
import com.yuanlrc.campus_market.service.common.CommentService;
import com.yuanlrc.campus_market.service.common.GoodsCategoryService;
import com.yuanlrc.campus_market.service.common.GoodsService;
import com.yuanlrc.campus_market.service.common.ReportGoodsService;
import com.yuanlrc.campus_market.service.common.StudentService;
import com.yuanlrc.campus_market.service.common.WantedGoodsService;
import com.yuanlrc.campus_market.util.SessionUtil;
import com.yuanlrc.campus_market.util.ValidateEntityUtil;
/**
* 学生中心控制器
* @author Administrator
*
*/
@RequestMapping("/home/student")
@Controller
public class HomeStudentController {
@Autowired
private GoodsCategoryService goodsCategoryService;
@Autowired
private StudentService studentService;
@Autowired
private GoodsService goodsService;
@Autowired
private WantedGoodsService wantedGoodsService;
@Autowired
private ReportGoodsService reportGoodsService;
@Autowired
private CommentService commentService;
/**
* 学生登录主页
* @param model
* @return
*/
@RequestMapping(value="/index",method=RequestMethod.GET)
public String index(Model model){
Student loginedStudent = (Student)SessionUtil.get(SessionConstant.SESSION_STUDENT_LOGIN_KEY);
model.addAttribute("goodsList", goodsService.findByStudent(loginedStudent));
model.addAttribute("wantedGoodsList", wantedGoodsService.findByStudent(loginedStudent));
model.addAttribute("reportGoodsList", reportGoodsService.findByStudent(loginedStudent));
return "home/student/index";
}
/**
* 修改个人信息提交表单
* @param student
* @return
*/
@RequestMapping(value="/edit_info",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> editInfo(Student student){
Student loginedStudent = (Student)SessionUtil.get(SessionConstant.SESSION_STUDENT_LOGIN_KEY);
loginedStudent.setAcademy(student.getAcademy());
loginedStudent.setGrade(student.getGrade());
loginedStudent.setMobile(student.getMobile());
loginedStudent.setNickname(student.getNickname());
loginedStudent.setQq(student.getQq());
loginedStudent.setSchool(student.getSchool());
if(studentService.save(loginedStudent) == null){
return Result.error(CodeMsg.HOME_STUDENT_EDITINFO_ERROR);
}
SessionUtil.set(SessionConstant.SESSION_STUDENT_LOGIN_KEY,loginedStudent);
return Result.success(true);
}
/**
* 保存用户头像
* @param headPic
* @return
*/
@RequestMapping(value="/update_head_pic",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> updateHeadPic(@RequestParam(name="headPic",required=true)String headPic){
Student loginedStudent = (Student)SessionUtil.get(SessionConstant.SESSION_STUDENT_LOGIN_KEY);
loginedStudent.setHeadPic(headPic);;
if(studentService.save(loginedStudent) == null){
return Result.error(CodeMsg.HOME_STUDENT_EDITINFO_ERROR);
}
SessionUtil.set(SessionConstant.SESSION_STUDENT_LOGIN_KEY,loginedStudent);
return Result.success(true);
}
/**
* 物品发布页面
* @param model
* @return
*/
@RequestMapping(value="/publish",method=RequestMethod.GET)
public String publish(Model model){
return "home/student/publish";
}
/**
* 商品发布表单提交
* @param goods
* @return
*/
@RequestMapping(value="/publish",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> publish(Goods goods){
CodeMsg validate = ValidateEntityUtil.validate(goods);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(goods.getGoodsCategory() == null || goods.getGoodsCategory().getId() == null || goods.getGoodsCategory().getId().longValue() == -1){
return Result.error(CodeMsg.HOME_STUDENT_PUBLISH_CATEGORY_EMPTY);
}
Student loginedStudent = (Student)SessionUtil.get(SessionConstant.SESSION_STUDENT_LOGIN_KEY);
goods.setStudent(loginedStudent);
if(goodsService.save(goods) == null){
return Result.error(CodeMsg.HOME_STUDENT_PUBLISH_ERROR);
}
return Result.success(true);
}
/**
* 物品编辑页面
* @param id
* @param model
* @return
*/
@RequestMapping(value="/edit_goods",method=RequestMethod.GET)
public String publish(@RequestParam(name="id",required=true)Long id,Model model){
Student loginedStudent = (Student)SessionUtil.get(SessionConstant.SESSION_STUDENT_LOGIN_KEY);
Goods goods = goodsService.find(id, loginedStudent.getId());
if(goods == null){
model.addAttribute("msg", "物品不存在!");
return "error/runtime_error";
}
model.addAttribute("goods", goods);
return "home/student/edit_goods";
}
/**
* 物品编辑表单提交
* @param goods
* @return
*/
@RequestMapping(value="/edit_goods",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> editGoods(Goods goods){
CodeMsg validate = ValidateEntityUtil.validate(goods);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(goods.getGoodsCategory() == null || goods.getGoodsCategory().getId() == null || goods.getGoodsCategory().getId().longValue() == -1){
return Result.error(CodeMsg.HOME_STUDENT_PUBLISH_CATEGORY_EMPTY);
}
Student loginedStudent = (Student)SessionUtil.get(SessionConstant.SESSION_STUDENT_LOGIN_KEY);
Goods existGoods = goodsService.find(goods.getId(), loginedStudent.getId());
if(existGoods == null){
return Result.error(CodeMsg.HOME_STUDENT_GOODS_NO_EXIST);
}
existGoods.setBuyPrice(goods.getBuyPrice());
existGoods.setContent(goods.getContent());
existGoods.setGoodsCategory(goods.getGoodsCategory());
existGoods.setName(goods.getName());
existGoods.setPhoto(goods.getPhoto());
existGoods.setSellPrice(goods.getSellPrice());
if(goodsService.save(existGoods) == null){
return Result.error(CodeMsg.HOME_STUDENT_GOODS_EDIT_ERROR);
}
return Result.success(true);
}
/**
* 用户设置是否擦亮物品
* @param id
* @param flag
* @return
*/
@RequestMapping(value="/update_flag",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> updateFlag(@RequestParam(name="id",required=true)Long id,
@RequestParam(name="flag",required=true,defaultValue="0")Integer flag){
Student loginedStudent = (Student)SessionUtil.get(SessionConstant.SESSION_STUDENT_LOGIN_KEY);
Goods existGoods = goodsService.find(id, loginedStudent.getId());
if(existGoods == null){
return Result.error(CodeMsg.HOME_STUDENT_GOODS_NO_EXIST);
}
existGoods.setFlag(flag);
if(goodsService.save(existGoods) == null){
return Result.error(CodeMsg.HOME_STUDENT_GOODS_EDIT_ERROR);
}
return Result.success(true);
}
/**
* 修改物品状态
* @param id
* @param status
* @return
*/
@RequestMapping(value="/update_status",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> updateStatus(@RequestParam(name="id",required=true)Long id,
@RequestParam(name="status",required=true,defaultValue="2")Integer status){
Student loginedStudent = (Student)SessionUtil.get(SessionConstant.SESSION_STUDENT_LOGIN_KEY);
Goods existGoods = goodsService.find(id, loginedStudent.getId())
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于springboot的校园二手交易系统(源代码+数据库.zip (516个子文件)
common_footer 0B
bootstrap.min.css 111KB
bootstrap.min.css 106KB
style.min.css 105KB
materialdesignicons.min.css 85KB
animate.css 71KB
bootstrap-datepicker3.css 22KB
want_list.css 22KB
jquery-confirm.min.css 22KB
index.css 22KB
user_center.css 22KB
product_detail.css 21KB
release_product.css 21KB
bootstrap-datepicker3.min.css 21KB
ion.rangeSlider.min.css 11KB
bootstrap-datetimepicker.css 9KB
bootstrap-datetimepicker.min.css 8KB
bootstrap-switch.css 6KB
bootstrap-table.min.css 6KB
bootstrap-switch.min.css 5KB
login2.css 5KB
bootstrap-colorpicker.css 5KB
bootstrap-colorpicker.min.css 4KB
highlight.css 3KB
jquery.tagsinput.min.css 903B
main.css 896B
want_list_creat.css 193B
materialdesignicons.eot 286KB
index.ftl 16KB
list.ftl 10KB
edit_goods.ftl 9KB
setting.ftl 9KB
publish.ftl 8KB
header-menu.ftl 8KB
edit.ftl 8KB
list.ftl 8KB
add.ftl 8KB
operator_log_list.ftl 7KB
list.ftl 7KB
index.ftl 7KB
list.ftl 7KB
list.ftl 7KB
edit.ftl 6KB
list.ftl 6KB
add.ftl 6KB
edit_wanted.ftl 4KB
publish_wanted.ftl 4KB
edit.ftl 4KB
update_userinfo.ftl 4KB
login.ftl 4KB
add.ftl 4KB
edit.ftl 4KB
add.ftl 3KB
top_header.ftl 3KB
update_pwd.ftl 3KB
icons.ftl 2KB
left_menu.ftl 1KB
right_menu.ftl 1KB
404.ftl 1KB
no_right.ftl 1KB
500.ftl 1KB
runtime_error.ftl 1KB
405.ftl 1KB
bottom_footer.ftl 861B
left-menu.ftl 800B
footer.ftl 667B
header.ftl 524B
third-menu.ftl 502B
loading.gif 17KB
blank.gif 43B
favicon.ico 4KB
favicon.ico 167B
ios_default_1493871419_107281_0 128KB
ios_default_1493871419_107281_1 118KB
ios_default_1493871419_107281_3 116KB
ios_default_1493871439_107281_2 130KB
HomeStudentController.java 16KB
SystemController.java 9KB
CodeMsg.java 9KB
CpachaUtil.java 6KB
MenuController.java 5KB
RoleController.java 5KB
IndexController.java 5KB
GoodsCategoryController.java 5KB
DatabaseBakService.java 5KB
UserController.java 5KB
GoodsController.java 5KB
Goods.java 5KB
GoodsService.java 5KB
FriendLinkController.java 4KB
WantedGoodsService.java 4KB
NewsController.java 4KB
Student.java 4KB
CommentService.java 4KB
SiteSetting.java 3KB
User.java 3KB
ReportGoodsService.java 3KB
AdminUploadController.java 3KB
HomeUploadController.java 3KB
OperaterLogService.java 3KB
共 516 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
博士僧小星
- 粉丝: 2402
- 资源: 5995
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 2-一款检查MD5值的简单小软件
- 在线考试系统、考试系统、在线教育考试系统、在线教育、跨平台考试、考试、智能考试、试题、错误试题、考试题目、试题组卷等
- abaqus数值模拟案例系列-随机纤维分布二维RVE模型微观横向拉伸损伤,设置了周期边界,采用Drucker-Prager(dp)准则,Ductile-Damage延性损伤,界面采用cohesive单
- 湖南网络建设与运维技能竞赛规程及内容详解
- 2-MonitorOff 显示器的开启与关闭工具
- Screenshot_2024-12-31-14-41-43-682_tv.danmaku.bili.jpg
- 电击穿 介电击穿 相场模拟 相场模型 comsol pde做的
- Tyranor模拟器.zip
- 基于IntelliJ IDEA开发的代码生成插件,支持自定义任意模板(Java,html,js,xml) 只要是与数据库相关的代码都可以通过自定义模板来生成 支持数据库类型与java类型映射关系配置
- Nginx 配置文件详解(带示例)
- comsol仿真,变压器匝间短路5%的电磁振动噪声模型 包括电磁场分布,磁密分布,振动形变,噪声分布等结果
- 10kg级的承重计,可以用来测量小型物品的重量.zip、arduino代码(C++)含ppt
- 驱动AD7124,使用STM32 HAL库
- C 编译的MAKEFILE 的介绍
- ELK+Filebeat+Kafka+ZooKeeper构建大数据日志分析平台6.7.2安装包
- 单相交流调压器仿真实验报告
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功