新增批量删除
This commit is contained in:
parent
49c3b3adc2
commit
b5c0a3abaf
|
@ -8,4 +8,7 @@ import com.zheng.cms.dao.mapper.CmsArticleMapper;
|
||||||
*/
|
*/
|
||||||
public interface CmsArticleService extends BaseService<CmsArticleMapper> {
|
public interface CmsArticleService extends BaseService<CmsArticleMapper> {
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
int deleteByPrimaryKeys(String ids);
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,4 +8,7 @@ import com.zheng.cms.dao.mapper.CmsCategoryMapper;
|
||||||
*/
|
*/
|
||||||
public interface CmsCategoryService extends BaseService<CmsCategoryMapper> {
|
public interface CmsCategoryService extends BaseService<CmsCategoryMapper> {
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
int deleteByPrimaryKeys(String ids);
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,4 +8,7 @@ import com.zheng.cms.dao.mapper.CmsCommentMapper;
|
||||||
*/
|
*/
|
||||||
public interface CmsCommentService extends BaseService<CmsCommentMapper> {
|
public interface CmsCommentService extends BaseService<CmsCommentMapper> {
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
int deleteByPrimaryKeys(String ids);
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,4 +10,7 @@ import com.zheng.cms.dao.model.UserVO;
|
||||||
*/
|
*/
|
||||||
public interface CmsTagService extends BaseService<CmsTagMapper> {
|
public interface CmsTagService extends BaseService<CmsTagMapper> {
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
int deleteByPrimaryKeys(String ids);
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,11 +2,13 @@ package com.zheng.cms.service.impl;
|
||||||
|
|
||||||
import com.zheng.cms.dao.mapper.CmsArticleMapper;
|
import com.zheng.cms.dao.mapper.CmsArticleMapper;
|
||||||
import com.zheng.cms.service.CmsArticleService;
|
import com.zheng.cms.service.CmsArticleService;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.NumberUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章service实现
|
* 文章service实现
|
||||||
|
@ -26,4 +28,25 @@ public class CmsArticleServiceImpl implements CmsArticleService {
|
||||||
return cmsArticleMapper;
|
return cmsArticleMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
@Override
|
||||||
|
public int deleteByPrimaryKeys(String ids) {
|
||||||
|
if (StringUtils.isBlank(ids)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
String[] idArray = ids.split("-");
|
||||||
|
int count = 0;
|
||||||
|
for (String id : idArray) {
|
||||||
|
if (StringUtils.isBlank(id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
count += cmsArticleMapper.deleteByPrimaryKey(Integer.parseInt(id));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@ package com.zheng.cms.service.impl;
|
||||||
|
|
||||||
import com.zheng.cms.dao.mapper.CmsCategoryMapper;
|
import com.zheng.cms.dao.mapper.CmsCategoryMapper;
|
||||||
import com.zheng.cms.service.CmsCategoryService;
|
import com.zheng.cms.service.CmsCategoryService;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -26,4 +27,25 @@ public class CmsCategoryServiceImpl implements CmsCategoryService {
|
||||||
return cmsCategoryMapper;
|
return cmsCategoryMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
@Override
|
||||||
|
public int deleteByPrimaryKeys(String ids) {
|
||||||
|
if (StringUtils.isBlank(ids)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
String[] idArray = ids.split("-");
|
||||||
|
int count = 0;
|
||||||
|
for (String id : idArray) {
|
||||||
|
if (StringUtils.isBlank(id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
count += cmsCategoryMapper.deleteByPrimaryKey(Integer.parseInt(id));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@ package com.zheng.cms.service.impl;
|
||||||
|
|
||||||
import com.zheng.cms.dao.mapper.CmsCommentMapper;
|
import com.zheng.cms.dao.mapper.CmsCommentMapper;
|
||||||
import com.zheng.cms.service.CmsCommentService;
|
import com.zheng.cms.service.CmsCommentService;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -26,4 +27,25 @@ public class CmsCommentServiceImpl implements CmsCommentService {
|
||||||
return cmsCommentMapper;
|
return cmsCommentMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
@Override
|
||||||
|
public int deleteByPrimaryKeys(String ids) {
|
||||||
|
if (StringUtils.isBlank(ids)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
String[] idArray = ids.split("-");
|
||||||
|
int count = 0;
|
||||||
|
for (String id : idArray) {
|
||||||
|
if (StringUtils.isBlank(id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
count += cmsCommentMapper.deleteByPrimaryKey(Integer.parseInt(id));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@ package com.zheng.cms.service.impl;
|
||||||
|
|
||||||
import com.zheng.cms.dao.mapper.CmsTagMapper;
|
import com.zheng.cms.dao.mapper.CmsTagMapper;
|
||||||
import com.zheng.cms.service.CmsTagService;
|
import com.zheng.cms.service.CmsTagService;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -26,4 +27,25 @@ public class CmsTagServiceImpl implements CmsTagService {
|
||||||
return cmsTagMapper;
|
return cmsTagMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
@Override
|
||||||
|
public int deleteByPrimaryKeys(String ids) {
|
||||||
|
if (StringUtils.isBlank(ids)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
String[] idArray = ids.split("-");
|
||||||
|
int count = 0;
|
||||||
|
for (String id : idArray) {
|
||||||
|
if (StringUtils.isBlank(id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
count += cmsTagMapper.deleteByPrimaryKey(Integer.parseInt(id));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -38,6 +38,7 @@ public class CmsArticleController extends BaseController {
|
||||||
* @param page
|
* @param page
|
||||||
* @param rows
|
* @param rows
|
||||||
* @param request
|
* @param request
|
||||||
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
|
@ -74,33 +75,30 @@ public class CmsArticleController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 新增post
|
* 新增post
|
||||||
* @param cmsArticle
|
* @param cmsArticle
|
||||||
* @param binding
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||||
public String add(@Valid CmsArticle cmsArticle, BindingResult binding) {
|
public String add(@Valid CmsArticle cmsArticle, Model model) {
|
||||||
if (binding.hasErrors()) {
|
|
||||||
for (ObjectError error : binding.getAllErrors()) {
|
|
||||||
_log.error(error.getDefaultMessage());
|
|
||||||
}
|
|
||||||
return "/article/add";
|
|
||||||
}
|
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
cmsArticle.setCtime(time);
|
cmsArticle.setCtime(time);
|
||||||
cmsArticle.setOrders(time);
|
cmsArticle.setOrders(time);
|
||||||
cmsArticleService.getMapper().insertSelective(cmsArticle);
|
int count = cmsArticleService.getMapper().insertSelective(cmsArticle);
|
||||||
|
model.addAttribute("count", count);
|
||||||
_log.info("新增记录id为:{}", cmsArticle.getArticleId());
|
_log.info("新增记录id为:{}", cmsArticle.getArticleId());
|
||||||
return "redirect:/article/list";
|
return "redirect:/article/list";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
* @param id
|
* @param ids
|
||||||
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/delete/{id}",method = RequestMethod.GET)
|
@RequestMapping(value = "/delete/{ids}",method = RequestMethod.GET)
|
||||||
public String delete(@PathVariable("id") int id) {
|
public String delete(@PathVariable("ids") String ids, Model model) {
|
||||||
cmsArticleService.getMapper().deleteByPrimaryKey(id);
|
int count = cmsArticleService.deleteByPrimaryKeys(ids);
|
||||||
|
model.addAttribute("count", count);
|
||||||
return "redirect:/article/list";
|
return "redirect:/article/list";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +110,8 @@ public class CmsArticleController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
|
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
|
||||||
public String update(@PathVariable("id") int id, Model model) {
|
public String update(@PathVariable("id") int id, Model model) {
|
||||||
model.addAttribute("article", cmsArticleService.getMapper().selectByPrimaryKey(id));
|
CmsArticle article = cmsArticleService.getMapper().selectByPrimaryKey(id);
|
||||||
|
model.addAttribute("article", article);
|
||||||
return "/article/update";
|
return "/article/update";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,17 +119,14 @@ public class CmsArticleController extends BaseController {
|
||||||
* 修改post
|
* 修改post
|
||||||
* @param id
|
* @param id
|
||||||
* @param cmsArticle
|
* @param cmsArticle
|
||||||
* @param binding
|
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
||||||
public String update(@PathVariable("id") int id, @Valid CmsArticle cmsArticle, BindingResult binding, Model model) {
|
public String update(@PathVariable("id") int id, @Valid CmsArticle cmsArticle, Model model) {
|
||||||
if (binding.hasErrors()) {
|
int count = cmsArticleService.getMapper().updateByPrimaryKeySelective(cmsArticle);
|
||||||
model.addAttribute("errors", binding.getAllErrors());
|
model.addAttribute("count", count);
|
||||||
return "/article/update/" + id;
|
model.addAttribute("id", id);
|
||||||
}
|
|
||||||
cmsArticleService.getMapper().updateByPrimaryKeySelective(cmsArticle);
|
|
||||||
return "redirect:/article/list";
|
return "redirect:/article/list";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class CmsCategoryController extends BaseController {
|
||||||
* @param page
|
* @param page
|
||||||
* @param rows
|
* @param rows
|
||||||
* @param request
|
* @param request
|
||||||
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
|
@ -74,33 +75,30 @@ public class CmsCategoryController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 新增post
|
* 新增post
|
||||||
* @param cmsCategory
|
* @param cmsCategory
|
||||||
* @param binding
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||||
public String add(@Valid CmsCategory cmsCategory, BindingResult binding) {
|
public String add(@Valid CmsCategory cmsCategory, Model model) {
|
||||||
if (binding.hasErrors()) {
|
|
||||||
for (ObjectError error : binding.getAllErrors()) {
|
|
||||||
_log.error(error.getDefaultMessage());
|
|
||||||
}
|
|
||||||
return "/category/add";
|
|
||||||
}
|
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
cmsCategory.setCtime(time);
|
cmsCategory.setCtime(time);
|
||||||
cmsCategory.setOrders(time);
|
cmsCategory.setOrders(time);
|
||||||
cmsCategoryService.getMapper().insertSelective(cmsCategory);
|
int count = cmsCategoryService.getMapper().insertSelective(cmsCategory);
|
||||||
|
model.addAttribute("count", count);
|
||||||
_log.info("新增记录id为:{}", cmsCategory.getCategoryId());
|
_log.info("新增记录id为:{}", cmsCategory.getCategoryId());
|
||||||
return "redirect:/category/list";
|
return "redirect:/category/list";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
* @param id
|
* @param ids
|
||||||
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/delete/{id}",method = RequestMethod.GET)
|
@RequestMapping(value = "/delete/{ids}",method = RequestMethod.GET)
|
||||||
public String delete(@PathVariable("id") int id) {
|
public String delete(@PathVariable("ids") String ids, Model model) {
|
||||||
cmsCategoryService.getMapper().deleteByPrimaryKey(id);
|
int count = cmsCategoryService.deleteByPrimaryKeys(ids);
|
||||||
|
model.addAttribute("count", count);
|
||||||
return "redirect:/category/list";
|
return "redirect:/category/list";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +110,8 @@ public class CmsCategoryController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
|
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
|
||||||
public String update(@PathVariable("id") int id, Model model) {
|
public String update(@PathVariable("id") int id, Model model) {
|
||||||
model.addAttribute("category", cmsCategoryService.getMapper().selectByPrimaryKey(id));
|
CmsCategory category = cmsCategoryService.getMapper().selectByPrimaryKey(id);
|
||||||
|
model.addAttribute("category", category);
|
||||||
return "/category/update";
|
return "/category/update";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,17 +119,14 @@ public class CmsCategoryController extends BaseController {
|
||||||
* 修改post
|
* 修改post
|
||||||
* @param id
|
* @param id
|
||||||
* @param cmsCategory
|
* @param cmsCategory
|
||||||
* @param binding
|
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
||||||
public String update(@PathVariable("id") int id, @Valid CmsCategory cmsCategory, BindingResult binding, Model model) {
|
public String update(@PathVariable("id") int id, @Valid CmsCategory cmsCategory, Model model) {
|
||||||
if (binding.hasErrors()) {
|
int count = cmsCategoryService.getMapper().updateByPrimaryKeySelective(cmsCategory);
|
||||||
model.addAttribute("errors", binding.getAllErrors());
|
model.addAttribute("count", count);
|
||||||
return "/category/update/" + id;
|
model.addAttribute("id", id);
|
||||||
}
|
|
||||||
cmsCategoryService.getMapper().updateByPrimaryKeySelective(cmsCategory);
|
|
||||||
return "redirect:/category/list";
|
return "redirect:/category/list";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class CmsCommentController extends BaseController {
|
||||||
* @param page
|
* @param page
|
||||||
* @param rows
|
* @param rows
|
||||||
* @param request
|
* @param request
|
||||||
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
|
@ -76,31 +77,28 @@ public class CmsCommentController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 新增post
|
* 新增post
|
||||||
* @param cmsComment
|
* @param cmsComment
|
||||||
* @param binding
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||||
public String add(@Valid CmsComment cmsComment, BindingResult binding) {
|
public String add(@Valid CmsComment cmsComment, Model model) {
|
||||||
if (binding.hasErrors()) {
|
|
||||||
for (ObjectError error : binding.getAllErrors()) {
|
|
||||||
_log.error(error.getDefaultMessage());
|
|
||||||
}
|
|
||||||
return "/comment/add";
|
|
||||||
}
|
|
||||||
cmsComment.setCtime(System.currentTimeMillis());
|
cmsComment.setCtime(System.currentTimeMillis());
|
||||||
cmsCommentService.getMapper().insertSelective(cmsComment);
|
int count = cmsCommentService.getMapper().insertSelective(cmsComment);
|
||||||
|
model.addAttribute("count", count);
|
||||||
_log.info("新增记录id为:{}", cmsComment.getArticleId());
|
_log.info("新增记录id为:{}", cmsComment.getArticleId());
|
||||||
return "redirect:/comment/list";
|
return "redirect:/comment/list";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
* @param id
|
* @param ids
|
||||||
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/delete/{id}",method = RequestMethod.GET)
|
@RequestMapping(value = "/delete/{ids}",method = RequestMethod.GET)
|
||||||
public String delete(@PathVariable("id") int id) {
|
public String delete(@PathVariable("ids") String ids, Model model) {
|
||||||
cmsCommentService.getMapper().deleteByPrimaryKey(id);
|
int count = cmsCommentService.deleteByPrimaryKeys(ids);
|
||||||
|
model.addAttribute("count", count);
|
||||||
return "redirect:/comment/list";
|
return "redirect:/comment/list";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +110,8 @@ public class CmsCommentController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
|
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
|
||||||
public String update(@PathVariable("id") int id, Model model) {
|
public String update(@PathVariable("id") int id, Model model) {
|
||||||
model.addAttribute("comment", cmsCommentService.getMapper().selectByPrimaryKey(id));
|
CmsComment comment = cmsCommentService.getMapper().selectByPrimaryKey(id);
|
||||||
|
model.addAttribute("comment", comment);
|
||||||
return "/comment/update";
|
return "/comment/update";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,17 +119,14 @@ public class CmsCommentController extends BaseController {
|
||||||
* 修改post
|
* 修改post
|
||||||
* @param id
|
* @param id
|
||||||
* @param cmsComment
|
* @param cmsComment
|
||||||
* @param binding
|
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
||||||
public String update(@PathVariable("id") int id, @Valid CmsComment cmsComment, BindingResult binding, Model model) {
|
public String update(@PathVariable("id") int id, @Valid CmsComment cmsComment, Model model) {
|
||||||
if (binding.hasErrors()) {
|
int count = cmsCommentService.getMapper().updateByPrimaryKeySelective(cmsComment);
|
||||||
model.addAttribute("errors", binding.getAllErrors());
|
model.addAttribute("count", count);
|
||||||
return "/comment/update/" + id;
|
model.addAttribute("id", id);
|
||||||
}
|
|
||||||
cmsCommentService.getMapper().updateByPrimaryKeySelective(cmsComment);
|
|
||||||
return "redirect:/comment/list";
|
return "redirect:/comment/list";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class CmsTagController extends BaseController {
|
||||||
* @param page
|
* @param page
|
||||||
* @param rows
|
* @param rows
|
||||||
* @param request
|
* @param request
|
||||||
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
|
@ -74,33 +75,30 @@ public class CmsTagController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 新增post
|
* 新增post
|
||||||
* @param cmsTag
|
* @param cmsTag
|
||||||
* @param binding
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||||
public String add(@Valid CmsTag cmsTag, BindingResult binding) {
|
public String add(@Valid CmsTag cmsTag, Model model) {
|
||||||
if (binding.hasErrors()) {
|
|
||||||
for (ObjectError error : binding.getAllErrors()) {
|
|
||||||
_log.error(error.getDefaultMessage());
|
|
||||||
}
|
|
||||||
return "/tag/add";
|
|
||||||
}
|
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
cmsTag.setCtime(time);
|
cmsTag.setCtime(time);
|
||||||
cmsTag.setOrders(time);
|
cmsTag.setOrders(time);
|
||||||
cmsTagService.getMapper().insertSelective(cmsTag);
|
int count = cmsTagService.getMapper().insertSelective(cmsTag);
|
||||||
|
model.addAttribute("count", count);
|
||||||
_log.info("新增记录id为:{}", cmsTag.getTagId());
|
_log.info("新增记录id为:{}", cmsTag.getTagId());
|
||||||
return "redirect:/tag/list";
|
return "redirect:/tag/list";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
* @param id
|
* @param ids
|
||||||
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/delete/{id}",method = RequestMethod.GET)
|
@RequestMapping(value = "/delete/{ids}",method = RequestMethod.GET)
|
||||||
public String delete(@PathVariable("id") int id) {
|
public String delete(@PathVariable("ids") String ids, Model model) {
|
||||||
cmsTagService.getMapper().deleteByPrimaryKey(id);
|
int count = cmsTagService.deleteByPrimaryKeys(ids);
|
||||||
|
model.addAttribute("count", count);
|
||||||
return "redirect:/tag/list";
|
return "redirect:/tag/list";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +110,8 @@ public class CmsTagController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
|
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
|
||||||
public String update(@PathVariable("id") int id, Model model) {
|
public String update(@PathVariable("id") int id, Model model) {
|
||||||
model.addAttribute("tag", cmsTagService.getMapper().selectByPrimaryKey(id));
|
CmsTag tag = cmsTagService.getMapper().selectByPrimaryKey(id);
|
||||||
|
model.addAttribute("tag", tag);
|
||||||
return "/tag/update";
|
return "/tag/update";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,17 +119,14 @@ public class CmsTagController extends BaseController {
|
||||||
* 修改post
|
* 修改post
|
||||||
* @param id
|
* @param id
|
||||||
* @param cmsTag
|
* @param cmsTag
|
||||||
* @param binding
|
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
||||||
public String update(@PathVariable("id") int id, @Valid CmsTag cmsTag, BindingResult binding, Model model) {
|
public String update(@PathVariable("id") int id, @Valid CmsTag cmsTag, Model model) {
|
||||||
if (binding.hasErrors()) {
|
int count = cmsTagService.getMapper().updateByPrimaryKeySelective(cmsTag);
|
||||||
model.addAttribute("errors", binding.getAllErrors());
|
model.addAttribute("count", count);
|
||||||
return "/tag/update/" + id;
|
model.addAttribute("id", id);
|
||||||
}
|
|
||||||
cmsTagService.getMapper().updateByPrimaryKeySelective(cmsTag);
|
|
||||||
return "redirect:/tag/list";
|
return "redirect:/tag/list";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue