feat: 后台会员反馈管理

This commit is contained in:
xiongxiaoyang
2023-04-18 11:23:45 +08:00
parent aa2929a3cd
commit e44978617f
16 changed files with 1095 additions and 2 deletions

View File

@ -0,0 +1,135 @@
package com.java2nb.novel.controller;
import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import io.swagger.annotations.ApiOperation;
import com.java2nb.novel.domain.UserFeedbackDO;
import com.java2nb.novel.service.UserFeedbackService;
import com.java2nb.common.utils.PageBean;
import com.java2nb.common.utils.Query;
import com.java2nb.common.utils.R;
/**
*
*
* @author xiongxy
* @email 1179705413@qq.com
* @date 2023-04-18 11:08:54
*/
@Controller
@RequestMapping("/novel/userFeedback")
public class UserFeedbackController {
@Autowired
private UserFeedbackService userFeedbackService;
@GetMapping()
@RequiresPermissions("novel:userFeedback:userFeedback")
String UserFeedback() {
return "novel/userFeedback/userFeedback";
}
@ApiOperation(value = "获取列表", notes = "获取列表")
@ResponseBody
@GetMapping("/list")
@RequiresPermissions("novel:userFeedback:userFeedback")
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
List<UserFeedbackDO> userFeedbackList = userFeedbackService.list(query);
int total = userFeedbackService.count(query);
PageBean pageBean = new PageBean(userFeedbackList, total);
return R.ok().put("data", pageBean);
}
@ApiOperation(value = "新增页面", notes = "新增页面")
@GetMapping("/add")
@RequiresPermissions("novel:userFeedback:add")
String add() {
return "novel/userFeedback/add";
}
@ApiOperation(value = "修改页面", notes = "修改页面")
@GetMapping("/edit/{id}")
@RequiresPermissions("novel:userFeedback:edit")
String edit(@PathVariable("id") Long id, Model model) {
UserFeedbackDO userFeedback = userFeedbackService.get(id);
model.addAttribute("userFeedback", userFeedback);
return "novel/userFeedback/edit";
}
@ApiOperation(value = "查看页面", notes = "查看页面")
@GetMapping("/detail/{id}")
@RequiresPermissions("novel:userFeedback:detail")
String detail(@PathVariable("id") Long id, Model model) {
UserFeedbackDO userFeedback = userFeedbackService.get(id);
model.addAttribute("userFeedback", userFeedback);
return "novel/userFeedback/detail";
}
/**
* 保存
*/
@ApiOperation(value = "新增", notes = "新增")
@ResponseBody
@PostMapping("/save")
@RequiresPermissions("novel:userFeedback:add")
public R save( UserFeedbackDO userFeedback) {
if (userFeedbackService.save(userFeedback) > 0) {
return R.ok();
}
return R.error();
}
/**
* 修改
*/
@ApiOperation(value = "修改", notes = "修改")
@ResponseBody
@RequestMapping("/update")
@RequiresPermissions("novel:userFeedback:edit")
public R update( UserFeedbackDO userFeedback) {
userFeedbackService.update(userFeedback);
return R.ok();
}
/**
* 删除
*/
@ApiOperation(value = "删除", notes = "删除")
@PostMapping("/remove")
@ResponseBody
@RequiresPermissions("novel:userFeedback:remove")
public R remove( Long id) {
if (userFeedbackService.remove(id) > 0) {
return R.ok();
}
return R.error();
}
/**
* 删除
*/
@ApiOperation(value = "批量删除", notes = "批量删除")
@PostMapping("/batchRemove")
@ResponseBody
@RequiresPermissions("novel:userFeedback:batchRemove")
public R remove(@RequestParam("ids[]") Long[] ids) {
userFeedbackService.batchRemove(ids);
return R.ok();
}
}

View File

