Commit e48b9566 authored by liqin's avatar liqin 💬

bug fixed

parent f224b1bd
...@@ -40,10 +40,6 @@ ...@@ -40,10 +40,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId> <artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions> <exclusions>
<exclusion>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</exclusion>
<exclusion> <exclusion>
<groupId>io.lettuce</groupId> <groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId> <artifactId>lettuce-core</artifactId>
...@@ -157,7 +153,7 @@ ...@@ -157,7 +153,7 @@
<version>3.3.1</version> <version>3.3.1</version>
</dependency> </dependency>
<!-- Shiro Authentication And Authorization --> <!-- Shiro Authentication And Authorization -->
<dependency> <!--<dependency>
<groupId>org.apache.shiro</groupId> <groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId> <artifactId>shiro-core</artifactId>
<version>1.7.1</version> <version>1.7.1</version>
...@@ -178,7 +174,14 @@ ...@@ -178,7 +174,14 @@
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency>-->
<!-- shiro dependency-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring-boot-web-starter</artifactId>
<version>1.6.0</version>
</dependency> </dependency>
<!-- Chinese ideograph To PinYin --> <!-- Chinese ideograph To PinYin -->
<dependency> <dependency>
<groupId>com.github.stuxuhai</groupId> <groupId>com.github.stuxuhai</groupId>
......
package cn.wisenergy.chnmuseum.party.auth.realm; package cn.wisenergy.chnmuseum.party.auth.realm;
import cn.wisenergy.chnmuseum.party.auth.token.JwtToken;
import cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil; import cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil;
import cn.wisenergy.chnmuseum.party.model.*; import cn.wisenergy.chnmuseum.party.model.*;
import cn.wisenergy.chnmuseum.party.service.PermissionService; import cn.wisenergy.chnmuseum.party.service.PermissionService;
...@@ -8,8 +9,6 @@ import cn.wisenergy.chnmuseum.party.service.RoleService; ...@@ -8,8 +9,6 @@ import cn.wisenergy.chnmuseum.party.service.RoleService;
import cn.wisenergy.chnmuseum.party.service.impl.EmployeeRoleServiceImpl; import cn.wisenergy.chnmuseum.party.service.impl.EmployeeRoleServiceImpl;
import cn.wisenergy.chnmuseum.party.service.impl.EmployeeServiceImpl; import cn.wisenergy.chnmuseum.party.service.impl.EmployeeServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.wisenergy.chnmuseum.party.auth.token.JwtToken;
import com.cmbchina.business.hall.model.*;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo; import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.authc.AuthenticationToken;
......
package cn.wisenergy.chnmuseum.party.common.mybatis; package cn.wisenergy.chnmuseum.party.common.mybatis;
import cn.wisenergy.datastation.common.core.utils.mybatis.query.InsertBatch; import cn.wisenergy.chnmuseum.party.common.mybatis.query.InsertBatch;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.core.injector.AbstractMethod; import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
......
package cn.wisenergy.chnmuseum.party.common.mybatis;
import com.github.pagehelper.Page;
import java.io.Serializable;
import java.util.List;
/**
* 对Page结果进行包装
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public class PageInfo<T> implements Serializable {
private static final long serialVersionUID = 8656597559014685635L;
/**
* 默认每页记录数
*/
private static final int DEFAULT_PAGE_SIZE = 10;
/**
* 最大每页记录数
*/
private static final int MAX_PAGE_SIZE = 1000;
private long total; //总记录数
private List<T> list; //结果集
private int pageNumber = 1; // 第几页
private int pageSize = DEFAULT_PAGE_SIZE; // 每页记录数
private int pages; // 总页数
private int size; // 当前页的数量 <= pageSize,该属性来自ArrayList的size属性
private int prevSize; // 上页页数
public PageInfo() {
}
public PageInfo(List<T> list) {
if (list instanceof Page) {
Page<T> page = (Page<T>) list;
this.pageNumber = page.getPageNum();
this.pageSize = page.getPageSize();
this.total = page.getTotal();
this.pages = page.getPages();
this.list = page;
this.size = page.size();
}
}
public PageInfo(Integer pageNumber, Integer pageSize) {
if (pageNumber != null && pageNumber >= 1) {
this.pageNumber = pageNumber;
}
if (pageSize != null && pageSize >= 1 && pageSize <= MAX_PAGE_SIZE) {
this.pageSize = pageSize;
}
}
public long getTotal() {
return total;
}
public void setTotal(long total) {
reset(this.pageSize, total);
}
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
public int getPageNumber() {
return pageNumber;
}
public void setPageNumber(int pageNumber) {
reset(this.pageSize, this.total);
this.pageNumber = pageNumber;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
reset(pageSize, this.total);
}
public int getPages() {
return pages;
}
public void setPages(int pages) {
this.pages = pages;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public int getPrevSize() {
return prevSize;
}
/**
* 重新设置属性
*
* @param pageSize
* @param total
*/
private void reset(int pageSize, long total) {
this.total = total;
this.pageSize = pageSize;
this.pages = (int) (total % pageSize == 0 ? total / pageSize : total / pageSize + 1);
this.prevSize = (pageNumber - 1) * pageSize;
}
}
...@@ -5,15 +5,9 @@ import java.text.DateFormat; ...@@ -5,15 +5,9 @@ import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.ParsePosition; import java.text.ParsePosition;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.poi.ss.usermodel.Cell;
public class DateUtil { public class DateUtil {
// 格式:年-月-日 小时:分钟:秒 // 格式:年-月-日 小时:分钟:秒
...@@ -601,19 +595,6 @@ public class DateUtil { ...@@ -601,19 +595,6 @@ public class DateUtil {
return date; return date;
} }
/**
* 针对yyyy-MM-dd HH:mm:ss格式,显示yyyymmdd
*/
public static String getYmdDateCN(String datestr) {
if (datestr == null)
return "";
if (datestr.length() < 10)
return "";
StringBuffer buf = new StringBuffer();
buf.append(datestr.substring(0, 4)).append(datestr.substring(5, 7)).append(datestr.substring(8, 10));
return buf.toString();
}
/** /**
* 获取本月第一天 * 获取本月第一天
* *
...@@ -779,11 +760,6 @@ public class DateUtil { ...@@ -779,11 +760,6 @@ public class DateUtil {
return cal.getTimeInMillis(); return cal.getTimeInMillis();
} }
public static boolean isCellDateFormatted(Cell cell) {
// TODO Auto-generated method stub
return false;
}
/** /**
* 将Date日期转换为 yyyyMMdd * 将Date日期转换为 yyyyMMdd
* *
......
package cn.wisenergy.chnmuseum.party.common.util;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
/**
* 导出excel工具类
*
* @author lmh
*/
public class ExcelUtil {
public static HSSFWorkbook getHSSFWorkbook(String sheetName, String[] title, String[][] values, HSSFWorkbook wb) {
// 第一步,创建一个webbook,对应一个Excel文件
if (wb == null) {
wb = new HSSFWorkbook();
}
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
HSSFSheet sheet = wb.createSheet(sheetName);
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
HSSFRow row = sheet.createRow(0);
// 第四步,创建单元格,并设置值表头 设置表头居中
HSSFCellStyle style = wb.createCellStyle();
// 创建一个居中格式
style.setAlignment(HorizontalAlignment.CENTER);
HSSFCell cell = null;
//创建标题
for (int i = 0; i < title.length; i++) {
cell = row.createCell(i);
cell.setCellValue(title[i]);
cell.setCellStyle(style);
sheet.setColumnWidth(i, 20 * 256 + 200);
}
HSSFCellStyle contentStyle = wb.createCellStyle();
// 设置单元格自动换行
contentStyle.setWrapText(true);
contentStyle.setAlignment(HorizontalAlignment.LEFT);
contentStyle.setVerticalAlignment(VerticalAlignment.CENTER);
//创建内容
for (int i = 0; i < values.length; i++) {
row = sheet.createRow(i + 1);
for (int j = 0; j < values[i].length; j++) {
sheet.setDefaultColumnStyle(j, contentStyle);
sheet.setColumnWidth(j, 20 * 256 + 200);
row.createCell(j).setCellValue(values[i][j]);
}
}
return wb;
}
public static HSSFWorkbook getHSSFWorkbookImg(String sheetName, String[] title, String[][] values, HSSFWorkbook wb, ByteArrayOutputStream outStream) {
// 第一步,创建一个webbook,对应一个Excel文件
if (wb == null) {
wb = new HSSFWorkbook();
}
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
HSSFSheet sheet = wb.createSheet(sheetName);
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
HSSFRow row = sheet.createRow(0);
// 第四步,创建单元格,并设置值表头 设置表头居中
HSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER); // 创建一个居中格式
HSSFCell cell = null;
//创建标题
for (int i = 0; i < title.length; i++) {
cell = row.createCell(i);
cell.setCellValue(title[i]);
cell.setCellStyle(style);
}
//创建内容
for (int i = 0; i < values.length; i++) {
row = sheet.createRow(i + 1);
for (int j = 0; j < values[i].length; j++) {
row.createCell(j).setCellValue(values[i][j]);
}
}
// 将图片写入流中
// 利用HSSFPatriarch将图片写入EXCEL
HSSFPatriarch patri = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0,
(short) 0, 1, (short) 1, 3);
patri.createPicture(anchor, wb.addPicture(
outStream.toByteArray(), HSSFWorkbook.PICTURE_TYPE_PNG));
return wb;
}
public static void setResponseHeader(HttpServletResponse response, String fileName) {
try {
try {
fileName = new String(fileName.getBytes(), "ISO8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response.setContentType("application/vnd.ms-excel;charset=utf-8");
// response.setContentType("application/octet-stream;charset=ISO8859-1");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
response.addHeader("Pargam", "no-cache");
response.addHeader("Cache-Control", "no-cache");
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static InputStream getInputStream(String path) {
InputStream inputStream = null;
HttpURLConnection httpURLConnection = null;
try {
URL url = new URL(path);
if (url != null) {
httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout(3000);
httpURLConnection.setRequestMethod("GET");
int responseCode = httpURLConnection.getResponseCode();
if (responseCode == 200) {
inputStream = httpURLConnection.getInputStream();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return inputStream;
}
/**
* @param @param fileNames
* @param @param request
* @param @return 设定文件
* @return String 返回类型
* @throws
* @Title: encodeFileName
* @Description: 导出文件转换文件名称编码
*/
public static String encodeFileName(String fileNames, HttpServletRequest request) {
String codedFilename = fileNames;
try {
String agent = request.getHeader("USER-AGENT");
if ((null != agent && -1 != agent.indexOf("MSIE")) || (null != agent
&& -1 != agent.indexOf("Trident")) || (null != agent && -1 != agent.indexOf("Edge"))) {// ie浏览器及Edge浏览器
codedFilename = URLEncoder.encode(fileNames, "UTF-8");
}
} catch (Exception e) {
e.printStackTrace();
}
return codedFilename;
}
}
package cn.wisenergy.chnmuseum.party.common.util;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
/**
* 导入excel工具类
*
* @author lmh
*/
public class ReadExcelUtil {
private static Logger logger = LoggerFactory.getLogger(ReadExcelUtil.class);
private final static String xls = "xls";
private final static String xlsx = "xlsx";
/**
* 读入excel文件,解析后返回
*
* @param file
* @throws IOException
*/
public static List<String[]> readExcel(MultipartFile file) throws IOException {
// 检查文件
checkFile(file);
// 获得Workbook工作薄对象
Workbook workbook = getWorkBook(file);
// 创建返回对象,把每行中的值作为一个数组,所有行作为一个集合返回
List<String[]> list = new ArrayList<String[]>();
if (workbook != null) {
for (int sheetNum = 0; sheetNum < workbook.getNumberOfSheets(); sheetNum++) {
// 获得当前sheet工作表
Sheet sheet = workbook.getSheetAt(sheetNum);
if (sheet == null) {
continue;
}
// 获得当前sheet的开始行
int firstRowNum = sheet.getFirstRowNum();
// 获得当前sheet的结束行
int lastRowNum = sheet.getLastRowNum();
if (firstRowNum <= 0 && lastRowNum < 1) {
break;
}
// 获取头部的长度
Row tiRow = sheet.getRow(firstRowNum);
int totalClumNum = tiRow.getPhysicalNumberOfCells();
// 循环除了第一行的所有行
for (int rowNum = firstRowNum + 1; rowNum <= lastRowNum; rowNum++) {
// 获得当前行
Row row = sheet.getRow(rowNum);
if (row == null) {
continue;
}
int lastCellNum = row.getPhysicalNumberOfCells();
if (lastCellNum <= 0) {
continue;
}
// 获得当前行的开始列
// int firstCellNum = row.getFirstCellNum(); 区第一个有值的列
// //获得当前行的列数
// int lastCellNum = row.getPhysicalNumberOfCells();
String[] cells = new String[totalClumNum];
// 循环当前行
for (int cellNum = 0; cellNum < totalClumNum; cellNum++) {
Cell cell = row.getCell(cellNum);
cells[cellNum] = getCellValue(cell);
}
list.add(cells);
}
}
workbook.close();
}
return list;
}
public static void checkFile(MultipartFile file) throws IOException {
// 判断文件是否存在
if (null == file) {
logger.error("文件不存在!");
throw new FileNotFoundException("文件不存在!");
}
// 获得文件名
String fileName = file.getOriginalFilename();
// 判断文件是否是excel文件
if (!fileName.endsWith(xls) && !fileName.endsWith(xlsx)) {
logger.error(fileName + "不是excel文件");
throw new IOException(fileName + "不是excel文件");
}
}
public static Workbook getWorkBook(MultipartFile file) {
// 获得文件名
String fileName = file.getOriginalFilename();
// 创建Workbook工作薄对象,表示整个excel
Workbook workbook = null;
try {
// 获取excel文件的io流
InputStream is = file.getInputStream();
// 根据文件后缀名不同(xls和xlsx)获得不同的Workbook实现类对象
if (fileName.endsWith(xls)) {
// 2003
workbook = new HSSFWorkbook(is);
} else if (fileName.endsWith(xlsx)) {
// 2007
workbook = new XSSFWorkbook(is);
}
} catch (IOException e) {
logger.info(e.getMessage());
}
return workbook;
}
public static String getCellValue(Cell cell) {
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
String cellValue = "";
if (cell == null) {
return cellValue;
}
CellType cellType = cell.getCellTypeEnum();
// 把数字当成String来读,避免出现1读成1.0的情况
if (cellType == CellType.NUMERIC) {
cell.setCellType(CellType.STRING);
}
// 判断数据的类型
switch (cellType) {
case NUMERIC: // 数字、日期
if (DateUtil.isCellDateFormatted(cell)) {
cellValue = fmt.format(cell.getDateCellValue()); // 日期型
} else {
cellValue = String.valueOf(cell.getStringCellValue()); // 数字
if (cellValue.contains("E")) {
cellValue = String.valueOf(new Double(cell.getStringCellValue()).longValue()); // 数字
}
}
break;
case STRING: // 字符串
cellValue = String.valueOf(cell.getStringCellValue());
break;
case BOOLEAN: // Boolean
cellValue = String.valueOf(cell.getBooleanCellValue());
break;
case FORMULA: // 公式
cellValue = String.valueOf(cell.getCellFormula());
break;
case BLANK: // 空值
cellValue = cell.getStringCellValue();
break;
case ERROR: // 故障
cellValue = "非法字符";
break;
default:
cellValue = "未知类型";
break;
}
return cellValue;
}
}
...@@ -22,7 +22,7 @@ public class FastJsonHttpMessageConvertersConfig { ...@@ -22,7 +22,7 @@ public class FastJsonHttpMessageConvertersConfig {
@Configuration @Configuration
@ConditionalOnClass({FastJsonHttpMessageConverter.class}) @ConditionalOnClass({FastJsonHttpMessageConverter.class})
@ConditionalOnProperty(name = { @ConditionalOnProperty(name = {
"spring.http.converters.preferred-json-mapper"}, havingValue = "fastjson", matchIfMissing = true) "spring.mvc.converters.preferred-json-mapper"}, havingValue = "fastjson", matchIfMissing = true)
protected static class FastJson2HttpMessageConverterConfiguration { protected static class FastJson2HttpMessageConverterConfiguration {
protected FastJson2HttpMessageConverterConfiguration() { protected FastJson2HttpMessageConverterConfiguration() {
} }
...@@ -40,7 +40,7 @@ public class FastJsonHttpMessageConvertersConfig { ...@@ -40,7 +40,7 @@ public class FastJsonHttpMessageConvertersConfig {
); );
// 处理ie浏览器保存数据时出现下载json数据问题 // 处理ie浏览器保存数据时出现下载json数据问题
List<MediaType> mediaTypes = new ArrayList<>(); List<MediaType> mediaTypes = new ArrayList<>();
mediaTypes.add(MediaType.APPLICATION_JSON_UTF8); mediaTypes.add(MediaType.APPLICATION_JSON);
mediaTypes.add(MediaType.TEXT_PLAIN); mediaTypes.add(MediaType.TEXT_PLAIN);
//mediaTypes.add(new MediaType("text", "plain", Charset.forName("UTF-8"))); //mediaTypes.add(new MediaType("text", "plain", Charset.forName("UTF-8")));
converter.setSupportedMediaTypes(mediaTypes); converter.setSupportedMediaTypes(mediaTypes);
......
...@@ -13,7 +13,7 @@ import java.util.Arrays; ...@@ -13,7 +13,7 @@ import java.util.Arrays;
@Configuration @Configuration
public class GlobalCorsConfig { public class GlobalCorsConfig {
@Value("${cors.url.list}") @Value("${cors.url.list:#{null}}")
private String corsUrlList; private String corsUrlList;
@Bean @Bean
......
package cn.wisenergy.chnmuseum.party.conf;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class HttpClientConf {
@Bean
public CloseableHttpClient httpClient() {
return HttpClientBuilder.create().build();
}
}
package cn.wisenergy.chnmuseum.party.conf; package cn.wisenergy.chnmuseum.party.conf;
import javax.annotation.Resource; import com.baomidou.mybatisplus.annotation.DbType;
import javax.sql.DataSource; import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
import org.apache.ibatis.mapping.DatabaseIdProvider; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import org.apache.ibatis.plugin.Interceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.boot.autoconfigure.MybatisProperties;
import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import com.baomidou.mybatisplus.MybatisConfiguration;
import com.baomidou.mybatisplus.MybatisXMLLanguageDriver;
import com.baomidou.mybatisplus.entity.GlobalConfiguration;
import com.baomidou.mybatisplus.enums.DBType;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean;
@Configuration @Configuration
@MapperScan("com.cmbchina.business.hall.mapper*") @MapperScan("cn.wisenergy.chnmuseum.party.mapper*")
@EnableConfigurationProperties(MybatisProperties.class) @EnableConfigurationProperties(MybatisPlusProperties.class)
public class MybatisPlusConfig { public class MybatisPlusConfig {
@Resource
private DataSource dataSource;
@Autowired
private MybatisProperties properties;
@Autowired
private ResourceLoader resourceLoader = new DefaultResourceLoader();
@Autowired(required = false)
private Interceptor[] interceptors;
@Autowired(required = false)
private DatabaseIdProvider databaseIdProvider;
/**
* mybatis-plus分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor page = new PaginationInterceptor();
page.setOverflowCurrent(false);
page.setDialectType("mysql");
return page;
}
/**
* 这里全部使用mybatis-autoconfigure 已经自动加载的资源。不手动指定 配置文件和mybatis-boot的配置文件同步
*/
@Bean
public MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean() {
MybatisSqlSessionFactoryBean mybatisPlus = new MybatisSqlSessionFactoryBean();
mybatisPlus.setDataSource(dataSource);
mybatisPlus.setVfs(SpringBootVFS.class);
if (StringUtils.hasText(this.properties.getConfigLocation())) {
mybatisPlus.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
}
mybatisPlus.setConfiguration(properties.getConfiguration());
if (!ObjectUtils.isEmpty(this.interceptors)) {
mybatisPlus.setPlugins(this.interceptors);
}
// MP 全局配置,更多内容进入类看注释
GlobalConfiguration globalConfig = new GlobalConfiguration();
globalConfig.setDbType(DBType.MYSQL.name());// 数据库类型
// ID 策略 AUTO->`0`("数据库ID自增") INPUT->`1`(用户输入ID")
// ID_WORKER->`2`("全局唯一ID") UUID->`3`("全局唯一ID")
globalConfig.setIdType(0);
// MP 属性下划线 转 驼峰 , 如果原生配置 mc.setMapUnderscoreToCamelCase(true)
// 开启,该配置可以无。
// globalConfig.setDbColumnUnderline(true);
mybatisPlus.setGlobalConfig(globalConfig);
MybatisConfiguration mc = new MybatisConfiguration();
mc.setLazyLoadingEnabled(true);
mc.setAggressiveLazyLoading(false);
/*
* mc.setCacheEnabled(true); mc.setCallSettersOnNulls(true);
*/
// 对于完全自定义的mapper需要加此项配置,才能实现下划线转驼峰
mc.setMapUnderscoreToCamelCase(false);
mc.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
mybatisPlus.setConfiguration(mc);
if (this.databaseIdProvider != null) {
mybatisPlus.setDatabaseIdProvider(this.databaseIdProvider);
}
if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
mybatisPlus.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
}
if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
mybatisPlus.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
}
if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
mybatisPlus.setMapperLocations(this.properties.resolveMapperLocations());
}
return mybatisPlus;
}
/** /**
* 注册一个StatViewServlet * 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题
*/ */
@Bean @Bean
public ServletRegistrationBean<StatViewServlet> DruidStatViewServle() { public MybatisPlusInterceptor mybatisPlusInterceptor() {
// org.springframework.boot.context.embedded.ServletRegistrationBean提供类的进行注册. MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
ServletRegistrationBean<StatViewServlet> servletRegistrationBean = new ServletRegistrationBean<>( interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
new StatViewServlet(), "/druid/*"); return interceptor;
// 添加初始化参数:initParams
// 白名单:
// servletRegistrationBean.addInitParameter("allow","127.0.0.1");
// IP黑名单 (存在共同时,deny优先于allow) : 如果满足deny的话提示:Sorry, you are not
// permitted to view this page.
// servletRegistrationBean.addInitParameter("deny","192.168.1.73");
// 登录查看信息的账号密码.
servletRegistrationBean.addInitParameter("loginUsername", "root");
servletRegistrationBean.addInitParameter("loginPassword", "root");
// 是否能够重置数据.
servletRegistrationBean.addInitParameter("resetEnable", "false");
return servletRegistrationBean;
} }
/**
* 注册一个:filterRegistrationBean
*/
@Bean @Bean
public FilterRegistrationBean<WebStatFilter> druidStatFilter() { public ConfigurationCustomizer configurationCustomizer() {
FilterRegistrationBean<WebStatFilter> filterRegistrationBean = new FilterRegistrationBean<>( return configuration -> configuration.setUseDeprecatedExecutor(false);
new WebStatFilter());
// 添加过滤规则.
filterRegistrationBean.addUrlPatterns("/*");
// 添加不需要忽略的格式信息.
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
return filterRegistrationBean;
} }
} }
package cn.wisenergy.chnmuseum.party.conf; package cn.wisenergy.chnmuseum.party.conf;
import cn.wisenergy.chnmuseum.party.auth.filter.JwtFilter; import cn.wisenergy.chnmuseum.party.auth.filter.JwtFilter;
import cn.wisenergy.chnmuseum.party.auth.realm.MyShiroRealm;
import cn.wisenergy.chnmuseum.party.model.PermissionInit; import cn.wisenergy.chnmuseum.party.model.PermissionInit;
import cn.wisenergy.chnmuseum.party.service.PermissionInitService; import cn.wisenergy.chnmuseum.party.service.PermissionInitService;
import cn.wisenergy.chnmuseum.party.auth.realm.MyShiroRealm;
import org.apache.shiro.mgt.DefaultSessionStorageEvaluator; import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
import org.apache.shiro.mgt.DefaultSubjectDAO; import org.apache.shiro.mgt.DefaultSubjectDAO;
import org.apache.shiro.mgt.SecurityManager; import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.mgt.SessionsSecurityManager;
import org.apache.shiro.spring.LifecycleBeanPostProcessor; import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean; import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.crazycake.shiro.RedisCacheManager; import org.crazycake.shiro.RedisCacheManager;
import org.crazycake.shiro.RedisSessionDAO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
...@@ -34,14 +34,11 @@ public class ShiroConfig { ...@@ -34,14 +34,11 @@ public class ShiroConfig {
private static final Logger logger = LoggerFactory.getLogger(ShiroConfig.class); private static final Logger logger = LoggerFactory.getLogger(ShiroConfig.class);
@Resource @Resource
private RedisSessionDAO redisSessionDAO; private PermissionInitService permissionInitService;
@Resource @Resource
private RedisCacheManager redisCacheManager; private RedisCacheManager redisCacheManager;
@Resource
private PermissionInitService permissionInitService;
/** /**
* ShiroFilterFactoryBean 处理拦截资源文件问题。 * ShiroFilterFactoryBean 处理拦截资源文件问题。
* <p> * <p>
...@@ -87,7 +84,7 @@ public class ShiroConfig { ...@@ -87,7 +84,7 @@ public class ShiroConfig {
} }
@Bean @Bean
public SecurityManager securityManager() { public SessionsSecurityManager securityManager() {
logger.info("ShiroConfiguration.securityManager()"); logger.info("ShiroConfiguration.securityManager()");
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
// 设置realm // 设置realm
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.enums.IdType;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Date;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.io.Serializable; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.activerecord.Model; import java.io.Serializable;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.enums.IdType;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.enums.IdType;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
......
package cn.wisenergy.chnmuseum.party.service; package cn.wisenergy.chnmuseum.party.service;
import com.baomidou.mybatisplus.mapper.Wrapper;
import cn.wisenergy.chnmuseum.party.common.util.DateUtil80; import cn.wisenergy.chnmuseum.party.common.util.DateUtil80;
import cn.wisenergy.chnmuseum.party.model.HttpResult; import cn.wisenergy.chnmuseum.party.model.HttpResult;
import cn.wisenergy.chnmuseum.party.model.PageViewRecord; import cn.wisenergy.chnmuseum.party.model.PageViewRecord;
import cn.wisenergy.chnmuseum.party.model.PageViews; import cn.wisenergy.chnmuseum.party.model.PageViews;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
...@@ -15,7 +15,6 @@ import org.springframework.util.LinkedMultiValueMap; ...@@ -15,7 +15,6 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import com.baomidou.mybatisplus.mapper.QueryWrapper;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
...@@ -178,7 +177,7 @@ public class PublicService { ...@@ -178,7 +177,7 @@ public class PublicService {
pageViewRecord.setType(cacheValue.getType()); pageViewRecord.setType(cacheValue.getType());
pageViewRecord.setDetailId(cacheValue.getDetailId()); pageViewRecord.setDetailId(cacheValue.getDetailId());
//将数据插入数据库 //将数据插入数据库
this.pageViewRecordService.insert(pageViewRecord); this.pageViewRecordService.save(pageViewRecord);
//记录每个页面的访问数量 //记录每个页面的访问数量
if (cacheValue.getType() == 1) { if (cacheValue.getType() == 1) {
typeOne += 1; typeOne += 1;
...@@ -191,11 +190,11 @@ public class PublicService { ...@@ -191,11 +190,11 @@ public class PublicService {
} }
} }
Wrapper<PageViews> viewsWrapper = new QueryWrapper<>(); QueryWrapper<PageViews> viewsWrapper = new QueryWrapper<>();
PageViews pageViews = new PageViews(); PageViews pageViews = new PageViews();
if (typeOne != 0) { if (typeOne != 0) {
viewsWrapper.eq("type", 1); viewsWrapper.eq("type", 1);
PageViews one = this.pageViewsService.selectOne(viewsWrapper); PageViews one = this.pageViewsService.getOne(viewsWrapper);
if (one != null) { if (one != null) {
pageViews.setId(one.getId()); pageViews.setId(one.getId());
pageViews.setTimes(one.getTimes() + typeOne); pageViews.setTimes(one.getTimes() + typeOne);
...@@ -205,7 +204,7 @@ public class PublicService { ...@@ -205,7 +204,7 @@ public class PublicService {
pageViews.setPageName("业务办理助手"); pageViews.setPageName("业务办理助手");
pageViews.setTimes(typeOne); pageViews.setTimes(typeOne);
pageViews.setViewDate(currDate); pageViews.setViewDate(currDate);
this.pageViewsService.insert(pageViews); this.pageViewsService.save(pageViews);
} }
} }
if (typeTwo != 0) { if (typeTwo != 0) {
...@@ -213,7 +212,7 @@ public class PublicService { ...@@ -213,7 +212,7 @@ public class PublicService {
pageViews = new PageViews(); pageViews = new PageViews();
viewsWrapper.eq("view_date", currDate); viewsWrapper.eq("view_date", currDate);
viewsWrapper.eq("type", 2); viewsWrapper.eq("type", 2);
PageViews one = this.pageViewsService.selectOne(viewsWrapper); PageViews one = this.pageViewsService.getOne(viewsWrapper);
if (one != null) { if (one != null) {
pageViews.setId(one.getId()); pageViews.setId(one.getId());
pageViews.setTimes(one.getTimes() + typeTwo); pageViews.setTimes(one.getTimes() + typeTwo);
...@@ -223,7 +222,7 @@ public class PublicService { ...@@ -223,7 +222,7 @@ public class PublicService {
pageViews.setPageName("网点服务地图"); pageViews.setPageName("网点服务地图");
pageViews.setTimes(typeTwo); pageViews.setTimes(typeTwo);
pageViews.setViewDate(currDate); pageViews.setViewDate(currDate);
this.pageViewsService.insert(pageViews); this.pageViewsService.save(pageViews);
} }
} }
if (typeThree != 0) { if (typeThree != 0) {
...@@ -231,7 +230,7 @@ public class PublicService { ...@@ -231,7 +230,7 @@ public class PublicService {
pageViews = new PageViews(); pageViews = new PageViews();
viewsWrapper.eq("view_date", currDate); viewsWrapper.eq("view_date", currDate);
viewsWrapper.eq("type", 3); viewsWrapper.eq("type", 3);
PageViews one = this.pageViewsService.selectOne(viewsWrapper); PageViews one = this.pageViewsService.getOne(viewsWrapper);
if (one != null) { if (one != null) {
pageViews.setId(one.getId()); pageViews.setId(one.getId());
pageViews.setTimes(one.getTimes() + typeThree); pageViews.setTimes(one.getTimes() + typeThree);
...@@ -241,7 +240,7 @@ public class PublicService { ...@@ -241,7 +240,7 @@ public class PublicService {
pageViews.setPageName("热门产品"); pageViews.setPageName("热门产品");
pageViews.setTimes(typeThree); pageViews.setTimes(typeThree);
pageViews.setViewDate(currDate); pageViews.setViewDate(currDate);
this.pageViewsService.insert(pageViews); this.pageViewsService.save(pageViews);
} }
} }
if (typeFour != 0) { if (typeFour != 0) {
...@@ -249,7 +248,7 @@ public class PublicService { ...@@ -249,7 +248,7 @@ public class PublicService {
pageViews = new PageViews(); pageViews = new PageViews();
viewsWrapper.eq("view_date", currDate); viewsWrapper.eq("view_date", currDate);
viewsWrapper.eq("type", 4); viewsWrapper.eq("type", 4);
PageViews one = this.pageViewsService.selectOne(viewsWrapper); PageViews one = this.pageViewsService.getOne(viewsWrapper);
if (one != null) { if (one != null) {
pageViews.setId(one.getId()); pageViews.setId(one.getId());
pageViews.setTimes(one.getTimes() + typeFour); pageViews.setTimes(one.getTimes() + typeFour);
...@@ -259,7 +258,7 @@ public class PublicService { ...@@ -259,7 +258,7 @@ public class PublicService {
pageViews.setPageName("热门活动"); pageViews.setPageName("热门活动");
pageViews.setTimes(typeFour); pageViews.setTimes(typeFour);
pageViews.setViewDate(currDate); pageViews.setViewDate(currDate);
this.pageViewsService.insert(pageViews); this.pageViewsService.save(pageViews);
} }
} }
//插入数据库后清空redis //插入数据库后清空redis
......
package cn.wisenergy.chnmuseum.party.web.controller; package cn.wisenergy.chnmuseum.party.web.controller;
import cn.wisenergy.chnmuseum.party.common.util.ExcelUtil;
import cn.wisenergy.chnmuseum.party.common.util.ReadExcelUtil;
import cn.wisenergy.chnmuseum.party.core.annotations.OperationLog; import cn.wisenergy.chnmuseum.party.core.annotations.OperationLog;
import cn.wisenergy.chnmuseum.party.model.*; import cn.wisenergy.chnmuseum.party.model.*;
import cn.wisenergy.chnmuseum.party.service.PublicService; import cn.wisenergy.chnmuseum.party.service.PublicService;
import cn.wisenergy.chnmuseum.party.service.impl.*; import cn.wisenergy.chnmuseum.party.service.impl.*;
import com.baomidou.mybatisplus.mapper.QueryWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cmbchina.business.hall.model.*;
import com.cmbchina.business.hall.service.impl.*;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController; import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -25,10 +19,8 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -25,10 +19,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.OutputStream;
import java.util.*; import java.util.*;
/** /**
...@@ -84,15 +76,15 @@ public class BankBranchInfoController extends BaseController { ...@@ -84,15 +76,15 @@ public class BankBranchInfoController extends BaseController {
@RequiresPermissions("/bankBranchInfo/getById") @RequiresPermissions("/bankBranchInfo/getById")
public ResponseEntity<BankBranchInfo> getById(String id) { public ResponseEntity<BankBranchInfo> getById(String id) {
try { try {
BankBranchInfo one = this.bankBranchInfoService.selectById(id); BankBranchInfo one = this.bankBranchInfoService.getById(id);
if (one.getCreator() != null && !"".equals(one.getCreator())) { if (one.getCreator() != null && !"".equals(one.getCreator())) {
Employee creatorName = this.employeeService.selectById(one.getCreator()); Employee creatorName = this.employeeService.getById(one.getCreator());
if (creatorName != null) { if (creatorName != null) {
one.setCreatorName(creatorName.getName()); one.setCreatorName(creatorName.getName());
} }
} }
if (one.getModifier() != null && !"".equals(one.getModifier())) { if (one.getModifier() != null && !"".equals(one.getModifier())) {
Employee modifierName = this.employeeService.selectById(one.getModifier()); Employee modifierName = this.employeeService.getById(one.getModifier());
if (modifierName != null) { if (modifierName != null) {
one.setModifierName(modifierName.getName()); one.setModifierName(modifierName.getName());
} }
...@@ -117,7 +109,7 @@ public class BankBranchInfoController extends BaseController { ...@@ -117,7 +109,7 @@ public class BankBranchInfoController extends BaseController {
@GetMapping(value = "/getByIdOnApp") @GetMapping(value = "/getByIdOnApp")
public ResponseEntity<BankBranchInfo> getByIdOnApp(String id, String userId, String bankId) { public ResponseEntity<BankBranchInfo> getByIdOnApp(String id, String userId, String bankId) {
try { try {
BankBranchInfo one = this.bankBranchInfoService.selectById(id); BankBranchInfo one = this.bankBranchInfoService.getById(id);
if (null != one) { if (null != one) {
//将数据放入缓存 //将数据放入缓存
this.publicService.cacheData(id, userId, bankId, 2); this.publicService.cacheData(id, userId, bankId, 2);
...@@ -168,9 +160,9 @@ public class BankBranchInfoController extends BaseController { ...@@ -168,9 +160,9 @@ public class BankBranchInfoController extends BaseController {
ew.ne("id", "0"); ew.ne("id", "0");
ew.eq("status", 1); ew.eq("status", 1);
ew.eq("is_deleted", 0); ew.eq("is_deleted", 0);
ew.orderBy("sortorder", true); ew.orderByAsc("sortorder");
ew.orderBy("create_time", false); ew.orderByDesc("create_time");
return ResponseEntity.ok(this.bankBranchInfoService.selectList(ew)); return ResponseEntity.ok(this.bankBranchInfoService.list(ew));
} catch (Exception e) { } catch (Exception e) {
logger.error("服务器错误!", e); logger.error("服务器错误!", e);
} }
...@@ -184,7 +176,7 @@ public class BankBranchInfoController extends BaseController { ...@@ -184,7 +176,7 @@ public class BankBranchInfoController extends BaseController {
public ResponseEntity<Map<String, Object>> add(BankBranchInfo bankBranchInfo) { public ResponseEntity<Map<String, Object>> add(BankBranchInfo bankBranchInfo) {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>(); Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
try { try {
Wrapper<BankBranchInfo> ew = new QueryWrapper<>(); QueryWrapper<BankBranchInfo> ew = new QueryWrapper<>();
ew.eq("is_deleted", 0); ew.eq("is_deleted", 0);
if (StringUtils.isNoneBlank(bankBranchInfo.getName())) { if (StringUtils.isNoneBlank(bankBranchInfo.getName())) {
ew.eq("name", bankBranchInfo.getName().trim()); ew.eq("name", bankBranchInfo.getName().trim());
...@@ -193,7 +185,7 @@ public class BankBranchInfoController extends BaseController { ...@@ -193,7 +185,7 @@ public class BankBranchInfoController extends BaseController {
resultMap.put("message", "请输入网点名称"); resultMap.put("message", "请输入网点名称");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
} }
BankBranchInfo one = this.bankBranchInfoService.selectOne(ew); BankBranchInfo one = this.bankBranchInfoService.getOne(ew);
if (one != null) { if (one != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "该网点已存在"); resultMap.put("message", "该网点已存在");
...@@ -201,8 +193,8 @@ public class BankBranchInfoController extends BaseController { ...@@ -201,8 +193,8 @@ public class BankBranchInfoController extends BaseController {
} }
if (bankBranchInfo.getSortorder() == null) { if (bankBranchInfo.getSortorder() == null) {
ew = new QueryWrapper<>(); ew = new QueryWrapper<>();
ew.setSqlSelect("max(sortorder) as sortorder"); ew.select("max(sortorder) as sortorder");
BankBranchInfo b = this.bankBranchInfoService.selectOne(ew); BankBranchInfo b = this.bankBranchInfoService.getOne(ew);
if (b == null) { if (b == null) {
bankBranchInfo.setSortorder(1); bankBranchInfo.setSortorder(1);
} else { } else {
...@@ -216,7 +208,7 @@ public class BankBranchInfoController extends BaseController { ...@@ -216,7 +208,7 @@ public class BankBranchInfoController extends BaseController {
bankBranchInfo.setUpdateTime(bankBranchInfo.getCreateTime()); bankBranchInfo.setUpdateTime(bankBranchInfo.getCreateTime());
//新建网点时默认在编辑中 //新建网点时默认在编辑中
bankBranchInfo.setIsShow(0); bankBranchInfo.setIsShow(0);
ret = this.bankBranchInfoService.insert(bankBranchInfo); ret = this.bankBranchInfoService.save(bankBranchInfo);
if (!ret) { if (!ret) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "添加失败"); resultMap.put("message", "添加失败");
...@@ -241,13 +233,13 @@ public class BankBranchInfoController extends BaseController { ...@@ -241,13 +233,13 @@ public class BankBranchInfoController extends BaseController {
public ResponseEntity<Map<String, Object>> edit(BankBranchInfo bankBranchInfo) { public ResponseEntity<Map<String, Object>> edit(BankBranchInfo bankBranchInfo) {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>(); Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
try { try {
Wrapper<BankBranchInfo> ew = new QueryWrapper<>(); QueryWrapper<BankBranchInfo> ew = new QueryWrapper<>();
ew.eq("is_deleted", 0); ew.eq("is_deleted", 0);
if (StringUtils.isNoneBlank(bankBranchInfo.getName())) { if (StringUtils.isNoneBlank(bankBranchInfo.getName())) {
ew.ne("id", bankBranchInfo.getId()); ew.ne("id", bankBranchInfo.getId());
ew.eq("name", bankBranchInfo.getName().trim()); ew.eq("name", bankBranchInfo.getName().trim());
} }
BankBranchInfo one = this.bankBranchInfoService.selectOne(ew); BankBranchInfo one = this.bankBranchInfoService.getOne(ew);
if (one != null) { if (one != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "该网点已存在"); resultMap.put("message", "该网点已存在");
...@@ -286,10 +278,10 @@ public class BankBranchInfoController extends BaseController { ...@@ -286,10 +278,10 @@ public class BankBranchInfoController extends BaseController {
try { try {
Boolean ret = false; Boolean ret = false;
//判断该网点下是否有关联用户 //判断该网点下是否有关联用户
Wrapper<Employee> employeeWrapper = new QueryWrapper<>(); QueryWrapper<Employee> employeeWrapper = new QueryWrapper<>();
employeeWrapper.eq("bank_branch_id", id); employeeWrapper.eq("bank_branch_id", id);
employeeWrapper.eq("is_deleted", 0); employeeWrapper.eq("is_deleted", 0);
Employee employee = this.employeeService.selectOne(employeeWrapper); Employee employee = this.employeeService.getOne(employeeWrapper);
if (employee != null) { if (employee != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "该网点下存在用户,不允许删除!"); resultMap.put("message", "该网点下存在用户,不允许删除!");
...@@ -297,9 +289,9 @@ public class BankBranchInfoController extends BaseController { ...@@ -297,9 +289,9 @@ public class BankBranchInfoController extends BaseController {
} }
//判断该网点下是否有关联的吐槽建议和呼叫记录 //判断该网点下是否有关联的吐槽建议和呼叫记录
Wrapper<DemandInfo> demandInfoWrapper = new QueryWrapper<>(); QueryWrapper<DemandInfo> demandInfoWrapper = new QueryWrapper<>();
demandInfoWrapper.eq("bank_branch_id", id); demandInfoWrapper.eq("bank_branch_id", id);
DemandInfo demandInfo = this.demandInfoService.selectOne(demandInfoWrapper); DemandInfo demandInfo = this.demandInfoService.getOne(demandInfoWrapper);
if (demandInfo != null) { if (demandInfo != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "该网点下存在吐槽建议或呼叫记录,不允许删除!"); resultMap.put("message", "该网点下存在吐槽建议或呼叫记录,不允许删除!");
...@@ -307,9 +299,9 @@ public class BankBranchInfoController extends BaseController { ...@@ -307,9 +299,9 @@ public class BankBranchInfoController extends BaseController {
} }
//判断该网点下是否有关联的业务服务指南 //判断该网点下是否有关联的业务服务指南
Wrapper<BusinessInfo> businessInfoWrapper = new QueryWrapper<>(); QueryWrapper<BusinessInfo> businessInfoWrapper = new QueryWrapper<>();
businessInfoWrapper.eq("bank_branch_id", id); businessInfoWrapper.eq("bank_branch_id", id);
BusinessInfo businessInfo = this.businessInfoService.selectOne(businessInfoWrapper); BusinessInfo businessInfo = this.businessInfoService.getOne(businessInfoWrapper);
if (businessInfo != null) { if (businessInfo != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "该网点下存在业务服务指南,不允许删除!"); resultMap.put("message", "该网点下存在业务服务指南,不允许删除!");
...@@ -317,9 +309,9 @@ public class BankBranchInfoController extends BaseController { ...@@ -317,9 +309,9 @@ public class BankBranchInfoController extends BaseController {
} }
//判断该网点下是否有关联的热门产品活动 //判断该网点下是否有关联的热门产品活动
Wrapper<HotProductActivity> hotProductActivityWrapper = new QueryWrapper<>(); QueryWrapper<HotProductActivity> hotProductActivityWrapper = new QueryWrapper<>();
hotProductActivityWrapper.eq("bank_branch_id", id); hotProductActivityWrapper.eq("bank_branch_id", id);
HotProductActivity hotProductActivity = this.hotProductActivityService.selectOne(hotProductActivityWrapper); HotProductActivity hotProductActivity = this.hotProductActivityService.getOne(hotProductActivityWrapper);
if (hotProductActivity != null) { if (hotProductActivity != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "该网点下存在热门产品或活动,不允许删除!"); resultMap.put("message", "该网点下存在热门产品或活动,不允许删除!");
...@@ -327,9 +319,9 @@ public class BankBranchInfoController extends BaseController { ...@@ -327,9 +319,9 @@ public class BankBranchInfoController extends BaseController {
} }
//判断该网点下是否有关联的热门产品活动预约记录 //判断该网点下是否有关联的热门产品活动预约记录
Wrapper<ProductAppointmentRecord> productAppointmentRecordWrapper = new QueryWrapper<>(); QueryWrapper<ProductAppointmentRecord> productAppointmentRecordWrapper = new QueryWrapper<>();
productAppointmentRecordWrapper.eq("bank_branch_id", id); productAppointmentRecordWrapper.eq("bank_branch_id", id);
ProductAppointmentRecord productAppointmentRecord = this.productAppointmentRecordService.selectOne(productAppointmentRecordWrapper); ProductAppointmentRecord productAppointmentRecord = this.productAppointmentRecordService.getOne(productAppointmentRecordWrapper);
if (productAppointmentRecord != null) { if (productAppointmentRecord != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "该网点下存在热门产品或活动预约记录,不允许删除!"); resultMap.put("message", "该网点下存在热门产品或活动预约记录,不允许删除!");
...@@ -341,9 +333,9 @@ public class BankBranchInfoController extends BaseController { ...@@ -341,9 +333,9 @@ public class BankBranchInfoController extends BaseController {
branchInfo.setIsDeleted(1); branchInfo.setIsDeleted(1);
ret = this.bankBranchInfoService.updateById(branchInfo); ret = this.bankBranchInfoService.updateById(branchInfo);
Wrapper<HotSpot> hotSpotWrapper = new QueryWrapper<>(); QueryWrapper<HotSpot> hotSpotWrapper = new QueryWrapper<>();
hotSpotWrapper.eq("bank_branch_id", id); hotSpotWrapper.eq("bank_branch_id", id);
ret = this.hotSpotService.delete(hotSpotWrapper); ret = this.hotSpotService.remove(hotSpotWrapper);
if (!ret) { if (!ret) {
// 删除失败, 500 // 删除失败, 500
resultMap.put("status", 500); resultMap.put("status", 500);
...@@ -409,7 +401,7 @@ public class BankBranchInfoController extends BaseController { ...@@ -409,7 +401,7 @@ public class BankBranchInfoController extends BaseController {
public ResponseEntity<List<BankBranchInfo>> getBankBox(String action, String bankId, String roleId) { public ResponseEntity<List<BankBranchInfo>> getBankBox(String action, String bankId, String roleId) {
try { try {
QueryWrapper<BankBranchInfo> ew = new QueryWrapper<>(); QueryWrapper<BankBranchInfo> ew = new QueryWrapper<>();
ew.setSqlSelect("id", "name"); ew.select("id", "name");
ew.eq("is_deleted", 0); ew.eq("is_deleted", 0);
if (action != null && "create".equals(action) && bankId != null && !"".equals(bankId)) { if (action != null && "create".equals(action) && bankId != null && !"".equals(bankId)) {
ew.eq("status", 1); ew.eq("status", 1);
...@@ -437,9 +429,9 @@ public class BankBranchInfoController extends BaseController { ...@@ -437,9 +429,9 @@ public class BankBranchInfoController extends BaseController {
//呼叫记录,意见建议页面网点归属下拉框,如果不是操作员显示除了通用的其他网点 //呼叫记录,意见建议页面网点归属下拉框,如果不是操作员显示除了通用的其他网点
ew.ne("id", '0'); ew.ne("id", '0');
} }
ew.orderBy("sortorder", true); ew.orderByAsc("sortorder");
ew.orderBy("create_time", false); ew.orderByDesc("create_time");
return ResponseEntity.ok(this.bankBranchInfoService.selectList(ew)); return ResponseEntity.ok(this.bankBranchInfoService.list(ew));
} catch (Exception e) { } catch (Exception e) {
logger.error("查询角色列表出错!", e); logger.error("查询角色列表出错!", e);
} }
...@@ -485,9 +477,9 @@ public class BankBranchInfoController extends BaseController { ...@@ -485,9 +477,9 @@ public class BankBranchInfoController extends BaseController {
bankBranchInfo.setHeadImage(bankBranchInfo.getImageUrl()); bankBranchInfo.setHeadImage(bankBranchInfo.getImageUrl());
boolean ret = this.bankBranchInfoService.updateById(bankBranchInfo); boolean ret = this.bankBranchInfoService.updateById(bankBranchInfo);
Wrapper<HotSpot> hotSpotWrapper = new QueryWrapper<>(); QueryWrapper<HotSpot> hotSpotWrapper = new QueryWrapper<>();
hotSpotWrapper.eq("bank_branch_id", bankBranchInfo.getId()); hotSpotWrapper.eq("bank_branch_id", bankBranchInfo.getId());
ret = this.hotSpotService.delete(hotSpotWrapper); ret = this.hotSpotService.remove(hotSpotWrapper);
if (!ret) { if (!ret) {
resultMap.put("status", 500); resultMap.put("status", 500);
...@@ -718,9 +710,10 @@ public class BankBranchInfoController extends BaseController { ...@@ -718,9 +710,10 @@ public class BankBranchInfoController extends BaseController {
boolean ret = false; boolean ret = false;
if (oldList.size() > 0) { if (oldList.size() > 0) {
//先清空之前的排序 //先清空之前的排序
Wrapper<BankBranchInfo> ew = new QueryWrapper<>(); QueryWrapper<BankBranchInfo> ew = new QueryWrapper<>();
ew.ne("id", "0"); ew.ne("id", "0");
ret = this.bankBranchInfoService.updateForSet("sortorder = null ", ew); ew.isNull("sortorder");
ret = this.bankBranchInfoService.update(ew);
//重新排序 //重新排序
for (int i = 0; i < oldList.size(); i++) { for (int i = 0; i < oldList.size(); i++) {
...@@ -749,222 +742,5 @@ public class BankBranchInfoController extends BaseController { ...@@ -749,222 +742,5 @@ public class BankBranchInfoController extends BaseController {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
} }
/**
* 下载网点excel表模板
*
* @return
*/
@ApiOperation(value = "下载网点excel表模板", notes = "下载网点excel表模板")
@GetMapping(value = "/branchTemplateDownload")
public ResponseEntity<String> branchTemplateDownload() {
/*文件名*/
String fileName = "网点导入模板" + ".xls";
/*sheet名*/
String sheetName = "网点导入模板" + ".xls";
/*标题*/
String[] title = new String[]{"网点名称", "经度(0-180)", "纬度(0-90)", "网点地址", "联系电话"};
String[][] values = {};
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(sheetName, title, values, null);
//将文件存到指定位置
try {
//对文件名进行编码
fileName = ExcelUtil.encodeFileName(fileName, request);
ExcelUtil.setResponseHeader(response, fileName);
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();
os.close();
} catch (Exception e) {
logger.error("下载失败");
}
return ResponseEntity.ok("下载成功");
}
/**
* 网点导入
*
* @param excelFile
* @param creator 当前登录账号ID
* @return
*/
@RequestMapping(value = "/branchImport", method = RequestMethod.POST)
public ResponseEntity<Map> branchImport(@RequestParam(value = "excelFile") MultipartFile excelFile, String creator) {
Map<String, Object> map = new HashMap<>();
try {
boolean rel = false;
//导入的网点列表
List<BankBranchInfo> branchInfoList = new ArrayList<BankBranchInfo>();
//表格数据
List<String[]> branchInfos = ReadExcelUtil.readExcel(excelFile);
if (branchInfos.size() > 0) {
//查询当前数据库用户的最大顺序号
Integer sortOrder = 1;
Wrapper<BankBranchInfo> branchInfoWrapper = new QueryWrapper<>();
branchInfoWrapper.setSqlSelect("max(sortorder) as sortorder");
BankBranchInfo b = this.bankBranchInfoService.selectOne(branchInfoWrapper);
if (b != null) {
sortOrder = b.getSortorder() + 1;
}
//查询数据库已存在的网点名称
String names = "";
//判断与数据库存在返回消息
String messages = "";
//表格是否重复返回消息
String excelMessages = "";
branchInfoWrapper = new QueryWrapper<>();
branchInfoWrapper.eq("is_deleted", 0);
List<BankBranchInfo> bankBranchInfos = this.bankBranchInfoService.selectList(branchInfoWrapper);
if (bankBranchInfos.size() > 0) {
for (BankBranchInfo branchInfo : bankBranchInfos) {
names += "," + "_" + branchInfo.getName().trim() + "_";
}
}
//表格内网点名称
Map<String, Object> excelNames = new HashMap<>();
//表格内经度
Map<String, Object> excelLon = new HashMap<>();
//表格内纬度
Map<String, Object> excelLat = new HashMap<>();
//表格内地址
Map<String, Object> excelAddr = new HashMap<>();
for (int j = 0; j < branchInfos.size(); j++) {
String[] row = branchInfos.get(j);
Integer order = j + 2;
//记录网点名称在表格中是的数据
if (excelNames.get("_" + row[0].trim() + "_") != null) {
excelNames.put("_" + row[0].trim() + "_", excelNames.get("_" + row[0].trim() + "_").toString() + "," + order);
} else {
excelNames.put("_" + row[0].trim() + "_", order);
}
//记录经度在表格中是的数据
if (excelLon.get("_" + row[1].trim() + "_") != null) {
excelLon.put("_" + row[1].trim() + "_", excelLon.get("_" + row[1].trim() + "_").toString() + "," + order);
} else {
excelLon.put("_" + row[1].trim() + "_", order);
}
//记录纬度在表格中是的数据
if (excelLat.get("_" + row[2].trim() + "_") != null) {
excelLat.put("_" + row[2].trim() + "_", excelLat.get("_" + row[2].trim() + "_").toString() + "," + order);
} else {
excelLat.put("_" + row[2].trim() + "_", order);
}
//记录网点地址在表格中是的数据
if (excelAddr.get("_" + row[3].trim() + "_") != null) {
excelAddr.put("_" + row[3].trim() + "_", excelAddr.get("_" + row[3].trim() + "_").toString() + "," + order);
} else {
excelAddr.put("_" + row[3].trim() + "_", order);
}
}
for (int i = 0; i < branchInfos.size(); i++) {
String[] excel = branchInfos.get(i);
boolean flag = false;
//验证网点名称不能为空
if (excelNames.get("_" + excel[0].trim() + "_") != null
&& !excelMessages.contains("第" + excelNames.get("_" + excel[0].trim() + "_") + "行网点名称不能为空!")
&& "".equals(excel[0].trim())) {
excelMessages += "<br/>" + "第" + excelNames.get("_" + excel[0].trim() + "_") + "行网点名称不能为空!";
}
//验证经度不能为空
if (excelLon.get("_" + excel[1].trim() + "_") != null
&& !excelMessages.contains("第" + excelLon.get("_" + excel[1].trim() + "_") + "行经度不能为空!")
&& "".equals(excel[1].trim())) {
excelMessages += "<br/>" + "第" + excelLon.get("_" + excel[1].trim() + "_") + "行经度不能为空!";
}
//验证纬度不能为空
if (excelLat.get("_" + excel[2].trim() + "_") != null
&& !excelMessages.contains("第" + excelLat.get("_" + excel[2].trim() + "_") + "行纬度不能为空!")
&& "".equals(excel[2].trim())) {
excelMessages += "<br/>" + "第" + excelLat.get("_" + excel[2].trim() + "_") + "行纬度不能为空!";
}
//验证网点地址不能为空
if (excelAddr.get("_" + excel[3].trim() + "_") != null
&& !excelMessages.contains("第" + excelAddr.get("_" + excel[3].trim() + "_") + "行网点地址不能为空!")
&& "".equals(excel[3].trim())) {
excelMessages += "<br/>" + "第" + excelAddr.get("_" + excel[3].trim() + "_") + "行网点地址不能为空!";
}
//验证网点在表格中是否重复
if (excelNames.get("_" + excel[0].trim() + "_") != null
&& !excelMessages.contains("第" + excelNames.get("_" + excel[0].trim() + "_") + "行网点名称不能为空!")
&& !excelMessages.contains("网点名称:" + excel[0].trim())
&& excelNames.get("_" + excel[0].trim() + "_").toString().contains(",")) {
excelMessages += "<br/>" + "第" + excelNames.get("_" + excel[0].trim() + "_") + "行网点名称:" + excel[0].trim() + ",为表格内重复内容。";
}
String message = "第" + (i + 2) + "行:";
//验证网点是否存在
if (names.contains("_" + excel[0].trim() + "_")) {
message += "网点:" + excel[0].trim() + ",在管理端已存在。";
flag = true;
}
if (flag) {
messages += "<br/>" + message;
continue;
}
if ("".equals(messages) && "".equals(excelMessages)) {
BankBranchInfo branchInfo = new BankBranchInfo();
branchInfo.setCreator(creator);
branchInfo.setCreateTime(new Date(System.currentTimeMillis()));
branchInfo.setUpdateTime(branchInfo.getCreateTime());
branchInfo.setIsDeleted(0);
branchInfo.setStatus(1);
branchInfo.setName(excel[0].trim());
branchInfo.setLon(excel[1].trim());
branchInfo.setLat(excel[2].trim());
branchInfo.setAddress(excel[3].trim());
branchInfo.setPhoneNum(excel[4].trim());
branchInfo.setSortorder(sortOrder);
branchInfo.setIsShow(0);
//顺序号+1
sortOrder += 1;
//存放当前用户数据
branchInfoList.add(branchInfo);
}
}
if (!"".equals(messages) || !"".equals(excelMessages)) {
map.put("status", 405);
map.put("message", "网点导入失败!具体原因如下:" + excelMessages + messages);
return ResponseEntity.status(HttpStatus.METHOD_NOT_ALLOWED).body(map);
}
rel = this.bankBranchInfoService.insertBatch(branchInfoList);
if (!rel) {
map.put("status", 400);
map.put("message", "网点导入失败!");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(map);
}
map.put("status", 200);
map.put("message", "网点导入成功!");
return ResponseEntity.ok(map);
} else {
map.put("status", 400);
map.put("message", "请填入数据后再进行导入!");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(map);
}
} catch (Exception e) {
logger.error(e.toString());
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
} }
package cn.wisenergy.chnmuseum.party.web.controller;
import cn.wisenergy.chnmuseum.party.core.annotations.OperationLog;
import cn.wisenergy.chnmuseum.party.model.BusinessInfo;
import cn.wisenergy.chnmuseum.party.service.PublicService;
import cn.wisenergy.chnmuseum.party.service.impl.BusinessInfoServiceImpl;
import cn.wisenergy.chnmuseum.party.service.impl.EmployeeServiceImpl;
import com.baomidou.mybatisplus.mapper.QueryWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.*;
/**
* <p>
* 业务信息 前端控制器
* </p>
*
* @author 杨智平
* @since 2018-08-29
*/
@Api(tags = "业务办理指南")
@RestController
@RequestMapping("/businessInfo")
public class BusinessInfoController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(BusinessInfoController.class);
@Resource
private BusinessInfoServiceImpl businessInfoService;
@Resource
private EmployeeServiceImpl employeeService;
@Resource
private PublicService publicService;
/**
* 获取业务服务指南
*
* @param id
* @return
*/
@ApiOperation(value = "通过业务ID获取业务服务指南")
@GetMapping(value = "/getById")
@RequiresPermissions("/businessInfo/getById")
public ResponseEntity<BusinessInfo> getById(String id) {
try {
BusinessInfo one = this.businessInfoService.selectOneById(id);
String creatorName = this.employeeService.selectById(one.getCreator()).getName();
one.setCreateEmployee(creatorName);
if (one.getModifier() != null) {
String modifierName = this.employeeService.selectById(one.getModifier()).getName();
one.setModifyEmployee(modifierName);
}
if (null != one) {
return ResponseEntity.ok(one);
}
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
} catch (Exception e) {
logger.error("查询业务信息出错!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
/**
* 获取业务服务指南列表
*
* @param name
* @return
*/
@ApiOperation(value = "获取业务服务指南列表信息")
@GetMapping(value = "/getList")
@RequiresPermissions("/businessInfo/getList")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "name", value = "业务名称", required = false, dataType = "String"),
@ApiImplicitParam(name = "bankId", value = "所属网点Id", required = false, dataType = "String")})
public ResponseEntity<Page<BusinessInfo>> getList(String name, String bankId, String roleId,
String currentBankId, String userId) {
try {
if (!"3".equals(roleId)) {
roleId = "0";
}
name = StringUtils.trimToNull(name);
Page<BusinessInfo> page = this.getPage();
Page<BusinessInfo> bankBranchInfoPage = this.businessInfoService.selectListByName(page, name, bankId, roleId, currentBankId, userId);
return ResponseEntity.ok(bankBranchInfoPage);
} catch (Exception e) {
logger.error("查询业务信息列表出错!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
/**
* 保存或提交业务服务指南
*/
@OperationLog("保存或提交业务服务指南")
@ApiOperation("保存或提交业务服务指南")
@PostMapping(value = "/add")
@RequiresPermissions("/businessInfo/add")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "action", value = "1-保存2-提交", required = true)})
public ResponseEntity<Map<String, Object>> add(BusinessInfo businessInfo, Integer action, String currentBankId) {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
try {
boolean ret = false;
Wrapper<BusinessInfo> ew = new QueryWrapper<>();
if (StringUtils.isNoneBlank(businessInfo.getName())) {
ew.ne("status",5);
ew.eq("name", businessInfo.getName());
if (businessInfo.getBankBranchId() != null && !"0".equals(businessInfo.getBankBranchId())) {
ew.andNew();
ew.eq("bank_branch_id", "0");
ew.or();
ew.eq("bank_branch_id", currentBankId);
}
BusinessInfo one = this.businessInfoService.selectOne(ew);
if (one != null) {
resultMap.put("status", 400);
resultMap.put("message", "该业务名称已存在");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
} else {
businessInfo.setName(StringUtils.trimToNull(businessInfo.getName()));
}
}
if (StringUtils.isBlank(businessInfo.getBankBranchId())) {
resultMap.put("status", 400);
resultMap.put("message", "请选择所属网点");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
}
if (businessInfo.getSortorder() == null || "".equals(businessInfo.getSortorder())) {
ew = new QueryWrapper<>();
ew.setSqlSelect("max(sortorder) as sortorder");
BusinessInfo one = this.businessInfoService.selectOne(ew);
if (one != null) {
businessInfo.setSortorder(one.getSortorder() + 1);
} else {
businessInfo.setSortorder(1);
}
}
if (action.equals(1)) {
//保存是到编辑中
businessInfo.setStatus(0);
} else if (action.equals(2)) {
//提交是到上线审核
businessInfo.setStatus(2);
}
businessInfo.setCreator(this.getUserId());
businessInfo.setSkipLink(StringUtils.trimToNull(businessInfo.getSkipLink()));
businessInfo.setCreateTime(new Date(System.currentTimeMillis()));
businessInfo.setUpdateTime(businessInfo.getCreateTime());
ret = this.businessInfoService.insert(businessInfo);
if (!ret) {
resultMap.put("status", 400);
resultMap.put("message", "添加失败");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
}
// 201
resultMap.put("status", 201);
resultMap.put("message", "添加成功");
return ResponseEntity.status(HttpStatus.CREATED).body(resultMap);
} catch (Exception e) {
logger.error("添加错误!", e);
}
resultMap.put("status", 500);
resultMap.put("message", "操作失败");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
}
@OperationLog("修改业务服务指南")
@ApiOperation(value = "修改业务服务指南")
@PutMapping(value = "/edit")
@RequiresPermissions("/businessInfo/edit")
public ResponseEntity<Map<String, Object>> edit(BusinessInfo businessInfo, Integer action, String currentBankId) {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
try {
Wrapper<BusinessInfo> ew = new QueryWrapper<>();
if (StringUtils.isNoneBlank(businessInfo.getName())) {
ew.ne("id", businessInfo.getId());
ew.ne("status",5);
ew.eq("name", businessInfo.getName().trim());
if (businessInfo.getBankBranchId() != null && !"0".equals(businessInfo.getBankBranchId())) {
ew.andNew();
ew.eq("bank_branch_id", "0");
ew.or();
ew.eq("bank_branch_id", currentBankId);
}
businessInfo.setName(businessInfo.getName().trim());
}
BusinessInfo one = this.businessInfoService.selectOne(ew);
if (one != null) {
resultMap.put("status", 400);
resultMap.put("message", "该业务已存在");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
}
if (action != null) {
if (action.equals(1)) {
//保存是到编辑中
businessInfo.setStatus(0);
} else if (action.equals(2)) {
//提交是到上线审核
businessInfo.setStatus(2);
}
}
businessInfo.setModifier(this.getUserId());
businessInfo.setUpdateTime(new Date(System.currentTimeMillis()));
boolean ret = this.businessInfoService.updateById(businessInfo);
if (!ret) {
resultMap.put("status", 500);
resultMap.put("message", "修改失败");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
} else {
resultMap.put("status", 201);
resultMap.put("message", "修改成功");
return ResponseEntity.ok(resultMap);
}
} catch (Exception e) {
logger.error("修改错误!", e);
}
resultMap.put("status", 500);
resultMap.put("message", "修改失败");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
}
/**
* 刪除
*
* @param id
* @return
*/
@OperationLog("刪除业务服务指南")
@ApiOperation(value = "刪除业务服务指南")
@DeleteMapping(value = "/delete")
@RequiresPermissions("/businessInfo/delete")
public ResponseEntity<Map<String, Object>> delete(@RequestParam(value = "id", required = true) String id) {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
try {
Boolean ret = this.businessInfoService.deleteById(id);
if (!ret) {
// 删除失败, 500
resultMap.put("status", 500);
resultMap.put("message", "服务器错误!");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
}
// 201
resultMap.put("status", 201);
resultMap.put("message", "删除成功!");
return ResponseEntity.status(HttpStatus.CREATED).body(resultMap);
} catch (Exception e) {
logger.error("服务器错误!", e);
}
// 500
resultMap.put("status", 500);
resultMap.put("message", "服务器错误!");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
}
/**
* 申请上线
*
* @param id
* @return
*/
@OperationLog("申请上线单个业务服务指南")
@ApiOperation(value = "上线审核单个业务服务指南")
@PutMapping(value = "/enable")
@RequiresPermissions("/businessInfo/enable")
public ResponseEntity<Map<String, Object>> enable(String id) {
try {
Map<String, Object> map = new HashMap<>();
BusinessInfo entity = new BusinessInfo();
entity.setId(id);
entity.setStatus(2);
entity.setModifier(this.getUserId());
entity.setUpdateTime(new Date(System.currentTimeMillis()));
boolean ret = this.businessInfoService.updateById(entity);
if (!ret) {
map.put("status", "500");
map.put("message", "服务器错误");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(map);
}
map.put("status", "201");
map.put("message", "上线成功");
return ResponseEntity.status(HttpStatus.CREATED).body(map);
} catch (Exception e) {
logger.error("上线出错!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(
null);
}
/**
* 申请下线
*
* @param id
* @return
*/
@OperationLog("申请下线单个业务服务指南")
@ApiOperation(value = "下线审核单个业务服务指南")
@PutMapping(value = "/disable")
@RequiresPermissions("/businessInfo/disable")
public ResponseEntity<Map<String, Object>> disable(String id) {
try {
Map<String, Object> map = new HashMap<>();
BusinessInfo entity = new BusinessInfo();
entity.setId(id);
entity.setStatus(3);
entity.setModifier(this.getUserId());
entity.setUpdateTime(new Date(System.currentTimeMillis()));
boolean ret = this.businessInfoService.updateById(entity);
if (!ret) {
map.put("status", "400");
map.put("message", "下线错误");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(map);
}
map.put("status", "201");
map.put("message", "下线成功");
return ResponseEntity.status(HttpStatus.CREATED).body(map);
} catch (Exception e) {
logger.error("下线出错!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(
null);
}
/**
* APP端查看业务服务指南列表
*
* @return
*/
@ApiOperation(value = "APP端查看业务服务指南列表")
@GetMapping(value = "/getAppBusinessList")
public ResponseEntity<Page<BusinessInfo>> getAppBusinessList(String bankId, String roleId) {
try {
Page<BusinessInfo> page = this.getPage();
Wrapper<BusinessInfo> ew = new QueryWrapper();
ew.setSqlSelect("id", "name", "icon");
if (roleId != null) {
if (bankId != null && "3".equals(roleId)) {
ew.eq("bank_branch_id", bankId);
} else if ("1".equals(roleId)) {
ew.eq("bank_branch_id", "0");
}
} else {
ew.eq("bank_branch_id", '0');
ew.or();
ew.eq("bank_branch_id", bankId);
ew.orderBy("bank_branch_id", false);
}
ew.andNew("status = 3 OR status = 4 OR status = 6");
ew.orderBy("sortorder", true);
ew.orderBy("update_time", false);
Page<BusinessInfo> businessInfoPage = this.businessInfoService.selectPage(page, ew);
return ResponseEntity.ok(businessInfoPage);
} catch (Exception e) {
logger.error("查询业务指南列表出错!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
/**
* APP端查看单个业务服务指南
*
* @param id
* @return
*/
@ApiOperation(value = "APP端查看单个业务服务指南")
@GetMapping(value = "/getAppBusinessInfoById")
public ResponseEntity<BusinessInfo> getAppBusinessInfoById(String id, String userId, String bankId) {
try {
Wrapper<BusinessInfo> ew = new QueryWrapper();
ew.setSqlSelect("name, PROCESS,guide,is_skip AS isSkip,skip_link AS skipLink");
ew.eq("id", id);
BusinessInfo one = this.businessInfoService.selectOne(ew);
if (null != one) {
//将数据放入缓存
this.publicService.cacheData(id, userId, bankId, 1);
return ResponseEntity.ok(one);
}
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
} catch (Exception e) {
logger.error("查询业务指南出错!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
/**
* 业务指南审核通过
*
* @param id
* @return
*/
@OperationLog("业务服务指南审核通过")
@ApiOperation(value = "业务服务指南审核通过")
@PutMapping(value = "/approved")
@RequiresPermissions("/businessInfo/approved")
public ResponseEntity<Map<String, Object>> approved(String id, Integer status) {
try {
Map<String, Object> map = new HashMap<>();
boolean ret = false;
if (StringUtils.isNotBlank(id)) {
BusinessInfo entity = new BusinessInfo();
entity.setId(id);
if (status != null) {
if (status == 2) {
entity.setStatus(4);
} else if (status == 3) {
entity.setStatus(5);
}
}
entity.setReviewer(this.getUserId());
entity.setUpdateTime(new Date(System.currentTimeMillis()));
ret = this.businessInfoService.updateById(entity);
} else {
map.put("status", "400");
map.put("message", "请选择需要审核的业务");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(map);
}
if (!ret) {
map.put("status", "400");
map.put("message", "审核通过失败");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(map);
} else {
map.put("status", "201");
map.put("message", "审核通过成功");
return ResponseEntity.status(HttpStatus.CREATED).body(map);
}
} catch (Exception e) {
logger.error("审核通过失败!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
/**
* 业务指南审核驳回
*
* @param id
* @param rejectReason 驳回原因
* @return
*/
@OperationLog("业务服务指南审核驳回")
@ApiOperation(value = "业务服务指南审核驳回")
@PutMapping(value = "/reject")
@RequiresPermissions("/businessInfo/reject")
public ResponseEntity<Map<String, Object>> reject(String id, String rejectReason, Integer status) {
try {
Map<String, Object> map = new HashMap<>();
if (rejectReason == null || "".equals(rejectReason.trim())) {
map.put("status", "400");
map.put("message", "请输入驳回原因!");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(map);
}
boolean ret = false;
if (StringUtils.isNotBlank(id)) {
BusinessInfo entity = new BusinessInfo();
entity.setId(id);
if (status != null) {
if (status == 2) {
entity.setStatus(1);
} else if (status == 3) {
entity.setStatus(6);
}
}
entity.setRejectReason(rejectReason);
entity.setReviewer(this.getUserId());
entity.setUpdateTime(new Date(System.currentTimeMillis()));
ret = this.businessInfoService.updateById(entity);
} else {
map.put("status", "400");
map.put("message", "请选择需要审核的业务");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(map);
}
if (!ret) {
map.put("status", "400");
map.put("message", "审核驳回失败");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(map);
} else {
map.put("status", "201");
map.put("message", "审核驳回成功");
return ResponseEntity.status(HttpStatus.CREATED).body(map);
}
} catch (Exception e) {
logger.error("审核驳回失败!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
/**
* 业务指南排序(供APP端展示内容使用)
*
* @param businessInfo
* @return
*/
@OperationLog("业务指南排序")
@ApiOperation(value = "业务指南排序")
@PutMapping(value = "/sort")
@RequiresPermissions("/businessInfo/sort")
public ResponseEntity<Map<String, Object>> sort(@RequestBody BusinessInfo businessInfo) {
try {
Map<String, Object> map = new HashMap<>();
// 对顺序号赋值封装
List<BusinessInfo> newList = new ArrayList<BusinessInfo>();
boolean ret = false;
if (businessInfo != null && businessInfo.getOldList().size() > 0) {
List<BusinessInfo> oldList = businessInfo.getOldList();
//先清空之前的排序
String bankBranchId = businessInfo.getBankBranchId();
Wrapper<BusinessInfo> ew = new QueryWrapper<>();
ew.eq("bank_branch_id", bankBranchId);
ret = this.businessInfoService.updateForSet("sortorder = null ", ew);
//重新排序
for (int i = 0; i < oldList.size(); i++) {
BusinessInfo entity = oldList.get(i);
entity.setSortorder(i + 1);
newList.add(entity);
}
ret = this.businessInfoService.updateBatchById(newList);
} else {
map.put("status", "400");
map.put("message", "请选择需要排序的业务");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(map);
}
if (!ret) {
map.put("status", "400");
map.put("message", "排序失败");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(map);
} else {
map.put("status", "201");
map.put("message", "排序成功");
return ResponseEntity.status(HttpStatus.CREATED).body(map);
}
} catch (Exception e) {
logger.error("排序失败!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}
package cn.wisenergy.chnmuseum.party.web.controller; package cn.wisenergy.chnmuseum.party.web.controller;
import cn.wisenergy.chnmuseum.party.common.util.ExcelUtil;
import cn.wisenergy.chnmuseum.party.model.DemandInfo; import cn.wisenergy.chnmuseum.party.model.DemandInfo;
import cn.wisenergy.chnmuseum.party.model.Employee; import cn.wisenergy.chnmuseum.party.model.Employee;
import cn.wisenergy.chnmuseum.party.service.PublicService; import cn.wisenergy.chnmuseum.party.service.PublicService;
import cn.wisenergy.chnmuseum.party.service.impl.DemandInfoServiceImpl; import cn.wisenergy.chnmuseum.party.service.impl.DemandInfoServiceImpl;
import cn.wisenergy.chnmuseum.party.service.impl.EmployeeServiceImpl; import cn.wisenergy.chnmuseum.party.service.impl.EmployeeServiceImpl;
import com.baomidou.mybatisplus.mapper.QueryWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController; import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vdurmont.emoji.EmojiParser; import com.vdurmont.emoji.EmojiParser;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -27,9 +24,6 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -27,9 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.OutputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
...@@ -180,7 +174,7 @@ public class DemandInfoController extends BaseController { ...@@ -180,7 +174,7 @@ public class DemandInfoController extends BaseController {
demandInfo.setContent(EmojiParser.parseToHtmlHexadecimal(demandInfo.getContent().trim())); demandInfo.setContent(EmojiParser.parseToHtmlHexadecimal(demandInfo.getContent().trim()));
demandInfo.setPhoneNumber(StringUtils.trimToNull(demandInfo.getPhoneNumber())); demandInfo.setPhoneNumber(StringUtils.trimToNull(demandInfo.getPhoneNumber()));
demandInfo.setCreateTime(new Date(System.currentTimeMillis())); demandInfo.setCreateTime(new Date(System.currentTimeMillis()));
ret = this.demandInfoService.insert(demandInfo); ret = this.demandInfoService.save(demandInfo);
if (!ret) { if (!ret) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "提交失败"); resultMap.put("message", "提交失败");
...@@ -229,7 +223,7 @@ public class DemandInfoController extends BaseController { ...@@ -229,7 +223,7 @@ public class DemandInfoController extends BaseController {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
} }
//验证反馈人是否存在 //验证反馈人是否存在
Employee employee = employeeService.selectById(personId); Employee employee = employeeService.getById(personId);
if (employee == null) { if (employee == null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "反馈链接有误"); resultMap.put("message", "反馈链接有误");
...@@ -243,7 +237,7 @@ public class DemandInfoController extends BaseController { ...@@ -243,7 +237,7 @@ public class DemandInfoController extends BaseController {
feedbackInfo = StringUtils.trimToNull(feedbackInfo); // 清除掉str首尾的空白字符,如果仅str全由空白字符组成则返回null feedbackInfo = StringUtils.trimToNull(feedbackInfo); // 清除掉str首尾的空白字符,如果仅str全由空白字符组成则返回null
} }
DemandInfo entity = this.demandInfoService.selectById(id); DemandInfo entity = this.demandInfoService.getById(id);
if (entity.getFeedbackInfo() != null) { if (entity.getFeedbackInfo() != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "您已反馈,请勿重复提交!"); resultMap.put("message", "您已反馈,请勿重复提交!");
...@@ -287,12 +281,12 @@ public class DemandInfoController extends BaseController { ...@@ -287,12 +281,12 @@ public class DemandInfoController extends BaseController {
public ResponseEntity<List<DemandInfo>> getListOnApp(Integer type, String advisorId, String bankBranchId) { public ResponseEntity<List<DemandInfo>> getListOnApp(Integer type, String advisorId, String bankBranchId) {
try { try {
Wrapper<DemandInfo> demandInfoWrapper = new QueryWrapper<>(); QueryWrapper<DemandInfo> demandInfoWrapper = new QueryWrapper<>();
demandInfoWrapper.eq("type", type) demandInfoWrapper.eq("type", type)
.eq("advisor_id", advisorId) .eq("advisor_id", advisorId)
.eq("bank_branch_id", bankBranchId) .eq("bank_branch_id", bankBranchId)
.orderBy("create_time", false); .orderByDesc("create_time");
List<DemandInfo> demandInfoList = this.demandInfoService.selectList(demandInfoWrapper); List<DemandInfo> demandInfoList = this.demandInfoService.list(demandInfoWrapper);
for (DemandInfo demandInfo : demandInfoList) { for (DemandInfo demandInfo : demandInfoList) {
demandInfo.setContent(EmojiParser.parseToUnicode(demandInfo.getContent())); demandInfo.setContent(EmojiParser.parseToUnicode(demandInfo.getContent()));
if (StringUtils.isNotBlank(demandInfo.getFeedbackInfo())) { if (StringUtils.isNotBlank(demandInfo.getFeedbackInfo())) {
...@@ -316,10 +310,10 @@ public class DemandInfoController extends BaseController { ...@@ -316,10 +310,10 @@ public class DemandInfoController extends BaseController {
@GetMapping(value = "/getByIdForApp") @GetMapping(value = "/getByIdForApp")
public ResponseEntity<DemandInfo> getByIdForApp(String id) { public ResponseEntity<DemandInfo> getByIdForApp(String id) {
try { try {
Wrapper<DemandInfo> ew = new QueryWrapper<>(); QueryWrapper<DemandInfo> ew = new QueryWrapper<>();
ew.setSqlSelect("id,line_number AS lineNumber,create_time AS createTime,phone_number AS phoneNumber,content,feedback_info AS feedbackInfo"); ew.select("id,line_number AS lineNumber,create_time AS createTime,phone_number AS phoneNumber,content,feedback_info AS feedbackInfo");
ew.eq("id", id); ew.eq("id", id);
DemandInfo one = this.demandInfoService.selectOne(ew); DemandInfo one = this.demandInfoService.getOne(ew);
if (null != one) { if (null != one) {
return ResponseEntity.ok(one); return ResponseEntity.ok(one);
} }
...@@ -331,119 +325,6 @@ public class DemandInfoController extends BaseController { ...@@ -331,119 +325,6 @@ public class DemandInfoController extends BaseController {
} }
/**
* 呼叫服务或者吐槽建议列表下载(excel)
*
* @param lineNumber
* @param content
* @param phoneNumber
* @param type
* @param time
* @return
*/
@ApiOperation(value = "呼叫服务或者吐槽建议列表下载(excel)")
@GetMapping(value = "/demandInfoDownload")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "lineNumber", value = "叫号单号", required = false),
@ApiImplicitParam(name = "content", value = "需求内容", required = false, dataType = "String"),
@ApiImplicitParam(name = "phoneNumber", value = "手机号码", required = false, dataType = "String"),
@ApiImplicitParam(name = "type", value = "消息类型:1-吐槽建议2-呼叫记录", required = true),
@ApiImplicitParam(name = "time", value = "反馈日期", required = false, dataType = "String"),
@ApiImplicitParam(name = "callTime", value = "呼叫日期", required = false, dataType = "String"),
@ApiImplicitParam(name = "bankBranchId", value = "归属网点ID", required = false, dataType = "String")})
public ResponseEntity<String> demandInfoDownload(String lineNumber, String content, String phoneNumber,
Integer type, String time, String callTime, String bankBranchId,
String roleId, String currentBankId) {
try {
if (!"3".equals(roleId)) {
roleId = "0";
}
/*文件名*/
String fileName = "呼叫记录" + ".xls";
/*sheet名*/
String sheetName = "呼叫记录";
/*标题*/
String[] title = new String[]{"呼叫编号", "呼叫内容", "呼叫日期", "手机号码", "归属网点"};
if (type == 1) {
fileName = "意见建议及反馈" + ".xls";
sheetName = "意见建议及反馈";
title = new String[]{"呼叫编号", "手机号码", "吐槽日期", "归属网点", "吐槽建议", "反馈人", "反馈时间", "反馈内容"};
}
String startDate = null;
String endDate = null;
String callStartDate = null;
String callEndDate = null;
if (StringUtils.isNoneBlank(time)) {
startDate = time + " 00:00:00";
endDate = time + " 23:59:59";
}
if (StringUtils.isNoneBlank(callTime)) {
callStartDate = callTime + " 00:00:00";
callEndDate = callTime + " 23:59:59";
}
lineNumber = StringUtils.trimToNull(lineNumber);
content = StringUtils.trimToNull(content);
phoneNumber = StringUtils.trimToNull(phoneNumber);
List<DemandInfo> demandInfoList = this.demandInfoService.selectDemandInfoList(lineNumber, content, phoneNumber,
startDate, endDate, type, bankBranchId, callStartDate, callEndDate, roleId, currentBankId);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String[][] values = new String[demandInfoList.size()][];
DecimalFormat df = new DecimalFormat("#.##");
for (int i = 0; i < demandInfoList.size(); i++) {
if (type == 1) {
values[i] = new String[title.length];
//将对象内容转换成string
DemandInfo obj = demandInfoList.get(i);
values[i][0] = obj.getLineNumber(); // 呼叫编号
values[i][1] = obj.getPhoneNumber(); // 手机号码
values[i][2] = sdf.format(obj.getCreateTime()); // 呼叫日期
values[i][3] = obj.getBankBranchName(); // 归属网点
values[i][4] = EmojiParser.parseToUnicode(obj.getContent()); // 吐槽建议
values[i][5] = obj.getFeedbackPersonName(); // 反馈人
if (obj.getFeedbackTime() == null) {
values[i][6] = null;
} else {
values[i][6] = sdf.format(obj.getFeedbackTime()); // 反馈时间
}
if (StringUtils.isNotBlank(obj.getFeedbackInfo())) {
values[i][7] = EmojiParser.parseToUnicode(obj.getFeedbackInfo()); // 反馈内容
} else {
values[i][7] = obj.getFeedbackInfo(); // 反馈内容
}
} else if (type == 2) {
values[i] = new String[title.length];
//将对象内容转换成string
DemandInfo obj = demandInfoList.get(i);
values[i][0] = obj.getLineNumber(); // 呼叫编号
values[i][1] = EmojiParser.parseToUnicode(obj.getContent()); // 呼叫内容
values[i][2] = sdf.format(obj.getCreateTime()); // 呼叫日期
values[i][3] = obj.getPhoneNumber(); // 手机号码
values[i][4] = obj.getBankBranchName(); // 归属网点
}
}
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(sheetName, title, values, null);
//将文件存到指定位置
try {
//对文件名进行编码
fileName = ExcelUtil.encodeFileName(fileName, request);
ExcelUtil.setResponseHeader(response, fileName);
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();
os.close();
} catch (Exception e) {
logger.error("下载失败");
}
return ResponseEntity.ok("下载成功");
} catch (Exception e) {
logger.error("服务器错误!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
} }
...@@ -14,8 +14,6 @@ import cn.wisenergy.chnmuseum.party.service.impl.EmployeeServiceImpl; ...@@ -14,8 +14,6 @@ import cn.wisenergy.chnmuseum.party.service.impl.EmployeeServiceImpl;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController; import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.mapper.QueryWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -78,7 +76,7 @@ public class EmployeeController extends BaseController { ...@@ -78,7 +76,7 @@ public class EmployeeController extends BaseController {
public ResponseEntity<Employee> getById(String Id) { public ResponseEntity<Employee> getById(String Id) {
try { try {
Employee employee = employeeService.selectByEmpId(Id); Employee employee = employeeService.selectByEmpId(Id);
BankBranchInfo bankBranch = this.bankBranchInfoService.selectById(employee.getBankBranchId()); BankBranchInfo bankBranch = this.bankBranchInfoService.getById(employee.getBankBranchId());
if (bankBranch != null) { if (bankBranch != null) {
employee.setBankBranchName(bankBranch.getName()); employee.setBankBranchName(bankBranch.getName());
} }
...@@ -160,12 +158,12 @@ public class EmployeeController extends BaseController { ...@@ -160,12 +158,12 @@ public class EmployeeController extends BaseController {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
} }
Wrapper<Employee> ew = new QueryWrapper<>(); QueryWrapper<Employee> ew = new QueryWrapper<>();
if (StringUtils.isNoneBlank(employee.getUsername())) { if (StringUtils.isNoneBlank(employee.getUsername())) {
employee.setUsername(employee.getUsername().trim()); employee.setUsername(employee.getUsername().trim());
ew.eq("is_deleted", 0); ew.eq("is_deleted", 0);
ew.eq("username", employee.getUsername()); ew.eq("username", employee.getUsername());
Employee one = this.employeeService.selectOne(ew); Employee one = this.employeeService.getOne(ew);
if (one != null) { if (one != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "账号已存在!"); resultMap.put("message", "账号已存在!");
...@@ -177,7 +175,7 @@ public class EmployeeController extends BaseController { ...@@ -177,7 +175,7 @@ public class EmployeeController extends BaseController {
ew = new QueryWrapper<>(); ew = new QueryWrapper<>();
ew.eq("is_deleted", 0); ew.eq("is_deleted", 0);
ew.eq("code", employee.getCode()); ew.eq("code", employee.getCode());
Employee one = this.employeeService.selectOne(ew); Employee one = this.employeeService.getOne(ew);
if (one != null) { if (one != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "该员工号已存在!"); resultMap.put("message", "该员工号已存在!");
...@@ -197,8 +195,8 @@ public class EmployeeController extends BaseController { ...@@ -197,8 +195,8 @@ public class EmployeeController extends BaseController {
boolean ret = false; boolean ret = false;
if (employee.getSortorder() == null) { if (employee.getSortorder() == null) {
ew = new QueryWrapper<>(); ew = new QueryWrapper<>();
ew.setSqlSelect("max(sortorder) as sortorder"); ew.select("max(sortorder) as sortorder");
Employee e = this.employeeService.selectOne(ew); Employee e = this.employeeService.getOne(ew);
if (e == null) { if (e == null) {
employee.setSortorder(1); employee.setSortorder(1);
} else { } else {
...@@ -273,9 +271,9 @@ public class EmployeeController extends BaseController { ...@@ -273,9 +271,9 @@ public class EmployeeController extends BaseController {
employee.setUpdateTime(new Date(System.currentTimeMillis())); employee.setUpdateTime(new Date(System.currentTimeMillis()));
ret = employeeService.updateById(employee); ret = employeeService.updateById(employee);
//查询当前用户拥有的角色 //查询当前用户拥有的角色
Wrapper<EmployeeRole> employeeRoleWrapper = new QueryWrapper<>(); QueryWrapper<EmployeeRole> employeeRoleWrapper = new QueryWrapper<>();
employeeRoleWrapper.eq("employee_id", employee.getId()); employeeRoleWrapper.eq("employee_id", employee.getId());
EmployeeRole employeeRole = this.employeeRoleService.selectOne(employeeRoleWrapper); EmployeeRole employeeRole = this.employeeRoleService.getOne(employeeRoleWrapper);
if (employeeRole != null && employee.getRoleId() != null if (employeeRole != null && employee.getRoleId() != null
&& employee.getRoleId() != employeeRole.getRoleId()) { && employee.getRoleId() != employeeRole.getRoleId()) {
......
...@@ -6,8 +6,7 @@ import cn.wisenergy.chnmuseum.party.model.RoleMenu; ...@@ -6,8 +6,7 @@ import cn.wisenergy.chnmuseum.party.model.RoleMenu;
import cn.wisenergy.chnmuseum.party.service.impl.MenuServiceImpl; import cn.wisenergy.chnmuseum.party.service.impl.MenuServiceImpl;
import cn.wisenergy.chnmuseum.party.service.impl.RoleMenuServiceImpl; import cn.wisenergy.chnmuseum.party.service.impl.RoleMenuServiceImpl;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController; import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.mapper.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -54,7 +53,7 @@ public class MenuController extends BaseController { ...@@ -54,7 +53,7 @@ public class MenuController extends BaseController {
@RequiresPermissions("/menu/get") @RequiresPermissions("/menu/get")
public ResponseEntity<Menu> get(String Id) { public ResponseEntity<Menu> get(String Id) {
try { try {
Menu menu = menuService.selectById(Id); Menu menu = menuService.getById(Id);
if (null == menu) { if (null == menu) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
} }
...@@ -76,13 +75,13 @@ public class MenuController extends BaseController { ...@@ -76,13 +75,13 @@ public class MenuController extends BaseController {
@RequiresPermissions("/menu/getMenuList") @RequiresPermissions("/menu/getMenuList")
public ResponseEntity<Page<Menu>> queryUserList(String name, String url) { public ResponseEntity<Page<Menu>> queryUserList(String name, String url) {
try { try {
Wrapper<Menu> ew = new QueryWrapper<>(); QueryWrapper<Menu> ew = new QueryWrapper<>();
ew.like("menu_name", name) ew.like("menu_name", name)
.like("menu_url", url) .like("menu_url", url)
.eq("is_deleted", 0) .eq("is_deleted", 0)
.orderBy("sort",true); .orderByAsc("sort");
Page<Menu> page = getPage(); Page<Menu> page = getPage();
Page<Menu> employeePage = menuService.selectPage(page, ew); Page<Menu> employeePage = menuService.page(page, ew);
return ResponseEntity.ok(employeePage); return ResponseEntity.ok(employeePage);
} catch (Exception e) { } catch (Exception e) {
logger.error("查询成员列表出错!", e); logger.error("查询成员列表出错!", e);
...@@ -111,16 +110,16 @@ public class MenuController extends BaseController { ...@@ -111,16 +110,16 @@ public class MenuController extends BaseController {
} }
if (!menu.getParentId().equals("0")) { if (!menu.getParentId().equals("0")) {
Menu parent = this.menuService.selectById(menu.getParentId()); Menu parent = this.menuService.getById(menu.getParentId());
String parentName = parent.getMenuName().trim(); String parentName = parent.getMenuName().trim();
menu.setMenuName(parentName + "-" + menu.getMenuName().trim()); menu.setMenuName(parentName + "-" + menu.getMenuName().trim());
} }
Wrapper<Menu> ew = new QueryWrapper<>(); QueryWrapper<Menu> ew = new QueryWrapper<>();
if (StringUtils.isNoneBlank(menu.getMenuName())) { if (StringUtils.isNoneBlank(menu.getMenuName())) {
menu.setMenuName(menu.getMenuName().trim()); menu.setMenuName(menu.getMenuName().trim());
ew.eq("menu_name", menu.getMenuName()); ew.eq("menu_name", menu.getMenuName());
Menu one = this.menuService.selectOne(ew); Menu one = this.menuService.getOne(ew);
if (one != null) { if (one != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "菜单名称已存在!"); resultMap.put("message", "菜单名称已存在!");
...@@ -131,7 +130,7 @@ public class MenuController extends BaseController { ...@@ -131,7 +130,7 @@ public class MenuController extends BaseController {
if (StringUtils.isNoneBlank(menu.getMenuUrl())) { if (StringUtils.isNoneBlank(menu.getMenuUrl())) {
ew = new QueryWrapper<>(); ew = new QueryWrapper<>();
ew.eq("menu_url", menu.getMenuUrl()); ew.eq("menu_url", menu.getMenuUrl());
Menu one = this.menuService.selectOne(ew); Menu one = this.menuService.getOne(ew);
if (one != null) { if (one != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "Url已存在!"); resultMap.put("message", "Url已存在!");
...@@ -142,8 +141,8 @@ public class MenuController extends BaseController { ...@@ -142,8 +141,8 @@ public class MenuController extends BaseController {
if (menu.getSort() != null) { if (menu.getSort() != null) {
ew = new QueryWrapper<>(); ew = new QueryWrapper<>();
ew.eq("sort", menu.getSort()); ew.eq("sort", menu.getSort());
ew.eq("is_deleted",0); ew.eq("is_deleted", 0);
Menu one = this.menuService.selectOne(ew); Menu one = this.menuService.getOne(ew);
if (one != null) { if (one != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "顺序号已存在!"); resultMap.put("message", "顺序号已存在!");
...@@ -154,7 +153,7 @@ public class MenuController extends BaseController { ...@@ -154,7 +153,7 @@ public class MenuController extends BaseController {
menu.setCreateTime(new Date(System.currentTimeMillis())); menu.setCreateTime(new Date(System.currentTimeMillis()));
menu.setUpdateTime(menu.getCreateTime()); menu.setUpdateTime(menu.getCreateTime());
ret = this.menuService.insert(menu); ret = this.menuService.save(menu);
if (!ret) { if (!ret) {
// 更新失败, 400 // 更新失败, 400
resultMap.put("status", 400); resultMap.put("status", 400);
...@@ -183,16 +182,16 @@ public class MenuController extends BaseController { ...@@ -183,16 +182,16 @@ public class MenuController extends BaseController {
boolean ret = false; boolean ret = false;
if (menu.getId() != null) { if (menu.getId() != null) {
if (!menu.getParentId().equals("0")) { if (!menu.getParentId().equals("0")) {
Menu parent = this.menuService.selectById(menu.getParentId()); Menu parent = this.menuService.getById(menu.getParentId());
String parentName = parent.getMenuName(); String parentName = parent.getMenuName();
menu.setMenuName(parentName + "-" + menu.getMenuName().trim()); menu.setMenuName(parentName + "-" + menu.getMenuName().trim());
} }
Wrapper<Menu> ew = new QueryWrapper<>(); QueryWrapper<Menu> ew = new QueryWrapper<>();
if (StringUtils.isNoneBlank(menu.getMenuName())) { if (StringUtils.isNoneBlank(menu.getMenuName())) {
menu.setMenuName(menu.getMenuName().trim()); menu.setMenuName(menu.getMenuName().trim());
ew.ne("id",menu.getId()); ew.ne("id", menu.getId());
ew.eq("menu_name", menu.getMenuName()); ew.eq("menu_name", menu.getMenuName());
Menu one = this.menuService.selectOne(ew); Menu one = this.menuService.getOne(ew);
if (one != null) { if (one != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "菜单名称已存在!"); resultMap.put("message", "菜单名称已存在!");
...@@ -202,9 +201,9 @@ public class MenuController extends BaseController { ...@@ -202,9 +201,9 @@ public class MenuController extends BaseController {
} }
if (StringUtils.isNoneBlank(menu.getMenuUrl())) { if (StringUtils.isNoneBlank(menu.getMenuUrl())) {
ew = new QueryWrapper<>(); ew = new QueryWrapper<>();
ew.ne("id",menu.getId()); ew.ne("id", menu.getId());
ew.eq("menu_url", menu.getMenuUrl()); ew.eq("menu_url", menu.getMenuUrl());
Menu one = this.menuService.selectOne(ew); Menu one = this.menuService.getOne(ew);
if (one != null) { if (one != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "Url已存在!"); resultMap.put("message", "Url已存在!");
...@@ -214,10 +213,10 @@ public class MenuController extends BaseController { ...@@ -214,10 +213,10 @@ public class MenuController extends BaseController {
} }
if (menu.getSort() != null) { if (menu.getSort() != null) {
ew = new QueryWrapper<>(); ew = new QueryWrapper<>();
ew.ne("id",menu.getId()); ew.ne("id", menu.getId());
ew.eq("sort", menu.getSort()); ew.eq("sort", menu.getSort());
ew.eq("is_deleted",0); ew.eq("is_deleted", 0);
Menu one = this.menuService.selectOne(ew); Menu one = this.menuService.getOne(ew);
if (one != null) { if (one != null) {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "顺序号已存在!"); resultMap.put("message", "顺序号已存在!");
...@@ -260,14 +259,14 @@ public class MenuController extends BaseController { ...@@ -260,14 +259,14 @@ public class MenuController extends BaseController {
roleMenu.setMenuId(menuId); roleMenu.setMenuId(menuId);
QueryWrapper<RoleMenu> ew = new QueryWrapper<RoleMenu>(); QueryWrapper<RoleMenu> ew = new QueryWrapper<RoleMenu>();
ew.setEntity(roleMenu); ew.setEntity(roleMenu);
List<RoleMenu> roleRightList = this.roleMenuService.selectList(ew); List<RoleMenu> roleRightList = this.roleMenuService.list(ew);
// 如果存在权限,先进行删除 // 如果存在权限,先进行删除
if (roleRightList.size() > 0) { if (roleRightList.size() > 0) {
for (RoleMenu rm : roleRightList) { for (RoleMenu rm : roleRightList) {
this.roleMenuService.delete(new QueryWrapper<RoleMenu>(rm)); this.roleMenuService.remove(new QueryWrapper<RoleMenu>(rm));
} }
} }
ret = this.menuService.deleteById(menuId); ret = this.menuService.removeById(menuId);
} else { } else {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).build(); return ResponseEntity.status(HttpStatus.BAD_REQUEST).build();
} }
...@@ -300,15 +299,15 @@ public class MenuController extends BaseController { ...@@ -300,15 +299,15 @@ public class MenuController extends BaseController {
if (StringUtils.isNotBlank(menuIds)) { if (StringUtils.isNotBlank(menuIds)) {
QueryWrapper<RoleMenu> ew = new QueryWrapper<RoleMenu>(); QueryWrapper<RoleMenu> ew = new QueryWrapper<RoleMenu>();
ew.in("menu_id", StringUtils.split(menuIds, ",")); ew.in("menu_id", StringUtils.split(menuIds, ","));
List<RoleMenu> roleRightList = this.roleMenuService.selectList(ew); List<RoleMenu> roleRightList = this.roleMenuService.list(ew);
// 如果存在权限,先进行删除 // 如果存在权限,先进行删除
if (roleRightList.size() > 0) { if (roleRightList.size() > 0) {
for (RoleMenu rm : roleRightList) { for (RoleMenu rm : roleRightList) {
this.roleMenuService.delete(new QueryWrapper<RoleMenu>(rm)); this.roleMenuService.remove(new QueryWrapper<RoleMenu>(rm));
} }
} }
ret = this.menuService.deleteBatchIds(Arrays.asList(StringUtils.split(menuIds, ","))); ret = this.menuService.removeByIds(Arrays.asList(StringUtils.split(menuIds, ",")));
} else { } else {
resultMap.put("status", 400); resultMap.put("status", 400);
resultMap.put("message", "错误请求!"); resultMap.put("message", "错误请求!");
...@@ -336,14 +335,14 @@ public class MenuController extends BaseController { ...@@ -336,14 +335,14 @@ public class MenuController extends BaseController {
@RequiresPermissions("/menu/getRoleMenu") @RequiresPermissions("/menu/getRoleMenu")
public ResponseEntity<List<Map<String, String>>> getRoleMenu(String roleId) { public ResponseEntity<List<Map<String, String>>> getRoleMenu(String roleId) {
try { try {
Wrapper<Menu> menuWrapper = new QueryWrapper<>(); QueryWrapper<Menu> menuWrapper = new QueryWrapper<>();
menuWrapper.orderBy("sort",true); menuWrapper.orderByAsc("sort");
List<Menu> list = this.menuService.selectList(menuWrapper); List<Menu> list = this.menuService.list(menuWrapper);
List<Object> roleMenuList = null; List<Object> roleMenuList = null;
if (roleId != null) { if (roleId != null) {
Wrapper<RoleMenu> wrapper = new QueryWrapper<>(); QueryWrapper<RoleMenu> wrapper = new QueryWrapper<>();
wrapper.eq("role_id", roleId).setSqlSelect("menu_id"); wrapper.eq("role_id", roleId).select("menu_id");
roleMenuList = this.roleMenuService.selectObjs(wrapper); roleMenuList = this.roleMenuService.listObjs(wrapper);
} }
List<Map<String, String>> menuList = new ArrayList<>(); List<Map<String, String>> menuList = new ArrayList<>();
...@@ -352,8 +351,8 @@ public class MenuController extends BaseController { ...@@ -352,8 +351,8 @@ public class MenuController extends BaseController {
map.put("id", m.getId()); map.put("id", m.getId());
map.put("parentId", m.getParentId()); map.put("parentId", m.getParentId());
map.put("menuName", m.getMenuName()); map.put("menuName", m.getMenuName());
map.put("menuUrl",m.getMenuUrl()); map.put("menuUrl", m.getMenuUrl());
map.put("sort",String.valueOf(m.getSort())); map.put("sort", String.valueOf(m.getSort()));
// 默认展开树 // 默认展开树
map.put("open", "true"); map.put("open", "true");
if (roleId != null) { if (roleId != null) {
......
package cn.wisenergy.chnmuseum.party.web.controller;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 页面访问记录
* </p>
*
* @author Yang Jianlong
* @since 2018-12-27
*/
@Api(tags = "页面访问记录")
@RestController
@RequestMapping("/pageViewRecord")
public class PageViewRecordController {
}
package cn.wisenergy.chnmuseum.party.web.controller;
import cn.wisenergy.chnmuseum.party.common.util.DateUtil;
import cn.wisenergy.chnmuseum.party.model.BarChart;
import cn.wisenergy.chnmuseum.party.model.BarChartData;
import cn.wisenergy.chnmuseum.party.model.PageViews;
import cn.wisenergy.chnmuseum.party.service.impl.PageViewsServiceImpl;
import com.baomidou.mybatisplus.mapper.QueryWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* <p>
* 页面访问量
* </p>
*
* @author Yang Jianlong
* @since 2018-12-27
*/
@Api(tags = "页面访问量")
@RestController
@RequestMapping("/pageViews")
public class PageViewsController {
@Resource
private PageViewsServiceImpl pageViewsService;
@ApiOperation(value = "统计页面访问量", notes = "统计页面访问量")
@RequestMapping(value = "/statisticsPageViews", method = RequestMethod.GET)
public BarChart statisticsPageViews(String startDate, String endDate, String statisticsType) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
if (statisticsType == null || "".equals(statisticsType)) {
statisticsType = "year";
}
if (startDate == null || "".equals(startDate) || endDate == null || "".equals(endDate)) {
Date nowDate = new Date();
endDate = sdf.format(nowDate);
if ("year".equals(statisticsType)) {
startDate = sdf.format(DateUtil.getSomeDay(nowDate, -2, statisticsType));
} else if ("month".equals(statisticsType)) {
startDate = sdf.format(DateUtil.getSomeDay(nowDate, -11, statisticsType));
} else if ("day".equals(statisticsType)) {
startDate = sdf.format(DateUtil.getSomeDay(nowDate, -29, statisticsType));
}
}
if ("year".equals(statisticsType)) {
sdf = new SimpleDateFormat("yyyy");
} else if ("month".equals(statisticsType)) {
sdf = new SimpleDateFormat("yyyy-MM");
}
BarChart barChart = new BarChart();
Map<String, List<Object>> legend = new HashMap<>();
List<Object> legendData = new ArrayList<>();
legendData.add("业务办理助手");
legendData.add("网点服务地图");
legendData.add("热门产品");
legendData.add("热门活动");
legend.put("data", legendData);
barChart.setLegend(legend);
Wrapper<PageViews> viewsWrapper = new QueryWrapper<>();
if ("year".equals(statisticsType)) {
viewsWrapper.setSqlSelect("type,(CASE type WHEN 1 THEN '业务办理助手' WHEN 2 THEN '网点服务地图' WHEN 3 THEN '热门产品' else '热门活动' END) AS typeName," +
"DATE_FORMAT(view_date, '%Y') AS dateType,SUM(times) AS totalTimes");
} else if ("month".equals(statisticsType)) {
viewsWrapper.setSqlSelect("type,(CASE type WHEN 1 THEN '业务办理助手' WHEN 2 THEN '网点服务地图' WHEN 3 THEN '热门产品' else '热门活动' END) AS typeName," +
"DATE_FORMAT(view_date, '%Y-%m') AS dateType,SUM(times) AS totalTimes");
} else {
viewsWrapper.setSqlSelect("type,(CASE type WHEN 1 THEN '业务办理助手' WHEN 2 THEN '网点服务地图' WHEN 3 THEN '热门产品' else '热门活动' END) AS typeName," +
"DATE_FORMAT(view_date, '%Y-%m-%d') AS dateType,SUM(times) AS totalTimes");
}
viewsWrapper.where("1=1");
if (startDate != null && endDate != null) {
viewsWrapper.between("view_date", startDate, endDate);
}
viewsWrapper.groupBy("type,dateType");
List<PageViews> viewsList = this.pageViewsService.selectList(viewsWrapper);
Map<String, Integer> seriesDataMap = new HashMap<>();
for (PageViews view : viewsList) {
seriesDataMap.put(view.getTypeName() + view.getDateType(), view.getTotalTimes());
}
List<Date> betweenDates = null;
try {
betweenDates = DateUtil.getBetweenDates(sdf.parse(startDate), sdf.parse(endDate), statisticsType);
} catch (ParseException e) {
e.printStackTrace();
}
Map<String, List<Object>> xAxis = new HashMap<>();
List<Object> xAxisData = new ArrayList<>();
List<BarChartData> barChartDataList = new ArrayList<>();
boolean flag = true;
for (Object typeName : legendData) {
List<Object> data = new ArrayList<>();
BarChartData barChartData = new BarChartData();
barChartData.setName(typeName.toString());
for (Date betweenDate : betweenDates) {
String parse = sdf.format(betweenDate);
if (flag) {
xAxisData.add(parse);
}
if (seriesDataMap.get(typeName + parse) != null) {
data.add(seriesDataMap.get(typeName + parse));
} else {
data.add(0);
}
}
flag = false;
barChartData.setData(data);
barChartDataList.add(barChartData);
}
xAxis.put("data", xAxisData);
barChart.setxAxis(xAxis);
barChart.setSeries(barChartDataList);
return barChart;
}
}
package cn.wisenergy.chnmuseum.party.web.controller;
import cn.wisenergy.chnmuseum.party.common.util.ExcelUtil;
import cn.wisenergy.chnmuseum.party.model.BankBranchInfo;
import cn.wisenergy.chnmuseum.party.model.Employee;
import cn.wisenergy.chnmuseum.party.model.HotProductActivity;
import cn.wisenergy.chnmuseum.party.model.ProductAppointmentRecord;
import cn.wisenergy.chnmuseum.party.service.PublicService;
import cn.wisenergy.chnmuseum.party.service.impl.BankBranchInfoServiceImpl;
import cn.wisenergy.chnmuseum.party.service.impl.EmployeeServiceImpl;
import cn.wisenergy.chnmuseum.party.service.impl.HotProductActivityServiceImpl;
import cn.wisenergy.chnmuseum.party.service.impl.ProductAppointmentRecordServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.OutputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* <p>
* 产品活动预约记录 前端控制器
* </p>
*
* @author 杨智平
* @since 2018-08-29
*/
@Api(tags = "产品活动预约记录")
@RestController
@RequestMapping("/productAppointmentRecord")
public class ProductAppointmentRecordController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(EmployeeController.class);
@Resource
private ProductAppointmentRecordServiceImpl productAppointmentRecordService;
@Resource
private BankBranchInfoServiceImpl bankBranchInfoService;
@Resource
private HotProductActivityServiceImpl hotProductActivityService;
@Resource
private EmployeeServiceImpl employeeService;
@Resource
private PublicService publicService;
/**
* 获取单个产品活动预约记录
*
* @param id
* @return
*/
@ApiOperation(value = "获取单个产品活动预约记录")
@GetMapping(value = "/getById")
@RequiresPermissions("/productAppointmentRecord/getById")
public ResponseEntity<ProductAppointmentRecord> getById(String id) {
try {
ProductAppointmentRecord one = this.productAppointmentRecordService.selectById(id);
BankBranchInfo bankBranch = this.bankBranchInfoService.selectById(one.getBankBranchId());
HotProductActivity hotProductActivity = this.hotProductActivityService.selectById(one.getProActId());
one.setBankBranchInfo(bankBranch);
one.setProActName(hotProductActivity.getName());
if (null != one) {
return ResponseEntity.ok(one);
}
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
} catch (Exception e) {
logger.error("获取单个产品活动预约记录出错!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
/**
* 获取产品活动预约记录列表
*
* @param proActName
* @param id
* @param bankId
* @param type
* @return
*/
@ApiOperation(value = "获取产品活动预约记录列表")
@GetMapping(value = "/getList")
@RequiresPermissions("/productAppointmentRecord/getList")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "proActName", value = "活动产品名称", required = false, dataType = "String"),
@ApiImplicitParam(name = "id", value = "预约记录Id", required = false, dataType = "String"),
@ApiImplicitParam(name = "bankId", value = "网点Id", required = false, dataType = "String"),
@ApiImplicitParam(name = "type", value = "1-产品2-活动", required = true, dataType = "String"),
@ApiImplicitParam(name = "bookPeopleId", value = "预约人ID", required = false, dataType = "String")})
public ResponseEntity<Page<ProductAppointmentRecord>> getList(String proActName, String id,
String bankId, String type, String bookPeopleId,
String roleId, String currentBankId) {
try {
if (!"3".equals(roleId)) {
roleId = "0";
}
Map<String, Object> map = new HashMap<>();
map.put("proActName", proActName);
map.put("id", id);
map.put("bankId", bankId);
map.put("type", type);
map.put("bookPeopleId", bookPeopleId);
map.put("roleId", roleId);
map.put("currentBankId", currentBankId);
Page<ProductAppointmentRecord> page = getPage();
Page<ProductAppointmentRecord> pPage = this.productAppointmentRecordService.getPARList(page, map);
return ResponseEntity.ok(pPage);
} catch (Exception e) {
logger.error("服务器错误!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
/**
* App提交预约信息
*/
@Transactional
@ApiOperation("App提交预约信息")
@PostMapping(value = "/add")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "proActId", value = "预约产品或者活动的ID", required = true, dataType = "String"),
@ApiImplicitParam(name = "name", value = "预约人姓名", required = false, dataType = "String"),
@ApiImplicitParam(name = "phoneNumber", value = "预约人手机号", required = true, dataType = "String"),
@ApiImplicitParam(name = "detail", value = "预约详情", dataType = "String"),
@ApiImplicitParam(name = "bankBranchId", value = "预约所属支行", required = true, dataType = "String"),
@ApiImplicitParam(name = "bookPeopleId", value = "预约人ID", required = true, dataType = "String"),
@ApiImplicitParam(name = "type", value = "1-产品2-活动", required = true)})
public ResponseEntity<Map<String, Object>> add(ProductAppointmentRecord entity) {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
try {
boolean ret = false;
HotProductActivity hotProductActivity = this.hotProductActivityService.selectById(entity.getProActId());
if (hotProductActivity == null || hotProductActivity.getIsShow() == 0
|| hotProductActivity.getIsShow() == 1 || hotProductActivity.getIsShow() == 2
|| hotProductActivity.getIsShow() == 5) {
resultMap.put("status", 400);
if (entity.getType() == 1) {
resultMap.put("message", "您预约的产品不存在或已下线!");
} else {
resultMap.put("message", "您预约的活动不存在或已下线!");
}
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
} else if (hotProductActivity != null && hotProductActivity.getType() == 1
&& hotProductActivity.getMaxMoney() < entity.getMoney()) {
//限制产品最大预约金额
resultMap.put("status", 400);
resultMap.put("message", "您的预约金额不能超过" + hotProductActivity.getMaxMoney() + "元!");
} else if (hotProductActivity != null && hotProductActivity.getType() == 2
&& hotProductActivity.getMaxNumber() < entity.getNumberOfPeople()) {
//限制活动最大预约人数
resultMap.put("status", 400);
resultMap.put("message", "您的预约人数不能超过" + hotProductActivity.getMaxNumber() + "人!");
}
//接收人员工号,多人使用|分割,如"01014760|01158451"
String recUsrNbr = "";
if (entity.getBankBranchId() != null) {
Employee emp = this.employeeService.getEmpCodeBybankId(entity.getBankBranchId());
if (emp != null) {
recUsrNbr = emp.getCode();
entity.setRecipientId(emp.getId());
}
}
entity.setName(StringUtils.trimToNull(entity.getName()));
entity.setPhoneNumber(StringUtils.trimToNull(entity.getPhoneNumber()));
entity.setCreateTime(new Date(System.currentTimeMillis()));
entity.setUpdateTime(entity.getCreateTime());
ret = this.productAppointmentRecordService.insert(entity);
if (!ret) {
resultMap.put("status", 400);
resultMap.put("message", "提交失败");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
}
if (!"".equals(recUsrNbr)) {
//招乎正文,要求以[发送人姓名OR发送人部室]正文格式
String zhCnt = "";
if (entity.getType() == 1) {
//产品
zhCnt = "客户" + entity.getName() + "(" + entity.getPhoneNumber()
+ ")预约了产品:" + entity.getProActName() + ",预约金额:" +
entity.getMoney() + ",请及时联系客户!";
} else if (entity.getType() == 2) {
//活动
zhCnt = "客户" + entity.getName() + "(" + entity.getPhoneNumber()
+ ")预约了活动:" + entity.getProActName() + ",预约人数:" +
entity.getNumberOfPeople() + ",请及时联系客户!";
}
logger.info(zhCnt);
//发送消息给大堂主管
this.publicService.sendMessage(zhCnt, recUsrNbr);
}
// 201
resultMap.put("status", 201);
resultMap.put("message", "提交成功");
return ResponseEntity.status(HttpStatus.CREATED).body(resultMap);
} catch (Exception e) {
logger.error("提交错误!", e);
}
resultMap.put("status", 500);
resultMap.put("message", "操作失败");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
}
/**
* App获取产品活动预约记录列表
*
* @param bankId
* @param type
* @param bookPeopleId
* @return
*/
@ApiOperation(value = "App获取产品活动预约记录列表")
@GetMapping(value = "/getListOnApp")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "bankId", value = "网点Id", required = true, dataType = "String"),
@ApiImplicitParam(name = "type", value = "1-产品2-活动", required = true, dataType = "String"),
@ApiImplicitParam(name = "bookPeopleId", value = "预约人ID", required = true, dataType = "String")})
public ResponseEntity<List<ProductAppointmentRecord>> getListOnApp(String bankId, String type, String bookPeopleId) {
try {
Map<String, Object> map = new HashMap<>();
map.put("bankId", bankId);
map.put("type", type);
map.put("bookPeopleId", bookPeopleId);
List<ProductAppointmentRecord> pList = this.productAppointmentRecordService.getPARListOnApp(map);
return ResponseEntity.ok(pList);
} catch (Exception e) {
logger.error("服务器错误!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
/**
* 导出excel表
*
* @param proActName
* @param id
* @param bankId
* @param type
* @param bookPeopleId
* @return
*/
@ApiOperation(value = "导出excel表", notes = "导出excel表")
@GetMapping(value = "/generalCaseDownload")
public ResponseEntity<String> proAppoRecordDownload(HttpServletRequest request,
String proActName, String id,
String bankId, String type, String bookPeopleId,
String roleId, String currentBankId) {
if (!"3".equals(roleId)) {
roleId = "0";
}
/*文件名*/
String fileName = "热门产品预约记录" + ".xls";
/*sheet名*/
String sheetName = "热门产品预约记录" + ".xls";
/*标题*/
String[] title = new String[]{"预约人", "预约金额(元)", "预约手机号", "产品名称", "预约时间", "归属网点"};
if (Integer.parseInt(type) == 2) {
fileName = "热门活动预约记录" + ".xls";
sheetName = "热门活动预约记录" + ".xls";
title = new String[]{"预约人", "预约人数", "预约手机号", "活动名称", "预约时间", "归属网点"};
}
Map<String, Object> map = new HashMap<>();
map.put("proActName", proActName);
map.put("id", id);
map.put("bankId", bankId);
map.put("type", type);
map.put("bookPeopleId", bookPeopleId);
map.put("roleId", roleId);
map.put("currentBankId", currentBankId);
List<ProductAppointmentRecord> pList = this.productAppointmentRecordService.downLoadPAR(map);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String[][] values = new String[pList.size()][];
DecimalFormat df = new DecimalFormat("#.##");
for (int i = 0; i < pList.size(); i++) {
values[i] = new String[title.length];
//将对象内容转换成string
ProductAppointmentRecord obj = pList.get(i);
values[i][0] = obj.getName();
if (Integer.parseInt(type) == 1) {
values[i][1] = df.format(obj.getMoney());
} else {
values[i][1] = String.valueOf(obj.getNumberOfPeople());
}
values[i][2] = obj.getPhoneNumber();
values[i][3] = obj.getProActName();
values[i][4] = sdf.format(obj.getCreateTime());
values[i][5] = obj.getBankName();
}
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(sheetName, title, values, null);
//将文件存到指定位置
try {
//对文件名进行编码
fileName = ExcelUtil.encodeFileName(fileName, request);
ExcelUtil.setResponseHeader(response, fileName);
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();
os.close();
} catch (Exception e) {
logger.error("下载失败");
}
return ResponseEntity.ok("下载成功");
}
}
package cn.wisenergy.chnmuseum.party.web.controller; package cn.wisenergy.chnmuseum.party.web.controller;
import cmb.netpayment.Security;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController; import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.sun.xml.fastinfoset.Encoder;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import sun.misc.BASE64Decoder; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory; import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec; import javax.crypto.spec.DESKeySpec;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
/** /**
...@@ -57,94 +49,9 @@ public class PublicController extends BaseController { ...@@ -57,94 +49,9 @@ public class PublicController extends BaseController {
@GetMapping(value = "/backHomepage") @GetMapping(value = "/backHomepage")
public void backHomepage(HttpServletResponse response, String userId, String bankId, String timeStamp) throws Exception { public void backHomepage(HttpServletResponse response, String userId, String bankId, String timeStamp) throws Exception {
logger.info(CMB_HOME_URL + "?userId=" + userId + "&bankId=" + bankId); logger.info(CMB_HOME_URL + "?userId=" + userId + "&bankId=" + bankId);
response.sendRedirect(CMB_HOME_URL + "?userId=" + userId + "&bankId=" + bankId+"&showtopbar=false"); response.sendRedirect(CMB_HOME_URL + "?userId=" + userId + "&bankId=" + bankId + "&showtopbar=false");
} }
@PostMapping(value = "/getcmbxml")
@ResponseBody
public void getcmbxml(String param, String sResponseXml) throws Exception {
//用dom4j将暗文xml转成dom树
Document document = DocumentHelper.parseText(sResponseXml);
// 获取根节点
Element rootElement = document.getRootElement();
// 获取根节点下的子节点head
Iterator iter = rootElement.elementIterator("Head");
String ResultType = "";
String CryptType = "";
// 遍历head节点
while (iter.hasNext()) {
Element recordEle = (Element) iter.next();
// 拿到head节点下的子节点ResultType值
ResultType = recordEle.elementTextTrim("ResultType");
// 拿到head节点下的子节点CryptType值
CryptType = recordEle.elementTextTrim("CryptType");
}
// 拿到根节点下的子节点Body值
String UserDataBase64 = rootElement.elementTextTrim("Body");
if (ResultType.equals("Y")) {
//登录成功进行转码、解密、验证签名操作
String loginInfo = UserDataBase64;
if ("2".equals(CryptType)) {
//进行解密数据
BASE64Decoder base64decoder = new BASE64Decoder();
loginInfo = new String(decrypt(base64decoder.decodeBuffer(UserDataBase64), CMB_CORPKEY));
}
String stringValue = loginInfo.substring(loginInfo.indexOf("<Body>") + 6, loginInfo.indexOf("</Body>"));
//用dom4j将登录信息明文xml转成dom树
Document loginInfoDom = DocumentHelper.parseText(loginInfo);
// 获取根节点
Element loginInfoDomRoot = loginInfoDom.getRootElement();
// 获取根节点下的子节点Body
Iterator bodyIter = loginInfoDomRoot.elementIterator("Body");
//用户ID,由身份证+姓名生成
String uniqueUserID = "";
// 拿到Body节点下的子节点TimeStamp值
String timeStamp = "";
while (bodyIter.hasNext()) {
Element bodyEle = (Element) bodyIter.next();
/*// 拿到Body节点下的子节点CorpNo值
String CorpNo = bodyEle.elementTextTrim("CorpNo");
// 拿到Body节点下的子节点CorpName值
String CorpName = bodyEle.elementTextTrim("CorpName");
// 拿到Body节点下的子节点AppName值
String AppName = bodyEle.elementTextTrim("AppName");
// 拿到Body节点下的子节点AppVersion值
String AppVersion = bodyEle.elementTextTrim("AppVersion");
// 拿到Body节点下的子节点UserID值
String userID = bodyEle.elementTextTrim("UserID");
// 拿到Body节点下的子节点NewUserID值
String NewUserID = bodyEle.elementTextTrim("NewUserID");*/
// 拿到Body节点下的子节点UniqueUserID值
uniqueUserID = bodyEle.elementTextTrim("UniqueUserID");
// 拿到Body节点下的子节点TimeStamp值
timeStamp = bodyEle.elementTextTrim("TimeStamp");
}
// 获取根节点下的子节点Tail
Iterator tailIter = loginInfoDomRoot.elementIterator("Tail");
String verify = "";
while (tailIter.hasNext()) {
Element tailEle = (Element) tailIter.next();
// 拿到Tail节点下的子节点Verify值
verify = tailEle.elementTextTrim("Verify");
}
//获取public.key路径
Resource resource = new ClassPathResource("public.key");
File file = resource.getFile();
String canonicalPath = file.getCanonicalPath();
//验证签名
boolean flag = this.verifySignature(stringValue + "&signature=" + verify, canonicalPath);
if (flag) {
//验证成功之后返回首页
this.backHomepage(response, uniqueUserID, param, timeStamp);
}
} else if (ResultType.equals("N")) {
//登录失败返回消息
throw new Exception("登录失败!失败原因:" + UserDataBase64);
}
}
/** /**
* 解密 * 解密
...@@ -171,15 +78,6 @@ public class PublicController extends BaseController { ...@@ -171,15 +78,6 @@ public class PublicController extends BaseController {
return cipher.doFinal(src); return cipher.doFinal(src);
} }
/**
* 验证签名
*/
public static boolean verifySignature(String signdata, String publickeypath) throws Exception {
Security verifier = new Security(publickeypath);
byte[] signdataByte = signdata.getBytes(Encoder.UTF_8);
return verifier.checkInfoFromBank(signdataByte);//成功时返回true
}
/** /**
* 验证token * 验证token
* *
......
...@@ -10,7 +10,6 @@ import cn.wisenergy.chnmuseum.party.service.impl.RoleMenuServiceImpl; ...@@ -10,7 +10,6 @@ import cn.wisenergy.chnmuseum.party.service.impl.RoleMenuServiceImpl;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController; import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cmbchina.business.hall.model.*;
import com.github.stuxuhai.jpinyin.PinyinHelper; import com.github.stuxuhai.jpinyin.PinyinHelper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
......
package cn.wisenergy.chnmuseum.party.web.controller.base; package cn.wisenergy.chnmuseum.party.web.controller.base;
import cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import java.io.Serializable;
import java.util.List;
import org.springframework.web.servlet.HandlerInterceptor; /**
import org.springframework.web.servlet.ModelAndView; * controller 基类控制器
*/
public class BaseController implements Serializable {
import com.alibaba.fastjson.JSONObject; private static final long serialVersionUID = 624841049563451448L;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; protected static final Logger logger = LoggerFactory.getLogger(BaseController.class);
public class BaseController extends SuperController implements HandlerInterceptor { @Resource
protected HttpServletRequest request;
@Override /**
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { * <p>
return true; * 获取分页对象
* </p>
*/
protected <T> Page<T> getPage() {
return getPage(10L);
} }
@Override protected <T> Page<T> getPage(long size) {
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, long _size = size, _index = 1;
ModelAndView modelAndView) { if (request.getParameter("_size") != null) {
_size = Integer.parseInt(request.getParameter("_size"));
} }
if (request.getParameter("_index") != null) {
@Override _index = Integer.parseInt(request.getParameter("_index"));
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { }
return new Page<>(_index, _size);
} }
/** /**
* 判断是否为合法的视图地址 * JSON 过滤相关字段
* <p>
* *
* @param modelAndView spring 视图对象 * @param obj 待过滤的对象
* @return boolean * @param propertyList 需要过滤掉的字段集合
* @return 过滤后的JSON结果
*/ */
protected boolean isLegalView(ModelAndView modelAndView) { protected String propertyFilter(Object obj, List<String> propertyList) {
boolean legal = false; SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
if (modelAndView != null) { for (String params : propertyList) {
String viewUrl = modelAndView.getViewName(); filter.getExcludes().add(params);
if (viewUrl.contains("redirect:")) {
legal = false;
} else {
legal = true;
} }
return JSONObject.toJSONString(obj, filter);
} }
return legal;
/**
* JSON 过滤相关字段,并保持结果为JSON对象
*
* @param obj 待过滤的对象
* @param propertyList 需要过滤掉的字段集合
* @return 过滤后的JSON对象结果
*/
protected JSONObject propertyFilterToJsonObject(Object obj, List<String> propertyList) {
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
for (String params : propertyList) {
filter.getExcludes().add(params);
}
return JSONObject.parseObject(JSONObject.toJSONString(obj, filter));
} }
/** /**
* <p> * JSON 过滤相关字段,并保持结果为JSON数组
* 转换为 bootstrap-table 需要的分页格式 JSON
* </p>
* *
* @param page 分页对象 * @param obj 待过滤的对象
* @return * @param propertyList 需要过滤掉的字段集合
* @return 过滤后的JSON数组结果
*/ */
protected String jsonPage(Page<?> page) { protected JSONArray propertyFilterToJsonArray(Object obj, List<String> propertyList) {
JSONObject jo = new JSONObject(); SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
jo.put("total", page.getTotal()); for (String params : propertyList) {
jo.put("rows", page.getRecords()); filter.getExcludes().add(params);
return toJson(jo); }
return JSONObject.parseArray(JSONObject.toJSONString(obj, filter));
} }
@Override /**
protected <T> Page<T> getPage(int size) { * <p>
int _size = size, _index = 1; * 根据token信息
if (request.getParameter("_size") != null) { * </p>
_size = Integer.parseInt(request.getParameter("_size")); */
protected String getUserId() {
String authorization = request.getHeader("Authorization");
if (StringUtils.isNotBlank(authorization)) {
if (authorization.startsWith("Bearer ")) {
authorization = authorization.substring(7);
} }
if (request.getParameter("_index") != null) {
int _offset = Integer.parseInt(request.getParameter("_index"));
_index = _offset / _size + 1;
} }
return new Page<T>(_index, _size); return JwtTokenUtil.getEmployeeId(authorization);
} }
protected String booleanToString(boolean rlt) { /**
return rlt ? "true" : "false"; * <p>
* 根据token信息
* </p>
*/
protected String getUserName() {
String authorization = request.getHeader("Authorization");
if (StringUtils.isNotBlank(authorization)) {
if (authorization.startsWith("Bearer ")) {
authorization = authorization.substring(7);
}
}
return JwtTokenUtil.getUsername(authorization);
} }
} }
package cn.wisenergy.chnmuseum.party.web.controller.base;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil;
import cn.wisenergy.chnmuseum.party.common.vo.AjaxResult;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
public class SuperController {
protected Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
protected HttpServletRequest request;
@Autowired
protected HttpServletResponse response;
@Autowired
protected HttpSession session;
@Autowired
protected ServletContext application;
/**
* <p>
* 获取分页对象
* </p>
*/
protected <T> Page<T> getPage() {
return getPage(10);
}
/**
* <p>
* 根据token信息
* </p>
*/
protected String getUserId() {
String authorization = request.getHeader("Authorization");
if (StringUtils.isNotBlank(authorization)) {
if (authorization.startsWith("Bearer ")) {
authorization = authorization.substring(7);
}
}
String employeeId= JwtTokenUtil.getEmployeeId(authorization);
return employeeId;
}
/**
* <p>
* 根据token信息
* </p>
*/
protected String getUserName() {
String authorization = request.getHeader("Authorization");
if (StringUtils.isNotBlank(authorization)) {
if (authorization.startsWith("Bearer ")) {
authorization = authorization.substring(7);
}
}
String username=JwtTokenUtil.getUsername(authorization);
return username;
}
/**
* <p>
* 获取分页对象
* </p>
*
* @param size
* 每页显示数量
* @return
*/
protected <T> Page<T> getPage(int size) {
int _size = size, _index = 1;
// 排序方式 asc升序 desc降序
boolean isAsc = false;
// 排序的字段
String orderByField = null;
if (request.getParameter("_size") != null) {
_size = Integer.parseInt(request.getParameter("_size"));
}
if (request.getParameter("_index") != null) {
_index = Integer.parseInt(request.getParameter("_index"));
}
if (request.getParameter("_sortBy") != null) {
orderByField = request.getParameter("_sortBy");
}
if (request.getParameter("_isAsc") != null) {
isAsc = Boolean.valueOf(request.getParameter("_isAsc"));
}
if (orderByField == null) {
return new Page<>(_index, _size);
}
return new Page<>(_index, _size, orderByField, isAsc);
}
/**
* 重定向至地址 url
*
* @param url
* 请求地址
* @return
*/
protected String redirectTo(String url) {
StringBuffer rto = new StringBuffer("redirect:");
rto.append(url);
return rto.toString();
}
/**
*
* 返回 JSON 格式对象
*
* @param object
* 转换对象
* @return
*/
protected String toJson(Object object) {
return JSON.toJSONString(object, SerializerFeature.BrowserCompatible);
}
/**
*
* 返回 JSON 格式对象
*
* @param object
* 转换对象
* @return
*/
protected String toJson(Object object, String format) {
if (format == null) {
return toJson(object);
}
return JSON.toJSONStringWithDateFormat(object, format, SerializerFeature.WriteDateUseDateFormat);
}
/**
* <p>
* 自动判定是否有跨域操作,转成字符串并返回
* </p>
*
* @param object
* @return 跨域或不跨域的字符串
*/
protected String callback(AjaxResult object) {
return callback(object, null);
}
protected String callback(AjaxResult object, String format) {
String callback = request.getParameter("callback");
if (callback == null) {
/**
* 非 JSONP 请求
*/
return toJson(object, format);
}
StringBuilder json = new StringBuilder();
json.append(callback);
json.append("(").append(toJson(object, format)).append(")");
return json.toString();
}
protected String callbackSuccess(Object obj) {
return callback(new AjaxResult(obj));
}
protected String callbackFail(String message) {
return callback(new AjaxResult(false, message));
}
}
package com.baidu.ueditor.extend; package com.baidu.ueditor.extend;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
import org.json.JSONObject;
import com.baidu.ueditor.define.AppInfo; import com.baidu.ueditor.define.AppInfo;
import com.baidu.ueditor.define.BaseState; import com.baidu.ueditor.define.BaseState;
import com.baidu.ueditor.define.FileType; import com.baidu.ueditor.define.FileType;
import com.baidu.ueditor.define.State; import com.baidu.ueditor.define.State;
import org.json.JSONObject;
import java.util.Base64;
import java.util.Map;
public final class UEBase64Uploader { public final class UEBase64Uploader {
...@@ -17,7 +16,7 @@ public final class UEBase64Uploader { ...@@ -17,7 +16,7 @@ public final class UEBase64Uploader {
// String fileName = request.getParameter(filedName); // String fileName = request.getParameter(filedName);
byte[] data = decode(fileName); byte[] data = decode(fileName);
long maxSize = ((Long) conf.get("maxSize")).longValue(); long maxSize = (Long) conf.get("maxSize");
if (!validSize(data, maxSize)) { if (!validSize(data, maxSize)) {
return new BaseState(false, AppInfo.MAX_SIZE); return new BaseState(false, AppInfo.MAX_SIZE);
...@@ -48,7 +47,7 @@ public final class UEBase64Uploader { ...@@ -48,7 +47,7 @@ public final class UEBase64Uploader {
} }
private static byte[] decode(String content) { private static byte[] decode(String content) {
return Base64.decodeBase64(content); return Base64.getDecoder().decode(content);
} }
private static boolean validSize(byte[] data, long length) { private static boolean validSize(byte[] data, long length) {
......
...@@ -7,11 +7,9 @@ import com.baidu.ueditor.define.BaseState; ...@@ -7,11 +7,9 @@ import com.baidu.ueditor.define.BaseState;
import com.baidu.ueditor.define.FileType; import com.baidu.ueditor.define.FileType;
import com.baidu.ueditor.define.State; import com.baidu.ueditor.define.State;
import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Base64;
import org.apache.commons.codec.binary.Base64; import java.util.Map;
public final class Base64Uploader { public final class Base64Uploader {
...@@ -20,7 +18,7 @@ public final class Base64Uploader { ...@@ -20,7 +18,7 @@ public final class Base64Uploader {
String fileName = request.getParameter(filedName); String fileName = request.getParameter(filedName);
byte[] data = decode(fileName); byte[] data = decode(fileName);
long maxSize = ((Long) conf.get("maxSize")).longValue(); long maxSize = (Long) conf.get("maxSize");
if (!validSize(data, maxSize)) { if (!validSize(data, maxSize)) {
return new BaseState(false, AppInfo.MAX_SIZE); return new BaseState(false, AppInfo.MAX_SIZE);
...@@ -47,7 +45,7 @@ public final class Base64Uploader { ...@@ -47,7 +45,7 @@ public final class Base64Uploader {
} }
private static byte[] decode(String content) { private static byte[] decode(String content) {
return Base64.decodeBase64(content); return Base64.getDecoder().decode(content);
} }
private static boolean validSize(byte[] data, long length) { private static boolean validSize(byte[] data, long length) {
......
...@@ -5,10 +5,7 @@ jwt.issuer=IATA ...@@ -5,10 +5,7 @@ jwt.issuer=IATA
jwt.authenticationPath=/auth jwt.authenticationPath=/auth
jwt.authTokenPrefix=Bearer jwt.authTokenPrefix=Bearer
cors.url.list=https://virthall.mbcloud.com,https://virthallmgr.mbcloud.com,https://virthall.bas.cmbchina.com,https://virthallmgr.bas.cmbchina.com #cors.url.list=https://virthall.mbcloud.com,https://virthallmgr.mbcloud.com,https://virthall.bas.cmbchina.com,https://virthallmgr.bas.cmbchina.com
mybatis.type-aliases-package=com.cmbchina.business.hall.model
mybatis.mapper-locations=classpath:mapper/*.xml
######################################################## ########################################################
###FastDFS ###FastDFS
...@@ -35,15 +32,12 @@ spring.datasource.druid.test-on-borrow=false ...@@ -35,15 +32,12 @@ spring.datasource.druid.test-on-borrow=false
spring.datasource.druid.test-on-return=false spring.datasource.druid.test-on-return=false
spring.datasource.druid.test-while-idle=true spring.datasource.druid.test-while-idle=true
spring.datasource.druid.time-between-eviction-runs-millis=60000 spring.datasource.druid.time-between-eviction-runs-millis=60000
spring.datasource.druid.url=jdbc:mysql://11.53.108.182:3306/bigdata_station?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai spring.datasource.druid.url=jdbc:mysql://192.168.110.93:3306/chnmuseum-party?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.druid.username=mdp_user spring.datasource.druid.username=root
spring.datasource.druid.password=n9xfGe-RqZQ43o2F-nRag4w spring.datasource.druid.password=password
spring.datasource.druid.validation-query=SELECT 1 FROM DUAL spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
spring.datasource.druid.validation-query-timeout=20 spring.datasource.druid.validation-query-timeout=20
#spring.datasource.druid.url=jdbc:mysql://139.217.202.240:43306/virtual-business-hall?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false
#spring.datasource.druid.username=root
#spring.datasource.druid.password=&y|agiUi@H)4gr
######################################################## ########################################################
###Redis ###Redis
...@@ -51,12 +45,12 @@ spring.datasource.druid.validation-query-timeout=20 ...@@ -51,12 +45,12 @@ spring.datasource.druid.validation-query-timeout=20
# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09 # Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
spring.redis.database=0 spring.redis.database=0
# Redis\u670D\u52A1\u5668\u5730\u5740 # Redis\u670D\u52A1\u5668\u5730\u5740
spring.redis.host=127.0.0.1 spring.redis.host=192.168.110.93
#spring.redis.host=42.159.83.54 #spring.redis.host=42.159.83.54
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u7AEF\u53E3 # Redis\u670D\u52A1\u5668\u8FDE\u63A5\u7AEF\u53E3
spring.redis.port=6379 spring.redis.port=6379
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09 # Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09
spring.redis.password= spring.redis.password=147258369
# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09 # \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09
spring.redis.timeout=100000 spring.redis.timeout=100000
# \u8FDE\u63A5\u6C60\u6700\u5927\u8FDE\u63A5\u6570\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09 # \u8FDE\u63A5\u6C60\u6700\u5927\u8FDE\u63A5\u6570\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
...@@ -69,47 +63,6 @@ spring.redis.jedis.pool.max-idle=8 ...@@ -69,47 +63,6 @@ spring.redis.jedis.pool.max-idle=8
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5 # \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5
spring.redis.jedis.pool.min-idle=0 spring.redis.jedis.pool.min-idle=0
########################################################
###Shiro
########################################################
spring.aop.proxy-target-class=true
spring.aop.auto=true
########################################################
###EMBEDDED SERVER CONFIGURATION
########################################################
# \u9879\u76EEcontextPath
server.servlet.path=/
# \u670D\u52A1\u7AEF\u53E3
server.port=8080
# tomcat\u6700\u5927\u7EBF\u7A0B\u6570\uFF0C\u9ED8\u8BA4\u4E3A200
server.tomcat.max-threads=100
# tomcat\u7684URI\u7F16\u7801
server.tomcat.uri-encoding=UTF-8
# server.jsp-servlet.class-name=org.apache.jasper.servlet.JspServlet
# server.jsp-servlet.init-parameters.development=true
server.error.whitelabel.enabled=false
########################################################
###Spring MVC
########################################################
spring.mvc.date-format=yyyy-MM-dd HH:mm:ss
#\u8868\u793A\u6240\u6709\u7684\u8BBF\u95EE\u90FD\u7ECF\u8FC7\u9759\u6001\u8D44\u6E90\u8DEF\u5F84\uFF1B
#spring.mvc.static-path-pattern=/**
#spring.mvc.static-path-pattern=/public/**
# \u4FEE\u6539\u9ED8\u8BA4\u7684\u9759\u6001\u8D44\u6E90\u5B58\u653E\u76EE\u5F55
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/statics/,classpath:/public/
spring.servlet.multipart.max-request-size=4096MB
spring.servlet.multipart.max-file-size=2048MB
spring.resources.add-mappings=true
spring.http.encoding.force=true
spring.http.converters.preferred-json-mapper=fastjson
########################################################
###thymeleaf
########################################################
spring.thymeleaf.mode=HTML
spring.thymeleaf.cache=false
######################################################## ########################################################
###Log ###Log
...@@ -120,33 +73,3 @@ logging.level.org.springframework.web=ERROR ...@@ -120,33 +73,3 @@ logging.level.org.springframework.web=ERROR
logging.level.druid.sql.ResultSet=DEBUG logging.level.druid.sql.ResultSet=DEBUG
#logging.level.console.level=DEBUG #logging.level.console.level=DEBUG
#logging.level.file.level=DEBUG #logging.level.file.level=DEBUG
\ No newline at end of file
########################################################
###\u865A\u62DF\u8425\u4E1A\u5385APP\u9996\u9875\u5730\u5740\u94FE\u63A5
########################################################
CMB_HOME_URL=https://virthall.mbcloud.com/dist/#/
########################################################
###\u865A\u62DF\u8425\u4E1A\u5385APP\u53CD\u9988\u5730\u5740\u94FE\u63A5
########################################################
CMB_FEEDBACK_URL=https://virthall.mbcloud.com/dist/#/feedBack?id=
########################################################
###\u62DB\u884Ccorpkey\u672C\u5546\u6237\u5BC6\u94A5
########################################################
CMB_CORPKEY=xsd0hwt4
########################################################
###\u7B2C\u4E09\u65B9\u7528\u6237\u552F\u4E00\u51ED\u8BC1
########################################################
CLIENT_ID=aaaaaaaabbbbbbbb
########################################################
###\u7B2C\u4E09\u65B9\u7528\u6237\u552F\u4E00\u51ED\u8BC1\u5BC6\u94A5
########################################################
CLIENT_SECRET=Wh12345678
########################################################
###\u83B7\u53D6access_token\u5730\u5740
########################################################
GET_ACCESSTOKEN=https://wuhan.wx.cmbchina.com/OAuth2CMBWH/
\ No newline at end of file
...@@ -8,8 +8,19 @@ cors.url.list=http://localhost:8080 ...@@ -8,8 +8,19 @@ cors.url.list=http://localhost:8080
cacheManager.principalIdFieldName = id cacheManager.principalIdFieldName = id
mybatis.type-aliases-package=com.cmbchina.business.hall.model mybatis-plus.check-config-location=true
mybatis.mapper-locations=classpath:mapper/*.xml mybatis-plus.mapper-locations=classpath*:/mapper/**/*.xml
mybatis-plus.type-aliases-package=cn.wisenergy.chnmuseum.party.model.**
mybatis-plus.global-config.db-config.id-type=assign_id
mybatis-plus.global-config.db-config.logic-delete-value=-1
mybatis-plus.global-config.db-config.logic-not-delete-value=0
mybatis-plus.global-config.banner=false
mybatis-plus.configuration.lazy-loading-enabled=true
mybatis-plus.configuration.aggressive-lazy-loading=false
mybatis-plus.configuration.map-underscore-to-camel-case=true
mybatis-plus.configuration.cache-enabled=false
mybatis-plus.configuration.call-setters-on-nulls=true
mybatis-plus.configuration.jdbc-type-for-null=null
######################################################## ########################################################
###FastDFS ###FastDFS
...@@ -18,57 +29,6 @@ dfsFileAccessBasePath=https://virthall.bas.cmbchina.com ...@@ -18,57 +29,6 @@ dfsFileAccessBasePath=https://virthall.bas.cmbchina.com
prefixPat=/data/fastdfs/data prefixPat=/data/fastdfs/data
IMAGE_BASE_URL=https://virthall.bas.cmbchina.com/ IMAGE_BASE_URL=https://virthall.bas.cmbchina.com/
####\u540C\u4E00\u4E2Atomcat\u4E0B\u9762\u90E8\u7F72\u591A\u4E2Assm \u9879\u76EE\u65F6\u9700\u8981\u52A0\u4EE5\u533A\u5206 \u4E0D\u7136\u542F\u52A8\u4F1A\u6709\u95EE\u9898####
spring.jmx.default-domain=virtual-business-hall-domain
########################################################
###DataSource
########################################################
spring.datasource.druid.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.druid.filters=stat,wall,slf4j,config,mergeStat
spring.datasource.druid.initial-size=1
spring.datasource.druid.max-active=20
spring.datasource.druid.max-pool-prepared-statement-per-connection-size=20
spring.datasource.druid.max-wait=60000
spring.datasource.druid.min-evictable-idle-time-millis=300000
spring.datasource.druid.min-idle=5
spring.datasource.druid.pool-prepared-statements=true
spring.datasource.druid.test-on-borrow=false
spring.datasource.druid.test-on-return=false
spring.datasource.druid.test-while-idle=true
spring.datasource.druid.time-between-eviction-runs-millis=60000
spring.datasource.druid.url=jdbc:mysql://192.168.110.69:3306/virtual-business-hall?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai
spring.datasource.druid.username=root
spring.datasource.druid.password=Root@123
spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
spring.datasource.druid.validation-query-timeout=20
#spring.datasource.druid.url=jdbc:mysql://139.217.202.240:43306/virtual-business-hall?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false
#spring.datasource.druid.username=root
#spring.datasource.druid.password=&y|agiUi@H)4gr
########################################################
###Redis
########################################################
# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
spring.redis.database=0
# Redis\u670D\u52A1\u5668\u5730\u5740
spring.redis.host=localhost
#spring.redis.host=42.159.83.54
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u7AEF\u53E3
spring.redis.port=6379
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09
spring.redis.password=
# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09
spring.redis.timeout=100000
# \u8FDE\u63A5\u6C60\u6700\u5927\u8FDE\u63A5\u6570\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.jedis.pool.max-active=8
# \u8FDE\u63A5\u6C60\u6700\u5927\u963B\u585E\u7B49\u5F85\u65F6\u95F4\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.jedis.pool.max-wait=-1
# jedis\u8D85\u65F6
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5
spring.redis.jedis.pool.max-idle=8
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5
spring.redis.jedis.pool.min-idle=0
######################################################## ########################################################
###Shiro ###Shiro
...@@ -80,11 +40,12 @@ spring.aop.auto=true ...@@ -80,11 +40,12 @@ spring.aop.auto=true
###EMBEDDED SERVER CONFIGURATION ###EMBEDDED SERVER CONFIGURATION
######################################################## ########################################################
# \u9879\u76EEcontextPath # \u9879\u76EEcontextPath
server.servlet.path=/ server.servlet.context-path=/
# \u670D\u52A1\u7AEF\u53E3 # \u670D\u52A1\u7AEF\u53E3
server.port=8080 server.port=8080
server.servlet.encoding.force=true
# tomcat\u6700\u5927\u7EBF\u7A0B\u6570\uFF0C\u9ED8\u8BA4\u4E3A200 # tomcat\u6700\u5927\u7EBF\u7A0B\u6570\uFF0C\u9ED8\u8BA4\u4E3A200
server.tomcat.max-threads=100 server.tomcat.threads.max=100
# tomcat\u7684URI\u7F16\u7801 # tomcat\u7684URI\u7F16\u7801
server.tomcat.uri-encoding=UTF-8 server.tomcat.uri-encoding=UTF-8
# server.jsp-servlet.class-name=org.apache.jasper.servlet.JspServlet # server.jsp-servlet.class-name=org.apache.jasper.servlet.JspServlet
...@@ -94,24 +55,24 @@ server.error.whitelabel.enabled=false ...@@ -94,24 +55,24 @@ server.error.whitelabel.enabled=false
######################################################## ########################################################
###Spring MVC ###Spring MVC
######################################################## ########################################################
spring.mvc.date-format=yyyy-MM-dd HH:mm:ss spring.mvc.format.date=yyyy-MM-dd HH:mm:ss
#\u8868\u793A\u6240\u6709\u7684\u8BBF\u95EE\u90FD\u7ECF\u8FC7\u9759\u6001\u8D44\u6E90\u8DEF\u5F84\uFF1B
#spring.mvc.static-path-pattern=/** #spring.mvc.static-path-pattern=/**
#spring.mvc.static-path-pattern=/public/** #spring.mvc.static-path-pattern=/public/**
# \u4FEE\u6539\u9ED8\u8BA4\u7684\u9759\u6001\u8D44\u6E90\u5B58\u653E\u76EE\u5F55 spring.web.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/statics/,classpath:/public/
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/statics/,classpath:/public/
spring.servlet.multipart.max-request-size=4096MB spring.servlet.multipart.max-request-size=4096MB
spring.servlet.multipart.max-file-size=2048MB spring.servlet.multipart.max-file-size=2048MB
spring.resources.add-mappings=true spring.web.resources.add-mappings=true
spring.http.encoding.force=true spring.mvc.converters.preferred-json-mapper=fastjson
spring.http.converters.preferred-json-mapper=fastjson
######################################################## ########################################################
###thymeleaf ###thymeleaf
######################################################## ########################################################
spring.profiles.active=prd spring.profiles.active=dev
spring.thymeleaf.mode=HTML spring.thymeleaf.mode=HTML
spring.thymeleaf.cache=false spring.thymeleaf.cache=false
shiro-redis.enabled=true
shiro-redis.redis-manager.host=192.168.110.93
shiro-redis.redis-manager.password=147258369
######################################################## ########################################################
###Log ###Log
...@@ -123,32 +84,3 @@ logging.level.druid.sql.ResultSet=DEBUG ...@@ -123,32 +84,3 @@ logging.level.druid.sql.ResultSet=DEBUG
#logging.level.console.level=DEBUG #logging.level.console.level=DEBUG
#logging.level.file.level=DEBUG #logging.level.file.level=DEBUG
########################################################
###\u865A\u62DF\u8425\u4E1A\u5385APP\u9996\u9875\u5730\u5740\u94FE\u63A5
########################################################
CMB_HOME_URL=https://virthall.bas.cmbchina.com/dist/#/
########################################################
###\u865A\u62DF\u8425\u4E1A\u5385APP\u53CD\u9988\u5730\u5740\u94FE\u63A5
########################################################
CMB_FEEDBACK_URL=https://virthall.bas.cmbchina.com/dist/#/feedBack?id=
########################################################
###\u62DB\u884Ccorpkey\u672C\u5546\u6237\u5BC6\u94A5
########################################################
CMB_CORPKEY=xsd0hwt4
########################################################
###\u7B2C\u4E09\u65B9\u7528\u6237\u552F\u4E00\u51ED\u8BC1
########################################################
CLIENT_ID=aaaaaaaabbbbbbbb
########################################################
###\u7B2C\u4E09\u65B9\u7528\u6237\u552F\u4E00\u51ED\u8BC1\u5BC6\u94A5
########################################################
CLIENT_SECRET=Wh12345678
########################################################
###\u83B7\u53D6access_token\u5730\u5740
########################################################
GET_ACCESSTOKEN=https://wuhan.wx.cmbchina.com/OAuth2CMBWH/
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment