feat: 后台网站信息管理

This commit is contained in:
xiongxiaoyang
2023-04-14 14:56:11 +08:00
parent b45b83fdb0
commit 2c3b735d49
37 changed files with 1821 additions and 543 deletions

View File

@ -1,6 +1,7 @@
package com.java2nb.common.config;
public class Constant {
//演示系统账户
public static String DEMO_ACCOUNT = "test";
//自动去除表前缀
@ -16,9 +17,11 @@ public class Constant {
//部门根节点id
public static Long DEPT_ROOT_ID = 0l;
//缓存方式
public static String CACHE_TYPE_REDIS ="redis";
public static String CACHE_TYPE_REDIS = "redis";
public static String LOG_ERROR = "error";
public static final String UPLOAD_FILES_PREFIX = "/files/";
}

View File

@ -71,7 +71,7 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/docs/**", "anon");
filterChainDefinitionMap.put("/layuimini/**", "anon");
filterChainDefinitionMap.put("/upload/**", "anon");
filterChainDefinitionMap.put("/files/**", "anon");
filterChainDefinitionMap.put(Constant.UPLOAD_FILES_PREFIX + "**", "anon");
filterChainDefinitionMap.put("/logout", "logout");
filterChainDefinitionMap.put("/blog", "anon");
filterChainDefinitionMap.put("/blog/open/**", "anon");

View File

@ -7,11 +7,14 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@Component
class WebConfigurer extends WebMvcConfigurerAdapter {
@Autowired
@Autowired
JnConfig jnConfig;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/files/**").addResourceLocations("file:///"+ jnConfig.getUploadPath());
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler(Constant.UPLOAD_FILES_PREFIX + "**")
.addResourceLocations("file:///" + jnConfig.getUploadPath());
}
}

View File

@ -1,12 +1,10 @@
package com.java2nb.common.controller;
import com.java2nb.common.config.Constant;
import com.java2nb.common.config.JnConfig;
import com.java2nb.common.domain.FileDO;
import com.java2nb.common.service.FileService;
import com.java2nb.common.utils.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -14,7 +12,11 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;
@ -23,7 +25,7 @@ import java.util.Map;
/**
* 文件上传
*
*
* @author xiongxy
* @email 1179705413@qq.com
* @date 2019-09-19 16:02:20
@ -32,165 +34,167 @@ import java.util.Map;
@RequestMapping("/common/sysFile")
public class FileController extends BaseController {
@Autowired
private FileService sysFileService;
@Autowired
private FileService sysFileService;
@Autowired
private JnConfig jnConfig;
@Autowired
private JnConfig jnConfig;
@GetMapping()
@RequiresPermissions("common:sysFile:sysFile")
String sysFile(Model model) {
Map<String, Object> params = new HashMap<>(16);
return "common/file/file";
}
@GetMapping()
@RequiresPermissions("common:sysFile:sysFile")
String sysFile(Model model) {
Map<String, Object> params = new HashMap<>(16);
return "common/file/file";
}
@ResponseBody
@GetMapping("/list")
@RequiresPermissions("common:sysFile:sysFile")
public PageBean list(@RequestParam Map<String, Object> params) {
// 查询列表数据
Query query = new Query(params);
List<FileDO> sysFileList = sysFileService.list(query);
int total = sysFileService.count(query);
PageBean pageBean = new PageBean(sysFileList, total);
return pageBean;
}
@ResponseBody
@GetMapping("/list")
@RequiresPermissions("common:sysFile:sysFile")
public PageBean list(@RequestParam Map<String, Object> params) {
// 查询列表数据
Query query = new Query(params);
List<FileDO> sysFileList = sysFileService.list(query);
int total = sysFileService.count(query);
PageBean pageBean = new PageBean(sysFileList, total);
return pageBean;
}
@GetMapping("/add")
// @RequiresPermissions("common:bComments")
String add() {
return "common/sysFile/add";
}
@GetMapping("/add")
// @RequiresPermissions("common:bComments")
String add() {
return "common/sysFile/add";
}
@GetMapping("/edit")
// @RequiresPermissions("common:bComments")
String edit(Long id, Model model) {
FileDO sysFile = sysFileService.get(id);
model.addAttribute("sysFile", sysFile);
return "common/sysFile/edit";
}
@GetMapping("/edit")
// @RequiresPermissions("common:bComments")
String edit(Long id, Model model) {
FileDO sysFile = sysFileService.get(id);
model.addAttribute("sysFile", sysFile);
return "common/sysFile/edit";
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("common:info")
public R info(@PathVariable("id") Long id) {
FileDO sysFile = sysFileService.get(id);
return R.ok().put("sysFile", sysFile);
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("common:info")
public R info(@PathVariable("id") Long id) {
FileDO sysFile = sysFileService.get(id);
return R.ok().put("sysFile", sysFile);
}
/**
* 保存
*/
@ResponseBody
@PostMapping("/save")
@RequiresPermissions("common:save")
public R save(FileDO sysFile) {
if (sysFileService.save(sysFile) > 0) {
return R.ok();
}
return R.error();
}
/**
* 保存
*/
@ResponseBody
@PostMapping("/save")
@RequiresPermissions("common:save")
public R save(FileDO sysFile) {
if (sysFileService.save(sysFile) > 0) {
return R.ok();
}
return R.error();
}
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("common:update")
public R update(@RequestBody FileDO sysFile) {
sysFileService.update(sysFile);
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("common:update")
public R update(@RequestBody FileDO sysFile) {
sysFileService.update(sysFile);
return R.ok();
}
return R.ok();
}
/**
* 删除
*/
@PostMapping("/remove")
@ResponseBody
// @RequiresPermissions("common:remove")
public R remove(Long id, HttpServletRequest request) {
if ("test".equals(getUsername())) {
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
}
String fileName = jnConfig.getUploadPath() + sysFileService.get(id).getUrl().replace("/files/", "");
if (sysFileService.remove(id) > 0) {
boolean b = FileUtil.deleteFile(fileName);
if (!b) {
return R.error("数据库记录删除成功,文件删除失败");
}
return R.ok();
} else {
return R.error();
}
}
/**
* 删除
*/
@PostMapping("/remove")
@ResponseBody
// @RequiresPermissions("common:remove")
public R remove(Long id, HttpServletRequest request) {
if ("test".equals(getUsername())) {
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
}
String fileName =
jnConfig.getUploadPath() + sysFileService.get(id).getUrl().replace(Constant.UPLOAD_FILES_PREFIX, "");
if (sysFileService.remove(id) > 0) {
boolean b = FileUtil.deleteFile(fileName);
if (!b) {
return R.error("数据库记录删除成功,文件删除失败");
}
return R.ok();
} else {
return R.error();
}
}
/**
* 删除
*/
@PostMapping("/batchRemove")
@ResponseBody
@RequiresPermissions("common:remove")
public R remove(@RequestParam("ids[]") Long[] ids) {
if ("test".equals(getUsername())) {
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
}
sysFileService.batchRemove(ids);
return R.ok();
}
/**
* 删除
*/
@PostMapping("/batchRemove")
@ResponseBody
@RequiresPermissions("common:remove")
public R remove(@RequestParam("ids[]") Long[] ids) {
if ("test".equals(getUsername())) {
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
}
sysFileService.batchRemove(ids);
return R.ok();
}
@ResponseBody
@PostMapping("/upload")
R upload(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
if ("test".equals(getUsername())) {
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
}
Date date = new Date();
String year = DateUtils.format(date,DateUtils.YEAR_PATTERN);
String month = DateUtils.format(date,DateUtils.MONTH_PATTERN);
String day = DateUtils.format(date,DateUtils.DAY_PATTERN);
@ResponseBody
@PostMapping("/upload")
R upload(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
if ("test".equals(getUsername())) {
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
}
Date date = new Date();
String year = DateUtils.format(date, DateUtils.YEAR_PATTERN);
String month = DateUtils.format(date, DateUtils.MONTH_PATTERN);
String day = DateUtils.format(date, DateUtils.DAY_PATTERN);
String fileName = file.getOriginalFilename();
String fileDir = year+"/"+month+"/"+day + "/";
fileName = FileUtil.renameToUUID(fileName);
FileDO sysFile = new FileDO(FileType.fileType(fileName), "/files/" + fileDir + fileName, date);
try {
FileUtil.uploadFile(file.getBytes(), jnConfig.getUploadPath()+fileDir, fileName);
} catch (Exception e) {
return R.error();
}
String fileName = file.getOriginalFilename();
String fileDir = year + "/" + month + "/" + day + "/";
fileName = FileUtil.renameToUUID(fileName);
FileDO sysFile = new FileDO(FileType.fileType(fileName), Constant.UPLOAD_FILES_PREFIX + fileDir + fileName,
date);
try {
FileUtil.uploadFile(file.getBytes(), jnConfig.getUploadPath() + fileDir, fileName);
} catch (Exception e) {
return R.error();
}
if (sysFileService.save(sysFile) > 0) {
return R.ok().put("fileName",sysFile.getUrl());
}
return R.error();
}
if (sysFileService.save(sysFile) > 0) {
return R.ok().put("fileName", sysFile.getUrl());
}
return R.error();
}
/**
* 文件下载
*/
@RequestMapping(value = "/download")
public void fileDownload(String filePath,String fileName, HttpServletResponse resp) throws Exception {
String realFilePath = jnConfig.getUploadPath() + filePath;
InputStream in = new FileInputStream(realFilePath);
//设置响应头对文件进行url编码
fileName = URLEncoder.encode(fileName, "UTF-8");
resp.setHeader("Content-Disposition", "attachment;filename=" + fileName);
/**
* 文件下载
*/
@RequestMapping(value = "/download")
public void fileDownload(String filePath, String fileName, HttpServletResponse resp) throws Exception {
String realFilePath = jnConfig.getUploadPath() + filePath;
InputStream in = new FileInputStream(realFilePath);
//设置响应头对文件进行url编码
fileName = URLEncoder.encode(fileName, "UTF-8");
resp.setHeader("Content-Disposition", "attachment;filename=" + fileName);
resp.setContentLength(in.available());
resp.setContentLength(in.available());
OutputStream out = resp.getOutputStream();
byte[] b = new byte[1024];
int len = 0;
while ((len = in.read(b)) != -1) {
out.write(b, 0, len);
}
out.flush();
out.close();
in.close();
}
OutputStream out = resp.getOutputStream();
byte[] b = new byte[1024];
int len = 0;
while ((len = in.read(b)) != -1) {
out.write(b, 0, len);
}
out.flush();
out.close();
in.close();
}
}

