mirror of
https://github.com/201206030/novel-plus.git
synced 2025-07-04 00:16:39 +00:00
feat: 后台网站信息管理
This commit is contained in:
@ -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/";
|
||||
|
||||
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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(",");
|
||||
|
Reference in New Issue
Block a user