新增备注列表
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package lingtao.net.bean;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 产品知识点;
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class Information {
|
||||
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String content;
|
||||
|
||||
private String type;
|
||||
|
||||
private String createBy;
|
||||
|
||||
private Date createDate;
|
||||
|
||||
private String updateBy;
|
||||
|
||||
private Date updateDate;
|
||||
/**
|
||||
* 附件
|
||||
*/
|
||||
private String attachment;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package lingtao.net.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import lingtao.net.bean.Information;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.service.InformationService;
|
||||
|
||||
@RestController
|
||||
public class InformationController {
|
||||
|
||||
@Autowired
|
||||
private InformationService informationService;
|
||||
|
||||
/**
|
||||
* 产品知识列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getInformations")
|
||||
public Msg getInformations(@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "limit", defaultValue = "10") Integer limit, Information information) {
|
||||
PageHelper.startPage(page, limit);
|
||||
List<Information> informationList = informationService.getInformations(information);
|
||||
PageInfo<Information> pageInfo = new PageInfo<Information>(informationList);
|
||||
return Msg.success().add("list", pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加产品知识
|
||||
*/
|
||||
@RequestMapping("/addInformation")
|
||||
public Msg addInformation(Information information, HttpSession session) {
|
||||
informationService.addInformation(information, session);
|
||||
return Msg.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改产品知识
|
||||
*/
|
||||
@RequestMapping("/updateInformation")
|
||||
public Msg updateInformation(Information information, HttpSession session) {
|
||||
informationService.updateInformationById(information, session);
|
||||
return Msg.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/deleteInformation")
|
||||
public Msg deleteInformation(@RequestParam("id") Integer id) {
|
||||
informationService.deleteInformationById(id);
|
||||
return Msg.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package lingtao.net.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lingtao.net.bean.Information;
|
||||
|
||||
public interface InformationMapper {
|
||||
|
||||
List<Information> getInformations(Information information);
|
||||
|
||||
void addInformation(Information information);
|
||||
|
||||
void updateInformationById(Information information);
|
||||
|
||||
void deleteInformationById(Integer id);
|
||||
|
||||
List<Information> getShortAnswers();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.Information;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.dao.InformationMapper;
|
||||
|
||||
@Service
|
||||
public class InformationService {
|
||||
|
||||
@Autowired
|
||||
private InformationMapper informationMapper;
|
||||
|
||||
public List<Information> getInformations(Information information) {
|
||||
return informationMapper.getInformations(information);
|
||||
}
|
||||
|
||||
public Msg addInformation(Information information, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
information.setCreateBy(user.getRealname());
|
||||
try {
|
||||
informationMapper.addInformation(information);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public Msg updateInformationById(Information information, HttpSession session) {
|
||||
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
|
||||
information.setUpdateBy(user.getRealname());
|
||||
try {
|
||||
informationMapper.updateInformationById(information);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Msg deleteInformationById(Integer id) {
|
||||
try {
|
||||
informationMapper.deleteInformationById(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
return Msg.fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<Information> getShortAnswers() {
|
||||
return informationMapper.getShortAnswers();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user