This commit is contained in:
2025-05-22 17:35:00 +08:00
parent dfc3947e9b
commit bef80caa1d
5 changed files with 131 additions and 154 deletions
+7 -46
View File
@@ -6,60 +6,21 @@ import lombok.Data;
/**
* 问题反馈
*
* @author Administrator
*
* @author Administrator
*/
@Data
public class Bug {
public Integer getId() {
return id;
}
private Integer id;
public void setId(Integer id) {
this.id = id;
}
private String product;
public String getProduct() {
return product;
}
private String bugRemark;
public void setProduct(String product) {
this.product = product;
}
private String createBy;
public String getBugRemark() {
return bugRemark;
}
private Date createDate;
public void setBugRemark(String bugRemark) {
this.bugRemark = bugRemark;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
private Integer id;
private String product;
private String bugRemark;
private String createBy;
private Date createDate;
private String answer;
}
@@ -28,78 +28,85 @@ import lingtao.net.service.BugService;
@RestController
public class BugController {
@Autowired
private BugService bugService;
@Autowired
private BugService bugService;
private String localPrefix = "abc\\bug";
private String localPrefix = "abc\\bug";
private String localPath = "C:\\lingtao\\quote_price\\upload";
private String localPath = "C:\\lingtao\\quote_price\\upload";
//private String localDomain = "http://47.114.150.226:8080/erp";
//private String localDomain = "http://47.114.150.226:8080/erp";
/**
* bug列表
*
* @param page
* @param limit
* @return
*/
@RequestMapping("/getBugs")
public PageInfo<Bug> getBugs(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit, Bug bug) {
PageHelper.startPage(page, limit);
List<Bug> bugList = bugService.getBugs(bug);
PageInfo<Bug> pageInfo = new PageInfo<Bug>(bugList);
return pageInfo;
}
/**
* bug列表
*
* @param page
* @param limit
* @return
*/
@RequestMapping("/getBugs")
public PageInfo<Bug> getBugs(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit, Bug bug) {
PageHelper.startPage(page, limit);
List<Bug> bugList = bugService.getBugs(bug);
PageInfo<Bug> pageInfo = new PageInfo<Bug>(bugList);
return pageInfo;
}
/**
* 添加角色
*/
@RequestMapping("/addBug")
public Msg addBug(Bug bug, HttpSession session) {
return bugService.addBug(bug, session);
}
/**
* 添加
*/
@RequestMapping("/addBug")
public Msg addBug(Bug bug, HttpSession session) {
return bugService.addBug(bug, session);
}
// 图片上传及新增
@RequestMapping("/bugUpload")
public Msg upload(@RequestParam("file") MultipartFile file) throws Exception {
if (file.isEmpty()) {
return Msg.fail("文件不能为空");
}
// 获取文件名后缀
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
// 获取path
String path = getPath(extension, FilenameUtils.getBaseName(file.getOriginalFilename()));
// 保存文件信息
File newFile = new File(localPath + File.separator + path);
try {
FileUtils.copyInputStreamToFile(new ByteArrayInputStream(file.getBytes()), newFile);
} catch (IOException e) {
throw new RuntimeErrorException(null, "");
}
return Msg.success();
}
/**
* 更新
*/
@RequestMapping("/updateBug")
public Msg updateBug(Bug bug, HttpSession session) {
return bugService.updateBug(bug);
}
/**
*
* @param prefixSelf 根据上传的接口存入自己的文件夹
* @param suffix 文件的后缀
* @param fileName 文件名
* @return
*/
public String getPath(String suffix, String fileName) {
// 图片上传及新增
@RequestMapping("/bugUpload")
public Msg upload(@RequestParam("file") MultipartFile file) throws Exception {
if (file.isEmpty()) {
return Msg.fail("文件不能为空");
}
// 获取文件名后缀
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
// 获取path
String path = getPath(extension, FilenameUtils.getBaseName(file.getOriginalFilename()));
// 保存文件信息
File newFile = new File(localPath + File.separator + path);
try {
FileUtils.copyInputStreamToFile(new ByteArrayInputStream(file.getBytes()), newFile);
} catch (IOException e) {
throw new RuntimeErrorException(null, "");
}
return Msg.success();
}
// 生成uuid
// String uuid = UUID.randomUUID().toString().replaceAll("-", "");
String path = null;
/**
* @param prefixSelf 根据上传的接口存入自己的文件夹
* @param suffix 文件的后缀
* @param fileName 文件名
* @return
*/
public String getPath(String suffix, String fileName) {
// 文件路径
path = DateUtils.formatDate(new Date(), "yyyyMMdd") + File.separator + fileName;
// 生成uuid
// String uuid = UUID.randomUUID().toString().replaceAll("-", "");
String path = null;
path = localPrefix + File.separator + File.separator + path;
// 文件路径
path = DateUtils.formatDate(new Date(), "yyyyMMdd") + File.separator + fileName;
return path + "." + suffix;
}
path = localPrefix + File.separator + File.separator + path;
return path + "." + suffix;
}
}
+4 -2
View File
@@ -6,7 +6,9 @@ import lingtao.net.bean.Bug;
public interface BugMapper {
List<Bug> getBugs(Bug bug);
List<Bug> getBugs(Bug bug);
int addBug(Bug bug);
int addBug(Bug bug);
int updateBug(Bug bug);
}
@@ -15,21 +15,29 @@ import lingtao.net.dao.BugMapper;
@Service
public class BugService {
@Autowired
private BugMapper bugMapper;
@Autowired
private BugMapper bugMapper;
public List<Bug> getBugs(Bug bug) {
return bugMapper.getBugs(bug);
}
public List<Bug> getBugs(Bug bug) {
return bugMapper.getBugs(bug);
}
public Msg addBug(Bug bug, HttpSession session) {
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
bug.setCreateBy(user.getRealname());
int i = bugMapper.addBug(bug);
if (i < 0) {
return Msg.fail();
}
return Msg.success();
}
public Msg addBug(Bug bug, HttpSession session) {
SysUser user = (SysUser) session.getAttribute("USER_SESSION");
bug.setCreateBy(user.getRealname());
int i = bugMapper.addBug(bug);
if (i < 0) {
return Msg.fail();
}
return Msg.success();
}
public Msg updateBug(Bug bug) {
int i = bugMapper.updateBug(bug);
if (i < 0) {
return Msg.fail();
}
return Msg.success();
}
}
+29 -30
View File
@@ -1,37 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="lingtao.net.dao.BugMapper">
<select id="getBugs" parameterType="Bug" resultType="Bug">
SELECT
*
FROM
bug
<where>
<if test="createBy !=null and createBy != '' ">
createBy like '%${createBy}%'
</if>
</where>
ORDER BY id DESC
</select>
<select id="getBugs" parameterType="Bug" resultType="Bug">
SELECT
*
FROM
bug
<where>
<if test="createBy !=null and createBy != '' ">
createBy like '%${createBy}%'
</if>
</where>
ORDER BY id DESC
</select>
<insert id="addBug" parameterType="Bug">
INSERT INTO bug
(
id,
product,
bugRemark,
createBy,
createDate
)
VALUES
(
NULL,
#{product},
#{bugRemark},
#{createBy},
now()
)
<insert id="addBug" parameterType="Bug">
INSERT INTO bug
(id,
product,
bugRemark,
createBy,
createDate)
VALUES (NULL,
#{product},
#{bugRemark},
#{createBy},
now())
</insert>
<update id="updateBug" parameterType="Bug">
update bug
set answer = #{answer}
where id = #{id}
</update>
</mapper>