View File

@ -1,72 +1,74 @@
package com.java2nb.common.service.impl;
import com.java2nb.common.config.Constant;
import com.java2nb.common.config.JnConfig;
import com.java2nb.common.dao.FileDao;
import com.java2nb.common.domain.FileDO;
import com.java2nb.common.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.io.File;
import java.util.List;
import java.util.Map;
import com.java2nb.common.dao.FileDao;
import com.java2nb.common.domain.FileDO;
import com.java2nb.common.service.FileService;
import org.springframework.util.StringUtils;
@Service
public class FileServiceImpl implements FileService {
@Autowired
private FileDao sysFileMapper;
@Autowired
private JnConfig jnConfig;
@Override
public FileDO get(Long id){
return sysFileMapper.get(id);
}
@Override
public List<FileDO> list(Map<String, Object> map){
return sysFileMapper.list(map);
}
@Override
public int count(Map<String, Object> map){
return sysFileMapper.count(map);
}
@Override
public int save(FileDO sysFile){
return sysFileMapper.save(sysFile);
}
@Override
public int update(FileDO sysFile){
return sysFileMapper.update(sysFile);
}
@Override
public int remove(Long id){
return sysFileMapper.remove(id);
}
@Override
public int batchRemove(Long[] ids){
return sysFileMapper.batchRemove(ids);
}
@Autowired
private FileDao sysFileMapper;
@Autowired
private JnConfig jnConfig;
@Override
public FileDO get(Long id) {
return sysFileMapper.get(id);
}
@Override
public List<FileDO> list(Map<String, Object> map) {
return sysFileMapper.list(map);
}
@Override
public int count(Map<String, Object> map) {
return sysFileMapper.count(map);
}
@Override
public int save(FileDO sysFile) {
return sysFileMapper.save(sysFile);
}
@Override
public int update(FileDO sysFile) {
return sysFileMapper.update(sysFile);
}
@Override
public int remove(Long id) {
return sysFileMapper.remove(id);
}
@Override
public int batchRemove(Long[] ids) {
return sysFileMapper.batchRemove(ids);
}
@Override
public Boolean isExist(String url) {
Boolean isExist = false;
if (!StringUtils.isEmpty(url)) {
String filePath = url.replace("/files/", "");
filePath = jnConfig.getUploadPath() + filePath;
File file = new File(filePath);
if (file.exists()) {
isExist = true;
}
}
return isExist;
}
}
Boolean isExist = false;
if (!StringUtils.isEmpty(url)) {
String filePath = url.replace(Constant.UPLOAD_FILES_PREFIX, "");
filePath = jnConfig.getUploadPath() + filePath;
File file = new File(filePath);
if (file.exists()) {
isExist = true;
}
}
return isExist;
}
}

View File

@ -0,0 +1,50 @@
package com.java2nb.novel.controller;
import com.java2nb.common.utils.R;
import com.java2nb.novel.domain.WebsiteInfoDO;
import com.java2nb.novel.service.WebsiteInfoService;
import io.swagger.annotations.ApiOperation;
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.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 网站信息表
*
* @author xiongxy
* @email 1179705413@qq.com
* @date 2023-04-14 11:05:43
*/
@Controller
@RequestMapping("/novel/websiteInfo")
public class WebsiteInfoController {
@Autowired
private WebsiteInfoService websiteInfoService;
@GetMapping()
@RequiresPermissions("novel:websiteInfo:detail")
String detail(Model model) {
WebsiteInfoDO websiteInfo = websiteInfoService.get(1L);
model.addAttribute("websiteInfo", websiteInfo);
return "novel/websiteInfo/detail";
}
/**
* 修改
*/
@ApiOperation(value = "修改网站信息表", notes = "修改网站信息表")
@ResponseBody
@RequestMapping("/update")
@RequiresPermissions("novel:websiteInfo:edit")
public R update(WebsiteInfoDO websiteInfo) {
websiteInfoService.update(websiteInfo);
return R.ok();
}
}

View File

@ -0,0 +1,32 @@
package com.java2nb.novel.dao;
import com.java2nb.novel.domain.WebsiteInfoDO;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
/**
* 网站信息表
* @author xiongxy
* @email 1179705413@qq.com
* @date 2023-04-14 11:05:43
*/
@Mapper
public interface WebsiteInfoDao {
WebsiteInfoDO get(Long id);
List<WebsiteInfoDO> list(Map<String,Object> map);
int count(Map<String,Object> map);
int save(WebsiteInfoDO websiteInfo);
int update(WebsiteInfoDO websiteInfo);
int remove(Long id);
int batchRemove(Long[] ids);
}

View File

@ -0,0 +1,208 @@
package com.java2nb.novel.domain;
import java.io.Serializable;
import java.math.BigDecimal;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.java2nb.common.jsonserializer.LongToStringSerializer;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 网站信息表
*
* @author xiongxy
* @email 1179705413@qq.com
* @date 2023-04-14 11:05:43
*/
public class WebsiteInfoDO implements Serializable {
private static final long serialVersionUID = 1L;
//主键
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
//所以通过序列化成字符串来解决
@JsonSerialize(using = LongToStringSerializer.class)
private Long id;
//网站名
private String name;
//网站域名
private String domain;
//SEO关键词
private String keyword;
//网站描述
private String description;
//站长QQ
private String qq;
//网站logo图片默认
private String logo;
//网站logo图片深色
private String logoDark;
//创建时间
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
//创建人ID
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
//所以通过序列化成字符串来解决
@JsonSerialize(using = LongToStringSerializer.class)
private Long createUserId;
//更新时间
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
//更新人ID
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
//所以通过序列化成字符串来解决
@JsonSerialize(using = LongToStringSerializer.class)
private Long updateUserId;
/**
* 设置:主键
*/
public void setId(Long id) {
this.id = id;
}
/**
* 获取:主键
*/
public Long getId() {
return id;
}
/**
* 设置:网站名
*/
public void setName(String name) {
this.name = name;
}
/**
* 获取:网站名
*/
public String getName() {
return name;
}
/**
* 设置:网站域名
*/
public void setDomain(String domain) {
this.domain = domain;
}
/**
* 获取:网站域名
*/
public String getDomain() {
return domain;
}
/**
* 设置SEO关键词
*/
public void setKeyword(String keyword) {
this.keyword = keyword;
}
/**
* 获取SEO关键词
*/
public String getKeyword() {
return keyword;
}
/**
* 设置:网站描述
*/
public void setDescription(String description) {
this.description = description;
}
/**
* 获取:网站描述
*/
public String getDescription() {
return description;
}
/**
* 设置站长QQ
*/
public void setQq(String qq) {
this.qq = qq;
}
/**
* 获取站长QQ
*/
public String getQq() {
return qq;
}
/**
* 设置网站logo图片默认
*/
public void setLogo(String logo) {
this.logo = logo;
}
/**
* 获取网站logo图片默认
*/
public String getLogo() {
return logo;
}
/**
* 设置网站logo图片深色
*/
public void setLogoDark(String logoDark) {
this.logoDark = logoDark;
}
/**
* 获取网站logo图片深色
*/
public String getLogoDark() {
return logoDark;
}
/**
* 设置:创建时间
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 获取:创建时间
*/
public Date getCreateTime() {
return createTime;
}
/**
* 设置创建人ID
*/
public void setCreateUserId(Long createUserId) {
this.createUserId = createUserId;
}
/**
* 获取创建人ID
*/
public Long getCreateUserId() {
return createUserId;
}
/**
* 设置:更新时间
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取:更新时间
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* 设置更新人ID
*/
public void setUpdateUserId(Long updateUserId) {
this.updateUserId = updateUserId;
}
/**
* 获取更新人ID
*/
public Long getUpdateUserId() {
return updateUserId;
}
}