@ -0,0 +1,32 @@
package com.java2nb.novel.dao;
import com.java2nb.novel.domain.UserFeedbackDO;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
/**
*
* @author xiongxy
* @email 1179705413@qq.com
* @date 2023-04-18 11:08:54
*/
@Mapper
public interface UserFeedbackDao {
UserFeedbackDO get(Long id);
List<UserFeedbackDO> list(Map<String,Object> map);
int count(Map<String,Object> map);
int save(UserFeedbackDO userFeedback);
int update(UserFeedbackDO userFeedback);
int remove(Long id);
int batchRemove(Long[] ids);
}

View File

@ -0,0 +1,103 @@
package com.java2nb.novel.domain;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.java2nb.common.jsonserializer.LongToStringSerializer;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @author xiongxy
* @email 1179705413@qq.com
* @date 2023-04-18 11:08:54
*/
public class UserFeedbackDO implements Serializable {
private static final long serialVersionUID = 1L;
//主键id
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
//所以通过序列化成字符串来解决
@JsonSerialize(using = LongToStringSerializer.class)
private Long id;
//用户id
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
//所以通过序列化成字符串来解决
@JsonSerialize(using = LongToStringSerializer.class)
private Long userId;
//反馈内容
private String content;
//反馈时间
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String userName;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
/**
* 设置主键id
*/
public void setId(Long id) {
this.id = id;
}
/**
* 获取主键id
*/
public Long getId() {
return id;
}
/**
* 设置用户id
*/
public void setUserId(Long userId) {
this.userId = userId;
}
/**
* 获取用户id
*/
public Long getUserId() {
return userId;
}
/**
* 设置:反馈内容
*/
public void setContent(String content) {
this.content = content;
}
/**
* 获取:反馈内容
*/
public String getContent() {
return content;
}
/**
* 设置:反馈时间
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 获取:反馈时间
*/
public Date getCreateTime() {
return createTime;
}
}

View File

@ -0,0 +1,30 @@
package com.java2nb.novel.service;
import com.java2nb.novel.domain.UserFeedbackDO;
import java.util.List;
import java.util.Map;
/**
*
*
* @author xiongxy
* @email 1179705413@qq.com
* @date 2023-04-18 11:08:54
*/
public interface UserFeedbackService {
UserFeedbackDO get(Long id);
List<UserFeedbackDO> list(Map<String, Object> map);
int count(Map<String, Object> map);
int save(UserFeedbackDO userFeedback);
int update(UserFeedbackDO userFeedback);
int remove(Long id);
int batchRemove(Long[] ids);
}

View File

@ -0,0 +1,67 @@
package com.java2nb.novel.service.impl;
import com.java2nb.novel.dao.UserDao;
import com.java2nb.novel.dao.UserFeedbackDao;
import com.java2nb.novel.domain.UserDO;
import com.java2nb.novel.domain.UserFeedbackDO;
import com.java2nb.novel.service.UserFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class UserFeedbackServiceImpl implements UserFeedbackService {
@Autowired
private UserFeedbackDao userFeedbackDao;
@Autowired
private UserDao userDao;
@Override
public UserFeedbackDO get(Long id) {
return userFeedbackDao.get(id);
}
@Override
public List<UserFeedbackDO> list(Map<String, Object> map) {
List<UserFeedbackDO> list = userFeedbackDao.list(map);
if (!CollectionUtils.isEmpty(list)) {
List<Long> userIds = list.stream().map(UserFeedbackDO::getUserId).collect(Collectors.toList());
Map<Long, String> userNameMap = userDao.batchGet(userIds).stream()
.collect(Collectors.toMap(UserDO::getId, UserDO::getUsername));
list.forEach(v -> v.setUserName(userNameMap.get(v.getUserId())));
}
return list;
}
@Override
public int count(Map<String, Object> map) {
return userFeedbackDao.count(map);
}
@Override
public int save(UserFeedbackDO userFeedback) {
return userFeedbackDao.save(userFeedback);
}
@Override
public int update(UserFeedbackDO userFeedback) {
return userFeedbackDao.update(userFeedback);
}
@Override
public int remove(Long id) {
return userFeedbackDao.remove(id);
}
@Override
public int batchRemove(Long[] ids) {
return userFeedbackDao.batchRemove(ids);
}
}