刘洋代码注释 #9

Merged
phfsut2ie merged 2 commits from develop into main 3 months ago

@ -6,7 +6,6 @@
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="jianshenfanggl" />
</profile>
</annotationProcessing>
</component>

@ -1,23 +1,7 @@
<<<<<<< HEAD
package com.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
// 声明该代码文件所在的包名
/**
*
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface APPLoginUser {
}
=======
// 声明该代码文件所在的包名为 com.annotation
package com.annotation;
// 导入 java.lang.annotation.ElementType 类,该类用于指定注解可以应用的目标元素类型,
// 例如类、方法、字段等,在定义注解时需要使用它来指定注解的作用目标
import java.lang.annotation.ElementType;
@ -34,8 +18,8 @@ import java.lang.annotation.RetentionPolicy;
// 配合 ElementType 来确定注解可以作用在哪些地方,比如类、方法、字段等
import java.lang.annotation.Target;
// 登录用户信息
// 自定义注解,用于标识需要注入当前登录用户信息的方法参数
// 登录用户信息
// 自定义注解,标识需要注入当前登录用户信息的方法参数
@Target(ElementType.PARAMETER)
// 指定该注解只能用于方法参数上
@Retention(RetentionPolicy.RUNTIME)
@ -44,4 +28,4 @@ public @interface APPLoginUser {
// 定义一个空注解,作为标记使用
// 实际使用时可以配合拦截器或参数解析器,自动注入当前登录用户对象
}
>>>>>>> develop

@ -1,18 +1,4 @@
<<<<<<< HEAD
package com.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ColumnInfo {
String comment();
String type();
}
=======
// 定义该文件所在的包路径,将该 Java 类组织到 com.annotation 这个包空间下,方便项目的模块化管理和避免类名冲突
package com.annotation;
@ -40,4 +26,4 @@ public @interface ColumnInfo {
// 定义type属性表示字段的类型
String type();
}
>>>>>>> develop

@ -1,18 +1,4 @@
<<<<<<< HEAD
package com.annotation;
import java.lang.annotation.*;
/**
* Token
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface IgnoreAuth {
}
=======
// 定义该文件所在的包路径
package com.annotation;
@ -31,4 +17,4 @@ public @interface IgnoreAuth {
// 这是一个标记注解,不包含任何属性
// 仅用于标识需要跳过Token验证的方法
}
>>>>>>> develop

@ -1,20 +1,4 @@
<<<<<<< HEAD
package com.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface LoginUser {
}
=======
// 定义该文件所在的包路径,在 Java 里,包是组织类和接口的一种方式,此包路径为 com.annotation能防止命名冲突也便于代码的管理与维护
package com.annotation;
@ -40,4 +24,4 @@ public @interface LoginUser {
// 这是一个标记注解,不包含任何属性
// 用于标识需要自动注入当前登录用户信息的参数
}
>>>>>>> develop

@ -1,44 +1,4 @@
<<<<<<< HEAD
package com.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import com.interceptor.AuthorizationInterceptor;
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport{
@Bean
public AuthorizationInterceptor getAuthorizationInterceptor() {
return new AuthorizationInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(getAuthorizationInterceptor()).addPathPatterns("/**").excludePathPatterns("/static/**");
super.addInterceptors(registry);
}
/**
* springboot 2.0WebMvcConfigurationSupport访addResourceHandlers
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/resources/")
.addResourceLocations("classpath:/static/")
.addResourceLocations("classpath:/admin/")
.addResourceLocations("classpath:/img/")
.addResourceLocations("classpath:/front/")
.addResourceLocations("classpath:/public/");
super.addResourceHandlers(registry);
}
}
=======
// 声明当前文件所在的包路径,在 Java 项目中,包用于组织代码结构,这里表示该文件属于 com.config 包,有助于模块化管理和避免命名冲突
package com.config;
@ -56,31 +16,17 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp
// 导入自定义的拦截器类,该拦截器类用于处理请求的授权逻辑,在请求到达控制器之前进行权限检查等操作
import com.interceptor.AuthorizationInterceptor;
// 拦截器配置类
// 用于配置Spring MVC拦截器和静态资源处理
@Configuration // 标识这是一个Spring配置类
public class InterceptorConfig extends WebMvcConfigurationSupport {
// 创建授权拦截器Bean
// @return AuthorizationInterceptor实例
@Bean
public AuthorizationInterceptor getAuthorizationInterceptor() {
return new AuthorizationInterceptor();
}
// 配置拦截器规则
// @param registry 拦截器注册器
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 注册授权拦截器并配置拦截规则
registry.addInterceptor(getAuthorizationInterceptor());
// 拦截所有请求路径
registry.addPathPatterns("/**");
// 排除静态资源路径
registry.excludePathPatterns("/static/**");
super.addInterceptors(registry);
}
//配置拦截器规则
//@param registry 拦截器注册器
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 注册授权拦截器并配置拦截规则
registry.addInterceptor(getAuthorizationInterceptor())
.addPathPatterns("/**") // 拦截所有请求路径
.excludePathPatterns("/static/**"); // 排除静态资源路径
super.addInterceptors(registry);
}
// 配置静态资源处理
// 注意在SpringBoot 2.0中自定义WebMvc配置会覆盖默认配置
// 需要手动添加静态资源路径配置
@ -105,4 +51,3 @@ public class InterceptorConfig extends WebMvcConfigurationSupport {
super.addResourceHandlers(registry);
}
}
>>>>>>> develop

@ -1,33 +1,4 @@
<<<<<<< HEAD
package com.config;
import java.util.Date;
import org.apache.ibatis.reflection.MetaObject;
import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
/**
*
*/
public class MyMetaObjectHandler extends MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
this.setFieldValByName("ctime", new Date(), metaObject);
}
@Override
public boolean openUpdateFill() {
return false;
}
@Override
public void updateFill(MetaObject metaObject) {
// 关闭更新填充、这里不执行
}
}
=======
// 声明当前文件所在的包路径
package com.config;
@ -40,12 +11,14 @@ import org.apache.ibatis.reflection.MetaObject;
// 导入MyBatis-Plus元对象处理器基类
import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
// 自定义字段自动填充处理器
// 用于实现实体类字段的自动填充功能
//自定义字段自动填充处理器
//用于实现实体类字段的自动填充功能
public class MyMetaObjectHandler extends MetaObjectHandler {
// 插入数据时的字段自动填充
// @param metaObject 元对象(包含实体类信息)
//插入数据时的字段自动填充
//@param metaObject 元对象(包含实体类信息)
@Override
public void insertFill(MetaObject metaObject) {
// 为"ctime"(创建时间)字段自动填充当前时间
@ -55,21 +28,24 @@ public class MyMetaObjectHandler extends MetaObjectHandler {
// this.setFieldValByName("createUser", getCurrentUserId(), metaObject);
}
// 是否开启更新时的字段填充
// @return false表示关闭更新时的自动填充
//是否开启更新时的字段填充
//@return false表示关闭更新时的自动填充
@Override
public boolean openUpdateFill() {
// 返回false表示不执行updateFill方法
return false;
}
// 更新数据时的字段自动填充(当前未启用)
// @param metaObject 元对象(包含实体类信息)
//更新数据时的字段自动填充(当前未启用)
//@param metaObject 元对象(包含实体类信息)
@Override
public void updateFill(MetaObject metaObject) {
// 由于openUpdateFill返回false此方法不会被执行
// 如需启用更新填充,可在此添加类似:
// this.setFieldValByName("utime", new Date(), metaObject);
}
}
>>>>>>> develop
}

@ -1,29 +1,4 @@
<<<<<<< HEAD
package com.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
/**
* mybatis-plus
*/
@Configuration
public class MybatisPlusConfig {
/**
*
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
=======
// 声明当前文件所在的包路径,在 Java 项目里,包用于组织和管理代码,此包路径为 com.config有助于将相关的配置类集中管理避免命名冲突
package com.config;
@ -37,14 +12,15 @@ import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
// 导入 MyBatis-Plus 框架中的 PaginationInterceptor 类,这是一个分页拦截器。使用该拦截器可以方便地实现数据库查询的分页功能,简化分页逻辑的编写
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
// MyBatis-Plus配置类
// 用于配置MyBatis-Plus的相关插件和组件
//MyBatis-Plus配置类
//用于配置MyBatis-Plus的相关插件和组件
@Configuration // 标识这是一个Spring配置类
public class MybatisPlusConfig {
// 配置MyBatis-Plus分页插件
// 该插件会自动处理分页逻辑,无需手动编写分页代码
// @return PaginationInterceptor 分页拦截器实例
//配置MyBatis-Plus分页插件
//该插件会自动处理分页逻辑,无需手动编写分页代码
//@return PaginationInterceptor 分页拦截器实例
@Bean
public PaginationInterceptor paginationInterceptor() {
// 创建并返回MyBatis-Plus的分页拦截器
@ -55,5 +31,6 @@ public class MybatisPlusConfig {
// - 性能分析插件
// - 乐观锁插件
// - SQL注入器等
}
>>>>>>> develop
}

@ -1,25 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSON;
import com.utils.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ResourceUtils;
=======
// 声明当前文件所在的包路径
package com.controller;
@ -44,129 +22,69 @@ import com.utils.StringUtil;
import org.apache.commons.lang3.StringUtils;
// 导入JSON对象类
import org.json.JSONObject;
// 导入日志相关类
// 导入SLF4J日志框架相关类(用于日志记录)
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// 导入Spring框架相关注解和类
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ResourceUtils;
// 导入Spring MVC注解
>>>>>>> develop
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
<<<<<<< HEAD
import com.annotation.IgnoreAuth;
import com.baidu.aip.face.AipFace;
import com.baidu.aip.face.MatchRequest;
import com.baidu.aip.util.Base64Util;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.ConfigEntity;
import com.service.CommonService;
import com.service.ConfigService;
=======
// 导入自定义注解
import com.annotation.IgnoreAuth;
// 导入百度AI相关类
import com.baidu.aip.face.AipFace;
import com.baidu.aip.face.MatchRequest;
import com.baidu.aip.util.Base64Util;
// 导入MyBatis-Plus相关类
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
// 导入实体类
import com.entity.ConfigEntity;
// 导入服务类
import com.service.CommonService;
import com.service.ConfigService;
// 导入工具类
>>>>>>> develop
import com.utils.BaiduUtil;
import com.utils.FileUtil;
import com.utils.R;
<<<<<<< HEAD
/**
*
*/
@RestController
public class CommonController {
private static final Logger logger = LoggerFactory.getLogger(CommonController.class);
=======
// 导入Spring框架核心注解和工具类
import org.springframework.beans.factory.annotation.Autowired; // 自动依赖注入注解
import org.springframework.beans.factory.annotation.Value; // 配置文件值注入注解
import org.springframework.util.ResourceUtils; // Spring资源工具类
// 导入Spring MVC控制器相关注解
import org.springframework.web.bind.annotation.PathVariable; // 路径变量注解
import org.springframework.web.bind.annotation.RequestBody; // 请求体注解
import org.springframework.web.bind.annotation.RequestMapping; // 请求映射注解
import org.springframework.web.bind.annotation.RequestParam; // 请求参数注解
import org.springframework.web.bind.annotation.RestController; // REST控制器注解
// 导入项目自定义注解
import com.annotation.IgnoreAuth; // 忽略认证的自定义注解
//通用接口控制器
//提供系统通用的各种功能接口
// 导入百度AI人脸识别SDK相关类
import com.baidu.aip.face.AipFace; // 百度人脸识别客户端主类
import com.baidu.aip.face.MatchRequest; // 人脸比对请求类
import com.baidu.aip.util.Base64Util; // 百度Base64编码工具类
// 导入MyBatis-Plus ORM框架相关类
import com.baomidou.mybatisplus.mapper.EntityWrapper; // 实体条件构造器
import com.baomidou.mybatisplus.mapper.Wrapper; // 条件构造器接口
// 导入项目实体类
import com.entity.ConfigEntity; // 系统配置实体类
// 导入项目服务层接口
import com.service.CommonService; // 通用服务接口
import com.service.ConfigService; // 配置服务接口
// 导入项目工具类
import com.utils.BaiduUtil; // 百度AI工具类
import com.utils.FileUtil; // 文件操作工具类
import com.utils.R; // 统一响应结果封装类
//通用接口控制器
//提供系统通用的各种功能接口
@RestController // 标识这是一个RESTful风格的控制器
public class CommonController {
// 日志记录器使用slf4j的LoggerFactory创建
private static final Logger logger = LoggerFactory.getLogger(CommonController.class);
// 自动注入通用服务
>>>>>>> develop
@Autowired
private CommonService commonService;
<<<<<<< HEAD
/**
* JavaMySQL
*
* @param mysqlUrl MySQL
* @param hostIP MySQLIP
* @param userName
* @param hostPort
* @param password
* @param savePath
* @param fileName
* @param databaseName
* @return truefalse
*/
@IgnoreAuth
@RequestMapping("/beifen")
public R beifen(String mysqlUrl, String hostIP, String userName, String hostPort, String password, String savePath, String fileName, String databaseName) {
File saveFile = new File(savePath);
if (!saveFile.exists()) {// 如果目录不存在 
saveFile.mkdirs();// 创建文件夹 
}
if (!savePath.endsWith(File.separator)) {
savePath = savePath + File.separator;
}
PrintWriter printWriter = null;
BufferedReader bufferedReader = null;
try {
Runtime runtime = Runtime.getRuntime();
String cmd = mysqlUrl + "mysqldump -h" + hostIP + " -u" + userName + " -P" + hostPort + " -p" + password + " " + databaseName;
runtime.exec(cmd);
Process process = runtime.exec(cmd);
InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream(), "utf8");
bufferedReader = new BufferedReader(inputStreamReader);
printWriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(savePath + fileName), "utf8"));
String line;
while ((line = bufferedReader.readLine()) != null) {
printWriter.println(line);
}
printWriter.flush();
} catch (Exception e) {
e.printStackTrace();
return R.error("备份数据出错");
} finally {
=======
// * MySQL数据库备份接口
// * @param mysqlUrl MySQL安装路径
// * MySQL数据库备份接口
// * @param mysqlUrl MySQL安装路径
// * @param hostIP 数据库服务器IP
// * @param userName 数据库用户名
// * @param userName 数据库用户名
// * @param hostPort 数据库端口
//* @param password 数据库密码
//* @param savePath 备份文件保存路径
//* @param fileName 备份文件名
//* @param databaseName 要备份的数据库名
//* @return 操作结果
//* @param password 数据库密码
//* @param savePath 备份文件保存路径
//* @param fileName 备份文件名
//* @param databaseName 要备份的数据库名
//* @return 操作结果
@IgnoreAuth // 忽略权限验证
@RequestMapping("/beifen") // 映射请求路径
@ -219,7 +137,6 @@ public class CommonController {
return R.error("备份数据出错");
} finally {
// 在finally块中确保资源关闭
>>>>>>> develop
try {
if (bufferedReader != null) {
bufferedReader.close();
@ -231,57 +148,21 @@ public class CommonController {
e.printStackTrace();
}
}
<<<<<<< HEAD
return R.ok();
}
/**
* JavaMySQL
*
* @param mysqlUrl MySQL
* @param hostIP MySQLIP
* @param userName
* @param hostPort
* @param password
* @param savePath
* @param fileName
* @param databaseName
*/
@IgnoreAuth
@RequestMapping("/huanyuan")
public R huanyuan(String mysqlUrl, String hostIP, String userName, String hostPort, String password, String savePath, String fileName, String databaseName) {
try {
Runtime rt = Runtime.getRuntime();
Process child1 = rt.exec(mysqlUrl+"mysql.exe -h" + hostIP + " -u" + userName + " -P" + hostPort + " -p" + password + " " + databaseName);
OutputStream out = child1.getOutputStream();//控制台的输入信息作为输出流
String inStr;
StringBuffer sb = new StringBuffer("");
String outStr;
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(savePath+"/"+fileName), "utf-8"));
while ((inStr = br.readLine()) != null) {
sb.append(inStr + "\r\n");
}
outStr = sb.toString();
OutputStreamWriter writer = new OutputStreamWriter(out, "utf8");
writer.write(outStr);
// 注这里如果用缓冲方式写入文件的话会导致中文乱码用flush()方法则可以避免
writer.flush();
=======
// 返回成功结果
return R.ok();
}
//* MySQL数据库还原接口
//* MySQL数据库还原接口
// * @param mysqlUrl MySQL安装路径
// * @param hostIP 数据库服务器IP
//* @param userName 数据库用户名
//* @param userName 数据库用户名
// * @param hostPort 数据库端口
// * @param password 数据库密码
// * @param savePath 备份文件路径
// * @param fileName 备份文件名
// * @param savePath 备份文件路径
// * @param fileName 备份文件名
// * @param databaseName 要还原的数据库名
//* @return 操作结果
//* @return 操作结果
@IgnoreAuth // 忽略权限验证
@RequestMapping("/huanyuan") // 映射请求路径
@ -316,102 +197,22 @@ public class CommonController {
writer.flush();
// 关闭资源
>>>>>>> develop
out.close();
br.close();
writer.close();
} catch (Exception e) {
<<<<<<< HEAD
e.printStackTrace();
return R.error("数据导入出错");
}
=======
// 打印异常堆栈
e.printStackTrace();
// 返回错误信息
return R.error("数据导入出错");
}
// 返回成功结果
>>>>>>> develop
return R.ok();
}
<<<<<<< HEAD
/**
*
* @return
*/
@RequestMapping("/pieSum")
public R pieSum(@RequestParam Map<String,Object> params) {
logger.debug("饼状图求和:,,Controller:{},,params:{}",this.getClass().getName(),params);
List<Map<String, Object>> result = commonService.pieSum(params);
return R.ok().put("data", result);
}
/**
*
* @return
*/
@RequestMapping("/pieCount")
public R pieCount(@RequestParam Map<String,Object> params) {
logger.debug("饼状图统计:,,Controller:{},,params:{}",this.getClass().getName(),params);
List<Map<String, Object>> result = commonService.pieCount(params);
return R.ok().put("data", result);
}
/**
*
* @return
*/
@RequestMapping("/barSumOne")
public R barSumOne(@RequestParam Map<String,Object> params) {
logger.debug("柱状图求和单列:,,Controller:{},,params:{}",this.getClass().getName(),params);
List<Map<String, Object>> result = commonService.barSumOne(params);
List<String> xAxis = new ArrayList<>();//报表x轴
List<List<String>> yAxis = new ArrayList<>();//y轴
List<String> legend = new ArrayList<>();//标题
List<String> yAxis0 = new ArrayList<>();
yAxis.add(yAxis0);
legend.add("");
for(Map<String, Object> map :result){
String oneValue = String.valueOf(map.get("name"));
String value = String.valueOf(map.get("value"));
xAxis.add(oneValue);
yAxis0.add(value);
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("xAxis",xAxis);
resultMap.put("yAxis",yAxis);
resultMap.put("legend",legend);
return R.ok().put("data", resultMap);
}
/**
*
* @return
*/
@RequestMapping("/barCountOne")
public R barCountOne(@RequestParam Map<String,Object> params) {
logger.debug("柱状图统计单列:,,Controller:{},,params:{}",this.getClass().getName(),params);
List<Map<String, Object>> result = commonService.barCountOne(params);
List<String> xAxis = new ArrayList<>();//报表x轴
List<List<String>> yAxis = new ArrayList<>();//y轴
List<String> legend = new ArrayList<>();//标题
List<String> yAxis0 = new ArrayList<>();
yAxis.add(yAxis0);
legend.add("");
for(Map<String, Object> map :result){
String oneValue = String.valueOf(map.get("name"));
String value = String.valueOf(map.get("value"));
xAxis.add(oneValue);
yAxis0.add(value);
}
=======
// * 饼状图求和接口
//* @param params 请求参数Map
//* @param params 请求参数Map
// * @return 包含求和结果的响应
@RequestMapping("/pieSum") // 映射请求路径
@ -427,7 +228,7 @@ public class CommonController {
// * 饼状图统计接口
// * @param params 请求参数Map
//* @return 包含统计结果的响应
//* @return 包含统计结果的响应
@RequestMapping("/pieCount") // 映射请求路径
public R pieCount(@RequestParam Map<String,Object> params) {
@ -439,9 +240,9 @@ public class CommonController {
return R.ok().put("data", result);
}
// * 单列柱状图求和接口
// * 单列柱状图求和接口
// * @param params 请求参数Map
//* @return 包含图表数据的响应
//* @return 包含图表数据的响应
@RequestMapping("/barSumOne") // 映射请求路径
public R barSumOne(@RequestParam Map<String,Object> params) {
@ -469,476 +270,10 @@ public class CommonController {
}
// 构建结果Map
>>>>>>> develop
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("xAxis",xAxis);
resultMap.put("yAxis",yAxis);
resultMap.put("legend",legend);
<<<<<<< HEAD
return R.ok().put("data", resultMap);
}
/**
*
* @return
*/
@RequestMapping("/barSumTwo")
public R barSumTwo(@RequestParam Map<String,Object> params) {
logger.debug("柱状图统计双列:,,Controller:{},,params:{}",this.getClass().getName(),params);
List<Map<String, Object>> result = commonService.barSumTwo(params);
List<String> xAxis = new ArrayList<>();//报表x轴
List<List<String>> yAxis = new ArrayList<>();//y轴
List<String> legend = new ArrayList<>();//标题
Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();
for(Map<String, Object> map :result){
String name1Value = String.valueOf(map.get("name1"));
String name2Value = String.valueOf(map.get("name2"));
String value = String.valueOf(map.get("value"));
if(!legend.contains(name2Value)){
legend.add(name2Value);//添加完成后 就是最全的第二列的类型
}
if(dataMap.containsKey(name1Value)){
dataMap.get(name1Value).put(name2Value,value);
}else{
HashMap<String, String> name1Data = new HashMap<>();
name1Data.put(name2Value,value);
dataMap.put(name1Value,name1Data);
}
}
for(int i =0; i<legend.size(); i++){
yAxis.add(new ArrayList<String>());
}
Set<String> keys = dataMap.keySet();
for(String key:keys){
xAxis.add(key);
HashMap<String, String> map = dataMap.get(key);
for(int i =0; i<legend.size(); i++){
List<String> data = yAxis.get(i);
if(StringUtil.isNotEmpty(map.get(legend.get(i)))){
data.add(map.get(legend.get(i)));
}else{
data.add("0");
}
}
}
System.out.println();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("xAxis",xAxis);
resultMap.put("yAxis",yAxis);
resultMap.put("legend",legend);
return R.ok().put("data", resultMap);
}
/**
*
* @return
*/
@RequestMapping("/barCountTwo")
public R barCountTwo(@RequestParam Map<String,Object> params) {
logger.debug("柱状图统计双列:,,Controller:{},,params:{}",this.getClass().getName(),params);
List<Map<String, Object>> result = commonService.barCountTwo(params);
List<String> xAxis = new ArrayList<>();//报表x轴
List<List<String>> yAxis = new ArrayList<>();//y轴
List<String> legend = new ArrayList<>();//标题
Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();
for(Map<String, Object> map :result){
String name1Value = String.valueOf(map.get("name1"));
String name2Value = String.valueOf(map.get("name2"));
String value = String.valueOf(map.get("value"));
if(!legend.contains(name2Value)){
legend.add(name2Value);//添加完成后 就是最全的第二列的类型
}
if(dataMap.containsKey(name1Value)){
dataMap.get(name1Value).put(name2Value,value);
}else{
HashMap<String, String> name1Data = new HashMap<>();
name1Data.put(name2Value,value);
dataMap.put(name1Value,name1Data);
}
}
for(int i =0; i<legend.size(); i++){
yAxis.add(new ArrayList<String>());
}
Set<String> keys = dataMap.keySet();
for(String key:keys){
xAxis.add(key);
HashMap<String, String> map = dataMap.get(key);
for(int i =0; i<legend.size(); i++){
List<String> data = yAxis.get(i);
if(StringUtil.isNotEmpty(map.get(legend.get(i)))){
data.add(map.get(legend.get(i)));
}else{
data.add("0");
}
}
}
System.out.println();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("xAxis",xAxis);
resultMap.put("yAxis",yAxis);
resultMap.put("legend",legend);
return R.ok().put("data", resultMap);
}
/**
tableName
condition1 1
condition1Value 1
average
Number(res.data.value.toFixed(1))
if(res.data){}
* */
@IgnoreAuth
@RequestMapping("/queryScore")
public R queryScore(@RequestParam Map<String, Object> params) {
logger.debug("queryScore:,,Controller:{},,params:{}",this.getClass().getName(),params);
Map<String, Object> queryScore = commonService.queryScore(params);
return R.ok().put("data", queryScore);
}
/**
*
* tableName
* groupColumn
* @return
*/
@RequestMapping("/newSelectGroupCount")
public R newSelectGroupCount(@RequestParam Map<String,Object> params) {
logger.debug("newSelectGroupCount:,,Controller:{},,params:{}",this.getClass().getName(),params);
List<Map<String, Object>> result = commonService.newSelectGroupCount(params);
return R.ok().put("data", result);
}
/**
*
* tableName
* groupColumn
* sumCloum
* @return
*/
@RequestMapping("/newSelectGroupSum")
public R newSelectGroupSum(@RequestParam Map<String,Object> params) {
logger.debug("newSelectGroupSum:,,Controller:{},,params:{}",this.getClass().getName(),params);
List<Map<String, Object>> result = commonService.newSelectGroupSum(params);
return R.ok().put("data", result);
}
/**
*
*/
@RequestMapping("/barSum")
public R barSum(@RequestParam Map<String,Object> params) {
logger.debug("barSum方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));
Boolean isJoinTableFlag = false;//是否有级联表相关
String one = "";//第一优先
String two = "";//第二优先
//处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组
//当前表
Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);
params.put("thisTable",thisTable);
//级联表
String joinTableString = String.valueOf(params.get("joinTable"));
if(StringUtil.isNotEmpty(joinTableString)) {
Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
params.put("joinTable", joinTable);
isJoinTableFlag = true;
}
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//当前表日期
thisTable.put("date",String.valueOf(thisTable.get("date")).split(","));
one = "thisDate0";
}
if(isJoinTableFlag){//级联表日期
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){
joinTable.put("date",String.valueOf(joinTable.get("date")).split(","));
if(StringUtil.isEmpty(one)){
one ="joinDate0";
}else{
if(StringUtil.isEmpty(two)){
two ="joinDate0";
}
}
}
}
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//当前表字符串
thisTable.put("string",String.valueOf(thisTable.get("string")).split(","));
if(StringUtil.isEmpty(one)){
one ="thisString0";
}else{
if(StringUtil.isEmpty(two)){
two ="thisString0";
}
}
}
if(isJoinTableFlag){//级联表字符串
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){
joinTable.put("string",String.valueOf(joinTable.get("string")).split(","));
if(StringUtil.isEmpty(one)){
one ="joinString0";
}else{
if(StringUtil.isEmpty(two)){
two ="joinString0";
}
}
}
}
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//当前表类型
thisTable.put("types",String.valueOf(thisTable.get("types")).split(","));
if(StringUtil.isEmpty(one)){
one ="thisTypes0";
}else{
if(StringUtil.isEmpty(two)){
two ="thisTypes0";
}
}
}
if(isJoinTableFlag){//级联表类型
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){
joinTable.put("types",String.valueOf(joinTable.get("types")).split(","));
if(StringUtil.isEmpty(one)){
one ="joinTypes0";
}else{
if(StringUtil.isEmpty(two)){
two ="joinTypes0";
}
}
}
}
List<Map<String, Object>> result = commonService.barSum(params);
List<String> xAxis = new ArrayList<>();//报表x轴
List<List<String>> yAxis = new ArrayList<>();//y轴
List<String> legend = new ArrayList<>();//标题
if(StringUtil.isEmpty(two)){//不包含第二列
List<String> yAxis0 = new ArrayList<>();
yAxis.add(yAxis0);
legend.add("");
for(Map<String, Object> map :result){
String oneValue = String.valueOf(map.get(one));
String value = String.valueOf(map.get("value"));
xAxis.add(oneValue);
yAxis0.add(value);
}
}else{//包含第二列
Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();
if(StringUtil.isNotEmpty(two)){
for(Map<String, Object> map :result){
String oneValue = String.valueOf(map.get(one));
String twoValue = String.valueOf(map.get(two));
String value = String.valueOf(map.get("value"));
if(!legend.contains(twoValue)){
legend.add(twoValue);//添加完成后 就是最全的第二列的类型
}
if(dataMap.containsKey(oneValue)){
dataMap.get(oneValue).put(twoValue,value);
}else{
HashMap<String, String> oneData = new HashMap<>();
oneData.put(twoValue,value);
dataMap.put(oneValue,oneData);
}
}
}
for(int i =0; i<legend.size(); i++){
yAxis.add(new ArrayList<String>());
}
Set<String> keys = dataMap.keySet();
for(String key:keys){
xAxis.add(key);
HashMap<String, String> map = dataMap.get(key);
for(int i =0; i<legend.size(); i++){
List<String> data = yAxis.get(i);
if(StringUtil.isNotEmpty(map.get(legend.get(i)))){
data.add(map.get(legend.get(i)));
}else{
data.add("0");
}
}
}
System.out.println();
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("xAxis",xAxis);
resultMap.put("yAxis",yAxis);
resultMap.put("legend",legend);
return R.ok().put("data", resultMap);
}
/**
*
*/
@RequestMapping("/barCount")
public R barCount(@RequestParam Map<String,Object> params) {
logger.debug("barCount方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));
Boolean isJoinTableFlag = false;//是否有级联表相关
String one = "";//第一优先
String two = "";//第二优先
//处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组
//当前表
Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);
params.put("thisTable",thisTable);
//级联表
String joinTableString = String.valueOf(params.get("joinTable"));
if(StringUtil.isNotEmpty(joinTableString)) {
Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
params.put("joinTable", joinTable);
isJoinTableFlag = true;
}
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//当前表日期
thisTable.put("date",String.valueOf(thisTable.get("date")).split(","));
one = "thisDate0";
}
if(isJoinTableFlag){//级联表日期
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){
joinTable.put("date",String.valueOf(joinTable.get("date")).split(","));
if(StringUtil.isEmpty(one)){
one ="joinDate0";
}else{
if(StringUtil.isEmpty(two)){
two ="joinDate0";
}
}
}
}
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//当前表字符串
thisTable.put("string",String.valueOf(thisTable.get("string")).split(","));
if(StringUtil.isEmpty(one)){
one ="thisString0";
}else{
if(StringUtil.isEmpty(two)){
two ="thisString0";
}
}
}
if(isJoinTableFlag){//级联表字符串
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){
joinTable.put("string",String.valueOf(joinTable.get("string")).split(","));
if(StringUtil.isEmpty(one)){
one ="joinString0";
}else{
if(StringUtil.isEmpty(two)){
two ="joinString0";
}
}
}
}
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//当前表类型
thisTable.put("types",String.valueOf(thisTable.get("types")).split(","));
if(StringUtil.isEmpty(one)){
one ="thisTypes0";
}else{
if(StringUtil.isEmpty(two)){
two ="thisTypes0";
}
}
}
if(isJoinTableFlag){//级联表类型
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){
joinTable.put("types",String.valueOf(joinTable.get("types")).split(","));
if(StringUtil.isEmpty(one)){
one ="joinTypes0";
}else{
if(StringUtil.isEmpty(two)){
two ="joinTypes0";
}
}
}
}
List<Map<String, Object>> result = commonService.barCount(params);
List<String> xAxis = new ArrayList<>();//报表x轴
List<List<String>> yAxis = new ArrayList<>();//y轴
List<String> legend = new ArrayList<>();//标题
if(StringUtil.isEmpty(two)){//不包含第二列
List<String> yAxis0 = new ArrayList<>();
yAxis.add(yAxis0);
legend.add("");
for(Map<String, Object> map :result){
String oneValue = String.valueOf(map.get(one));
String value = String.valueOf(map.get("value"));
xAxis.add(oneValue);
yAxis0.add(value);
}
}else{//包含第二列
Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();
if(StringUtil.isNotEmpty(two)){
for(Map<String, Object> map :result){
String oneValue = String.valueOf(map.get(one));
String twoValue = String.valueOf(map.get(two));
String value = String.valueOf(map.get("value"));
if(!legend.contains(twoValue)){
legend.add(twoValue);//添加完成后 就是最全的第二列的类型
}
if(dataMap.containsKey(oneValue)){
dataMap.get(oneValue).put(twoValue,value);
}else{
HashMap<String, String> oneData = new HashMap<>();
oneData.put(twoValue,value);
dataMap.put(oneValue,oneData);
}
}
}
for(int i =0; i<legend.size(); i++){
yAxis.add(new ArrayList<String>());
}
Set<String> keys = dataMap.keySet();
for(String key:keys){
xAxis.add(key);
HashMap<String, String> map = dataMap.get(key);
for(int i =0; i<legend.size(); i++){
List<String> data = yAxis.get(i);
if(StringUtil.isNotEmpty(map.get(legend.get(i)))){
data.add(map.get(legend.get(i)));
}else{
data.add("0");
}
}
}
System.out.println();
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("xAxis",xAxis);
resultMap.put("yAxis",yAxis);
resultMap.put("legend",legend);
return R.ok().put("data", resultMap);
}
}
=======
// 返回成功结果和数据
return R.ok().put("data", resultMap);
}
@ -959,5 +294,4 @@ public class CommonController {
// - 返回值说明
// - 关键处理逻辑说明
// - 异常处理说明
}
>>>>>>> develop
}