View File

@ -0,0 +1,30 @@
package com.java2nb.novel.service;
import com.java2nb.novel.domain.WebsiteInfoDO;
import java.util.List;
import java.util.Map;
/**
* 网站信息表
*
* @author xiongxy
* @email 1179705413@qq.com
* @date 2023-04-14 11:05:43
*/
public interface WebsiteInfoService {
WebsiteInfoDO get(Long id);
List<WebsiteInfoDO> list(Map<String, Object> map);
int count(Map<String, Object> map);
int save(WebsiteInfoDO websiteInfo);
int update(WebsiteInfoDO websiteInfo);
int remove(Long id);
int batchRemove(Long[] ids);
}

View File

@ -0,0 +1,55 @@
package com.java2nb.novel.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import com.java2nb.novel.dao.WebsiteInfoDao;
import com.java2nb.novel.domain.WebsiteInfoDO;
import com.java2nb.novel.service.WebsiteInfoService;
@Service
public class WebsiteInfoServiceImpl implements WebsiteInfoService {
@Autowired
private WebsiteInfoDao websiteInfoDao;
@Override
public WebsiteInfoDO get(Long id){
return websiteInfoDao.get(id);
}
@Override
public List<WebsiteInfoDO> list(Map<String, Object> map){
return websiteInfoDao.list(map);
}
@Override
public int count(Map<String, Object> map){
return websiteInfoDao.count(map);
}
@Override
public int save(WebsiteInfoDO websiteInfo){
return websiteInfoDao.save(websiteInfo);
}
@Override
public int update(WebsiteInfoDO websiteInfo){
return websiteInfoDao.update(websiteInfo);
}
@Override
public int remove(Long id){
return websiteInfoDao.remove(id);
}
@Override
public int batchRemove(Long[] ids){
return websiteInfoDao.batchRemove(ids);
}
}

View File

