mirror of
https://github.com/201206030/novel-plus.git
synced 2025-07-05 00:36:39 +00:00
上传后台管理系统代码
This commit is contained in:
@ -0,0 +1,56 @@
|
||||
package com.java2nb.common.service;
|
||||
|
||||
import com.java2nb.common.domain.DictDO;
|
||||
import com.java2nb.system.domain.UserDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典表
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-09-29 18:28:07
|
||||
*/
|
||||
public interface DictService {
|
||||
|
||||
DictDO get(Long id);
|
||||
|
||||
List<DictDO> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(DictDO dict);
|
||||
|
||||
int update(DictDO dict);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
|
||||
List<DictDO> listType();
|
||||
|
||||
String getName(String type,String value);
|
||||
|
||||
/**
|
||||
* 获取爱好列表
|
||||
* @return
|
||||
* @param userDO
|
||||
*/
|
||||
List<DictDO> getHobbyList(UserDO userDO);
|
||||
|
||||
/**
|
||||
* 获取性别列表
|
||||
* @return
|
||||
*/
|
||||
List<DictDO> getSexList();
|
||||
|
||||
/**
|
||||
* 根据type获取数据
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
List<DictDO> listByType(String type);
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.java2nb.common.service;
|
||||
|
||||
import com.java2nb.common.domain.FileDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-09-19 16:02:20
|
||||
*/
|
||||
public interface FileService {
|
||||
|
||||
FileDO get(Long id);
|
||||
|
||||
List<FileDO> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(FileDO sysFile);
|
||||
|
||||
int update(FileDO sysFile);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
|
||||
/**
|
||||
* 判断一个文件是否存在
|
||||
* @param url FileDO中存的路径
|
||||
* @return
|
||||
*/
|
||||
Boolean isExist(String url);
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.java2nb.common.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.java2nb.common.domain.GenColumnsDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author xiongxy
|
||||
* @Time 2019-10-20 11:23:09
|
||||
* @description
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public interface GeneratorService {
|
||||
List<Map<String, Object>> list(String tableName);
|
||||
|
||||
void generatorCode(String[] tableNames);
|
||||
|
||||
byte[] downloadCode(String[] tableNames);
|
||||
|
||||
|
||||
List<GenColumnsDO> listColumnsByTableName(String tableName);
|
||||
|
||||
boolean genColumnsSave(List<GenColumnsDO> list);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.java2nb.common.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.java2nb.common.domain.LogDO;
|
||||
import com.java2nb.common.domain.PageDO;
|
||||
import com.java2nb.common.utils.Query;
|
||||
@Service
|
||||
public interface LogService {
|
||||
void save(LogDO logDO);
|
||||
PageDO<LogDO> queryList(Query query);
|
||||
int remove(Long id);
|
||||
int batchRemove(Long[] ids);
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package com.java2nb.common.service.impl;
|
||||
|
||||
import com.java2nb.common.utils.StringUtils;
|
||||
import com.java2nb.system.domain.UserDO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.java2nb.common.dao.DictDao;
|
||||
import com.java2nb.common.domain.DictDO;
|
||||
import com.java2nb.common.service.DictService;
|
||||
|
||||
|
||||
@Service
|
||||
public class DictServiceImpl implements DictService {
|
||||
@Autowired
|
||||
private DictDao dictDao;
|
||||
|
||||
@Override
|
||||
public DictDO get(Long id) {
|
||||
return dictDao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictDO> list(Map<String, Object> map) {
|
||||
return dictDao.list(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> map) {
|
||||
return dictDao.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(DictDO dict) {
|
||||
return dictDao.save(dict);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(DictDO dict) {
|
||||
return dictDao.update(dict);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(Long id) {
|
||||
return dictDao.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchRemove(Long[] ids) {
|
||||
return dictDao.batchRemove(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public List<DictDO> listType() {
|
||||
return dictDao.listType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(String type, String value) {
|
||||
Map<String, Object> param = new HashMap<String, Object>(16);
|
||||
param.put("type", type);
|
||||
param.put("value", value);
|
||||
String rString = dictDao.list(param).get(0).getName();
|
||||
return rString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictDO> getHobbyList(UserDO userDO) {
|
||||
Map<String, Object> param = new HashMap<>(16);
|
||||
param.put("type", "hobby");
|
||||
List<DictDO> hobbyList = dictDao.list(param);
|
||||
|
||||
if (StringUtils.isNotEmpty(userDO.getHobby())) {
|
||||
String userHobbys[] = userDO.getHobby().split(";");
|
||||
for (String userHobby : userHobbys) {
|
||||
for (DictDO hobby : hobbyList) {
|
||||
if (!Objects.equals(userHobby, hobby.getId().toString())) {
|
||||
continue;
|
||||
}
|
||||
hobby.setRemarks("true");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hobbyList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictDO> getSexList() {
|
||||
Map<String, Object> param = new HashMap<>(16);
|
||||
param.put("type", "sex");
|
||||
return dictDao.list(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictDO> listByType(String type) {
|
||||
Map<String, Object> param = new HashMap<>(16);
|
||||
param.put("type", type);
|
||||
return dictDao.list(param);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.java2nb.common.service.impl;
|
||||
|
||||
import com.java2nb.common.config.JnConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
package com.java2nb.common.service.impl;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import com.java2nb.common.dao.GenColumnsDao;
|
||||
import com.java2nb.common.domain.GenColumnsDO;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.configuration.PropertiesConfiguration;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.java2nb.common.dao.GeneratorMapper;
|
||||
import com.java2nb.common.service.GeneratorService;
|
||||
import com.java2nb.common.utils.GenUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
@Service
|
||||
public class GeneratorServiceImpl implements GeneratorService {
|
||||
@Autowired
|
||||
GeneratorMapper generatorMapper;
|
||||
|
||||
@Autowired
|
||||
GenColumnsDao genColumnsDao;
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> list(String tableName) {
|
||||
List<Map<String, Object>> list = generatorMapper.list(tableName);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generatorCode(String[] tableNames) {
|
||||
for (String tableName : tableNames) {
|
||||
//查询表信息
|
||||
Map<String, String> table = generatorMapper.get(tableName);
|
||||
//查询列信息
|
||||
List<Map<String, String>> columns = generatorMapper.listColumns(tableName);
|
||||
//生成代码
|
||||
GenUtils.generatorCode(table, columns, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] downloadCode(String[] tableNames) {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||
for (String tableName : tableNames) {
|
||||
//查询表信息
|
||||
Map<String, String> table = generatorMapper.get(tableName);
|
||||
//查询列信息
|
||||
List<Map<String, String>> columns = generatorMapper.listColumns(tableName);
|
||||
//生成代码
|
||||
GenUtils.generatorCode(table, columns, zip);
|
||||
}
|
||||
IOUtils.closeQuietly(zip);
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GenColumnsDO> listColumnsByTableName(String tableName) {
|
||||
Map<String, Object> query = new HashMap<>();
|
||||
query.put("tableName", tableName);
|
||||
query.put("sort", "column_sort");
|
||||
query.put("order", "asc");
|
||||
List<GenColumnsDO> columnList = genColumnsDao.list(query);
|
||||
if (columnList.size() == 0) {
|
||||
//查询列信息
|
||||
List<Map<String, String>> columns = generatorMapper.listColumns(tableName);
|
||||
|
||||
int columnSort = 0;
|
||||
for (Map<String, String> column : columns) {
|
||||
GenColumnsDO genColumnsDO = transGenColumnDO(tableName,column,++columnSort);
|
||||
|
||||
if(!"PRI".equalsIgnoreCase(column.get("columnKey"))) {
|
||||
columnList.add(genColumnsDO);
|
||||
}else{
|
||||
genColumnsDO.setColumnSort(0);
|
||||
genColumnsDO.setPageType(11);
|
||||
columnList.add(0,genColumnsDO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
Map<String, String> column = generatorMapper.getPriColumn(tableName);
|
||||
GenColumnsDO genColumnsDO = transGenColumnDO(tableName,column,0);
|
||||
genColumnsDO.setPageType(11);
|
||||
columnList.add(0,genColumnsDO);
|
||||
}
|
||||
return columnList;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public boolean genColumnsSave(List<GenColumnsDO> list) {
|
||||
GenColumnsDO pkColumn = list.get(0);
|
||||
String tableName = pkColumn.getTableName();
|
||||
genColumnsDao.deleteByTableName(tableName);
|
||||
list.remove(0);
|
||||
genColumnsDao.saveBatch(list);
|
||||
//查询表信息
|
||||
Map<String, String> table = generatorMapper.get(tableName);
|
||||
//生成代码
|
||||
GenUtils.generatorCode(table,pkColumn, list);
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public GenColumnsDO transGenColumnDO(String tableName,Map<String, String> column,int columnSort){
|
||||
GenColumnsDO genColumnsDO = new GenColumnsDO();
|
||||
genColumnsDO.setTableName(tableName);
|
||||
genColumnsDO.setColumnName(column.get("columnName"));
|
||||
genColumnsDO.setColumnType(column.get("dataType"));
|
||||
genColumnsDO.setColumnComment(column.get("columnComment"));
|
||||
PropertiesConfiguration conf = new PropertiesConfiguration("generator.properties");
|
||||
genColumnsDO.setJavaType(conf.getString(column.get("dataType")));
|
||||
genColumnsDO.setColumnSort(columnSort);
|
||||
genColumnsDO.setExtra(column.get("extra"));
|
||||
genColumnsDO.setIsRequired(0);
|
||||
if ("Date".equals(conf.getString(column.get("dataType")))) {
|
||||
genColumnsDO.setPageType(4);
|
||||
|
||||
} else {
|
||||
genColumnsDO.setPageType(1);
|
||||
}
|
||||
genColumnsDO.setColumnLabel(column.get("columnComment"));
|
||||
return genColumnsDO;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.java2nb.common.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.java2nb.common.dao.LogDao;
|
||||
import com.java2nb.common.domain.LogDO;
|
||||
import com.java2nb.common.domain.PageDO;
|
||||
import com.java2nb.common.service.LogService;
|
||||
import com.java2nb.common.utils.Query;
|
||||
|
||||
@Service
|
||||
public class LogServiceImpl implements LogService {
|
||||
@Autowired
|
||||
LogDao logMapper;
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void save(LogDO logDO) {
|
||||
logMapper.save(logDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageDO<LogDO> queryList(Query query) {
|
||||
int total = logMapper.count(query);
|
||||
List<LogDO> logs = logMapper.list(query);
|
||||
PageDO<LogDO> page = new PageDO<>();
|
||||
page.setTotal(total);
|
||||
page.setRows(logs);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(Long id) {
|
||||
int count = logMapper.remove(id);
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchRemove(Long[] ids){
|
||||
return logMapper.batchRemove(ids);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user