ADD file via upload

B/S
p7ajvprf6 3 years ago
parent f0403e3971
commit ec597e78d0

@ -0,0 +1,104 @@
package com.campus.controller;
import com.campus.domain.Goods;
import com.campus.domain.User;
import com.campus.service.CampusService;
import com.campus.utils.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("campus")
public class CampusController {
@Autowired
private CampusService campusService;
//登录
@PostMapping("userlogin")
public Object userlogin(@RequestBody User user)
{
//System.out.println(user);
if(campusService.userLogin(user)) return JsonData.buildSuccess();
else return JsonData.buildError("用户名或密码错误");
}
//添加新用户
@PostMapping("newuser")
public Object newuser(@RequestBody User user)
{
if (!campusService.userLogin(user)) {
if (campusService.newUser(user)) {
return JsonData.buildSuccess();
} else
return JsonData.buildError("注册失败");
}
else return JsonData.buildError("用户名已存在");
}
//更新密码
@PostMapping("userupdate")
public Object userUpdate(@RequestBody User user) {
if (campusService.userUpdate(user)) {
return JsonData.buildSuccess();
} else
return JsonData.buildError("更新失败");
}
//查询用户
@PostMapping("userselect")
public Object userselect(@RequestBody User user) {
if (!campusService.userselect(user).isEmpty()) {
return JsonData.buildSuccess();
}
else return JsonData.buildError("密码错误");
}
//查询物品
@PostMapping("goodslist")
public Object goodslist(@RequestBody Goods goods)
{
List<Goods> goodsList=campusService.goodsSelect(goods);
if(!goodsList.isEmpty())
return JsonData.buildSuccess(goodsList);
else return JsonData.buildError("查询失败!");
}
//更新物品
@PostMapping("goodsupdate")
public Object goodsupdate(@RequestBody Goods goods)
{
if(campusService.goodsUpdate(goods))
return JsonData.buildSuccess();
else return JsonData.buildError("更新失败!");
}
//插入新物品
@PostMapping("goodsinter")
public Object goodsinter(@RequestBody Goods goods)
{
System.out.println(goods);
if(goods.getCommit()!=null&&goods.getImg()!=null&&goods.getPrice()!=null
&&goods.getType()!=null&&goods.getUsername()!=null&&goods.getPhone()!=null)
{
if(campusService.goodsInter(goods))
return JsonData.buildSuccess();
else
return JsonData.buildError("插入失败!");
}
else return JsonData.buildError("信息不完整!");
}
//删除物品
@PostMapping("goodsdelete")
public Object goodsdelete(@RequestBody Goods goods)
{
if(campusService.goodsDelete(goods))
return JsonData.buildSuccess();
else
return JsonData.buildError("删除失败!");
}
}
Loading…
Cancel
Save