@ -1,14 +1,19 @@
package com.java2nb.system.service.impl;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.util.*;
import com.java2nb.common.config.Constant;
import com.java2nb.common.config.JnConfig;
import com.java2nb.common.domain.FileDO;
import com.java2nb.common.domain.Tree;
import com.java2nb.common.service.FileService;
import com.java2nb.common.utils.*;
import com.java2nb.system.dao.DeptDao;
import com.java2nb.system.dao.SysUserDao;
import com.java2nb.system.dao.UserRoleDao;
import com.java2nb.system.domain.DeptDO;
import com.java2nb.system.domain.UserDO;
import com.java2nb.system.domain.UserRoleDO;
import com.java2nb.system.service.DeptService;
import com.java2nb.system.service.SysUserService;
import com.java2nb.system.vo.UserVO;
import org.apache.commons.lang.ArrayUtils;
import org.slf4j.Logger;
@ -16,22 +21,17 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.java2nb.common.domain.Tree;
import com.java2nb.system.dao.DeptDao;
import com.java2nb.system.dao.SysUserDao;
import com.java2nb.system.dao.UserRoleDao;
import com.java2nb.system.domain.DeptDO;
import com.java2nb.system.domain.UserDO;
import com.java2nb.system.domain.UserRoleDO;
import com.java2nb.system.service.SysUserService;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.util.*;
@Transactional
@Service
public class SysUserServiceImpl implements SysUserService {
@Autowired
SysUserDao userMapper;
@Autowired
@ -64,7 +64,7 @@ public class SysUserServiceImpl implements SysUserService {
List<Long> childIds = deptService.listChildrenIds(deptIdl);
childIds.add(deptIdl);
map.put("deptId", null);
map.put("deptIds",childIds);
map.put("deptIds", childIds);
}
return userMapper.listByPerm(map);
}
@ -213,7 +213,7 @@ public class SysUserServiceImpl implements SysUserService {
public Map<String, Object> updatePersonalImg(MultipartFile file, String avatar_data, Long userId) throws Exception {
String fileName = file.getOriginalFilename();
fileName = FileUtil.renameToUUID(fileName);
FileDO sysFile = new FileDO(FileType.fileType(fileName), "/files/" + fileName, new Date());
FileDO sysFile = new FileDO(FileType.fileType(fileName), Constant.UPLOAD_FILES_PREFIX + fileName, new Date());
//获取图片后缀
String prefix = fileName.substring((fileName.lastIndexOf(".") + 1));
String[] str = avatar_data.split(",");

View File

@ -10,7 +10,7 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: test123456
#password:

View File

@ -0,0 +1,152 @@
<?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="com.java2nb.novel.dao.WebsiteInfoDao">
<select id="get" resultType="com.java2nb.novel.domain.WebsiteInfoDO">
select `id`,`name`,`domain`,`keyword`,`description`,`qq`,`logo`,`logo_dark`,`create_time`,`create_user_id`,`update_time`,`update_user_id` from website_info where id = #{value}
</select>
<select id="list" resultType="com.java2nb.novel.domain.WebsiteInfoDO">
select `id`,`name`,`domain`,`keyword`,`description`,`qq`,`logo`,`logo_dark`,`create_time`,`create_user_id`,`update_time`,`update_user_id` from website_info
<where>
<if test="id != null and id != ''"> and id = #{id} </if>
<if test="name != null and name != ''"> and name = #{name} </if>
<if test="domain != null and domain != ''"> and domain = #{domain} </if>
<if test="keyword != null and keyword != ''"> and keyword = #{keyword} </if>
<if test="description != null and description != ''"> and description = #{description} </if>
<if test="qq != null and qq != ''"> and qq = #{qq} </if>
<if test="logo != null and logo != ''"> and logo = #{logo} </if>
<if test="logoDark != null and logoDark != ''"> and logo_dark = #{logoDark} </if>
<if test="createTime != null and createTime != ''"> and create_time = #{createTime} </if>
<if test="createUserId != null and createUserId != ''"> and create_user_id = #{createUserId} </if>
<if test="updateTime != null and updateTime != ''"> and update_time = #{updateTime} </if>
<if test="updateUserId != null and updateUserId != ''"> and update_user_id = #{updateUserId} </if>
</where>
<choose>
<when test="sort != null and sort.trim() != ''">
order by ${sort} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="count" resultType="int">
select count(*) from website_info
<where>
<if test="id != null and id != ''"> and id = #{id} </if>
<if test="name != null and name != ''"> and name = #{name} </if>
<if test="domain != null and domain != ''"> and domain = #{domain} </if>
<if test="keyword != null and keyword != ''"> and keyword = #{keyword} </if>
<if test="description != null and description != ''"> and description = #{description} </if>
<if test="qq != null and qq != ''"> and qq = #{qq} </if>
<if test="logo != null and logo != ''"> and logo = #{logo} </if>
<if test="logoDark != null and logoDark != ''"> and logo_dark = #{logoDark} </if>
<if test="createTime != null and createTime != ''"> and create_time = #{createTime} </if>
<if test="createUserId != null and createUserId != ''"> and create_user_id = #{createUserId} </if>
<if test="updateTime != null and updateTime != ''"> and update_time = #{updateTime} </if>
<if test="updateUserId != null and updateUserId != ''"> and update_user_id = #{updateUserId} </if>
</where>
</select>
<insert id="save" parameterType="com.java2nb.novel.domain.WebsiteInfoDO">
insert into website_info
(
`id`,
`name`,
`domain`,
`keyword`,
`description`,
`qq`,
`logo`,
`logo_dark`,
`create_time`,
`create_user_id`,
`update_time`,
`update_user_id`
)
values
(
#{id},
#{name},
#{domain},
#{keyword},
#{description},
#{qq},
#{logo},
#{logoDark},
#{createTime},
#{createUserId},
#{updateTime},
#{updateUserId}
)
</insert>
<insert id="saveSelective" parameterType="com.java2nb.novel.domain.WebsiteInfoDO">
insert into website_info
(
<if test="id != null"> `id`, </if>
<if test="name != null"> `name`, </if>
<if test="domain != null"> `domain`, </if>
<if test="keyword != null"> `keyword`, </if>
<if test="description != null"> `description`, </if>
<if test="qq != null"> `qq`, </if>
<if test="logo != null"> `logo`, </if>
<if test="logoDark != null"> `logo_dark`, </if>
<if test="createTime != null"> `create_time`, </if>
<if test="createUserId != null"> `create_user_id`, </if>
<if test="updateTime != null"> `update_time`, </if>
<if test="updateUserId != null"> `update_user_id` </if>
)
values
(
<if test="id != null"> #{id}, </if>
<if test="name != null"> #{name}, </if>
<if test="domain != null"> #{domain}, </if>
<if test="keyword != null"> #{keyword}, </if>
<if test="description != null"> #{description}, </if>
<if test="qq != null"> #{qq}, </if>
<if test="logo != null"> #{logo}, </if>
<if test="logoDark != null"> #{logoDark}, </if>
<if test="createTime != null"> #{createTime}, </if>
<if test="createUserId != null"> #{createUserId}, </if>
<if test="updateTime != null"> #{updateTime}, </if>
<if test="updateUserId != null"> #{updateUserId} </if>
)
</insert>
<update id="update" parameterType="com.java2nb.novel.domain.WebsiteInfoDO">
update website_info
<set>
<if test="name != null">`name` = #{name}, </if>
<if test="domain != null">`domain` = #{domain}, </if>
<if test="keyword != null">`keyword` = #{keyword}, </if>
<if test="description != null">`description` = #{description}, </if>
<if test="qq != null">`qq` = #{qq}, </if>
<if test="logo != null">`logo` = #{logo}, </if>
<if test="logoDark != null">`logo_dark` = #{logoDark}, </if>
<if test="createTime != null">`create_time` = #{createTime}, </if>
<if test="createUserId != null">`create_user_id` = #{createUserId}, </if>
<if test="updateTime != null">`update_time` = #{updateTime}, </if>
<if test="updateUserId != null">`update_user_id` = #{updateUserId}</if>
</set>
where id = #{id}
</update>
<delete id="remove">
delete from website_info where id = #{value}
</delete>
<delete id="batchRemove">
delete from website_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,99 @@
var E = window.wangEditor;
$("[id^='contentEditor']").each(function (index, ele) {
var relName = $(ele).attr("id").substring(13);
var editor = new E('#contentEditor' + relName);
// 自定义菜单配置
editor.customConfig.menus = [
'head', // 标题
'bold', // 粗体
'fontSize', // 字号
'fontName', // 字体
'italic', // 斜体
'underline', // 下划线
'strikeThrough', // 删除线
'foreColor', // 文字颜色
//'backColor', // 背景颜色
//'link', // 插入链接
'list', // 列表
'justify', // 对齐方式
'quote', // 引用
'emoticon', // 表情
'image', // 插入图片
//'table', // 表格
//'video', // 插入视频
//'code', // 插入代码
'undo', // 撤销
'redo' // 重复
];
editor.customConfig.onchange = function (html) {
// html 即变化之后的内容
$("#" + relName).val(html);
}
editor.customConfig.uploadImgShowBase64 = true;
editor.create();
editor.txt.html($("#" + relName).val());
})
$("[id^='picImage']").each(function (index, ele) {
var relName = $(ele).attr("id").substring(8);
layui.use('upload', function () {
var upload = layui.upload;
//执行实例
var uploadInst = upload.render({
elem: '#picImage' + relName, //绑定元素
url: '/common/sysFile/upload', //上传接口
size: 1000,
accept: 'file',
done: function (r) {
$("#picImage" + relName).attr("src", r.fileName);
$("#" + relName).val(r.fileName);
},
error: function (r) {
layer.msg(r.msg);
}
});
});
});
$().ready(function () {
validateRule();
});
$.validator.setDefaults({
submitHandler: function () {
update();
}
});
function update() {
$.ajax({
cache: true,
type: "POST",
url: "/novel/websiteInfo/update",
data: $('#signupForm').serialize(),// 你的formid
async: false,
error: function (request) {
layer.alert("Connection error");
},
success: function (data) {
if (data.code == 0) {
layer.msg("操作成功");
} else {
layer.alert(data.msg)
}
}
});
}
function validateRule() {
var icon = "<i class='fa fa-times-circle'></i> ";
$("#signupForm").validate({
ignore: "",
rules: {},
messages: {}
})
}

View File

@ -1,18 +0,0 @@
-- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('1', '作者表', 'novel/author', 'novel:author:author', '1', 'fa', '6');
-- 按钮父菜单ID
set @parentId = @@identity;
-- 菜单对应按钮SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '查看', null, 'novel:author:detail', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '新增', null, 'novel:author:add', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '修改', null, 'novel:author:edit', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, 'novel:author:remove', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '批量删除', null, 'novel:author:batchRemove', '2', null, '6';

View File

@ -1,18 +0,0 @@
-- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('1', '作家邀请码表', 'novel/authorCode', 'novel:authorCode:authorCode', '1', 'fa', '6');
-- 按钮父菜单ID
set @parentId = @@identity;
-- 菜单对应按钮SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '查看', null, 'novel:authorCode:detail', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '新增', null, 'novel:authorCode:add', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '修改', null, 'novel:authorCode:edit', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, 'novel:authorCode:remove', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '批量删除', null, 'novel:authorCode:batchRemove', '2', null, '6';

View File

@ -1,18 +0,0 @@
-- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('1', '小说表', 'novel/book', 'novel:book:book', '1', 'fa', '6');
-- 按钮父菜单ID
set @parentId = @@identity;
-- 菜单对应按钮SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '查看', null, 'novel:book:detail', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '新增', null, 'novel:book:add', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '修改', null, 'novel:book:edit', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, 'novel:book:remove', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '批量删除', null, 'novel:book:batchRemove', '2', null, '6';

View File

@ -1,18 +0,0 @@
-- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('1', '新闻类别表', 'novel/category', 'novel:category:category', '1', 'fa', '6');
-- 按钮父菜单ID
set @parentId = @@identity;
-- 菜单对应按钮SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '查看', null, 'novel:category:detail', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '新增', null, 'novel:category:add', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '修改', null, 'novel:category:edit', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, 'novel:category:remove', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '批量删除', null, 'novel:category:batchRemove', '2', null, '6';

View File

@ -1,18 +0,0 @@
-- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('1', '新闻表', 'novel/news', 'novel:news:news', '1', 'fa', '6');
-- 按钮父菜单ID
set @parentId = @@identity;
-- 菜单对应按钮SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '查看', null, 'novel:news:detail', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '新增', null, 'novel:news:add', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '修改', null, 'novel:news:edit', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, 'novel:news:remove', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '批量删除', null, 'novel:news:batchRemove', '2', null, '6';

View File

@ -1,18 +0,0 @@
-- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('1', '充值订单', 'novel/pay', 'novel:pay:pay', '1', 'fa', '6');
-- 按钮父菜单ID
set @parentId = @@identity;
-- 菜单对应按钮SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '查看', null, 'novel:pay:detail', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '新增', null, 'novel:pay:add', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '修改', null, 'novel:pay:edit', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, 'novel:pay:remove', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '批量删除', null, 'novel:pay:batchRemove', '2', null, '6';

View File

@ -1,18 +0,0 @@
-- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('1', '', 'novel/user', 'novel:user:user', '1', 'fa', '6');
-- 按钮父菜单ID
set @parentId = @@identity;
-- 菜单对应按钮SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '查看', null, 'novel:user:detail', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '新增', null, 'novel:user:add', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '修改', null, 'novel:user:edit', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, 'novel:user:remove', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '批量删除', null, 'novel:user:batchRemove', '2', null, '6';

View File

@ -0,0 +1,36 @@
--菜单SQL
INSERT
INTO`sys_menu`(`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES('247', '网站信息表', 'novel/websiteInfo', 'novel:websiteInfo:websiteInfo', '1', 'fa', '6');
--按钮父菜单ID
set
@parentId
= @@identity;
--菜单对应按钮SQL
INSERT
INTO`sys_menu`(`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT
@parentId,
'查看', null, 'novel:websiteInfo:detail', '2', null, '6';
INSERT
INTO`sys_menu`(`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT
@parentId,
'新增', null, 'novel:websiteInfo:add', '2', null, '6';
INSERT
INTO`sys_menu`(`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT
@parentId,
'修改', null, 'novel:websiteInfo:edit', '2', null, '6';
INSERT
INTO`sys_menu`(`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT
@parentId,
'删除', null, 'novel:websiteInfo:remove', '2', null, '6';
INSERT
INTO`sys_menu`(`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT
@parentId,
'批量删除', null, 'novel:websiteInfo:batchRemove', '2', null, '6';

View File

@ -0,0 +1,93 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<form class="form-horizontal m-t" id="signupForm">
<input id="id" name="id" th:value="${websiteInfo.id}"
type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label">网站名:</label>
<div class="col-sm-8">
<input id="name" name="name"
th:value="${websiteInfo.name}"
class="form-control"
type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">网站域名:</label>
<div class="col-sm-8">
<input id="domain" name="domain"
th:value="${websiteInfo.domain}"
class="form-control"
type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">SEO关键词</label>
<div class="col-sm-8">
<input id="keyword" name="keyword"
th:value="${websiteInfo.keyword}"
class="form-control"
type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">网站描述:</label>
<div class="col-sm-8">
<input id="description" name="description"
th:value="${websiteInfo.description}"
class="form-control"
type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">站长QQ</label>
<div class="col-sm-8">
<input id="qq" name="qq"
th:value="${websiteInfo.qq}"
class="form-control"
type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">网站logo图片默认</label>
<div class="col-sm-8">
<input id="description" name="logo"
th:value="${websiteInfo.logo}"
class="form-control"
type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">网站logo图片深色</label>
<div class="col-sm-8">
<input id="description" name="logoDark"
th:value="${websiteInfo.logoDark}"
class="form-control"
type="text">
</div>
</div>
<div class="form-group">
<div class="col-sm-8 col-sm-offset-3">
<button type="submit" class="btn btn-primary">保存</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/wangEditor/release/wangEditor.js"></script>
<script type="text/javascript" src="/js/appjs/novel/websiteInfo/edit.js">
</script>
</body>
</html>