master
ck 5 years ago
parent a7a5b4694c
commit 37e86f0e14

@ -24,6 +24,8 @@
package com.jingcheng.cms.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
@ -42,6 +44,7 @@ public class BaseEntity {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
@TableId(type = IdType.INPUT)
private Long id;
private Date createDateTime;
private Date updateDateTime;

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.jingcheng.cms.constants.Constants;
import com.jingcheng.cms.mapper.ArticleMapper;
import com.jingcheng.cms.model.Article;
import com.jingcheng.cms.model.Users;
import com.jingcheng.cms.service.ArticleSerive;
import com.jingcheng.cms.util.AjaxResult;
import com.jingcheng.cms.util.PageUtils;
@ -85,6 +86,10 @@ public class ArticleSerivceImpl implements ArticleSerive {
ajaxResult.setRetmsg("未找到文章");
return ajaxResult;
}
Example example = new Example(Article.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id",id);
article = new Article();
article.setTitle(title);
article.setFirstCategory(firstCategory);
article.setSecondCategory(secondCategory);
@ -92,7 +97,7 @@ public class ArticleSerivceImpl implements ArticleSerive {
article.setFileType(fileType);
article.setState(state);
article.setContent(content);
articleMapper.updateByPrimaryKeySelective(article);
articleMapper.updateByExampleSelective(article,example);
ajaxResult.setRetmsg("成功修改文章");
}
return ajaxResult;
@ -158,10 +163,15 @@ public class ArticleSerivceImpl implements ArticleSerive {
if (null == article){
continue;
}
Example example = new Example(Article.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id",id);
article = new Article();
article.setState(Constants.DISABLE);
articleMapper.updateByPrimaryKeySelective(article);
articleMapper.updateByExampleSelective(article,example);
}
return null;
ajaxResult.setRetmsg("批量删除成功");
return ajaxResult;
}

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.jingcheng.cms.constants.Constants;
import com.jingcheng.cms.mapper.CategoryMapper;
import com.jingcheng.cms.mapper.CategoryTypeMapper;
import com.jingcheng.cms.model.Article;
import com.jingcheng.cms.model.Category;
import com.jingcheng.cms.model.CategoryType;
import com.jingcheng.cms.service.CategoryService;
@ -82,10 +83,14 @@ public class CategoryServiceImpl implements CategoryService {
ajaxResult.setRetcode(AjaxResult.FAILED);
return ajaxResult;
}else {
Example example = new Example(Category.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id",id);
category = new Category();
category.setName(name);
category.setSortNum(sortNum);
category.setTypeName(typeName);
categoryMapper.updateByPrimaryKeySelective(category);
categoryMapper.updateByExampleSelective(category,example);
}
ajaxResult.setRetmsg("成功修改分类");
}else {
@ -112,8 +117,12 @@ public class CategoryServiceImpl implements CategoryService {
ajaxResult.setRetcode(AjaxResult.FAILED);
return ajaxResult;
}else {
Example example = new Example(Category.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id",id);
category = new Category();
category.setState(Constants.DISABLE);
categoryMapper.updateByPrimaryKeySelective(category);
categoryMapper.updateByExampleSelective(category,example);
ajaxResult.setRetmsg("分类删除成功");
return ajaxResult;
}

@ -3,6 +3,7 @@ package com.jingcheng.cms.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.jingcheng.cms.constants.Constants;
import com.jingcheng.cms.mapper.PopularLabelMapper;
import com.jingcheng.cms.model.Article;
import com.jingcheng.cms.model.PopularLabel;
import com.jingcheng.cms.service.PopularLabelService;
import com.jingcheng.cms.util.AjaxResult;
@ -47,9 +48,13 @@ public class PopularLabelServiceImpl implements PopularLabelService {
ajaxResult.setRetcode(AjaxResult.FAILED);
return ajaxResult;
}else {
Example example = new Example(PopularLabel.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id",id);
popularLabel = new PopularLabel();
popularLabel.setName(name);
popularLabel.setSortNum(sortNum);
popularLabelMapper.updateByPrimaryKeySelective(popularLabel);
popularLabelMapper.updateByExampleSelective(popularLabel,example);
}
ajaxResult.setRetmsg("成功修改热门标签");
}else {
@ -74,8 +79,12 @@ public class PopularLabelServiceImpl implements PopularLabelService {
ajaxResult.setRetcode(AjaxResult.FAILED);
return ajaxResult;
}else {
Example example = new Example(PopularLabel.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id",id);
popularLabel = new PopularLabel();
popularLabel.setState(Constants.DISABLE);
popularLabelMapper.updateByPrimaryKeySelective(popularLabel);
popularLabelMapper.updateByExampleSelective(popularLabel,example);
ajaxResult.setRetmsg("热门标签删除成功");
return ajaxResult;
}

@ -6,10 +6,8 @@ import com.jingcheng.cms.mapper.UsersMapper;
import com.jingcheng.cms.model.PopularLabel;
import com.jingcheng.cms.model.Users;
import com.jingcheng.cms.service.UsersService;
import com.jingcheng.cms.util.AjaxResult;
import com.jingcheng.cms.util.JWTUtil;
import com.jingcheng.cms.util.LogUtils;
import com.jingcheng.cms.util.PageUtils;
import com.jingcheng.cms.util.*;
import lombok.SneakyThrows;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
@ -18,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.List;
@Service
@ -73,8 +72,10 @@ public class UsersServiceImpl implements UsersService {
return pageJson;
}
@SneakyThrows
@Override
public AjaxResult saveUsers(JSONObject jsonObject) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
AjaxResult ajaxResult = new AjaxResult();
Long id = jsonObject.getLong("id");
String userName = jsonObject.getString("userName");
@ -87,10 +88,14 @@ public class UsersServiceImpl implements UsersService {
ajaxResult.setRetcode(AjaxResult.FAILED);
return ajaxResult;
}else {
Example example = new Example(Users.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id",id);
users = new Users();
users.setUserName(userName);
users.setUserNo(userNo);
users.setPassword(password);
usersMapper.updateByPrimaryKeySelective(users);
usersMapper.updateByExampleSelective(users,example);
}
ajaxResult.setRetmsg("成功修改用户");
}else {
@ -116,8 +121,12 @@ public class UsersServiceImpl implements UsersService {
ajaxResult.setRetcode(AjaxResult.FAILED);
return ajaxResult;
}else {
Example example = new Example(Users.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id",id);
users = new Users();
users.setState(Constants.DISABLE);
usersMapper.updateByPrimaryKeySelective(users);
usersMapper.updateByExampleSelective(users,example);
ajaxResult.setRetmsg("用户删除成功");
return ajaxResult;
}

@ -2,8 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jingcheng.cms.mapper.UsersMapper">
<insert id="addUsers" parameterType="com.jingcheng.cms.model.Users">
INSERT INTO users(`user_name`,`user_no`,`password`)
values (#{userName},#{userNo},#{password})
<insert id="addUsers" parameterType="com.jingcheng.cms.model.Users" keyProperty="id" useGeneratedKeys="true">
INSERT INTO users(`user_name`,`user_no`,`password`,`state`)
values (#{userName},#{userNo},#{password},1)
</insert>
</mapper>
Loading…
Cancel
Save