首页>代码>ssm个人博客,包括登录注册,前端后台功能全面完整>/lingnanblog-/src/main/java/neusoft/controller/admin/BlogTypeAdminController.java
package neusoft.controller.admin; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import neusoft.pojo.BlogType; import neusoft.service.BlogService; import neusoft.service.BlogTypeService; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import neusoft.pojo.PageBean; import neusoft.service.BlogTypeService; import neusoft.util.ResponseUtil; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @Controller @RequestMapping("/admin/blogType") public class BlogTypeAdminController { @Resource private BlogTypeService blogTypeService; @Resource private BlogService blogService; @RequestMapping("/list") public String list(@RequestParam(value="page",required=false)String page,@RequestParam(value="rows",required=false)String rows,HttpServletResponse response)throws Exception{ PageBean pageBean=new PageBean(Integer.parseInt(page),Integer.parseInt(rows)); Map<String,Object> map=new HashMap<String,Object>(); map.put("start", pageBean.getStart()); map.put("size", pageBean.getPageSize()); List<BlogType> blogTypeList=blogTypeService.list(map); Long total=blogTypeService.getTotal(map); JSONObject result=new JSONObject(); JSONArray jsonArray=JSONArray.fromObject(blogTypeList); result.put("rows", jsonArray); result.put("total", total); ResponseUtil.write(response, result); return null; } @RequestMapping("/save") public String save(BlogType blogType,HttpServletResponse response)throws Exception{ int resultTotal=0; // �����ļ�¼���� if(blogType.getId()==null){ resultTotal=blogTypeService.add(blogType); }else{ resultTotal=blogTypeService.update(blogType); } JSONObject result=new JSONObject(); if(resultTotal>0){ result.put("success", true); }else{ result.put("success", false); } ResponseUtil.write(response, result); return null; } @RequestMapping("/delete") public String delete(@RequestParam(value="ids")String ids,HttpServletResponse response)throws Exception{ System.out.println(ids); String []idsStr=ids.split(","); JSONObject result=new JSONObject(); for(int i=0;i<idsStr.length;i++){ if(blogService.getBlogByTypeId(Integer.parseInt(idsStr[i]))>0){ result.put("exist", "该类别下您已经发布了博客,不能删除!"); }else{ blogTypeService.delete(Integer.parseInt(idsStr[i])); } } result.put("success", true); ResponseUtil.write(response, result); return null; } }
最近下载更多
问耳朵 LV2
2023年12月14日
我是helloworld LV23
2023年6月18日
monolog LV4
2023年6月18日
微信网友_6495054193971200 LV2
2023年5月30日
zxc131313 LV12
2022年12月9日
刘鹏yyds LV10
2022年11月23日
SCP11451 LV6
2022年10月10日
LJLljl002 LV5
2022年9月18日
℡ LV8
2022年6月6日
taoshen95 LV14
2022年5月6日
最近浏览更多
songsmm LV1
3月11日
李林112233 LV2
1月13日
微信网友_6802079662936064 LV3
2023年12月31日
263648 LV7
2023年12月28日
a2056769602
2023年12月27日
暂无贡献等级
wwewww LV4
2023年12月18日
问耳朵 LV2
2023年12月14日
limenghaoqwer LV2
2023年12月10日
hamberduan LV1
2023年12月10日
shuangfu LV24
2023年12月2日