更新notice
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package com.lovenav.service.serviceImpl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.lovenav.dao.NoticeDao;
|
||||
import com.lovenav.entity.Notice;
|
||||
import com.lovenav.service.NoticeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
public class NoticeServiceImpl implements NoticeService {
|
||||
@Autowired
|
||||
private NoticeDao noticeDao;
|
||||
public String add(Notice notice){
|
||||
HashMap<String,Object> hashMap = new HashMap<>();
|
||||
int result = noticeDao.insert(notice);
|
||||
if(result>0){
|
||||
hashMap.put("code",200);
|
||||
hashMap.put("msg","添加成功");
|
||||
return JSON.toJSONString(hashMap);
|
||||
}else{
|
||||
hashMap.put("code",500);
|
||||
hashMap.put("msg","添加成功");
|
||||
return JSON.toJSONString(hashMap);
|
||||
}
|
||||
}
|
||||
public String delete(int id){
|
||||
HashMap<String,Object> hashMap = new HashMap<>();
|
||||
int result = noticeDao.deleteByPrimaryKey(id);
|
||||
if(result>0){
|
||||
hashMap.put("code",200);
|
||||
hashMap.put("msg","删除成功");
|
||||
return JSON.toJSONString(hashMap);
|
||||
}else{
|
||||
hashMap.put("code",500);
|
||||
hashMap.put("msg","删除失败");
|
||||
return JSON.toJSONString(hashMap);
|
||||
}
|
||||
}
|
||||
public String select(int id){
|
||||
HashMap<String,Object> hashMap = new HashMap<>();
|
||||
Notice result = noticeDao.selectByPrimaryKey(id);
|
||||
if(result != null){
|
||||
return JSON.toJSONString(result);
|
||||
}else{
|
||||
hashMap.put("code",500);
|
||||
hashMap.put("msg","查找失败");
|
||||
return JSON.toJSONString(hashMap);
|
||||
}
|
||||
}
|
||||
public String update(Notice notice){
|
||||
HashMap<String,Object> hashMap = new HashMap<>();
|
||||
int result = noticeDao.updateByPrimaryKeySelective(notice);
|
||||
if(result > 0){
|
||||
hashMap.put("code",200);
|
||||
hashMap.put("msg","修改成功");
|
||||
return JSON.toJSONString(hashMap);
|
||||
}else{
|
||||
hashMap.put("code",500);
|
||||
hashMap.put("msg","修改失败");
|
||||
return JSON.toJSONString(hashMap);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user