@ -1,116 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.util.Arrays;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.service.ConfigService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;
/**
*
*/
@RequestMapping("config")
@RestController
public class ConfigController{
@Autowired
private ConfigService configService;
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ConfigEntity config){
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
PageUtils page = configService.queryPage(params);
return R.ok().put("data", page);
}
/**
*
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ConfigEntity config){
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
PageUtils page = configService.queryPage(params);
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
ConfigEntity config = configService.selectById(id);
return R.ok().put("data", config);
}
/**
*
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") String id){
ConfigEntity config = configService.selectById(id);
return R.ok().put("data", config);
}
/**
* name
*/
@RequestMapping("/info")
public R infoByName(@RequestParam String name){
ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
return R.ok().put("data", config);
}
/**
*
*/
@PostMapping("/save")
public R save(@RequestBody ConfigEntity config){
// ValidatorUtils.validateEntity(config);
configService.insert(config);
return R.ok();
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody ConfigEntity config){
// ValidatorUtils.validateEntity(config);
configService.updateById(config);//全部更新
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
configService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}
=======
package com.controller;
import java.util.Arrays; // 导入Java的Arrays类用于操作数组
@ -166,7 +53,7 @@ public class ConfigController {
}
// 详情
// 详情
@IgnoreAuth // 忽略认证注解
@RequestMapping("/detail/{id}") // 映射请求路径为 "/detail/{id}"
public R detail(@PathVariable("id") String id) { // 从路径变量中获取 id 参数
@ -175,7 +62,7 @@ public class ConfigController {
}
// 根据name获取信息
// 根据name获取信息
@RequestMapping("/info") // 映射请求路径为 "/info"
public R infoByName(@RequestParam String name) { // 从请求参数中获取 name 参数
@ -184,7 +71,7 @@ public class ConfigController {
}
// 保存
// 保存
@PostMapping("/save") // 映射请求路径为 "/save",并指定请求方法为 POST
public R save(@RequestBody ConfigEntity config) { // 从请求体中获取配置实体对象
// ValidatorUtils.validateEntity(config); // 验证实体(注释掉)
@ -193,7 +80,7 @@ public class ConfigController {
}
//修改
//修改
@RequestMapping("/update") // 映射请求路径为 "/update"
public R update(@RequestBody ConfigEntity config) { // 从请求体中获取配置实体对象
@ -210,4 +97,3 @@ public class ConfigController {
}
}
>>>>>>> develop

@ -1,274 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
*
*
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/dictionary")
public class DictionaryController {
private static final Logger logger = LoggerFactory.getLogger(DictionaryController.class);
private static final String TABLE_NAME = "dictionary";
@Autowired
private DictionaryService dictionaryService;
@Autowired
private TokenService tokenService;
@Autowired
private ForumService forumService;//健身论坛
@Autowired
private JianshenkechengService jianshenkechengService;//健身课程
@Autowired
private JianshenkechengCollectionService jianshenkechengCollectionService;//课程收藏
@Autowired
private JianshenkechengLiuyanService jianshenkechengLiuyanService;//课程留言
@Autowired
private JiaolianService jiaolianService;//教练
@Autowired
private JiaolianYuyueService jiaolianYuyueService;//教练预约申请
@Autowired
private NewsService newsService;//健身资讯
@Autowired
private SingleSeachService singleSeachService;//单页数据
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
*
*/
@RequestMapping("/page")
@IgnoreAuth
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
PageUtils page = dictionaryService.queryPage(params);
//字典表数据转换
List<DictionaryView> list =(List<DictionaryView>)page.getList();
for(DictionaryView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
DictionaryEntity dictionary = dictionaryService.selectById(id);
if(dictionary !=null){
//entity转view
DictionaryView view = new DictionaryView();
BeanUtils.copyProperties( dictionary , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
@RequestMapping("/save")
public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.eq("dic_code", dictionary.getDicCode())
.eq("index_name", dictionary.getIndexName())
;
if(dictionary.getDicCode().contains("_erji_types")){
queryWrapper.eq("super_id",dictionary.getSuperId());
}
logger.info("sql语句:"+queryWrapper.getSqlSegment());
DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper);
if(dictionaryEntity==null){
dictionary.setCreateTime(new Date());
dictionaryService.insert(dictionary);
//字典表新增数据,把数据再重新查出,放入监听器中
List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
ServletContext servletContext = request.getServletContext();
Map<String, Map<Integer,String>> map = new HashMap<>();
for(DictionaryEntity d :dictionaryEntities){
Map<Integer, String> m = map.get(d.getDicCode());
if(m ==null || m.isEmpty()){
m = new HashMap<>();
}
m.put(d.getCodeIndex(),d.getIndexName());
map.put(d.getDicCode(),m);
}
servletContext.setAttribute("dictionaryMap",map);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
DictionaryEntity oldDictionaryEntity = dictionaryService.selectById(dictionary.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
dictionaryService.updateById(dictionary);//根据id更新
//如果字典表修改数据的话,把数据再重新查出,放入监听器中
List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
ServletContext servletContext = request.getServletContext();
Map<String, Map<Integer,String>> map = new HashMap<>();
for(DictionaryEntity d :dictionaryEntities){
Map<Integer, String> m = map.get(d.getDicCode());
if(m ==null || m.isEmpty()){
m = new HashMap<>();
}
m.put(d.getCodeIndex(),d.getIndexName());
map.put(d.getDicCode(),m);
}
servletContext.setAttribute("dictionaryMap",map);
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<DictionaryEntity> oldDictionaryList =dictionaryService.selectBatchIds(Arrays.asList(ids));//要删除的数据
dictionaryService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
*
*/
@RequestMapping("/maxCodeIndex")
public R maxCodeIndex(@RequestBody DictionaryEntity dictionary){
logger.debug("maxCodeIndex:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
List<String> descs = new ArrayList<>();
descs.add("code_index");
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.eq("dic_code", dictionary.getDicCode())
.orderDesc(descs);
logger.info("sql语句:"+queryWrapper.getSqlSegment());
List<DictionaryEntity> dictionaryEntityList = dictionaryService.selectList(queryWrapper);
if(dictionaryEntityList.size()>0 ){
return R.ok().put("maxCodeIndex",dictionaryEntityList.get(0).getCodeIndex()+1);
}else{
return R.ok().put("maxCodeIndex",1);
}
}
/**
*
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<DictionaryEntity> dictionaryList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
DictionaryEntity dictionaryEntity = new DictionaryEntity();
// dictionaryEntity.setDicCode(data.get(0)); //字段 要改的
// dictionaryEntity.setDicName(data.get(0)); //字段名 要改的
// dictionaryEntity.setCodeIndex(Integer.valueOf(data.get(0))); //编码 要改的
// dictionaryEntity.setIndexName(data.get(0)); //编码名字 要改的
// dictionaryEntity.setSuperId(Integer.valueOf(data.get(0))); //父字段id 要改的
// dictionaryEntity.setBeizhu(data.get(0)); //备注 要改的
// dictionaryEntity.setCreateTime(date);//时间
dictionaryList.add(dictionaryEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
dictionaryService.insertBatch(dictionaryList);
return R.ok();
=======
package com.controller;
// 文件操作相关类
import java.io.File;
@ -330,10 +59,10 @@ import com.utils.R;
// FastJSON包
import com.alibaba.fastjson.*;
//字典
//后端接口
//@author
// @email
//字典
//后端接口
//@author
// @email
@RestController // 声明这是一个RESTful风格的控制器
@Controller // 声明这是一个Spring MVC控制器
@ -371,7 +100,7 @@ public class DictionaryController {
private UsersService usersService; // 注入管理员服务
//后端列表
//后端列表
@RequestMapping("/page") // 处理分页请求
@IgnoreAuth // 忽略鉴权
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
@ -389,7 +118,7 @@ public class DictionaryController {
}
//后端详情
//后端详情
@RequestMapping("/info/{id}") // 处理详情请求
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录日志
@ -407,7 +136,7 @@ public class DictionaryController {
}
//后端保存
//后端保存
@RequestMapping("/save") // 处理保存请求
public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString()); // 记录日志
@ -448,7 +177,7 @@ public class DictionaryController {
}
//后端修改
//后端修改
@RequestMapping("/update") // 处理更新请求
public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString()); // 记录日志
@ -476,7 +205,7 @@ public class DictionaryController {
}
//删除
//删除
@RequestMapping("/delete") // 处理删除请求
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); // 记录日志
@ -487,7 +216,7 @@ public class DictionaryController {
}
//最大值
//最大值
@RequestMapping("/maxCodeIndex") // 处理获取最大编码请求
public R maxCodeIndex(@RequestBody DictionaryEntity dictionary){
logger.debug("maxCodeIndex:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString()); // 记录日志
@ -506,7 +235,7 @@ public class DictionaryController {
}
//批量上传
//批量上传
@RequestMapping("/batchInsert") // 处理批量上传请求
public R save(String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); // 记录日志
@ -545,26 +274,12 @@ public class DictionaryController {
}
dictionaryService.insertBatch(dictionaryList); // 批量插入数据
return R.ok(); // 返回成功响应
>>>>>>> develop
}
}
}
}catch (Exception e){
<<<<<<< HEAD
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
}
=======
e.printStackTrace(); // 打印异常堆栈
return R.error(511,"批量插入数据异常,请联系管理员"); // 返回错误响应
}
}
}
>>>>>>> develop

@ -1,114 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;
/**
*
*/
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
@Autowired
private ConfigService configService;
/**
*
*/
@RequestMapping("/upload")
public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
if (file.isEmpty()) {
throw new EIException("上传文件不能为空");
}
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if(!path.exists()) {
path = new File("");
}
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) {
upload.mkdirs();
}
String fileName = new Date().getTime()+"."+fileExt;
File dest = new File(upload.getAbsolutePath()+"/"+fileName);
file.transferTo(dest);
if(StringUtils.isNotBlank(type) && type.equals("1")) {
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
if(configEntity==null) {
configEntity = new ConfigEntity();
configEntity.setName("faceFile");
configEntity.setValue(fileName);
} else {
configEntity.setValue(fileName);
}
configService.insertOrUpdate(configEntity);
}
return R.ok().put("file", fileName);
}
/**
*
*/
@IgnoreAuth
@RequestMapping("/download")
public ResponseEntity<byte[]> download(@RequestParam String fileName) {
try {
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if(!path.exists()) {
path = new File("");
}
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) {
upload.mkdirs();
}
File file = new File(upload.getAbsolutePath()+"/"+fileName);
if(file.exists()){
/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
getResponse().sendError(403);
}*/
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentDispositionFormData("attachment", fileName);
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
}
} catch (IOException e) {
e.printStackTrace();
}
return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
}
=======
package com.controller; // 定义包路径
// 文件操作相关类
@ -175,8 +64,8 @@ import com.service.ConfigService;
import com.utils.R;
//上传文件映射表
//文件上传下载控制器
//上传文件映射表
//文件上传下载控制器
@RestController // 声明为RESTful控制器
@RequestMapping("file") // 基础请求路径映射
@SuppressWarnings({"unchecked","rawtypes"}) // 抑制警告
@ -185,11 +74,11 @@ public class FileController{
private ConfigService configService;
//上传文件
//@param file 上传的文件对象
//@param type 文件类型标识
//@return 上传结果
//* @throws Exception 可能抛出的异常
//上传文件
//@param file 上传的文件对象
//@param type 文件类型标识
//@return 上传结果
//* @throws Exception 可能抛出的异常
@RequestMapping("/upload") // 文件上传请求映射
public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
@ -233,9 +122,9 @@ public class FileController{
}
//下载文件
//@param fileName 要下载的文件名
// @return 文件下载响应
//下载文件
//@param fileName 要下载的文件名
// @return 文件下载响应
@IgnoreAuth // 忽略权限验证
@RequestMapping("/download") // 文件下载请求映射
@ -267,5 +156,4 @@ public class FileController{
// 返回服务器错误响应
return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
}
>>>>>>> develop
}

@ -1,45 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
*
*
* @author
* @email
*/
=======
package com.controller;// 定义包路径表示该文件位于com.controller包下
import java.io.File; // 导入文件操作类
@ -74,120 +32,17 @@ import com.utils.R; // 导入统一返回结果类
import com.alibaba.fastjson.*; // 导入FastJSON相关类
//健身论坛
//后端接口
//@author
//@email
//健身论坛
//后端接口
//@author
//@email
>>>>>>> develop
@RestController
@Controller
@RequestMapping("/forum")
public class ForumController {
private static final Logger logger = LoggerFactory.getLogger(ForumController.class);
<<<<<<< HEAD
private static final String TABLE_NAME = "forum";
@Autowired
private ForumService forumService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private JianshenkechengService jianshenkechengService;//健身课程
@Autowired
private JianshenkechengCollectionService jianshenkechengCollectionService;//课程收藏
@Autowired
private JianshenkechengLiuyanService jianshenkechengLiuyanService;//课程留言
@Autowired
private JiaolianService jiaolianService;//教练
@Autowired
private JiaolianYuyueService jiaolianYuyueService;//教练预约申请
@Autowired
private NewsService newsService;//健身资讯
@Autowired
private SingleSeachService singleSeachService;//单页数据
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
PageUtils page = forumService.queryPage(params);
//字典表数据转换
List<ForumView> list =(List<ForumView>)page.getList();
for(ForumView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
ForumEntity forum = forumService.selectById(id);
if(forum !=null){
//entity转view
ForumView view = new ForumView();
BeanUtils.copyProperties( forum , view );//把实体数据重构到view中
//级联表 用户
//级联表
YonghuEntity yonghu = yonghuService.selectById(forum.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"
, "jiaolianId"
, "usersId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setYonghuId(yonghu.getId());
}
//级联表 教练
//级联表
JiaolianEntity jiaolian = jiaolianService.selectById(forum.getJiaolianId());
if(jiaolian != null){
BeanUtils.copyProperties( jiaolian , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"
, "jiaolianId"
, "usersId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setJiaolianId(jiaolian.getId());
}
//级联表 管理员
//管理员表做额外的处理
UsersEntity users = usersService.selectById(forum.getUsersId());
if(users != null){
view.setUsersId(users.getId());
view.setUusername(users.getUsername());
view.setUpassword(users.getPassword());
view.setUrole(users.getRole());
view.setUaddtime(users.getAddtime());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
=======
private static final String TABLE_NAME = "forum"; // 数据库表名
@Autowired
@ -218,7 +73,7 @@ public class ForumController {
private UsersService usersService; // 管理员服务
//后端列表
//后端列表
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
@ -235,7 +90,7 @@ public class ForumController {
}
//后端详情
//后端详情
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
@ -278,81 +133,11 @@ public class ForumController {
}
//后端保存
>>>>>>> develop
//后端保存
@RequestMapping("/save")
public R save(@RequestBody ForumEntity forum, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,forum:{}",this.getClass().getName(),forum.toString());
<<<<<<< HEAD
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("用户".equals(role))
forum.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
else if("教练".equals(role))
forum.setJiaolianId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
else if("管理员".equals(role))
forum.setUsersId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
Wrapper<ForumEntity> queryWrapper = new EntityWrapper<ForumEntity>()
.eq("forum_name", forum.getForumName())
.eq("yonghu_id", forum.getYonghuId())
.eq("jiaolian_id", forum.getJiaolianId())
.eq("users_id", forum.getUsersId())
.eq("super_ids", forum.getSuperIds())
.eq("forum_state_types", forum.getForumStateTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
ForumEntity forumEntity = forumService.selectOne(queryWrapper);
if(forumEntity==null){
forum.setInsertTime(new Date());
forum.setCreateTime(new Date());
forumService.insert(forum);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody ForumEntity forum, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,forum:{}",this.getClass().getName(),forum.toString());
ForumEntity oldForumEntity = forumService.selectById(forum.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("用户".equals(role))
// forum.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
// else if("教练".equals(role))
// forum.setJiaolianId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
// else if("管理员".equals(role))
// forum.setUsersId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
if("".equals(forum.getForumContent()) || "null".equals(forum.getForumContent())){
forum.setForumContent(null);
}
forum.setUpdateTime(new Date());
forumService.updateById(forum);//根据id更新
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<ForumEntity> oldForumList =forumService.selectBatchIds(Arrays.asList(ids));//要删除的数据
forumService.deleteBatchIds(Arrays.asList(ids));
=======
String role = String.valueOf(request.getSession().getAttribute("role")); // 获取用户角色
if(false)
return R.error(511,"永远不会进入");
@ -385,7 +170,7 @@ public class ForumController {
}
//后端修改
//后端修改
@RequestMapping("/update")
public R update(@RequestBody ForumEntity forum, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,forum:{}",this.getClass().getName(),forum.toString());
@ -402,69 +187,18 @@ public class ForumController {
}
//删除
//删除
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<ForumEntity> oldForumList =forumService.selectBatchIds(Arrays.asList(ids)); // 查询要删除的数据
forumService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
>>>>>>> develop
return R.ok();
}
<<<<<<< HEAD
/**
*
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<ForumEntity> forumList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
ForumEntity forumEntity = new ForumEntity();
// forumEntity.setForumName(data.get(0)); //帖子标题 要改的
// forumEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的
// forumEntity.setJiaolianId(Integer.valueOf(data.get(0))); //教练 要改的
// forumEntity.setUsersId(Integer.valueOf(data.get(0))); //管理员 要改的
// forumEntity.setForumContent("");//详情和图片
// forumEntity.setSuperIds(Integer.valueOf(data.get(0))); //父id 要改的
// forumEntity.setForumStateTypes(Integer.valueOf(data.get(0))); //帖子状态 要改的
// forumEntity.setInsertTime(date);//时间
// forumEntity.setUpdateTime(sdf.parse(data.get(0))); //修改时间 要改的
// forumEntity.setCreateTime(date);//时间
forumList.add(forumEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
=======
//批量上传
//批量上传
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
@ -495,7 +229,6 @@ public class ForumController {
forumList.add(forumEntity); // 添加到列表
}
// 批量插入数据
>>>>>>> develop
forumService.insertBatch(forumList);
return R.ok();
}
@ -503,19 +236,6 @@ public class ForumController {
}
}catch (Exception e){
e.printStackTrace();
<<<<<<< HEAD
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
/**
*
*/
@IgnoreAuth
=======
return R.error(511,"批量插入数据异常,请联系管理员"); // 异常处理
}
}
@ -523,74 +243,10 @@ public class ForumController {
// 前端列表
@IgnoreAuth // 忽略认证
>>>>>>> develop
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
<<<<<<< HEAD
CommonUtil.checkMap(params);
PageUtils page = forumService.queryPage(params);
//字典表数据转换
List<ForumView> list =(List<ForumView>)page.getList();
for(ForumView c:list)
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
ForumEntity forum = forumService.selectById(id);
if(forum !=null){
//entity转view
ForumView view = new ForumView();
BeanUtils.copyProperties( forum , view );//把实体数据重构到view中
//级联表
YonghuEntity yonghu = yonghuService.selectById(forum.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"
, "jiaolianId"
, "usersId"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//级联表
JiaolianEntity jiaolian = jiaolianService.selectById(forum.getJiaolianId());
if(jiaolian != null){
BeanUtils.copyProperties( jiaolian , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"
, "jiaolianId"
, "usersId"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setJiaolianId(jiaolian.getId());
}
UsersEntity users = usersService.selectById(forum.getUsersId());
if(users != null){
view.setUsersId(users.getId());
view.setUusername(users.getUsername());
view.setUpassword(users.getPassword());
view.setUrole(users.getRole());
view.setUaddtime(users.getAddtime());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
=======
CommonUtil.checkMap(params); // 检查参数
PageUtils page = forumService.queryPage(params); // 查询分页数据
@ -603,7 +259,7 @@ public class ForumController {
}
//前端详情
//前端详情
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
@ -647,37 +303,11 @@ public class ForumController {
}
//前端保存
>>>>>>> develop
//前端保存
@RequestMapping("/add")
public R add(@RequestBody ForumEntity forum, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,forum:{}",this.getClass().getName(),forum.toString());
Wrapper<ForumEntity> queryWrapper = new EntityWrapper<ForumEntity>()
<<<<<<< HEAD
.eq("forum_name", forum.getForumName())
.eq("yonghu_id", forum.getYonghuId())
.eq("jiaolian_id", forum.getJiaolianId())
.eq("users_id", forum.getUsersId())
.eq("super_ids", forum.getSuperIds())
.eq("forum_state_types", forum.getForumStateTypes())
// .notIn("forum_types", new Integer[]{102})
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
ForumEntity forumEntity = forumService.selectOne(queryWrapper);
if(forumEntity==null){
forum.setInsertTime(new Date());
forum.setCreateTime(new Date());
forumService.insert(forum);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
}
=======
.eq("forum_name", forum.getForumName()) // 帖子标题
.eq("yonghu_id", forum.getYonghuId()) // 用户ID
.eq("jiaolian_id", forum.getJiaolianId()) // 教练ID
@ -697,5 +327,4 @@ public class ForumController {
return R.error(511,"表中有相同数据"); // 数据已存在返回错误
}
}
}
>>>>>>> develop
}

@ -1,250 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
*
*
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/jianshenkechengCollection")
public class JianshenkechengCollectionController {
private static final Logger logger = LoggerFactory.getLogger(JianshenkechengCollectionController.class);
private static final String TABLE_NAME = "jianshenkechengCollection";
@Autowired
private JianshenkechengCollectionService jianshenkechengCollectionService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private ForumService forumService;//健身论坛
@Autowired
private JianshenkechengService jianshenkechengService;//健身课程
@Autowired
private JianshenkechengLiuyanService jianshenkechengLiuyanService;//课程留言
@Autowired
private JiaolianService jiaolianService;//教练
@Autowired
private JiaolianYuyueService jiaolianYuyueService;//教练预约申请
@Autowired
private NewsService newsService;//健身资讯
@Autowired
private SingleSeachService singleSeachService;//单页数据
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("教练".equals(role))
params.put("jiaolianId",request.getSession().getAttribute("userId"));
CommonUtil.checkMap(params);
PageUtils page = jianshenkechengCollectionService.queryPage(params);
//字典表数据转换
List<JianshenkechengCollectionView> list =(List<JianshenkechengCollectionView>)page.getList();
for(JianshenkechengCollectionView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
JianshenkechengCollectionEntity jianshenkechengCollection = jianshenkechengCollectionService.selectById(id);
if(jianshenkechengCollection !=null){
//entity转view
JianshenkechengCollectionView view = new JianshenkechengCollectionView();
BeanUtils.copyProperties( jianshenkechengCollection , view );//把实体数据重构到view中
//级联表 健身课程
//级联表
JianshenkechengEntity jianshenkecheng = jianshenkechengService.selectById(jianshenkechengCollection.getJianshenkechengId());
if(jianshenkecheng != null){
BeanUtils.copyProperties( jianshenkecheng , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setJianshenkechengId(jianshenkecheng.getId());
}
//级联表 用户
//级联表
YonghuEntity yonghu = yonghuService.selectById(jianshenkechengCollection.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
@RequestMapping("/save")
public R save(@RequestBody JianshenkechengCollectionEntity jianshenkechengCollection, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,jianshenkechengCollection:{}",this.getClass().getName(),jianshenkechengCollection.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("用户".equals(role))
jianshenkechengCollection.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
Wrapper<JianshenkechengCollectionEntity> queryWrapper = new EntityWrapper<JianshenkechengCollectionEntity>()
.eq("jianshenkecheng_id", jianshenkechengCollection.getJianshenkechengId())
.eq("yonghu_id", jianshenkechengCollection.getYonghuId())
.eq("jianshenkecheng_collection_types", jianshenkechengCollection.getJianshenkechengCollectionTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
JianshenkechengCollectionEntity jianshenkechengCollectionEntity = jianshenkechengCollectionService.selectOne(queryWrapper);
if(jianshenkechengCollectionEntity==null){
jianshenkechengCollection.setInsertTime(new Date());
jianshenkechengCollection.setCreateTime(new Date());
jianshenkechengCollectionService.insert(jianshenkechengCollection);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody JianshenkechengCollectionEntity jianshenkechengCollection, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,jianshenkechengCollection:{}",this.getClass().getName(),jianshenkechengCollection.toString());
JianshenkechengCollectionEntity oldJianshenkechengCollectionEntity = jianshenkechengCollectionService.selectById(jianshenkechengCollection.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("用户".equals(role))
// jianshenkechengCollection.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
jianshenkechengCollectionService.updateById(jianshenkechengCollection);//根据id更新
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<JianshenkechengCollectionEntity> oldJianshenkechengCollectionList =jianshenkechengCollectionService.selectBatchIds(Arrays.asList(ids));//要删除的数据
jianshenkechengCollectionService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
*
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<JianshenkechengCollectionEntity> jianshenkechengCollectionList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
JianshenkechengCollectionEntity jianshenkechengCollectionEntity = new JianshenkechengCollectionEntity();
// jianshenkechengCollectionEntity.setJianshenkechengId(Integer.valueOf(data.get(0))); //健身课程 要改的
// jianshenkechengCollectionEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的
// jianshenkechengCollectionEntity.setJianshenkechengCollectionTypes(Integer.valueOf(data.get(0))); //类型 要改的
// jianshenkechengCollectionEntity.setInsertTime(date);//时间
// jianshenkechengCollectionEntity.setCreateTime(date);//时间
jianshenkechengCollectionList.add(jianshenkechengCollectionEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
jianshenkechengCollectionService.insertBatch(jianshenkechengCollectionList);
return R.ok();
=======
package com.controller; // 定义包路径表示该文件位于com.controller包下
import java.io.File; // 导入文件操作类
@ -279,10 +32,10 @@ import com.utils.R; // 导入统一返回结果类
import com.alibaba.fastjson.*; // 导入FastJSON相关类
//课程收藏
//后端接口
//@author
// @email
//课程收藏
//后端接口
//@author
// @email
@RestController // 标识为RESTful控制器
@Controller // 标识为Spring控制器
@ -320,7 +73,7 @@ public class JianshenkechengCollectionController {
private UsersService usersService; // 管理员服务
//后端列表
//后端列表
@RequestMapping("/page") // 处理分页请求
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); // 记录日志
@ -344,7 +97,7 @@ public class JianshenkechengCollectionController {
}
//后端详情
//后端详情
@RequestMapping("/info/{id}") // 处理详情请求
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录日志
@ -374,7 +127,7 @@ public class JianshenkechengCollectionController {
}
//后端保存
//后端保存
@RequestMapping("/save") // 处理保存请求
public R save(@RequestBody JianshenkechengCollectionEntity jianshenkechengCollection, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,jianshenkechengCollection:{}",this.getClass().getName(),jianshenkechengCollection.toString()); // 记录日志
@ -404,7 +157,7 @@ public class JianshenkechengCollectionController {
}
//后端修改
//后端修改
@RequestMapping("/update") // 处理更新请求
public R update(@RequestBody JianshenkechengCollectionEntity jianshenkechengCollection, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,jianshenkechengCollection:{}",this.getClass().getName(),jianshenkechengCollection.toString()); // 记录日志
@ -415,7 +168,7 @@ public class JianshenkechengCollectionController {
}
//删除
//删除
@RequestMapping("/delete") // 处理删除请求
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); // 记录日志
@ -426,7 +179,7 @@ public class JianshenkechengCollectionController {
}
//批量上传
//批量上传
@RequestMapping("/batchInsert") // 处理批量上传请求
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); // 记录日志
@ -459,108 +212,17 @@ public class JianshenkechengCollectionController {
// 批量插入数据
jianshenkechengCollectionService.insertBatch(jianshenkechengCollectionList);
return R.ok(); // 返回成功
>>>>>>> develop
}
}
}
}catch (Exception e){
<<<<<<< HEAD
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
=======
e.printStackTrace(); // 打印异常堆栈
return R.error(511,"批量插入数据异常,请联系管理员"); // 异常处理
>>>>>>> develop
}
}
<<<<<<< HEAD
/**
*
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
PageUtils page = jianshenkechengCollectionService.queryPage(params);
//字典表数据转换
List<JianshenkechengCollectionView> list =(List<JianshenkechengCollectionView>)page.getList();
for(JianshenkechengCollectionView c:list)
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
JianshenkechengCollectionEntity jianshenkechengCollection = jianshenkechengCollectionService.selectById(id);
if(jianshenkechengCollection !=null){
//entity转view
JianshenkechengCollectionView view = new JianshenkechengCollectionView();
BeanUtils.copyProperties( jianshenkechengCollection , view );//把实体数据重构到view中
//级联表
JianshenkechengEntity jianshenkecheng = jianshenkechengService.selectById(jianshenkechengCollection.getJianshenkechengId());
if(jianshenkecheng != null){
BeanUtils.copyProperties( jianshenkecheng , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setJianshenkechengId(jianshenkecheng.getId());
}
//级联表
YonghuEntity yonghu = yonghuService.selectById(jianshenkechengCollection.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
@RequestMapping("/add")
public R add(@RequestBody JianshenkechengCollectionEntity jianshenkechengCollection, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,jianshenkechengCollection:{}",this.getClass().getName(),jianshenkechengCollection.toString());
Wrapper<JianshenkechengCollectionEntity> queryWrapper = new EntityWrapper<JianshenkechengCollectionEntity>()
.eq("jianshenkecheng_id", jianshenkechengCollection.getJianshenkechengId())
.eq("yonghu_id", jianshenkechengCollection.getYonghuId())
.eq("jianshenkecheng_collection_types", jianshenkechengCollection.getJianshenkechengCollectionTypes())
// .notIn("jianshenkecheng_collection_types", new Integer[]{102})
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
JianshenkechengCollectionEntity jianshenkechengCollectionEntity = jianshenkechengCollectionService.selectOne(queryWrapper);
if(jianshenkechengCollectionEntity==null){
jianshenkechengCollection.setInsertTime(new Date());
jianshenkechengCollection.setCreateTime(new Date());
jianshenkechengCollectionService.insert(jianshenkechengCollection);
return R.ok();
}else {
return R.error(511,"您已经收藏过了");
}
}
}
=======
//前端列表
//前端列表
@IgnoreAuth // 忽略认证
@RequestMapping("/list") // 处理列表请求
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
@ -578,7 +240,7 @@ public class JianshenkechengCollectionController {
}
//前端详情
//前端详情
@RequestMapping("/detail/{id}") // 处理详情请求
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录日志
@ -609,7 +271,7 @@ public class JianshenkechengCollectionController {
}
//前端保存
//前端保存
@RequestMapping("/add") // 处理添加请求
public R add(@RequestBody JianshenkechengCollectionEntity jianshenkechengCollection, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,jianshenkechengCollection:{}",this.getClass().getName(),jianshenkechengCollection.toString()); // 记录日志
@ -630,5 +292,4 @@ public class JianshenkechengCollectionController {
return R.error(511,"您已经收藏过了"); // 已经收藏过返回错误
}
}
}
>>>>>>> develop
}

@ -1,277 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
*
*
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/jianshenkecheng")
public class JianshenkechengController {
private static final Logger logger = LoggerFactory.getLogger(JianshenkechengController.class);
private static final String TABLE_NAME = "jianshenkecheng";
@Autowired
private JianshenkechengService jianshenkechengService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private ForumService forumService;//健身论坛
@Autowired
private JianshenkechengCollectionService jianshenkechengCollectionService;//课程收藏
@Autowired
private JianshenkechengLiuyanService jianshenkechengLiuyanService;//课程留言
@Autowired
private JiaolianService jiaolianService;//教练
@Autowired
private JiaolianYuyueService jiaolianYuyueService;//教练预约申请
@Autowired
private NewsService newsService;//健身资讯
@Autowired
private SingleSeachService singleSeachService;//单页数据
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("教练".equals(role))
params.put("jiaolianId",request.getSession().getAttribute("userId"));
params.put("dataDeleteStart",1);params.put("dataDeleteEnd",1);
CommonUtil.checkMap(params);
PageUtils page = jianshenkechengService.queryPage(params);
//字典表数据转换
List<JianshenkechengView> list =(List<JianshenkechengView>)page.getList();
for(JianshenkechengView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
JianshenkechengEntity jianshenkecheng = jianshenkechengService.selectById(id);
if(jianshenkecheng !=null){
//entity转view
JianshenkechengView view = new JianshenkechengView();
BeanUtils.copyProperties( jianshenkecheng , view );//把实体数据重构到view中
//级联表 教练
//级联表
JiaolianEntity jiaolian = jiaolianService.selectById(jianshenkecheng.getJiaolianId());
if(jiaolian != null){
BeanUtils.copyProperties( jiaolian , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "jiaolianId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setJiaolianId(jiaolian.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
@RequestMapping("/save")
public R save(@RequestBody JianshenkechengEntity jianshenkecheng, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,jianshenkecheng:{}",this.getClass().getName(),jianshenkecheng.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("教练".equals(role))
jianshenkecheng.setJiaolianId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
Wrapper<JianshenkechengEntity> queryWrapper = new EntityWrapper<JianshenkechengEntity>()
.eq("jiaolian_id", jianshenkecheng.getJiaolianId())
.eq("jianshenkecheng_name", jianshenkecheng.getJianshenkechengName())
.eq("jianshenkecheng_video", jianshenkecheng.getJianshenkechengVideo())
.eq("zan_number", jianshenkecheng.getZanNumber())
.eq("cai_number", jianshenkecheng.getCaiNumber())
.eq("jianshenkecheng_types", jianshenkecheng.getJianshenkechengTypes())
.eq("data_delete", 1)
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
JianshenkechengEntity jianshenkechengEntity = jianshenkechengService.selectOne(queryWrapper);
if(jianshenkechengEntity==null){
jianshenkecheng.setZanNumber(1);
jianshenkecheng.setCaiNumber(1);
jianshenkecheng.setJianshenkechengClicknum(1);
jianshenkecheng.setDataDelete(1);
jianshenkecheng.setInsertTime(new Date());
jianshenkecheng.setCreateTime(new Date());
jianshenkechengService.insert(jianshenkecheng);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody JianshenkechengEntity jianshenkecheng, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,jianshenkecheng:{}",this.getClass().getName(),jianshenkecheng.toString());
JianshenkechengEntity oldJianshenkechengEntity = jianshenkechengService.selectById(jianshenkecheng.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("教练".equals(role))
// jianshenkecheng.setJiaolianId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
if("".equals(jianshenkecheng.getJianshenkechengPhoto()) || "null".equals(jianshenkecheng.getJianshenkechengPhoto())){
jianshenkecheng.setJianshenkechengPhoto(null);
}
if("".equals(jianshenkecheng.getJianshenkechengVideo()) || "null".equals(jianshenkecheng.getJianshenkechengVideo())){
jianshenkecheng.setJianshenkechengVideo(null);
}
if("".equals(jianshenkecheng.getJianshenkechengContent()) || "null".equals(jianshenkecheng.getJianshenkechengContent())){
jianshenkecheng.setJianshenkechengContent(null);
}
jianshenkechengService.updateById(jianshenkecheng);//根据id更新
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<JianshenkechengEntity> oldJianshenkechengList =jianshenkechengService.selectBatchIds(Arrays.asList(ids));//要删除的数据
ArrayList<JianshenkechengEntity> list = new ArrayList<>();
for(Integer id:ids){
JianshenkechengEntity jianshenkechengEntity = new JianshenkechengEntity();
jianshenkechengEntity.setId(id);
jianshenkechengEntity.setDataDelete(2);
list.add(jianshenkechengEntity);
}
if(list != null && list.size() >0){
jianshenkechengService.updateBatchById(list);
}
return R.ok();
}
/**
*
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<JianshenkechengEntity> jianshenkechengList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
JianshenkechengEntity jianshenkechengEntity = new JianshenkechengEntity();
// jianshenkechengEntity.setJiaolianId(Integer.valueOf(data.get(0))); //教练 要改的
// jianshenkechengEntity.setJianshenkechengName(data.get(0)); //健身课程名称 要改的
// jianshenkechengEntity.setJianshenkechengPhoto("");//详情和图片
// jianshenkechengEntity.setJianshenkechengVideo(data.get(0)); //课程视频 要改的
// jianshenkechengEntity.setZanNumber(Integer.valueOf(data.get(0))); //赞 要改的
// jianshenkechengEntity.setCaiNumber(Integer.valueOf(data.get(0))); //踩 要改的
// jianshenkechengEntity.setJianshenkechengTypes(Integer.valueOf(data.get(0))); //健身课程类型 要改的
// jianshenkechengEntity.setJianshenkechengClicknum(Integer.valueOf(data.get(0))); //健身课程热度 要改的
// jianshenkechengEntity.setJianshenkechengContent("");//详情和图片
// jianshenkechengEntity.setDataDelete(1);//逻辑删除字段
// jianshenkechengEntity.setInsertTime(date);//时间
// jianshenkechengEntity.setCreateTime(date);//时间
jianshenkechengList.add(jianshenkechengEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
jianshenkechengService.insertBatch(jianshenkechengList);
return R.ok();
=======
package com.controller; // 声明包路径表示该文件位于com.controller包下
import java.io.File; // 导入文件操作类
@ -306,10 +32,10 @@ import com.utils.R; // 导入统一返回结果类
import com.alibaba.fastjson.*; // 导入FastJSON相关类
// 健身课程
//后端接口
//@author
//@email
// 健身课程
//后端接口
//@author
//@email
@RestController // 标识为RESTful控制器
@Controller // 标识为Spring控制器
@ -347,7 +73,7 @@ public class JianshenkechengController {
private UsersService usersService; // 管理员服务
//后端列表
//后端列表
@RequestMapping("/page") // 处理分页请求
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); // 记录日志
@ -372,7 +98,7 @@ public class JianshenkechengController {
}
//后端详情
//后端详情
@RequestMapping("/info/{id}") // 处理详情请求
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录日志
@ -396,7 +122,7 @@ public class JianshenkechengController {
}
//后端保存
//后端保存
@RequestMapping("/save") // 处理保存请求
public R save(@RequestBody JianshenkechengEntity jianshenkecheng, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,jianshenkecheng:{}",this.getClass().getName(),jianshenkecheng.toString()); // 记录日志
@ -434,7 +160,7 @@ public class JianshenkechengController {
}
//后端修改
//后端修改
@RequestMapping("/update") // 处理更新请求
public R update(@RequestBody JianshenkechengEntity jianshenkecheng, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,jianshenkecheng:{}",this.getClass().getName(),jianshenkecheng.toString()); // 记录日志
@ -455,7 +181,7 @@ public class JianshenkechengController {
}
//删除
//删除
@RequestMapping("/delete") // 处理删除请求
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); // 记录日志
@ -475,7 +201,7 @@ public class JianshenkechengController {
}
//批量上传
//批量上传
@RequestMapping("/batchInsert") // 处理批量上传请求
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); // 记录日志
@ -508,178 +234,17 @@ public class JianshenkechengController {
// 批量插入数据
jianshenkechengService.insertBatch(jianshenkechengList);
return R.ok(); // 返回成功
>>>>>>> develop
}
}
}
}catch (Exception e){
<<<<<<< HEAD
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
=======
e.printStackTrace(); // 打印异常堆栈
return R.error(511,"批量插入数据异常,请联系管理员"); // 异常处理
>>>>>>> develop
}
}
<<<<<<< HEAD
/**
*
*/
@IgnoreAuth
@RequestMapping("/gexingtuijian")
public R gexingtuijian(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("gexingtuijian方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
List<JianshenkechengView> returnJianshenkechengViewList = new ArrayList<>();
//查看收藏
Map<String, Object> params1 = new HashMap<>(params);params1.put("sort","id");params1.put("yonghuId",request.getSession().getAttribute("userId"));
params1.put("shangxiaTypes",1);
params1.put("jianshenkechengYesnoTypes",2);
PageUtils pageUtils = jianshenkechengCollectionService.queryPage(params1);
List<JianshenkechengCollectionView> collectionViewsList =(List<JianshenkechengCollectionView>)pageUtils.getList();
Map<Integer,Integer> typeMap=new HashMap<>();//购买的类型list
for(JianshenkechengCollectionView collectionView:collectionViewsList){
Integer jianshenkechengTypes = collectionView.getJianshenkechengTypes();
if(typeMap.containsKey(jianshenkechengTypes)){
typeMap.put(jianshenkechengTypes,typeMap.get(jianshenkechengTypes)+1);
}else{
typeMap.put(jianshenkechengTypes,1);
}
}
List<Integer> typeList = new ArrayList<>();//排序后的有序的类型 按最多到最少
typeMap.entrySet().stream().sorted((o1, o2) -> o2.getValue() - o1.getValue()).forEach(e -> typeList.add(e.getKey()));//排序
Integer limit = Integer.valueOf(String.valueOf(params.get("limit")));
for(Integer type:typeList){
Map<String, Object> params2 = new HashMap<>(params);params2.put("jianshenkechengTypes",type);
params2.put("shangxiaTypes",1);
params2.put("jianshenkechengYesnoTypes",2);
PageUtils pageUtils1 = jianshenkechengService.queryPage(params2);
List<JianshenkechengView> jianshenkechengViewList =(List<JianshenkechengView>)pageUtils1.getList();
returnJianshenkechengViewList.addAll(jianshenkechengViewList);
if(returnJianshenkechengViewList.size()>= limit) break;//返回的推荐数量大于要的数量 跳出循环
}
params.put("shangxiaTypes",1);
params.put("jianshenkechengYesnoTypes",2);
//正常查询出来商品,用于补全推荐缺少的数据
PageUtils page = jianshenkechengService.queryPage(params);
if(returnJianshenkechengViewList.size()<limit){//返回数量还是小于要求数量
int toAddNum = limit - returnJianshenkechengViewList.size();//要添加的数量
List<JianshenkechengView> jianshenkechengViewList =(List<JianshenkechengView>)page.getList();
for(JianshenkechengView jianshenkechengView:jianshenkechengViewList){
Boolean addFlag = true;
for(JianshenkechengView returnJianshenkechengView:returnJianshenkechengViewList){
if(returnJianshenkechengView.getId().intValue() ==jianshenkechengView.getId().intValue()) addFlag=false;//返回的数据中已存在此商品
}
if(addFlag){
toAddNum=toAddNum-1;
returnJianshenkechengViewList.add(jianshenkechengView);
if(toAddNum==0) break;//够数量了
}
}
}else {
returnJianshenkechengViewList = returnJianshenkechengViewList.subList(0, limit);
}
for(JianshenkechengView c:returnJianshenkechengViewList)
dictionaryService.dictionaryConvert(c, request);
page.setList(returnJianshenkechengViewList);
return R.ok().put("data", page);
}
/**
*
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
PageUtils page = jianshenkechengService.queryPage(params);
//字典表数据转换
List<JianshenkechengView> list =(List<JianshenkechengView>)page.getList();
for(JianshenkechengView c:list)
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
JianshenkechengEntity jianshenkecheng = jianshenkechengService.selectById(id);
if(jianshenkecheng !=null){
//点击数量加1
jianshenkecheng.setJianshenkechengClicknum(jianshenkecheng.getJianshenkechengClicknum()+1);
jianshenkechengService.updateById(jianshenkecheng);
//entity转view
JianshenkechengView view = new JianshenkechengView();
BeanUtils.copyProperties( jianshenkecheng , view );//把实体数据重构到view中
//级联表
JiaolianEntity jiaolian = jiaolianService.selectById(jianshenkecheng.getJiaolianId());
if(jiaolian != null){
BeanUtils.copyProperties( jiaolian , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "jiaolianId"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setJiaolianId(jiaolian.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
@RequestMapping("/add")
public R add(@RequestBody JianshenkechengEntity jianshenkecheng, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,jianshenkecheng:{}",this.getClass().getName(),jianshenkecheng.toString());
Wrapper<JianshenkechengEntity> queryWrapper = new EntityWrapper<JianshenkechengEntity>()
.eq("jiaolian_id", jianshenkecheng.getJiaolianId())
.eq("jianshenkecheng_name", jianshenkecheng.getJianshenkechengName())
.eq("jianshenkecheng_video", jianshenkecheng.getJianshenkechengVideo())
.eq("zan_number", jianshenkecheng.getZanNumber())
.eq("cai_number", jianshenkecheng.getCaiNumber())
.eq("jianshenkecheng_types", jianshenkecheng.getJianshenkechengTypes())
.eq("jianshenkecheng_clicknum", jianshenkecheng.getJianshenkechengClicknum())
.eq("data_delete", jianshenkecheng.getDataDelete())
// .notIn("jianshenkecheng_types", new Integer[]{102})
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
JianshenkechengEntity jianshenkechengEntity = jianshenkechengService.selectOne(queryWrapper);
if(jianshenkechengEntity==null){
jianshenkecheng.setZanNumber(1);
jianshenkecheng.setCaiNumber(1);
jianshenkecheng.setJianshenkechengClicknum(1);
jianshenkecheng.setDataDelete(1);
jianshenkecheng.setInsertTime(new Date());
jianshenkecheng.setCreateTime(new Date());
jianshenkechengService.insert(jianshenkecheng);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
}
=======
//个性推荐
//个性推荐
@IgnoreAuth // 忽略认证
@RequestMapping("/gexingtuijian") // 处理个性推荐请求
public R gexingtuijian(@RequestParam Map<String, Object> params, HttpServletRequest request){
@ -743,7 +308,7 @@ public class JianshenkechengController {
}
//前端列表
//前端列表
@IgnoreAuth // 忽略认证
@RequestMapping("/list") // 处理列表请求
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
@ -761,7 +326,7 @@ public class JianshenkechengController {
}
//前端详情
//前端详情
@RequestMapping("/detail/{id}") // 处理详情请求
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录日志
@ -791,7 +356,7 @@ public class JianshenkechengController {
}
//前端保存
//前端保存
@RequestMapping("/add") // 处理添加请求
public R add(@RequestBody JianshenkechengEntity jianshenkecheng, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,jianshenkecheng:{}",this.getClass().getName(),jianshenkecheng.toString()); // 记录日志
@ -821,5 +386,4 @@ public class JianshenkechengController {
return R.error(511,"表中有相同数据"); // 数据已存在返回错误
}
}
}
>>>>>>> develop
}

@ -1,248 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
*
*
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/jianshenkechengLiuyan")
public class JianshenkechengLiuyanController {
private static final Logger logger = LoggerFactory.getLogger(JianshenkechengLiuyanController.class);
private static final String TABLE_NAME = "jianshenkechengLiuyan";
@Autowired
private JianshenkechengLiuyanService jianshenkechengLiuyanService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private ForumService forumService;//健身论坛
@Autowired
private JianshenkechengService jianshenkechengService;//健身课程
@Autowired
private JianshenkechengCollectionService jianshenkechengCollectionService;//课程收藏
@Autowired
private JiaolianService jiaolianService;//教练
@Autowired
private JiaolianYuyueService jiaolianYuyueService;//教练预约申请
@Autowired
private NewsService newsService;//健身资讯
@Autowired
private SingleSeachService singleSeachService;//单页数据
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("教练".equals(role))
params.put("jiaolianId",request.getSession().getAttribute("userId"));
CommonUtil.checkMap(params);
PageUtils page = jianshenkechengLiuyanService.queryPage(params);
//字典表数据转换
List<JianshenkechengLiuyanView> list =(List<JianshenkechengLiuyanView>)page.getList();
for(JianshenkechengLiuyanView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
JianshenkechengLiuyanEntity jianshenkechengLiuyan = jianshenkechengLiuyanService.selectById(id);
if(jianshenkechengLiuyan !=null){
//entity转view
JianshenkechengLiuyanView view = new JianshenkechengLiuyanView();
BeanUtils.copyProperties( jianshenkechengLiuyan , view );//把实体数据重构到view中
//级联表 健身课程
//级联表
JianshenkechengEntity jianshenkecheng = jianshenkechengService.selectById(jianshenkechengLiuyan.getJianshenkechengId());
if(jianshenkecheng != null){
BeanUtils.copyProperties( jianshenkecheng , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setJianshenkechengId(jianshenkecheng.getId());
}
//级联表 用户
//级联表
YonghuEntity yonghu = yonghuService.selectById(jianshenkechengLiuyan.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
@RequestMapping("/save")
public R save(@RequestBody JianshenkechengLiuyanEntity jianshenkechengLiuyan, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,jianshenkechengLiuyan:{}",this.getClass().getName(),jianshenkechengLiuyan.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("用户".equals(role))
jianshenkechengLiuyan.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
jianshenkechengLiuyan.setCreateTime(new Date());
jianshenkechengLiuyan.setInsertTime(new Date());
jianshenkechengLiuyanService.insert(jianshenkechengLiuyan);
return R.ok();
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody JianshenkechengLiuyanEntity jianshenkechengLiuyan, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,jianshenkechengLiuyan:{}",this.getClass().getName(),jianshenkechengLiuyan.toString());
JianshenkechengLiuyanEntity oldJianshenkechengLiuyanEntity = jianshenkechengLiuyanService.selectById(jianshenkechengLiuyan.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("用户".equals(role))
// jianshenkechengLiuyan.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
if("".equals(jianshenkechengLiuyan.getJianshenkechengLiuyanText()) || "null".equals(jianshenkechengLiuyan.getJianshenkechengLiuyanText())){
jianshenkechengLiuyan.setJianshenkechengLiuyanText(null);
}
if("".equals(jianshenkechengLiuyan.getReplyText()) || "null".equals(jianshenkechengLiuyan.getReplyText())){
jianshenkechengLiuyan.setReplyText(null);
}
jianshenkechengLiuyan.setUpdateTime(new Date());
jianshenkechengLiuyanService.updateById(jianshenkechengLiuyan);//根据id更新
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<JianshenkechengLiuyanEntity> oldJianshenkechengLiuyanList =jianshenkechengLiuyanService.selectBatchIds(Arrays.asList(ids));//要删除的数据
jianshenkechengLiuyanService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
*
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<JianshenkechengLiuyanEntity> jianshenkechengLiuyanList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
JianshenkechengLiuyanEntity jianshenkechengLiuyanEntity = new JianshenkechengLiuyanEntity();
// jianshenkechengLiuyanEntity.setJianshenkechengId(Integer.valueOf(data.get(0))); //健身课程 要改的
// jianshenkechengLiuyanEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的
// jianshenkechengLiuyanEntity.setJianshenkechengLiuyanText(data.get(0)); //留言内容 要改的
// jianshenkechengLiuyanEntity.setInsertTime(date);//时间
// jianshenkechengLiuyanEntity.setReplyText(data.get(0)); //回复内容 要改的
// jianshenkechengLiuyanEntity.setUpdateTime(sdf.parse(data.get(0))); //回复时间 要改的
// jianshenkechengLiuyanEntity.setCreateTime(date);//时间
jianshenkechengLiuyanList.add(jianshenkechengLiuyanEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
jianshenkechengLiuyanService.insertBatch(jianshenkechengLiuyanList);
return R.ok();
=======
package com.controller; // 声明包路径表示该文件位于com.controller包下
import java.io.File; // 导入文件操作类,用于处理文件上传
@ -277,10 +32,10 @@ import com.utils.R; // 导入统一返回结果类
import com.alibaba.fastjson.*; // 导入FastJSON相关类
//课程留言
//后端接口
//@author
//@email
//课程留言
//后端接口
//@author
//@email
@RestController // 标识为RESTful控制器用于处理HTTP请求
@Controller // 标识为Spring控制器
@RequestMapping("/jianshenkechengLiuyan") // 定义请求映射路径
@ -317,8 +72,8 @@ public class JianshenkechengLiuyanController {
private UsersService usersService; // 自动注入管理员服务
//后端列表
//处理分页查询请求
//后端列表
//处理分页查询请求
@RequestMapping("/page") // 映射分页查询请求
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); // 记录请求日志
@ -341,8 +96,8 @@ public class JianshenkechengLiuyanController {
}
//后端详情
//根据ID查询单条留言详情
//后端详情
//根据ID查询单条留言详情
@RequestMapping("/info/{id}") // 映射详情查询请求
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录请求日志
@ -373,8 +128,8 @@ public class JianshenkechengLiuyanController {
}
//后端保存
//处理新增留言请求
//后端保存
//处理新增留言请求
@RequestMapping("/save") // 映射保存请求
public R save(@RequestBody JianshenkechengLiuyanEntity jianshenkechengLiuyan, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,jianshenkechengLiuyan:{}",this.getClass().getName(),jianshenkechengLiuyan.toString()); // 记录请求日志
@ -393,8 +148,8 @@ public class JianshenkechengLiuyanController {
}
//后端修改
//处理更新留言请
//后端修改
//处理更新留言请
@RequestMapping("/update") // 映射更新请求
public R update(@RequestBody JianshenkechengLiuyanEntity jianshenkechengLiuyan, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,jianshenkechengLiuyan:{}",this.getClass().getName(),jianshenkechengLiuyan.toString()); // 记录请求日志
@ -414,8 +169,8 @@ public class JianshenkechengLiuyanController {
}
//删除
//处理删除留言请求
//删除
//处理删除留言请求
@RequestMapping("/delete") // 映射删除请求
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); // 记录请求日志
@ -425,8 +180,8 @@ public class JianshenkechengLiuyanController {
}
//批量上传
//处理批量导入数据请求
//批量上传
//处理批量导入数据请求
@RequestMapping("/batchInsert") // 映射批量导入请求
public R save(String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); // 记录请求日志
@ -457,97 +212,18 @@ public class JianshenkechengLiuyanController {
}
jianshenkechengLiuyanService.insertBatch(jianshenkechengLiuyanList); // 批量插入数据
return R.ok(); // 返回成功信息
>>>>>>> develop
}
}
}
}catch (Exception e){
<<<<<<< HEAD
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
=======
e.printStackTrace(); // 打印异常堆栈
return R.error(511,"批量插入数据异常,请联系管理员"); // 返回错误信息
>>>>>>> develop
}
}
<<<<<<< HEAD
/**
*
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
PageUtils page = jianshenkechengLiuyanService.queryPage(params);
//字典表数据转换
List<JianshenkechengLiuyanView> list =(List<JianshenkechengLiuyanView>)page.getList();
for(JianshenkechengLiuyanView c:list)
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
JianshenkechengLiuyanEntity jianshenkechengLiuyan = jianshenkechengLiuyanService.selectById(id);
if(jianshenkechengLiuyan !=null){
//entity转view
JianshenkechengLiuyanView view = new JianshenkechengLiuyanView();
BeanUtils.copyProperties( jianshenkechengLiuyan , view );//把实体数据重构到view中
//级联表
JianshenkechengEntity jianshenkecheng = jianshenkechengService.selectById(jianshenkechengLiuyan.getJianshenkechengId());
if(jianshenkecheng != null){
BeanUtils.copyProperties( jianshenkecheng , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setJianshenkechengId(jianshenkecheng.getId());
}
//级联表
YonghuEntity yonghu = yonghuService.selectById(jianshenkechengLiuyan.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
@RequestMapping("/add")
public R add(@RequestBody JianshenkechengLiuyanEntity jianshenkechengLiuyan, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,jianshenkechengLiuyan:{}",this.getClass().getName(),jianshenkechengLiuyan.toString());
jianshenkechengLiuyan.setCreateTime(new Date());
jianshenkechengLiuyan.setInsertTime(new Date());
jianshenkechengLiuyanService.insert(jianshenkechengLiuyan);
return R.ok();
}
}
=======
//前端列表
//处理前端分页查询请求
//前端列表
//处理前端分页查询请求
@IgnoreAuth // 忽略认证
@RequestMapping("/list") // 映射列表查询请求
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
@ -564,8 +240,8 @@ public class JianshenkechengLiuyanController {
}
//前端详情
//处理前端详情查询请求
//前端详情
//处理前端详情查询请求
@RequestMapping("/detail/{id}") // 映射详情查询请求
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录请求日志
@ -596,8 +272,8 @@ public class JianshenkechengLiuyanController {
}
//前端保存
//处理前端新增留言请求
//前端保存
//处理前端新增留言请求
@RequestMapping("/add") // 映射新增请求
public R add(@RequestBody JianshenkechengLiuyanEntity jianshenkechengLiuyan, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,jianshenkechengLiuyan:{}",this.getClass().getName(),jianshenkechengLiuyan.toString()); // 记录请求日志
@ -606,5 +282,4 @@ public class JianshenkechengLiuyanController {
jianshenkechengLiuyanService.insert(jianshenkechengLiuyan); // 调用服务层保存数据
return R.ok(); // 返回成功信息
}
}
>>>>>>> develop
}

@ -1,235 +1,203 @@
<<<<<<< HEAD
// 声明当前 Java 文件所属的包此包用于存放控制器类处理与教练相关的HTTP请求
package com.controller;
// 导入Java IO包中的File类用于文件操作
import java.io.File;
// 导入Java数学包中的BigDecimal类用于高精度计算
import java.math.BigDecimal;
// 导入Java网络包中的URL类用于处理统一资源定位符
import java.net.URL;
// 导入Java文本包中的SimpleDateFormat类用于日期格式化
import java.text.SimpleDateFormat;
// 导入FastJSON库中的JSONObject类用于JSON数据处理
import com.alibaba.fastjson.JSONObject;
// 导入Java工具包中的所有类包括集合、日期等工具
import java.util.*;
// 导入Spring框架的BeanUtils类用于对象属性复制
import org.springframework.beans.BeanUtils;
// 导入Servlet的HttpServletRequest类用于处理HTTP请求
import javax.servlet.http.HttpServletRequest;
// 导入Spring框架的ContextLoader类用于获取应用上下文
import org.springframework.web.context.ContextLoader;
// 导入Servlet的ServletContext类表示Servlet上下文
import javax.servlet.ServletContext;
// 导入自定义的TokenService类用于令牌管理
import com.service.TokenService;
// 导入自定义工具类包中的所有工具类
import com.utils.*;
// 导入反射相关的InvocationTargetException类
import java.lang.reflect.InvocationTargetException;
// 导入自定义的DictionaryService类用于字典数据管理
import com.service.DictionaryService;
// 导入Apache Commons Lang3库的StringUtils类用于字符串处理
import org.apache.commons.lang3.StringUtils;
// 导入自定义的IgnoreAuth注解用于标记不需要认证的接口
import com.annotation.IgnoreAuth;
// 导入SLF4J日志框架的Logger接口
import org.slf4j.Logger;
// 导入SLF4J日志框架的LoggerFactory类
import org.slf4j.LoggerFactory;
// 导入Spring框架的Autowired注解用于依赖注入
import org.springframework.beans.factory.annotation.Autowired;
// 导入Spring框架的Controller注解标记该类为控制器
import org.springframework.stereotype.Controller;
// 导入Spring框架的RestController和RequestMapping等注解
import org.springframework.web.bind.annotation.*;
// 导入MyBatis Plus的EntityWrapper类用于构建查询条件
import com.baomidou.mybatisplus.mapper.EntityWrapper;
// 导入MyBatis Plus的Wrapper接口
import com.baomidou.mybatisplus.mapper.Wrapper;
// 导入自定义实体类包中的所有类
import com.entity.*;
// 导入自定义视图实体类包中的所有类
import com.entity.view.*;
// 导入自定义服务类包中的所有类
import com.service.*;
// 导入自定义分页工具类
import com.utils.PageUtils;
// 导入自定义统一返回结果类
import com.utils.R;
// 导入FastJSON库中的所有类
import com.alibaba.fastjson.*;
/**
*
*
*
* @author
* @email
*/
=======
// 声明当前 Java 文件所属的包,此包一般用于存放控制器相关的类,负责处理 HTTP 请求和响应
package com.controller;
// 导入 Java 标准库中的 File 类,用于操作文件和目录
import java.io.File;
// 导入 Java 标准库中的 BigDecimal 类,用于进行高精度的十进制数运算
import java.math.BigDecimal;
// 导入 Java 标准库中的 URL 类,用于表示统一资源定位符,可用于处理网络资源
import java.net.URL;
// 导入 Java 标准库中的 SimpleDateFormat 类,用于格式化和解析日期时间
import java.text.SimpleDateFormat;
// 导入阿里巴巴的 FastJSON 库中的 JSONObject 类,用于处理 JSON 对象,方便进行 JSON 数据的操作
import com.alibaba.fastjson.JSONObject;
// 导入 Java 标准库中的 java.util 包下的所有类,该包包含了集合框架、日期和时间、随机数生成等常用工具类
import java.util.*;
// 导入 Spring 框架中的 BeanUtils 类,用于对象属性的复制,方便在不同对象之间传递数据
import org.springframework.beans.BeanUtils;
// 导入 Java Servlet API 中的 HttpServletRequest 类,用于封装 HTTP 请求信息,在控制器中可获取请求参数等
import javax.servlet.http.HttpServletRequest;
// 导入 Spring 框架中的 ContextLoader 类,用于获取 Spring 的应用上下文
import org.springframework.web.context.ContextLoader;
// 导入 Java Servlet API 中的 ServletContext 类,用于表示 Servlet 上下文,可获取应用的全局信息
import javax.servlet.ServletContext;
// 导入自定义的 TokenService 类,该类可能用于处理令牌相关的业务逻辑
import com.service.TokenService;
// 导入自定义的 utils 包下的所有类,这些类通常包含一些通用的工具方法
import com.utils.*;
// 导入 Java 反射机制中的 InvocationTargetException 类,当使用反射调用方法时,如果被调用的方法抛出异常,会被封装成该异常抛出
import java.lang.reflect.InvocationTargetException;
// 导入自定义的 DictionaryService 类,该类可能用于处理字典数据的业务逻辑
import com.service.DictionaryService;
// 导入 Apache Commons Lang3 库中的 StringUtils 类,提供了许多方便的字符串操作方法
import org.apache.commons.lang3.StringUtils;
// 导入自定义的 IgnoreAuth 注解,该注解可能用于标记不需要进行身份验证的接口
import com.annotation.IgnoreAuth;
// 导入 SLF4J 日志框架中的 Logger 接口,用于记录日志信息
import org.slf4j.Logger;
// 导入 SLF4J 日志框架中的 LoggerFactory 类,用于创建 Logger 实例
import org.slf4j.LoggerFactory;
// 导入 Spring 框架中的 Autowired 注解,用于自动注入依赖的 Bean
import org.springframework.beans.factory.annotation.Autowired;
// 导入 Spring 框架中的 Controller 注解,用于标记该类为控制器类,处理 HTTP 请求
import org.springframework.stereotype.Controller;
// 导入 Spring 框架中的 RestController 和 RequestMapping 等注解,用于构建 RESTful 风格的接口
import org.springframework.web.bind.annotation.*;
// 导入 MyBatis-Plus 框架中的 EntityWrapper 类,用于构建实体对象的查询条件
import com.baomidou.mybatisplus.mapper.EntityWrapper;
// 导入 MyBatis-Plus 框架中的 Wrapper 接口EntityWrapper 实现了该接口,用于灵活构建查询条件
import com.baomidou.mybatisplus.mapper.Wrapper;
// 导入自定义的 entity 包下的所有类,这些类通常是实体类,对应数据库表结构
import com.entity.*;
// 导入自定义的 view 包下的所有类,这些类可能是用于视图展示的实体类
import com.entity.view.*;
// 导入自定义的 service 包下的所有类,这些类通常包含业务逻辑处理方法
import com.service.*;
// 导入自定义的 PageUtils 类,用于处理分页相关的逻辑
import com.utils.PageUtils;
// 导入自定义的 R 类,通常用于封装统一的响应结果
import com.utils.R;
// 导入阿里巴巴的 FastJSON 库中的所有类,进一步方便进行 JSON 数据的操作
import com.alibaba.fastjson.*;
//教练
//后端接口
//@author
//@email
>>>>>>> develop
@RestController
@Controller
@RequestMapping("/jiaolian")
*/
@RestController // 标记为RESTful控制器
@Controller // 标记为Spring控制器
@RequestMapping("/jiaolian") // 定义基础请求路径
public class JiaolianController {
// 创建日志记录器
private static final Logger logger = LoggerFactory.getLogger(JiaolianController.class);
// 定义常量表名
private static final String TABLE_NAME = "jiaolian";
// 自动注入教练服务
@Autowired
private JiaolianService jiaolianService;
// 自动注入令牌服务
@Autowired
private TokenService tokenService;
// 自动注入字典服务
@Autowired
private DictionaryService dictionaryService;//字典
private DictionaryService dictionaryService;
// 自动注入论坛服务
@Autowired
private ForumService forumService;//健身论坛
private ForumService forumService;
// 自动注入健身课程服务
@Autowired
private JianshenkechengService jianshenkechengService;//健身课程
private JianshenkechengService jianshenkechengService;
// 自动注入课程收藏服务
@Autowired
private JianshenkechengCollectionService jianshenkechengCollectionService;//课程收藏
private JianshenkechengCollectionService jianshenkechengCollectionService;
// 自动注入课程留言服务
@Autowired
private JianshenkechengLiuyanService jianshenkechengLiuyanService;//课程留言
private JianshenkechengLiuyanService jianshenkechengLiuyanService;
// 自动注入教练预约服务
@Autowired
private JiaolianYuyueService jiaolianYuyueService;//教练预约申请
private JiaolianYuyueService jiaolianYuyueService;
// 自动注入健身资讯服务
@Autowired
private NewsService newsService;//健身资讯
private NewsService newsService;
// 自动注入单页数据服务
@Autowired
private SingleSeachService singleSeachService;//单页数据
private SingleSeachService singleSeachService;
// 自动注入用户服务
@Autowired
private YonghuService yonghuService;//用户
private YonghuService yonghuService;
// 自动注入管理员服务
@Autowired
private UsersService usersService;//管理员
private UsersService usersService;
<<<<<<< HEAD
/**
*
*/
=======
//后端列表
>>>>>>> develop
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
logger.debug("分页查询方法:,,控制器:{},,参数:{}",this.getClass().getName(),JSONObject.toJSONString(params));
// 获取当前用户角色
String role = String.valueOf(request.getSession().getAttribute("role"));
// 根据角色设置查询条件
if(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("教练".equals(role))
params.put("jiaolianId",request.getSession().getAttribute("userId"));
params.put("dataDeleteStart",1);params.put("dataDeleteEnd",1);
// 设置数据删除状态条件
params.put("dataDeleteStart",1);
params.put("dataDeleteEnd",1);
// 检查参数有效性
CommonUtil.checkMap(params);
// 调用服务层查询分页数据
PageUtils page = jiaolianService.queryPage(params);
//字典数据转换
// 字典数据转换
List<JiaolianView> list =(List<JiaolianView>)page.getList();
for(JiaolianView c:list){
//修改对应字典表字段
// 转换字典表字段
dictionaryService.dictionaryConvert(c, request);
}
// 返回分页数据
return R.ok().put("data", page);
}
<<<<<<< HEAD
/**
*
*/
=======
//后端详情
>>>>>>> develop
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
logger.debug("详情查询方法:,,控制器:{},,ID:{}",this.getClass().getName(),id);
// 根据ID查询教练信息
JiaolianEntity jiaolian = jiaolianService.selectById(id);
if(jiaolian !=null){
//entity转view
// 实体转视图
JiaolianView view = new JiaolianView();
BeanUtils.copyProperties( jiaolian , view );//把实体数据重构到view中
//修改对应字典表字段
// 复制属性
BeanUtils.copyProperties( jiaolian , view );
// 转换字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
<<<<<<< HEAD
/**
*
*/
=======
//后端保存
>>>>>>> develop
*
*/
@RequestMapping("/save")
public R save(@RequestBody JiaolianEntity jiaolian, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,jiaolian:{}",this.getClass().getName(),jiaolian.toString());
logger.debug("保存方法:,,控制器:{},,教练信息:{}",this.getClass().getName(),jiaolian.toString());
// 获取当前用户角色
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
// 构建查询条件,检查用户名和手机号是否已存在
Wrapper<JiaolianEntity> queryWrapper = new EntityWrapper<JiaolianEntity>()
.eq("username", jiaolian.getUsername())
.or()
.eq("jiaolian_phone", jiaolian.getJiaolianPhone())
.eq("data_delete", 1)
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
.eq("username", jiaolian.getUsername())
.or()
.eq("jiaolian_phone", jiaolian.getJiaolianPhone())
.eq("data_delete", 1)
;
logger.info("SQL语句:"+queryWrapper.getSqlSegment());
// 执行查询
JiaolianEntity jiaolianEntity = jiaolianService.selectOne(queryWrapper);
if(jiaolianEntity==null){
jiaolian.setDataDelete(1);
jiaolian.setInsertTime(new Date());
jiaolian.setCreateTime(new Date());
jiaolian.setPassword("123456");
// 设置默认值
jiaolian.setDataDelete(1); // 数据删除状态
jiaolian.setInsertTime(new Date()); // 插入时间
jiaolian.setCreateTime(new Date()); // 创建时间
jiaolian.setPassword("123456"); // 默认密码
// 保存教练信息
jiaolianService.insert(jiaolian);
return R.ok();
}else {
@ -237,54 +205,47 @@ public class JiaolianController {
}
}
<<<<<<< HEAD
/**
*
*/
=======
//后端修改
>>>>>>> develop
*
*/
@RequestMapping("/update")
public R update(@RequestBody JiaolianEntity jiaolian, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,jiaolian:{}",this.getClass().getName(),jiaolian.toString());
JiaolianEntity oldJiaolianEntity = jiaolianService.selectById(jiaolian.getId());//查询原先数据
logger.debug("修改方法:,,控制器:{},,教练信息:{}",this.getClass().getName(),jiaolian.toString());
// 查询原有数据
JiaolianEntity oldJiaolianEntity = jiaolianService.selectById(jiaolian.getId());
// 获取当前用户角色
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// 处理空字段
if("".equals(jiaolian.getJiaolianPhoto()) || "null".equals(jiaolian.getJiaolianPhoto())){
jiaolian.setJiaolianPhoto(null);
jiaolian.setJiaolianPhoto(null);
}
if("".equals(jiaolian.getJiaolianContent()) || "null".equals(jiaolian.getJiaolianContent())){
jiaolian.setJiaolianContent(null);
jiaolian.setJiaolianContent(null);
}
jiaolianService.updateById(jiaolian);//根据id更新
return R.ok();
// 更新数据
jiaolianService.updateById(jiaolian);
return R.ok();
}
<<<<<<< HEAD
/**
*
*/
=======
//删除
>>>>>>> develop
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<JiaolianEntity> oldJiaolianList =jiaolianService.selectBatchIds(Arrays.asList(ids));//要删除的数据
logger.debug("删除方法:,,控制器:{},,IDs:{}",this.getClass().getName(),ids.toString());
// 查询要删除的数据
List<JiaolianEntity> oldJiaolianList =jiaolianService.selectBatchIds(Arrays.asList(ids));
// 准备更新列表
ArrayList<JiaolianEntity> list = new ArrayList<>();
for(Integer id:ids){
JiaolianEntity jiaolianEntity = new JiaolianEntity();
jiaolianEntity.setId(id);
jiaolianEntity.setDataDelete(2);
jiaolianEntity.setDataDelete(2); // 标记为删除
list.add(jiaolianEntity);
}
// 批量更新删除状态
if(list != null && list.size() >0){
jiaolianService.updateBatchById(list);
}
@ -292,25 +253,24 @@ public class JiaolianController {
return R.ok();
}
<<<<<<< HEAD
/**
*
*
*/
=======
//批量上传
>>>>>>> develop
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
logger.debug("批量导入方法:,,控制器:{},,文件名:{}",this.getClass().getName(),fileName);
// 获取当前用户ID
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
// 创建日期格式化对象
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<JiaolianEntity> jiaolianList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
// 准备导入的数据列表
List<JiaolianEntity> jiaolianList = new ArrayList<>();
// 需要检查重复的字段映射
Map<String, List<String>> seachFields= new HashMap<>();
// 当前日期
Date date = new Date();
// 检查文件后缀
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
@ -319,53 +279,54 @@ public class JiaolianController {
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
// 获取文件路径
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
// 读取Excel文件
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());
dataList.remove(0);// 删除标题行
for(List<String> data:dataList){
//循环
// 创建教练实体
JiaolianEntity jiaolianEntity = new JiaolianEntity();
// jiaolianEntity.setUsername(data.get(0)); //账户 要改的
// jiaolianEntity.setPassword("123456");//密码
// jiaolianEntity.setJiaolianName(data.get(0)); //教练名称 要改的
// jiaolianEntity.setJiaolianPhone(data.get(0)); //教练手机号 要改的
// jiaolianEntity.setJiaolianPhoto("");//详情和图片
// jiaolianEntity.setSexTypes(Integer.valueOf(data.get(0))); //性别 要改的
// jiaolianEntity.setJiaolianEmail(data.get(0)); //教练邮箱 要改的
// jiaolianEntity.setJiaolianContent("");//详情和图片
// jiaolianEntity.setDataDelete(1);//逻辑删除字段
// jiaolianEntity.setInsertTime(date);//时间
// jiaolianEntity.setCreateTime(date);//时间
// 设置各字段值示例代码实际应根据Excel列设置
// jiaolianEntity.setUsername(data.get(0)); // 账户
// jiaolianEntity.setPassword("123456"); // 密码
// jiaolianEntity.setJiaolianName(data.get(0)); // 教练名称
// jiaolianEntity.setJiaolianPhone(data.get(0)); // 教练手机号
// jiaolianEntity.setJiaolianPhoto(""); // 照片
// jiaolianEntity.setSexTypes(Integer.valueOf(data.get(0))); // 性别
// jiaolianEntity.setJiaolianEmail(data.get(0)); // 邮箱
// jiaolianEntity.setJiaolianContent(""); // 内容
// jiaolianEntity.setDataDelete(1); // 删除状态
// jiaolianEntity.setInsertTime(date); // 插入时间
// jiaolianEntity.setCreateTime(date); // 创建时间
jiaolianList.add(jiaolianEntity);
//把要查询是否重复的字段放入map中
//账户
if(seachFields.containsKey("username")){
List<String> username = seachFields.get("username");
username.add(data.get(0));//要改的
}else{
List<String> username = new ArrayList<>();
username.add(data.get(0));//要改的
seachFields.put("username",username);
}
//教练手机号
if(seachFields.containsKey("jiaolianPhone")){
List<String> jiaolianPhone = seachFields.get("jiaolianPhone");
jiaolianPhone.add(data.get(0));//要改的
}else{
List<String> jiaolianPhone = new ArrayList<>();
jiaolianPhone.add(data.get(0));//要改的
seachFields.put("jiaolianPhone",jiaolianPhone);
}
// 收集需要检查重复的字段
// 账户字段检查
if(seachFields.containsKey("username")){
List<String> username = seachFields.get("username");
username.add(data.get(0));
}else{
List<String> username = new ArrayList<>();
username.add(data.get(0));
seachFields.put("username",username);
}
// 手机号字段检查
if(seachFields.containsKey("jiaolianPhone")){
List<String> jiaolianPhone = seachFields.get("jiaolianPhone");
jiaolianPhone.add(data.get(0));
}else{
List<String> jiaolianPhone = new ArrayList<>();
jiaolianPhone.add(data.get(0));
seachFields.put("jiaolianPhone",jiaolianPhone);
}
}
//查询是否重复
//账户
// 检查账户是否重复
List<JiaolianEntity> jiaolianEntities_username = jiaolianService.selectList(new EntityWrapper<JiaolianEntity>().in("username", seachFields.get("username")).eq("data_delete", 1));
if(jiaolianEntities_username.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
@ -374,7 +335,7 @@ public class JiaolianController {
}
return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
}
//教练手机号
// 检查手机号是否重复
List<JiaolianEntity> jiaolianEntities_jiaolianPhone = jiaolianService.selectList(new EntityWrapper<JiaolianEntity>().in("jiaolian_phone", seachFields.get("jiaolianPhone")).eq("data_delete", 1));
if(jiaolianEntities_jiaolianPhone.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
@ -383,6 +344,7 @@ public class JiaolianController {
}
return R.error(511,"数据库的该表中的 [教练手机号] 字段已经存在 存在数据为:"+repeatFields.toString());
}
// 批量插入数据
jiaolianService.insertBatch(jiaolianList);
return R.ok();
}
@ -394,23 +356,23 @@ public class JiaolianController {
}
}
<<<<<<< HEAD
/**
*
*/
=======
//登录
>>>>>>> develop
@IgnoreAuth
*
*/
@IgnoreAuth // 忽略认证
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
// 根据用户名查询教练
JiaolianEntity jiaolian = jiaolianService.selectOne(new EntityWrapper<JiaolianEntity>().eq("username", username));
// 验证账号密码
if(jiaolian==null || !jiaolian.getPassword().equals(password))
return R.error("账号或密码不正确");
// 检查账号状态
else if(jiaolian.getDataDelete() != 1)
return R.error("账户已被删除");
// 生成令牌
String token = tokenService.generateToken(jiaolian.getId(),username, "jiaolian", "教练");
// 构建返回结果
R r = R.ok();
r.put("token", token);
r.put("role","教练");
@ -420,117 +382,107 @@ public class JiaolianController {
return r;
}
<<<<<<< HEAD
/**
*
*/
=======
//注册
>>>>>>> develop
@IgnoreAuth
*
*/
@IgnoreAuth // 忽略认证
@PostMapping(value = "/register")
public R register(@RequestBody JiaolianEntity jiaolian, HttpServletRequest request) {
// ValidatorUtils.validateEntity(user);
// 构建查询条件,检查用户名和手机号是否已存在
Wrapper<JiaolianEntity> queryWrapper = new EntityWrapper<JiaolianEntity>()
.eq("username", jiaolian.getUsername())
.or()
.eq("jiaolian_phone", jiaolian.getJiaolianPhone())
.andNew()
.eq("data_delete", 1)
;
.eq("username", jiaolian.getUsername())
.or()
.eq("jiaolian_phone", jiaolian.getJiaolianPhone())
.andNew()
.eq("data_delete", 1)
;
// 执行查询
JiaolianEntity jiaolianEntity = jiaolianService.selectOne(queryWrapper);
if(jiaolianEntity != null)
return R.error("账户或者教练手机号已经被使用");
jiaolian.setDataDelete(1);
jiaolian.setInsertTime(new Date());
jiaolian.setCreateTime(new Date());
// 设置默认值
jiaolian.setDataDelete(1); // 数据状态
jiaolian.setInsertTime(new Date()); // 插入时间
jiaolian.setCreateTime(new Date()); // 创建时间
// 保存教练信息
jiaolianService.insert(jiaolian);
return R.ok();
}
<<<<<<< HEAD
/**
*
*/
=======
//重置密码
>>>>>>> develop
@GetMapping(value = "/resetPassword")
public R resetPassword(Integer id, HttpServletRequest request) {
// 根据ID查询教练
JiaolianEntity jiaolian = jiaolianService.selectById(id);
// 重置密码为默认值
jiaolian.setPassword("123456");
// 更新密码
jiaolianService.updateById(jiaolian);
return R.ok();
}
<<<<<<< HEAD
/**
*
*/
=======
//修改密码
>>>>>>> develop
@GetMapping(value = "/updatePassword")
public R updatePassword(String oldPassword, String newPassword, HttpServletRequest request) {
/**
*
*/
@GetMapping(value = "/updatePassword")
public R updatePassword(String oldPassword, String newPassword, HttpServletRequest request) {
// 获取当前登录教练
JiaolianEntity jiaolian = jiaolianService.selectById((Integer)request.getSession().getAttribute("userId"));
if(newPassword == null){
return R.error("新密码不能为空") ;
}
if(!oldPassword.equals(jiaolian.getPassword())){
return R.error("原密码输入错误");
}
if(newPassword.equals(jiaolian.getPassword())){
return R.error("新密码不能和原密码一致") ;
}
// 验证新密码
if(newPassword == null){
return R.error("新密码不能为空") ;
}
// 验证旧密码
if(!oldPassword.equals(jiaolian.getPassword())){
return R.error("原密码输入错误");
}
// 检查新旧密码是否相同
if(newPassword.equals(jiaolian.getPassword())){
return R.error("新密码不能和原密码一致") ;
}
// 更新密码
jiaolian.setPassword(newPassword);
jiaolianService.updateById(jiaolian);
return R.ok();
}
jiaolianService.updateById(jiaolian);
return R.ok();
}
<<<<<<< HEAD
/**
*
*
*/
=======
//忘记密码
>>>>>>> develop
@IgnoreAuth
@IgnoreAuth // 忽略认证
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request) {
// 根据用户名查询教练
JiaolianEntity jiaolian = jiaolianService.selectOne(new EntityWrapper<JiaolianEntity>().eq("username", username));
if(jiaolian!=null){
// 重置密码为默认值
jiaolian.setPassword("123456");
// 更新密码
jiaolianService.updateById(jiaolian);
return R.ok();
}else{
return R.error("账号不存在");
}else {
return R.error("账号不存在");
}
}
<<<<<<< HEAD
/**
* session
*/
=======
//获取用户的session用户信息
>>>>>>> develop
*
*/
@RequestMapping("/session")
public R getCurrJiaolian(HttpServletRequest request){
// 从会话中获取用户ID
Integer id = (Integer)request.getSession().getAttribute("userId");
// 查询教练信息
JiaolianEntity jiaolian = jiaolianService.selectById(id);
if(jiaolian !=null){
//entity转view
// 实体转视图
JiaolianView view = new JiaolianView();
BeanUtils.copyProperties( jiaolian , view );//把实体数据重构到view中
//修改对应字典表字段
// 复制属性
BeanUtils.copyProperties( jiaolian , view );
// 转换字典字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
@ -538,108 +490,86 @@ public class JiaolianController {
}
}
<<<<<<< HEAD
/**
* 退
*/
=======
//退出
>>>>>>> develop
* 退
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
// 使会话失效
request.getSession().invalidate();
return R.ok("退出成功");
}
<<<<<<< HEAD
/**
*
*/
=======
//前端列表
>>>>>>> develop
@IgnoreAuth
*
*/
@IgnoreAuth // 忽略认证
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
logger.debug("前端列表查询方法:,,控制器:{},,参数:{}",this.getClass().getName(),JSONObject.toJSONString(params));
// 检查参数有效性
CommonUtil.checkMap(params);
// 查询分页数据
PageUtils page = jiaolianService.queryPage(params);
//字典数据转换
// 字典数据转换
List<JiaolianView> list =(List<JiaolianView>)page.getList();
for(JiaolianView c:list)
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
dictionaryService.dictionaryConvert(c, request); // 转换字典字段
return R.ok().put("data", page);
}
<<<<<<< HEAD
/**
*
*/
=======
//前端详情
>>>>>>> develop
*
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
logger.debug("前端详情查询方法:,,控制器:{},,ID:{}",this.getClass().getName(),id);
// 根据ID查询教练
JiaolianEntity jiaolian = jiaolianService.selectById(id);
if(jiaolian !=null){
//entity转view
JiaolianView view = new JiaolianView();
BeanUtils.copyProperties( jiaolian , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
if(jiaolian !=null){
// 实体转视图
JiaolianView view = new JiaolianView();
// 复制属性
BeanUtils.copyProperties( jiaolian , view );
// 转换字典字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
<<<<<<< HEAD
/**
*
*/
=======
//前端保存
>>>>>>> develop
*
*/
@RequestMapping("/add")
public R add(@RequestBody JiaolianEntity jiaolian, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,jiaolian:{}",this.getClass().getName(),jiaolian.toString());
logger.debug("前端保存方法:,,控制器:{},,教练信息:{}",this.getClass().getName(),jiaolian.toString());
// 构建查询条件,检查用户名和手机号是否已存在
Wrapper<JiaolianEntity> queryWrapper = new EntityWrapper<JiaolianEntity>()
.eq("username", jiaolian.getUsername())
.or()
.eq("jiaolian_phone", jiaolian.getJiaolianPhone())
.andNew()
.eq("data_delete", 1)
// .notIn("jiaolian_types", new Integer[]{102})
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
.eq("username", jiaolian.getUsername())
.or()
.eq("jiaolian_phone", jiaolian.getJiaolianPhone())
.andNew()
.eq("data_delete", 1)
;
logger.info("SQL语句:"+queryWrapper.getSqlSegment());
// 执行查询
JiaolianEntity jiaolianEntity = jiaolianService.selectOne(queryWrapper);
if(jiaolianEntity==null){
jiaolian.setDataDelete(1);
jiaolian.setInsertTime(new Date());
jiaolian.setCreateTime(new Date());
jiaolian.setPassword("123456");
jiaolianService.insert(jiaolian);
// 设置默认值
jiaolian.setDataDelete(1); // 数据状态
jiaolian.setInsertTime(new Date()); // 插入时间
jiaolian.setCreateTime(new Date()); // 创建时间
jiaolian.setPassword("123456"); // 默认密码
// 保存教练信息
jiaolianService.insert(jiaolian);
return R.ok();
}else {
return R.error(511,"账户或者教练手机号已经被使用");
}
}
}
}

@ -1,283 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
*
*
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/jiaolianYuyue")
public class JiaolianYuyueController {
private static final Logger logger = LoggerFactory.getLogger(JiaolianYuyueController.class);
private static final String TABLE_NAME = "jiaolianYuyue";
@Autowired
private JiaolianYuyueService jiaolianYuyueService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private ForumService forumService;//健身论坛
@Autowired
private JianshenkechengService jianshenkechengService;//健身课程
@Autowired
private JianshenkechengCollectionService jianshenkechengCollectionService;//课程收藏
@Autowired
private JianshenkechengLiuyanService jianshenkechengLiuyanService;//课程留言
@Autowired
private JiaolianService jiaolianService;//教练
@Autowired
private NewsService newsService;//健身资讯
@Autowired
private SingleSeachService singleSeachService;//单页数据
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("教练".equals(role))
params.put("jiaolianId",request.getSession().getAttribute("userId"));
CommonUtil.checkMap(params);
PageUtils page = jiaolianYuyueService.queryPage(params);
//字典表数据转换
List<JiaolianYuyueView> list =(List<JiaolianYuyueView>)page.getList();
for(JiaolianYuyueView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
JiaolianYuyueEntity jiaolianYuyue = jiaolianYuyueService.selectById(id);
if(jiaolianYuyue !=null){
//entity转view
JiaolianYuyueView view = new JiaolianYuyueView();
BeanUtils.copyProperties( jiaolianYuyue , view );//把实体数据重构到view中
//级联表 用户
//级联表
YonghuEntity yonghu = yonghuService.selectById(jiaolianYuyue.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
@RequestMapping("/save")
public R save(@RequestBody JiaolianYuyueEntity jiaolianYuyue, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,jiaolianYuyue:{}",this.getClass().getName(),jiaolianYuyue.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("用户".equals(role))
jiaolianYuyue.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
Wrapper<JiaolianYuyueEntity> queryWrapper = new EntityWrapper<JiaolianYuyueEntity>()
.eq("yonghu_id", jiaolianYuyue.getYonghuId())
.in("jiaolian_yuyue_yesno_types", new Integer[]{1,2})
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
JiaolianYuyueEntity jiaolianYuyueEntity = jiaolianYuyueService.selectOne(queryWrapper);
if(jiaolianYuyueEntity==null){
jiaolianYuyue.setJiaolianYuyueYesnoTypes(1);
jiaolianYuyue.setInsertTime(new Date());
jiaolianYuyue.setCreateTime(new Date());
jiaolianYuyueService.insert(jiaolianYuyue);
return R.ok();
}else {
if(jiaolianYuyueEntity.getJiaolianYuyueYesnoTypes()==1)
return R.error(511,"有相同的待审核的数据");
else if(jiaolianYuyueEntity.getJiaolianYuyueYesnoTypes()==2)
return R.error(511,"有相同的审核通过的数据");
else
return R.error(511,"表中有相同数据");
}
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody JiaolianYuyueEntity jiaolianYuyue, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,jiaolianYuyue:{}",this.getClass().getName(),jiaolianYuyue.toString());
JiaolianYuyueEntity oldJiaolianYuyueEntity = jiaolianYuyueService.selectById(jiaolianYuyue.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("用户".equals(role))
// jiaolianYuyue.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
if("".equals(jiaolianYuyue.getJiaolianYuyueText()) || "null".equals(jiaolianYuyue.getJiaolianYuyueText())){
jiaolianYuyue.setJiaolianYuyueText(null);
}
if("".equals(jiaolianYuyue.getJiaolianYuyueYesnoText()) || "null".equals(jiaolianYuyue.getJiaolianYuyueYesnoText())){
jiaolianYuyue.setJiaolianYuyueYesnoText(null);
}
jiaolianYuyueService.updateById(jiaolianYuyue);//根据id更新
return R.ok();
}
/**
*
*/
@RequestMapping("/shenhe")
public R shenhe(@RequestBody JiaolianYuyueEntity jiaolianYuyueEntity, HttpServletRequest request){
logger.debug("shenhe方法:,,Controller:{},,jiaolianYuyueEntity:{}",this.getClass().getName(),jiaolianYuyueEntity.toString());
JiaolianYuyueEntity oldJiaolianYuyue = jiaolianYuyueService.selectById(jiaolianYuyueEntity.getId());//查询原先数据
// if(jiaolianYuyueEntity.getJiaolianYuyueYesnoTypes() == 2){//通过
// jiaolianYuyueEntity.setJiaolianYuyueTypes();
// }else if(jiaolianYuyueEntity.getJiaolianYuyueYesnoTypes() == 3){//拒绝
// jiaolianYuyueEntity.setJiaolianYuyueTypes();
// }
jiaolianYuyueService.updateById(jiaolianYuyueEntity);//审核
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<JiaolianYuyueEntity> oldJiaolianYuyueList =jiaolianYuyueService.selectBatchIds(Arrays.asList(ids));//要删除的数据
jiaolianYuyueService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
*
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<JiaolianYuyueEntity> jiaolianYuyueList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
JiaolianYuyueEntity jiaolianYuyueEntity = new JiaolianYuyueEntity();
// jiaolianYuyueEntity.setJiaolianYuyueUuidNumber(data.get(0)); //预约编号 要改的
// jiaolianYuyueEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的
// jiaolianYuyueEntity.setJiaolianYuyueText(data.get(0)); //预约备注 要改的
// jiaolianYuyueEntity.setJiaolianYuyueTime(sdf.parse(data.get(0))); //预约时间 要改的
// jiaolianYuyueEntity.setJiaolianYuyueYesnoTypes(Integer.valueOf(data.get(0))); //预约状态 要改的
// jiaolianYuyueEntity.setJiaolianYuyueYesnoText(data.get(0)); //审核回复 要改的
// jiaolianYuyueEntity.setInsertTime(date);//时间
// jiaolianYuyueEntity.setCreateTime(date);//时间
jiaolianYuyueList.add(jiaolianYuyueEntity);
//把要查询是否重复的字段放入map中
//预约编号
if(seachFields.containsKey("jiaolianYuyueUuidNumber")){
List<String> jiaolianYuyueUuidNumber = seachFields.get("jiaolianYuyueUuidNumber");
jiaolianYuyueUuidNumber.add(data.get(0));//要改的
}else{
List<String> jiaolianYuyueUuidNumber = new ArrayList<>();
jiaolianYuyueUuidNumber.add(data.get(0));//要改的
seachFields.put("jiaolianYuyueUuidNumber",jiaolianYuyueUuidNumber);
}
}
//查询是否重复
//预约编号
=======
package com.controller; // 声明包路径表示该文件位于com.controller包下
import java.io.File; // 导入文件操作类,用于处理文件上传
@ -312,10 +32,10 @@ import com.utils.R; // 导入统一返回结果类
import com.alibaba.fastjson.*; // 导入FastJSON相关类
//教练预约申请
//后端接口
//@author
// @email
//教练预约申请
//后端接口
//@author
// @email
@RestController // 标识为RESTful控制器用于处理HTTP请求
@Controller // 标识为Spring控制器
@ -353,8 +73,8 @@ public class JiaolianYuyueController {
private UsersService usersService; // 自动注入管理员服务
//后端列表
//处理分页查询请求
//后端列表
//处理分页查询请求
@RequestMapping("/page") // 映射分页查询请求
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); // 记录请求日志
@ -377,8 +97,8 @@ public class JiaolianYuyueController {
}
//后端详情
//根据ID查询单条预约详情
//后端详情
//根据ID查询单条预约详情
@RequestMapping("/info/{id}") // 映射详情查询请求
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录请求日志
@ -402,8 +122,8 @@ public class JiaolianYuyueController {
}
//后端保存
//处理新增预约请求
//后端保存
//处理新增预约请求
@RequestMapping("/save") // 映射保存请求
public R save(@RequestBody JiaolianYuyueEntity jiaolianYuyue, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,jiaolianYuyue:{}",this.getClass().getName(),jiaolianYuyue.toString()); // 记录请求日志
@ -438,8 +158,8 @@ public class JiaolianYuyueController {
}
//后端修改
//处理更新预约请求
//后端修改
//处理更新预约请求
@RequestMapping("/update") // 映射更新请求
public R update(@RequestBody JiaolianYuyueEntity jiaolianYuyue, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,jiaolianYuyue:{}",this.getClass().getName(),jiaolianYuyue.toString()); // 记录请求日志
@ -458,8 +178,8 @@ public class JiaolianYuyueController {
}
//审核
//处理预约审核请求
//审核
//处理预约审核请求
@RequestMapping("/shenhe") // 映射审核请求
public R shenhe(@RequestBody JiaolianYuyueEntity jiaolianYuyueEntity, HttpServletRequest request){
logger.debug("shenhe方法:,,Controller:{},,jiaolianYuyueEntity:{}",this.getClass().getName(),jiaolianYuyueEntity.toString()); // 记录请求日志
@ -471,8 +191,8 @@ public class JiaolianYuyueController {
}
//删除
//处理删除预约请求
//删除
//处理删除预约请求
@RequestMapping("/delete") // 映射删除请求
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); // 记录请求日志
@ -482,8 +202,8 @@ public class JiaolianYuyueController {
}
//批量上传
//处理批量导入数据请求
//批量上传
//处理批量导入数据请求
@RequestMapping("/batchInsert") // 映射批量导入请求
public R save(String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); // 记录请求日志
@ -524,7 +244,6 @@ public class JiaolianYuyueController {
}
// 检查预约编号是否已存在
>>>>>>> develop
List<JiaolianYuyueEntity> jiaolianYuyueEntities_jiaolianYuyueUuidNumber = jiaolianYuyueService.selectList(new EntityWrapper<JiaolianYuyueEntity>().in("jiaolian_yuyue_uuid_number", seachFields.get("jiaolianYuyueUuidNumber")));
if(jiaolianYuyueEntities_jiaolianYuyueUuidNumber.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
@ -533,117 +252,20 @@ public class JiaolianYuyueController {
}
return R.error(511,"数据库的该表中的 [预约编号] 字段已经存在 存在数据为:"+repeatFields.toString());
}
<<<<<<< HEAD
jiaolianYuyueService.insertBatch(jiaolianYuyueList);
return R.ok();
=======
jiaolianYuyueService.insertBatch(jiaolianYuyueList); // 批量插入数据
return R.ok(); // 返回成功信息
>>>>>>> develop
}
}
}
}catch (Exception e){
<<<<<<< HEAD
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
=======
e.printStackTrace(); // 打印异常堆栈
return R.error(511,"批量插入数据异常,请联系管理员"); // 返回错误信息
>>>>>>> develop
}
}
<<<<<<< HEAD
/**
*
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
PageUtils page = jiaolianYuyueService.queryPage(params);
//字典表数据转换
List<JiaolianYuyueView> list =(List<JiaolianYuyueView>)page.getList();
for(JiaolianYuyueView c:list)
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
JiaolianYuyueEntity jiaolianYuyue = jiaolianYuyueService.selectById(id);
if(jiaolianYuyue !=null){
//entity转view
JiaolianYuyueView view = new JiaolianYuyueView();
BeanUtils.copyProperties( jiaolianYuyue , view );//把实体数据重构到view中
//级联表
YonghuEntity yonghu = yonghuService.selectById(jiaolianYuyue.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
@RequestMapping("/add")
public R add(@RequestBody JiaolianYuyueEntity jiaolianYuyue, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,jiaolianYuyue:{}",this.getClass().getName(),jiaolianYuyue.toString());
Wrapper<JiaolianYuyueEntity> queryWrapper = new EntityWrapper<JiaolianYuyueEntity>()
.eq("jiaolian_yuyue_uuid_number", jiaolianYuyue.getJiaolianYuyueUuidNumber())
.eq("yonghu_id", jiaolianYuyue.getYonghuId())
.eq("jiaolian_yuyue_text", jiaolianYuyue.getJiaolianYuyueText())
.in("jiaolian_yuyue_yesno_types", new Integer[]{1,2})
.eq("jiaolian_yuyue_yesno_text", jiaolianYuyue.getJiaolianYuyueYesnoText())
// .notIn("jiaolian_yuyue_types", new Integer[]{102})
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
JiaolianYuyueEntity jiaolianYuyueEntity = jiaolianYuyueService.selectOne(queryWrapper);
if(jiaolianYuyueEntity==null){
jiaolianYuyue.setJiaolianYuyueYesnoTypes(1);
jiaolianYuyue.setInsertTime(new Date());
jiaolianYuyue.setCreateTime(new Date());
jiaolianYuyueService.insert(jiaolianYuyue);
return R.ok();
}else {
if(jiaolianYuyueEntity.getJiaolianYuyueYesnoTypes()==1)
return R.error(511,"有相同的待审核的数据");
else if(jiaolianYuyueEntity.getJiaolianYuyueYesnoTypes()==2)
return R.error(511,"有相同的审核通过的数据");
else
return R.error(511,"表中有相同数据");
}
}
}
=======
//前端列表
//处理前端分页查询请求
//前端列表
//处理前端分页查询请求
@IgnoreAuth // 忽略认证
@RequestMapping("/list") // 映射列表查询请求
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
@ -660,8 +282,8 @@ public class JiaolianYuyueController {
}
//前端详情
//处理前端详情查询请求
//前端详情
//处理前端详情查询请求
@RequestMapping("/detail/{id}") // 映射详情查询请求
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录请求日志
@ -685,7 +307,7 @@ public class JiaolianYuyueController {
}
//前端保存
//前端保存
//处理前端新增预约请求
@RequestMapping("/add") // 映射新增请求
public R add(@RequestBody JiaolianYuyueEntity jiaolianYuyue, HttpServletRequest request){
@ -715,5 +337,4 @@ public class JiaolianYuyueController {
return R.error(511,"表中有相同数据"); // 返回错误信息
}
}
}
>>>>>>> develop
}

@ -1,45 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
*
*
* @author
* @email
*/
=======
package com.controller; // 定义包名为com.controller
import java.io.File; // 文件操作类
@ -75,99 +33,17 @@ import com.alibaba.fastjson.*; // 阿里巴巴FastJSON库
//健身资讯
//后端接口
//@author
// @email
//健身资讯
//后端接口
//@author
// @email
>>>>>>> develop
@RestController
@Controller
@RequestMapping("/news")
public class NewsController {
private static final Logger logger = LoggerFactory.getLogger(NewsController.class);
<<<<<<< HEAD
private static final String TABLE_NAME = "news";
@Autowired
private NewsService newsService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private ForumService forumService;//健身论坛
@Autowired
private JianshenkechengService jianshenkechengService;//健身课程
@Autowired
private JianshenkechengCollectionService jianshenkechengCollectionService;//课程收藏
@Autowired
private JianshenkechengLiuyanService jianshenkechengLiuyanService;//课程留言
@Autowired
private JiaolianService jiaolianService;//教练
@Autowired
private JiaolianYuyueService jiaolianYuyueService;//教练预约申请
@Autowired
private SingleSeachService singleSeachService;//单页数据
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("教练".equals(role))
params.put("jiaolianId",request.getSession().getAttribute("userId"));
CommonUtil.checkMap(params);
PageUtils page = newsService.queryPage(params);
//字典表数据转换
List<NewsView> list =(List<NewsView>)page.getList();
for(NewsView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
NewsEntity news = newsService.selectById(id);
if(news !=null){
//entity转view
NewsView view = new NewsView();
BeanUtils.copyProperties( news , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
=======
private static final String TABLE_NAME = "news"; // 数据库表名
@Autowired
@ -198,11 +74,11 @@ public class NewsController {
private UsersService usersService; // 管理员服务
//后端列表
//分页查询健身资讯数据
//@param params 请求参数,包含分页和查询条件
//@param request HTTP请求对象
//@return 返回分页数据和状态信息
//后端列表
//分页查询健身资讯数据
//@param params 请求参数,包含分页和查询条件
//@param request HTTP请求对象
//@return 返回分页数据和状态信息
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
@ -226,11 +102,11 @@ public class NewsController {
}
//后端详情
//根据ID查询单条健身资讯详情
//@param id 资讯ID
//@param request HTTP请求对象
//@return 返回资讯详情和状态信息
//后端详情
//根据ID查询单条健身资讯详情
//@param id 资讯ID
//@param request HTTP请求对象
//@return 返回资讯详情和状态信息
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
@ -248,109 +124,15 @@ public class NewsController {
}
//后端保存
//新增健身资讯
//@param news 资讯实体
//@param request HTTP请求对象
//@return 返回操作结果状态
>>>>>>> develop
//后端保存
//新增健身资讯
//@param news 资讯实体
//@param request HTTP请求对象
//@return 返回操作结果状态
@RequestMapping("/save")
public R save(@RequestBody NewsEntity news, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString());
<<<<<<< HEAD
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper<NewsEntity> queryWrapper = new EntityWrapper<NewsEntity>()
.eq("news_name", news.getNewsName())
.eq("news_types", news.getNewsTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
NewsEntity newsEntity = newsService.selectOne(queryWrapper);
if(newsEntity==null){
news.setInsertTime(new Date());
news.setCreateTime(new Date());
newsService.insert(news);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody NewsEntity news, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString());
NewsEntity oldNewsEntity = newsService.selectById(news.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
if("".equals(news.getNewsPhoto()) || "null".equals(news.getNewsPhoto())){
news.setNewsPhoto(null);
}
if("".equals(news.getNewsContent()) || "null".equals(news.getNewsContent())){
news.setNewsContent(null);
}
newsService.updateById(news);//根据id更新
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<NewsEntity> oldNewsList =newsService.selectBatchIds(Arrays.asList(ids));//要删除的数据
newsService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
*
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<NewsEntity> newsList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
NewsEntity newsEntity = new NewsEntity();
// newsEntity.setNewsName(data.get(0)); //资讯标题 要改的
// newsEntity.setNewsTypes(Integer.valueOf(data.get(0))); //资讯类型 要改的
=======
String role = String.valueOf(request.getSession().getAttribute("role")); // 获取用户角色
if(false)
return R.error(511,"永远不会进入");
@ -373,11 +155,11 @@ public class NewsController {
}
}
//后端修改
//更新健身资讯
//@param news 资讯实体
//@param request HTTP请求对象
//@return 返回操作结果状态
//后端修改
//更新健身资讯
//@param news 资讯实体
//@param request HTTP请求对象
//@return 返回操作结果状态
@RequestMapping("/update")
public R update(@RequestBody NewsEntity news, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString());
@ -398,11 +180,11 @@ public class NewsController {
}
//删除
//批量删除健身资讯
//@param ids 要删除的资讯ID数组
//@param request HTTP请求对象
//@return 返回操作结果状态
//删除
//批量删除健身资讯
//@param ids 要删除的资讯ID数组
//@param request HTTP请求对象
//@return 返回操作结果状态
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
@ -413,11 +195,11 @@ public class NewsController {
}
//批量上传
//通过Excel文件批量导入健身资讯数据
//@param fileName Excel文件名
//@param request HTTP请求对象
//@return 返回操作结果状态
//批量上传
//通过Excel文件批量导入健身资讯数据
//@param fileName Excel文件名
//@param request HTTP请求对象
//@return 返回操作结果状态
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
@ -447,22 +229,10 @@ public class NewsController {
NewsEntity newsEntity = new NewsEntity();
// newsEntity.setNewsName(data.get(0)); // 资讯标题 要改的
// newsEntity.setNewsTypes(Integer.valueOf(data.get(0))); // 资讯类型 要改的
>>>>>>> develop
// newsEntity.setNewsPhoto("");//详情和图片
// newsEntity.setInsertTime(date);//时间
// newsEntity.setNewsContent("");//详情和图片
// newsEntity.setCreateTime(date);//时间
<<<<<<< HEAD
newsList.add(newsEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
newsService.insertBatch(newsList);
return R.ok();
=======
newsList.add(newsEntity); // 添加到列表
// 把要查询是否重复的字段放入map中
@ -471,78 +241,26 @@ public class NewsController {
// 查询是否重复
newsService.insertBatch(newsList); // 批量插入
return R.ok(); // 返回成功
>>>>>>> develop
}
}
}
}catch (Exception e){
e.printStackTrace();
<<<<<<< HEAD
return R.error(511,"批量插入数据异常,请联系管理员");
=======
return R.error(511,"批量插入数据异常,请联系管理员"); // 返回错误信息
>>>>>>> develop
}
}
<<<<<<< HEAD
/**
*
*/
=======
//前端列表
//分页查询健身资讯数据(无需认证)
//@param params 请求参数,包含分页和查询条件
//@param request HTTP请求对象
//@return 返回分页数据和状态信息
>>>>>>> develop
//前端列表
//分页查询健身资讯数据(无需认证)
//@param params 请求参数,包含分页和查询条件
//@param request HTTP请求对象
//@return 返回分页数据和状态信息
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
<<<<<<< HEAD
CommonUtil.checkMap(params);
PageUtils page = newsService.queryPage(params);
//字典表数据转换
List<NewsView> list =(List<NewsView>)page.getList();
for(NewsView c:list)
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
NewsEntity news = newsService.selectById(id);
if(news !=null){
//entity转view
NewsView view = new NewsView();
BeanUtils.copyProperties( news , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
=======
CommonUtil.checkMap(params); // 检查参数
PageUtils page = newsService.queryPage(params); // 分页查询
@ -555,11 +273,11 @@ public class NewsController {
}
//前端详情
//根据ID查询单条健身资讯详情
//@param id 资讯ID
//@param request HTTP请求对象
//@return 返回资讯详情和状态信息
//前端详情
//根据ID查询单条健身资讯详情
//@param id 资讯ID
//@param request HTTP请求对象
//@return 返回资讯详情和状态信息
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
@ -578,37 +296,15 @@ public class NewsController {
}
//前端保存
//新增健身资讯
//@param news 资讯实体
//@param request HTTP请求对象
//@return 返回操作结果状态
>>>>>>> develop
//前端保存
//新增健身资讯
//@param news 资讯实体
//@param request HTTP请求对象
//@return 返回操作结果状态
@RequestMapping("/add")
public R add(@RequestBody NewsEntity news, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString());
Wrapper<NewsEntity> queryWrapper = new EntityWrapper<NewsEntity>()
<<<<<<< HEAD
.eq("news_name", news.getNewsName())
.eq("news_types", news.getNewsTypes())
// .notIn("news_types", new Integer[]{102})
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
NewsEntity newsEntity = newsService.selectOne(queryWrapper);
if(newsEntity==null){
news.setInsertTime(new Date());
news.setCreateTime(new Date());
newsService.insert(news);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
}
=======
.eq("news_name", news.getNewsName()) // 资讯标题相等
.eq("news_types", news.getNewsTypes()) // 资讯类型相等
// .notIn("news_types", new Integer[]{102})
@ -625,5 +321,4 @@ public class NewsController {
return R.error(511,"表中有相同数据"); // 返回错误信息
}
}
}
>>>>>>> develop
}

@ -1,241 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
*
*
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/singleSeach")
public class SingleSeachController {
private static final Logger logger = LoggerFactory.getLogger(SingleSeachController.class);
private static final String TABLE_NAME = "singleSeach";
@Autowired
private SingleSeachService singleSeachService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private ForumService forumService;//健身论坛
@Autowired
private JianshenkechengService jianshenkechengService;//健身课程
@Autowired
private JianshenkechengCollectionService jianshenkechengCollectionService;//课程收藏
@Autowired
private JianshenkechengLiuyanService jianshenkechengLiuyanService;//课程留言
@Autowired
private JiaolianService jiaolianService;//教练
@Autowired
private JiaolianYuyueService jiaolianYuyueService;//教练预约申请
@Autowired
private NewsService newsService;//健身资讯
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("教练".equals(role))
params.put("jiaolianId",request.getSession().getAttribute("userId"));
CommonUtil.checkMap(params);
PageUtils page = singleSeachService.queryPage(params);
//字典表数据转换
List<SingleSeachView> list =(List<SingleSeachView>)page.getList();
for(SingleSeachView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
SingleSeachEntity singleSeach = singleSeachService.selectById(id);
if(singleSeach !=null){
//entity转view
SingleSeachView view = new SingleSeachView();
BeanUtils.copyProperties( singleSeach , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
@RequestMapping("/save")
public R save(@RequestBody SingleSeachEntity singleSeach, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,singleSeach:{}",this.getClass().getName(),singleSeach.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper<SingleSeachEntity> queryWrapper = new EntityWrapper<SingleSeachEntity>()
.eq("single_seach_types",singleSeach.getSingleSeachTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
SingleSeachEntity singleSeachEntity = singleSeachService.selectOne(queryWrapper);
if(singleSeachEntity==null){
singleSeach.setCreateTime(new Date());
singleSeachService.insert(singleSeach);
return R.ok();
}else {
return R.error(511,"该类型已经有存在的,请删除后重新新增");
}
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody SingleSeachEntity singleSeach, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,singleSeach:{}",this.getClass().getName(),singleSeach.toString());
SingleSeachEntity oldSingleSeachEntity = singleSeachService.selectById(singleSeach.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
if("".equals(singleSeach.getSingleSeachPhoto()) || "null".equals(singleSeach.getSingleSeachPhoto())){
singleSeach.setSingleSeachPhoto(null);
}
if("".equals(singleSeach.getSingleSeachContent()) || "null".equals(singleSeach.getSingleSeachContent())){
singleSeach.setSingleSeachContent(null);
}
singleSeachService.updateById(singleSeach);//根据id更新
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<SingleSeachEntity> oldSingleSeachList =singleSeachService.selectBatchIds(Arrays.asList(ids));//要删除的数据
singleSeachService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
*
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<SingleSeachEntity> singleSeachList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
SingleSeachEntity singleSeachEntity = new SingleSeachEntity();
// singleSeachEntity.setSingleSeachName(data.get(0)); //名字 要改的
// singleSeachEntity.setSingleSeachTypes(Integer.valueOf(data.get(0))); //数据类型 要改的
// singleSeachEntity.setSingleSeachPhoto("");//详情和图片
// singleSeachEntity.setSingleSeachContent("");//详情和图片
// singleSeachEntity.setCreateTime(date);//时间
singleSeachList.add(singleSeachEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
singleSeachService.insertBatch(singleSeachList);
return R.ok();
}
}
}
}catch (Exception e){
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
=======
// 声明当前文件所在的包路径
package com.controller;
@ -273,10 +35,10 @@ import com.utils.R; // 通用返回结果类
import com.alibaba.fastjson.*; // FastJSON工具包
//单页数据
//后端接口控制器
//@author
//@email
//单页数据
//后端接口控制器
//@author
//@email
@RestController // 标识这是一个RESTful风格的控制器
@Controller // 标识这是一个Spring MVC控制器
@ -315,11 +77,11 @@ public class SingleSeachController {
private UsersService usersService; // 管理员服务
//后端列表
//分页查询单页数据
//@param params 请求参数Map
//@param request HTTP请求对象
//@return 返回分页数据结果
//后端列表
//分页查询单页数据
//@param params 请求参数Map
//@param request HTTP请求对象
//@return 返回分页数据结果
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
@ -343,11 +105,11 @@ public class SingleSeachController {
}
//后端详情
//根据ID查询单条单页数据详情
//@param id 数据ID
//@param request HTTP请求对象
//@return 返回查询结果
//后端详情
//根据ID查询单条单页数据详情
//@param id 数据ID
//@param request HTTP请求对象
//@return 返回查询结果
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录日志
@ -363,12 +125,12 @@ public class SingleSeachController {
}
//后端保存
//新增单页数据
//@param singleSeach 单页数据实体
//@param request HTTP请求对象
//@return 返回操作结果
//@RequestMapping("/save")
//后端保存
//新增单页数据
//@param singleSeach 单页数据实体
//@param request HTTP请求对象
//@return 返回操作结果
//@RequestMapping("/save")
public R save(@RequestBody SingleSeachEntity singleSeach, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,singleSeach:{}",this.getClass().getName(),singleSeach.toString()); // 记录日志
String role = String.valueOf(request.getSession().getAttribute("role")); // 获取用户角色
@ -391,10 +153,10 @@ public class SingleSeachController {
}
//后端修改
//更新单页数据
//@param singleSeach 单页数据实体
//@param request HTTP请求对象
//@return 返回操作结果
//更新单页数据
//@param singleSeach 单页数据实体
//@param request HTTP请求对象
//@return 返回操作结果
@RequestMapping("/update")
public R update(@RequestBody SingleSeachEntity singleSeach, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,singleSeach:{}",this.getClass().getName(),singleSeach.toString()); // 记录日志
@ -413,11 +175,11 @@ public class SingleSeachController {
}
//删除
//批量删除单页数据
//@param ids 要删除的ID数组
//@param request HTTP请求对象
//@return 返回操作结果
//删除
//批量删除单页数据
//@param ids 要删除的ID数组
//@param request HTTP请求对象
//@return 返回操作结果
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); // 记录日志
@ -427,11 +189,11 @@ public class SingleSeachController {
}
//批量上传/
//通过Excel批量导入数据
//@param fileName Excel文件名
//@param request HTTP请求对象
//@return 返回操作结果
//批量上传/
//通过Excel批量导入数据
//@param fileName Excel文件名
//@param request HTTP请求对象
//@return 返回操作结果
@RequestMapping("/batchInsert")
public R save(String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); // 记录日志
@ -469,78 +231,15 @@ public class SingleSeachController {
}catch (Exception e){ // 捕获异常
e.printStackTrace(); // 打印异常堆栈
return R.error(511,"批量插入数据异常,请联系管理员"); // 返回错误信息
>>>>>>> develop
}
}
<<<<<<< HEAD
/**
*
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
PageUtils page = singleSeachService.queryPage(params);
//字典表数据转换
List<SingleSeachView> list =(List<SingleSeachView>)page.getList();
for(SingleSeachView c:list)
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
SingleSeachEntity singleSeach = singleSeachService.selectOne(new EntityWrapper<SingleSeachEntity>().eq("single_seach_types", id));
if(singleSeach != null)
return R.ok().put("data", singleSeach);
else
return R.error(511,"查不到数据");
}
/**
*
*/
@RequestMapping("/add")
public R add(@RequestBody SingleSeachEntity singleSeach, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,singleSeach:{}",this.getClass().getName(),singleSeach.toString());
Wrapper<SingleSeachEntity> queryWrapper = new EntityWrapper<SingleSeachEntity>()
.eq("single_seach_types",singleSeach.getSingleSeachTypes())
// .notIn("single_seach_types", new Integer[]{102})
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
SingleSeachEntity singleSeachEntity = singleSeachService.selectOne(queryWrapper);
if(singleSeachEntity==null){
singleSeach.setCreateTime(new Date());
singleSeachService.insert(singleSeach);
return R.ok();
}else {
return R.error(511,"该类型已经有存在的,请删除后重新新增");
}
}
}
=======
//前端列表
//无需认证的分页查询
//@param params 请求参数Map
//@param request HTTP请求对象
//@return 返回分页数据结果
//前端列表
//无需认证的分页查询
//@param params 请求参数Map
//@param request HTTP请求对象
//@return 返回分页数据结果
@IgnoreAuth // 忽略认证
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
@ -556,11 +255,11 @@ public class SingleSeachController {
}
//前端详情
//根据类型查询单条数据
//@param id 数据类型ID
//@param request HTTP请求对象
//@return 返回查询结果
//前端详情
//根据类型查询单条数据
//@param id 数据类型ID
//@param request HTTP请求对象
//@return 返回查询结果
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录日志
@ -573,11 +272,11 @@ public class SingleSeachController {
}
//前端保存
//新增单页数据
//@param singleSeach 单页数据实体
//@param request HTTP请求对象
//@return 返回操作结果
//前端保存
//新增单页数据
//@param singleSeach 单页数据实体
//@param request HTTP请求对象
//@return 返回操作结果
@RequestMapping("/add")
public R add(@RequestBody SingleSeachEntity singleSeach, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,singleSeach:{}",this.getClass().getName(),singleSeach.toString()); // 记录日志
@ -595,5 +294,4 @@ public class SingleSeachController {
return R.error(511,"该类型已经有存在的,请删除后重新新增"); // 返回错误信息
}
}
}
>>>>>>> develop
}

@ -1,197 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.util.List;
import java.util.Arrays;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.UsersEntity;
import com.service.TokenService;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
/**
*
*/
@RequestMapping("users")
@RestController
public class UsersController {
@Autowired
private UsersService usersService;
@Autowired
private TokenService tokenService;
/**
*
*/
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
UsersEntity user = usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
if(user==null || !user.getPassword().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
R r = R.ok();
r.put("token", token);
r.put("role",user.getRole());
r.put("userId",user.getId());
return r;
}
/**
*
*/
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody UsersEntity user){
// ValidatorUtils.validateEntity(user);
if(usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
usersService.insert(user);
return R.ok();
}
/**
* 退
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
*
*/
@GetMapping(value = "/updatePassword")
public R updatePassword(String oldPassword, String newPassword, HttpServletRequest request) {
UsersEntity users = usersService.selectById((Integer)request.getSession().getAttribute("userId"));
if(newPassword == null){
return R.error("新密码不能为空") ;
}
if(!oldPassword.equals(users.getPassword())){
return R.error("原密码输入错误");
}
if(newPassword.equals(users.getPassword())){
return R.error("新密码不能和原密码一致") ;
}
users.setPassword(newPassword);
usersService.updateById(users);
return R.ok();
}
/**
*
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
UsersEntity user = usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
if(user==null) {
return R.error("账号不存在");
}
user.setPassword("123456");
usersService.update(user,null);
return R.ok("密码已重置为123456");
}
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,UsersEntity user){
EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>();
PageUtils page = usersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/list")
public R list( UsersEntity user){
EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>();
ew.allEq(MPUtil.allEQMapPre( user, "user"));
return R.ok().put("data", usersService.selectListView(ew));
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
UsersEntity user = usersService.selectById(id);
return R.ok().put("data", user);
}
/**
* session
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Integer id = (Integer)request.getSession().getAttribute("userId");
UsersEntity user = usersService.selectById(id);
return R.ok().put("data", user);
}
/**
*
*/
@PostMapping("/save")
public R save(@RequestBody UsersEntity user){
// ValidatorUtils.validateEntity(user);
if(usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
usersService.insert(user);
return R.ok();
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody UsersEntity user){
// ValidatorUtils.validateEntity(user);
usersService.updateById(user);//全部更新
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
List<UsersEntity> user = usersService.selectList(null);
if(user.size() > 1){
usersService.deleteBatchIds(Arrays.asList(ids));
}else{
return R.error("管理员最少保留一个");
}
return R.ok();
}
}
=======
package com.controller; // 声明当前类所在的包路径
// 导入Java集合类
@ -225,7 +31,7 @@ import com.utils.PageUtils; // 分页工具类
import com.utils.R; // 统一返回结果类
//用户登录相关功能控制器
//处理用户认证、注册、密码管理等操作
//处理用户认证、注册、密码管理等操作
@RequestMapping("users") // 定义基础请求路径为/users
@RestController // 标识这是一个RESTful风格的控制器
public class UsersController {
@ -237,12 +43,12 @@ public class UsersController {
private TokenService tokenService;
//用户登录接口
//@param username 用户名
//@param password 密码
//@param captcha 验证码(未使用)
//@param request HTTP请求对象
//@return 返回登录结果和Token信息
//用户登录接口
//@param username 用户名
//@param password 密码
//@param captcha 验证码(未使用)
//@param request HTTP请求对象
//@return 返回登录结果和Token信息
@IgnoreAuth // 忽略认证检查
@PostMapping(value = "/login") // 处理POST /users/login请求
public R login(String username, String password, String captcha, HttpServletRequest request) {
@ -263,9 +69,9 @@ public class UsersController {
}
//用户注册接口
//@param user 用户实体对象(通过请求体传入)
//@return 返回注册结果
//用户注册接口
//@param user 用户实体对象(通过请求体传入)
//@return 返回注册结果
@IgnoreAuth // 忽略认证检查
@PostMapping(value = "/register") // 处理POST /users/register请求
public R register(@RequestBody UsersEntity user){
@ -278,9 +84,9 @@ public class UsersController {
}
//用户退出接口
//@param request HTTP请求对象
//@return 返回退出结果
//用户退出接口
//@param request HTTP请求对象
//@return 返回退出结果
@GetMapping(value = "logout") // 处理GET /users/logout请求
public R logout(HttpServletRequest request) {
request.getSession().invalidate(); // 使会话失效
@ -288,11 +94,11 @@ public class UsersController {
}
//修改密码接口
//@param oldPassword 旧密码
//@param newPassword 新密码
//@param request HTTP请求对象
//@return 返回修改结果
//修改密码接口
//@param oldPassword 旧密码
//@param newPassword 新密码
//@param request HTTP请求对象
//@return 返回修改结果
@GetMapping(value = "/updatePassword") // 处理GET /users/updatePassword请求
public R updatePassword(String oldPassword, String newPassword, HttpServletRequest request) {
// 获取当前用户
@ -316,10 +122,10 @@ public class UsersController {
}
//密码重置接口
//@param username 用户名
//@param request HTTP请求对象
//@return 返回重置结果
//密码重置接口
//@param username 用户名
//@param request HTTP请求对象
//@return 返回重置结果
@IgnoreAuth // 忽略认证检查
@RequestMapping(value = "/resetPass") // 处理/users/resetPass请求
public R resetPass(String username, HttpServletRequest request){
@ -335,10 +141,10 @@ public class UsersController {
}
//分页查询用户列表
//@param params 请求参数Map
//@param user 用户实体(用于条件查询)
//@return 返回分页结果
//分页查询用户列表
//@param params 请求参数Map
//@param user 用户实体(用于条件查询)
//@return 返回分页结果
@RequestMapping("/page") // 处理/users/page请求
public R page(@RequestParam Map<String, Object> params,UsersEntity user){
// 创建条件构造器
@ -349,9 +155,9 @@ public class UsersController {
}
//查询用户列表
//@param user 用户实体(用于条件查询)
//@return 返回用户列表
//查询用户列表
//@param user 用户实体(用于条件查询)
//@return 返回用户列表
@RequestMapping("/list") // 处理/users/list请求
public R list(UsersEntity user){
// 创建条件构造器
@ -362,9 +168,9 @@ public class UsersController {
}
//获取用户详细信息
//@param id 用户ID
//@return 返回用户信息
//获取用户详细信息
//@param id 用户ID
//@return 返回用户信息
@RequestMapping("/info/{id}") // 处理/users/info/{id}请求
public R info(@PathVariable("id") String id){
UsersEntity user = usersService.selectById(id); // 根据ID查询用户
@ -372,9 +178,9 @@ public class UsersController {
}
// 获取当前会话用户信息
//@param request HTTP请求对象
// @return 返回当前用户信息
// 获取当前会话用户信息
//@param request HTTP请求对象
// @return 返回当前用户信息
@RequestMapping("/session") // 处理/users/session请求
public R getCurrUser(HttpServletRequest request){
@ -385,9 +191,9 @@ public class UsersController {
}
//保存用户信息
//@param user 用户实体对象(通过请求体传入)
// @return 返回保存结果
//保存用户信息
//@param user 用户实体对象(通过请求体传入)
// @return 返回保存结果
@PostMapping("/save") // 处理POST /users/save请求
public R save(@RequestBody UsersEntity user){
@ -400,9 +206,9 @@ public class UsersController {
}
// 更新用户信息
//@param user 用户实体对象(通过请求体传入)
//@return 返回更新结果
// 更新用户信息
//@param user 用户实体对象(通过请求体传入)
//@return 返回更新结果
@RequestMapping("/update") // 处理/users/update请求
public R update(@RequestBody UsersEntity user){
@ -411,9 +217,9 @@ public class UsersController {
}
//删除用户
//@param ids 用户ID数组(通过请求体传入)
// @return 返回删除结果
//删除用户
//@param ids 用户ID数组(通过请求体传入)
// @return 返回删除结果
@RequestMapping("/delete") // 处理/users/delete请求
public R delete(@RequestBody Long[] ids){
@ -427,5 +233,4 @@ public class UsersController {
}
return R.ok(); // 返回成功结果
}
}
>>>>>>> develop
}

@ -1,415 +1,3 @@
<<<<<<< HEAD
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
*
*
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/yonghu")
public class YonghuController {
private static final Logger logger = LoggerFactory.getLogger(YonghuController.class);
private static final String TABLE_NAME = "yonghu";
@Autowired
private YonghuService yonghuService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private ForumService forumService;//健身论坛
@Autowired
private JianshenkechengService jianshenkechengService;//健身课程
@Autowired
private JianshenkechengCollectionService jianshenkechengCollectionService;//课程收藏
@Autowired
private JianshenkechengLiuyanService jianshenkechengLiuyanService;//课程留言
@Autowired
private JiaolianService jiaolianService;//教练
@Autowired
private JiaolianYuyueService jiaolianYuyueService;//教练预约申请
@Autowired
private NewsService newsService;//健身资讯
@Autowired
private SingleSeachService singleSeachService;//单页数据
@Autowired
private UsersService usersService;//管理员
/**
*
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("教练".equals(role))
params.put("jiaolianId",request.getSession().getAttribute("userId"));
params.put("dataDeleteStart",1);params.put("dataDeleteEnd",1);
CommonUtil.checkMap(params);
PageUtils page = yonghuService.queryPage(params);
//字典表数据转换
List<YonghuView> list =(List<YonghuView>)page.getList();
for(YonghuView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
YonghuEntity yonghu = yonghuService.selectById(id);
if(yonghu !=null){
//entity转view
YonghuView view = new YonghuView();
BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
@RequestMapping("/save")
public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
.eq("username", yonghu.getUsername())
.or()
.eq("yonghu_phone", yonghu.getYonghuPhone())
.or()
.eq("yonghu_id_number", yonghu.getYonghuIdNumber())
.eq("data_delete", 1)
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
if(yonghuEntity==null){
yonghu.setDataDelete(1);
yonghu.setInsertTime(new Date());
yonghu.setCreateTime(new Date());
yonghu.setPassword("123456");
yonghuService.insert(yonghu);
return R.ok();
}else {
return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
}
}
/**
*
*/
@RequestMapping("/update")
public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
YonghuEntity oldYonghuEntity = yonghuService.selectById(yonghu.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
if("".equals(yonghu.getYonghuPhoto()) || "null".equals(yonghu.getYonghuPhoto())){
yonghu.setYonghuPhoto(null);
}
yonghuService.updateById(yonghu);//根据id更新
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<YonghuEntity> oldYonghuList =yonghuService.selectBatchIds(Arrays.asList(ids));//要删除的数据
ArrayList<YonghuEntity> list = new ArrayList<>();
for(Integer id:ids){
YonghuEntity yonghuEntity = new YonghuEntity();
yonghuEntity.setId(id);
yonghuEntity.setDataDelete(2);
list.add(yonghuEntity);
}
if(list != null && list.size() >0){
yonghuService.updateBatchById(list);
}
return R.ok();
}
/**
*
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<YonghuEntity> yonghuList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
YonghuEntity yonghuEntity = new YonghuEntity();
// yonghuEntity.setUsername(data.get(0)); //账户 要改的
// yonghuEntity.setPassword("123456");//密码
// yonghuEntity.setYonghuName(data.get(0)); //用户名称 要改的
// yonghuEntity.setYonghuPhone(data.get(0)); //用户手机号 要改的
// yonghuEntity.setYonghuIdNumber(data.get(0)); //用户身份证号 要改的
// yonghuEntity.setYonghuPhoto("");//详情和图片
// yonghuEntity.setSexTypes(Integer.valueOf(data.get(0))); //性别 要改的
// yonghuEntity.setYonghuEmail(data.get(0)); //用户邮箱 要改的
// yonghuEntity.setNewMoney(data.get(0)); //现有余额 要改的
// yonghuEntity.setDataDelete(1);//逻辑删除字段
// yonghuEntity.setInsertTime(date);//时间
// yonghuEntity.setCreateTime(date);//时间
yonghuList.add(yonghuEntity);
//把要查询是否重复的字段放入map中
//账户
if(seachFields.containsKey("username")){
List<String> username = seachFields.get("username");
username.add(data.get(0));//要改的
}else{
List<String> username = new ArrayList<>();
username.add(data.get(0));//要改的
seachFields.put("username",username);
}
//用户手机号
if(seachFields.containsKey("yonghuPhone")){
List<String> yonghuPhone = seachFields.get("yonghuPhone");
yonghuPhone.add(data.get(0));//要改的
}else{
List<String> yonghuPhone = new ArrayList<>();
yonghuPhone.add(data.get(0));//要改的
seachFields.put("yonghuPhone",yonghuPhone);
}
//用户身份证号
if(seachFields.containsKey("yonghuIdNumber")){
List<String> yonghuIdNumber = seachFields.get("yonghuIdNumber");
yonghuIdNumber.add(data.get(0));//要改的
}else{
List<String> yonghuIdNumber = new ArrayList<>();
yonghuIdNumber.add(data.get(0));//要改的
seachFields.put("yonghuIdNumber",yonghuIdNumber);
}
}
//查询是否重复
//账户
List<YonghuEntity> yonghuEntities_username = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("username", seachFields.get("username")).eq("data_delete", 1));
if(yonghuEntities_username.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
for(YonghuEntity s:yonghuEntities_username){
repeatFields.add(s.getUsername());
}
return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
}
//用户手机号
List<YonghuEntity> yonghuEntities_yonghuPhone = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_phone", seachFields.get("yonghuPhone")).eq("data_delete", 1));
if(yonghuEntities_yonghuPhone.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
for(YonghuEntity s:yonghuEntities_yonghuPhone){
repeatFields.add(s.getYonghuPhone());
}
return R.error(511,"数据库的该表中的 [用户手机号] 字段已经存在 存在数据为:"+repeatFields.toString());
}
//用户身份证号
List<YonghuEntity> yonghuEntities_yonghuIdNumber = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_id_number", seachFields.get("yonghuIdNumber")).eq("data_delete", 1));
if(yonghuEntities_yonghuIdNumber.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
for(YonghuEntity s:yonghuEntities_yonghuIdNumber){
repeatFields.add(s.getYonghuIdNumber());
}
return R.error(511,"数据库的该表中的 [用户身份证号] 字段已经存在 存在数据为:"+repeatFields.toString());
}
yonghuService.insertBatch(yonghuList);
return R.ok();
}
}
}
}catch (Exception e){
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
/**
*
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
if(yonghu==null || !yonghu.getPassword().equals(password))
return R.error("账号或密码不正确");
else if(yonghu.getDataDelete() != 1)
return R.error("账户已被删除");
String token = tokenService.generateToken(yonghu.getId(),username, "yonghu", "用户");
R r = R.ok();
r.put("token", token);
r.put("role","用户");
r.put("username",yonghu.getYonghuName());
r.put("tableName","yonghu");
r.put("userId",yonghu.getId());
return r;
}
/**
*
*/
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody YonghuEntity yonghu, HttpServletRequest request) {
// ValidatorUtils.validateEntity(user);
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
.eq("username", yonghu.getUsername())
.or()
.eq("yonghu_phone", yonghu.getYonghuPhone())
.or()
.eq("yonghu_id_number", yonghu.getYonghuIdNumber())
.andNew()
.eq("data_delete", 1)
;
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
if(yonghuEntity != null)
return R.error("账户或者用户手机号或者用户身份证号已经被使用");
yonghu.setNewMoney(0.0);
yonghu.setDataDelete(1);
yonghu.setInsertTime(new Date());
yonghu.setCreateTime(new Date());
yonghuService.insert(yonghu);
return R.ok();
}
/**
*
*/
@GetMapping(value = "/resetPassword")
public R resetPassword(Integer id, HttpServletRequest request) {
YonghuEntity yonghu = yonghuService.selectById(id);
yonghu.setPassword("123456");
yonghuService.updateById(yonghu);
return R.ok();
}
/**
*
*/
@GetMapping(value = "/updatePassword")
public R updatePassword(String oldPassword, String newPassword, HttpServletRequest request) {
YonghuEntity yonghu = yonghuService.selectById((Integer)request.getSession().getAttribute("userId"));
if(newPassword == null){
return R.error("新密码不能为空") ;
}
if(!oldPassword.equals(yonghu.getPassword())){
return R.error("原密码输入错误");
}
if(newPassword.equals(yonghu.getPassword())){
return R.error("新密码不能和原密码一致") ;
}
yonghu.setPassword(newPassword);
yonghuService.updateById(yonghu);
return R.ok();
}
/**
*
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request) {
YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
if(yonghu!=null){
yonghu.setPassword("123456");
yonghuService.updateById(yonghu);
return R.ok();
}else{
return R.error("账号不存在");
=======
package com.controller; // 声明当前类所在的包路径
// 导入Java IO类
@ -468,8 +56,8 @@ import com.utils.R; // 统一返回结果类
import com.alibaba.fastjson.*; // FastJSON工具类
//用户控制器
// 处理用户相关操作的RESTful接口
//用户控制器
// 处理用户相关操作的RESTful接口
@RestController // 标识为RESTful控制器
@Controller // 标识为Spring MVC控制器
@ -508,9 +96,9 @@ public class YonghuController {
private UsersService usersService; // 管理员服务
//后端分页列表
//@param params 请求参数Map
//@param request HTTP请求对象
//@return 分页结果
//@param params 请求参数Map
//@param request HTTP请求对象
//@return 分页结果
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
@ -534,10 +122,10 @@ public class YonghuController {
}
//后端详情
//@param id 用户ID
//@param request HTTP请求对象
//@return 用户详情
//后端详情
//@param id 用户ID
//@param request HTTP请求对象
//@return 用户详情
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
@ -553,9 +141,9 @@ public class YonghuController {
}
//后端保存用户
//@param yonghu 用户实体
//@param request HTTP请求对象
//@return 操作结果
//@param yonghu 用户实体
//@param request HTTP请求对象
//@return 操作结果
@RequestMapping("/save")
public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
@ -588,10 +176,10 @@ public class YonghuController {
}
//后端修改用户
//@param yonghu 用户实体
//@param request HTTP请求对象
//@return 操作结果
//后端修改用户
//@param yonghu 用户实体
//@param request HTTP请求对象
//@return 操作结果
@RequestMapping("/update")
public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
@ -607,10 +195,10 @@ public class YonghuController {
}
//删除用户(逻辑删除)
//@param ids 用户ID数组
//@param request HTTP请求对象
//@return 操作结果
//删除用户(逻辑删除)
//@param ids 用户ID数组
//@param request HTTP请求对象
//@return 操作结果
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
@ -629,10 +217,10 @@ public class YonghuController {
}
//批量导入用户数据
//@param fileName Excel文件名
//@param request HTTP请求对象
//@return 导入结果
//批量导入用户数据
//@param fileName Excel文件名
//@param request HTTP请求对象
//@return 导入结果
@RequestMapping("/batchInsert")
public R save(String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
@ -735,12 +323,12 @@ public class YonghuController {
}
//用户登录
//@param username 用户名
//@param password 密码
//@param captcha 验证码
//@param request HTTP请求对象
//@return 登录结果
//用户登录
//@param username 用户名
//@param password 密码
//@param captcha 验证码
//@param request HTTP请求对象
//@return 登录结果
@IgnoreAuth // 忽略认证
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
@ -760,10 +348,10 @@ public class YonghuController {
}
//用户注册
//@param yonghu 用户实体
// @param request HTTP请求对象
//@return 注册结果
//用户注册
//@param yonghu 用户实体
// @param request HTTP请求对象
//@return 注册结果
@IgnoreAuth // 忽略认证
@PostMapping(value = "/register")
@ -790,10 +378,10 @@ public class YonghuController {
}
//重置密码为默认值
//@param id 用户ID
//@param request HTTP请求对象
// @return 操作结果
//重置密码为默认值
//@param id 用户ID
//@param request HTTP请求对象
// @return 操作结果
@GetMapping(value = "/resetPassword")
public R resetPassword(Integer id, HttpServletRequest request) {
@ -804,10 +392,10 @@ public class YonghuController {
}
//修改密码
//@param oldPassword 旧密码
//@param newPassword 新密码
//@param request HTTP请求对象
// @return 操作结果
//@param oldPassword 旧密码
//@param newPassword 新密码
//@param request HTTP请求对象
// @return 操作结果
@GetMapping(value = "/updatePassword")
public R updatePassword(String oldPassword, String newPassword, HttpServletRequest request) {
@ -827,9 +415,9 @@ public class YonghuController {
}
//忘记密码(重置为默认密码)
//@param username 用户名
//@param request HTTP请求对象
//@return 操作结果
//@param username 用户名
//@param request HTTP请求对象
//@return 操作结果
@IgnoreAuth // 忽略认证
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request) {
@ -840,33 +428,13 @@ public class YonghuController {
return R.ok(); // 返回成功结果
}else{ // 如果用户不存在
return R.error("账号不存在"); // 返回错误信息
>>>>>>> develop
}
}
<<<<<<< HEAD
/**
* session
*/
@RequestMapping("/session")
public R getCurrYonghu(HttpServletRequest request){
Integer id = (Integer)request.getSession().getAttribute("userId");
YonghuEntity yonghu = yonghuService.selectById(id);
if(yonghu !=null){
//entity转view
YonghuView view = new YonghuView();
BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
=======
//获取当前会话用户信息
//@param request HTTP请求对象
//@return 用户信息
//获取当前会话用户信息
//@param request HTTP请求对象
//@return 用户信息
@RequestMapping("/session")
public R getCurrYonghu(HttpServletRequest request){
Integer id = (Integer)request.getSession().getAttribute("userId"); // 获取当前用户ID
@ -878,102 +446,13 @@ public class YonghuController {
return R.ok().put("data", view); // 返回用户信息
}else {
return R.error(511,"查不到数据"); // 返回错误信息
>>>>>>> develop
}
}
<<<<<<< HEAD
/**
* 退
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
*
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
PageUtils page = yonghuService.queryPage(params);
//字典表数据转换
List<YonghuView> list =(List<YonghuView>)page.getList();
for(YonghuView c:list)
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
return R.ok().put("data", page);
}
/**
*
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
YonghuEntity yonghu = yonghuService.selectById(id);
if(yonghu !=null){
//entity转view
YonghuView view = new YonghuView();
BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
*
*/
@RequestMapping("/add")
public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
.eq("username", yonghu.getUsername())
.or()
.eq("yonghu_phone", yonghu.getYonghuPhone())
.or()
.eq("yonghu_id_number", yonghu.getYonghuIdNumber())
.andNew()
.eq("data_delete", 1)
// .notIn("yonghu_types", new Integer[]{102})
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
if(yonghuEntity==null){
yonghu.setDataDelete(1);
yonghu.setInsertTime(new Date());
yonghu.setCreateTime(new Date());
yonghu.setPassword("123456");
yonghuService.insert(yonghu);
return R.ok();
}else {
return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
}
}
}
=======
//用户退出
//@param request HTTP请求对象
//@return 操作结果
//用户退出
//@param request HTTP请求对象
//@return 操作结果
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate(); // 使会话失效
@ -981,10 +460,10 @@ public class YonghuController {
}
//前端分页列表
//@param params 请求参数
//@param request HTTP请求对象
//@return 分页结果
//前端分页列表
//@param params 请求参数
//@param request HTTP请求对象
//@return 分页结果
@IgnoreAuth // 忽略认证
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
@ -1001,10 +480,10 @@ public class YonghuController {
}
//前端详情
//@param id 用户ID
//@param request HTTP请求对象
//@return 用户详情
//前端详情
//@param id 用户ID
//@param request HTTP请求对象
//@return 用户详情
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
@ -1020,10 +499,10 @@ public class YonghuController {
}
//前端保存用户
//@param yonghu 用户实体
//@param request HTTP请求对象
//@return 操作结果
//前端保存用户
//@param yonghu 用户实体
//@param request HTTP请求对象
//@return 操作结果
@RequestMapping("/add")
public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
@ -1050,5 +529,4 @@ public class YonghuController {
return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用"); // 返回错误信息
}
}
}
>>>>>>> develop
}
Loading…
Cancel
Save