更新
This commit is contained in:
parent
85b047e938
commit
4127e7d5e4
@ -9,31 +9,30 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/banners")
|
||||
public class BannersController {
|
||||
@Autowired
|
||||
private BannersService bannersService;
|
||||
|
||||
// 跳转链接
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/jump_url")
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/banners/jump_url")
|
||||
public String jump(int id) {
|
||||
return bannersService.Jump_url(id);
|
||||
}
|
||||
|
||||
// 添加banner
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/add_banner")
|
||||
public String add(@RequestBody Banners banners) {
|
||||
@RequestMapping( "/banners/add_banner")
|
||||
public String add(Banners banners) {
|
||||
return bannersService.Add_banner(banners);
|
||||
}
|
||||
|
||||
// 删除banner
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/delete_url")
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/banners/delete_url")
|
||||
public String delete(int id) {
|
||||
return bannersService.Delete_banner(id);
|
||||
}
|
||||
|
||||
// 首页显示banner
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/view_banner")
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/banners/view_banner")
|
||||
public String view() {
|
||||
return bannersService.View_banner();
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import com.lovenav.entity.Banners;
|
||||
import com.lovenav.service.BannersService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
|
||||
@ -31,10 +33,14 @@ public class BannersServiceImpl implements BannersService {
|
||||
// 添加banner
|
||||
@Override
|
||||
public String Add_banner(Banners banners) {
|
||||
Date date = new Date(System.currentTimeMillis());
|
||||
banners.setCreatetime(date);
|
||||
int result = bannersDao.insert(banners);
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
if(result>0){
|
||||
return JSON.toJSONString(banners);
|
||||
hashMap.put("code",200);
|
||||
hashMap.put("msg","添加成功");
|
||||
return JSON.toJSONString(hashMap);
|
||||
}else{
|
||||
hashMap.put("code",500);
|
||||
hashMap.put("msg","添加banner失败");
|
||||
|
Loading…
Reference in New Issue
Block a user