Merge pull request 'jianshenfangglApplication' (#7) from feature/dw into develop

pull/8/head
p2x9nfpei 3 months ago
commit 70076bd47a

4
.idea/.gitignore vendored

@ -2,7 +2,11 @@
/shelf/
/workspace.xml
# 数据源本地存储已忽略文件
<<<<<<< HEAD
/../../../../../../:\Users\33424\Desktop\jianshenfanggl没有注释\.idea/dataSources/
=======
/../../../../../../../:\Users\33424\Desktop\gym\jianshenfanggl\.idea/dataSources/
>>>>>>> develop
/dataSources.local.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/

@ -0,0 +1 @@
jianshenfanggl

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="jianshenfanggl" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="jianshenfanggl" options="-parameters" />
</option>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
</component>
</project>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>

@ -2,7 +2,11 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<<<<<<< HEAD
<module fileurl="file://$PROJECT_DIR$/jianshenfanggl.iml" filepath="$PROJECT_DIR$/jianshenfanggl.iml" />
=======
<module fileurl="file://$PROJECT_DIR$/.idea/jianshenfanggl.iml" filepath="$PROJECT_DIR$/.idea/jianshenfanggl.iml" />
>>>>>>> develop
</modules>
</component>
</project>

@ -2,5 +2,9 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<<<<<<< HEAD
<mapping directory="$PROJECT_DIR$/gym" vcs="Git" />
=======
>>>>>>> develop
</component>
</project>

1
gym

@ -0,0 +1 @@
Subproject commit efe5258eda99ba1aac5fb7fffdc2414d5412705d

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
</module>

@ -1,3 +1,20 @@
<<<<<<< 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;
@ -26,4 +43,5 @@ import java.lang.annotation.Target;
public @interface APPLoginUser {
// 定义一个空注解,作为标记使用
// 实际使用时可以配合拦截器或参数解析器,自动注入当前登录用户对象
}
}
>>>>>>> develop

@ -1,3 +1,18 @@
<<<<<<< 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;
@ -24,4 +39,5 @@ public @interface ColumnInfo {
// 定义type属性表示字段的类型
String type();
}
}
>>>>>>> develop

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

@ -1,3 +1,20 @@
<<<<<<< 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;
@ -22,4 +39,5 @@ import java.lang.annotation.Target;
public @interface LoginUser {
// 这是一个标记注解,不包含任何属性
// 用于标识需要自动注入当前登录用户信息的参数
}
}
>>>>>>> develop

@ -1,3 +1,44 @@
<<<<<<< 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;
@ -63,4 +104,5 @@ public class InterceptorConfig extends WebMvcConfigurationSupport {
registry.addResourceLocations("classpath:/public/");
super.addResourceHandlers(registry);
}
}
}
>>>>>>> develop

@ -1,3 +1,33 @@
<<<<<<< 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;
@ -41,4 +71,5 @@ public class MyMetaObjectHandler extends MetaObjectHandler {
// 如需启用更新填充,可在此添加类似:
// this.setFieldValByName("utime", new Date(), metaObject);
}
}
}
>>>>>>> develop

@ -1,3 +1,29 @@
<<<<<<< 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;
@ -29,4 +55,5 @@ public class MybatisPlusConfig {
// - 性能分析插件
// - 乐观锁插件
// - SQL注入器等
}
}
>>>>>>> develop

@ -1,3 +1,25 @@
<<<<<<< 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;
@ -31,12 +53,24 @@ 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相关类
@ -52,10 +86,19 @@ 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);
=======
//通用接口控制器
//提供系统通用的各种功能接口
@ -65,10 +108,55 @@ public class CommonController {
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安装路径
// * @param hostIP 数据库服务器IP
@ -131,6 +219,7 @@ public class CommonController {
return R.error("备份数据出错");
} finally {
// 在finally块中确保资源关闭
>>>>>>> develop
try {
if (bufferedReader != null) {
bufferedReader.close();
@ -142,6 +231,42 @@ 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();
}
@ -191,20 +316,100 @@ 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
// * @return 包含求和结果的响应
@ -264,10 +469,476 @@ 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);
}
@ -288,4 +959,5 @@ public class CommonController {
// - 返回值说明
// - 关键处理逻辑说明
// - 异常处理说明
}
}
>>>>>>> develop

@ -1,3 +1,116 @@
<<<<<<< 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类用于操作数组
@ -97,3 +210,4 @@ public class ConfigController {
}
}
>>>>>>> develop

@ -1,3 +1,274 @@
<<<<<<< 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;
@ -274,12 +545,26 @@ 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,3 +1,114 @@
<<<<<<< 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; // 定义包路径
// 文件操作相关类
@ -156,4 +267,5 @@ public class FileController{
// 返回服务器错误响应
return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
}
>>>>>>> develop
}

@ -1,3 +1,45 @@
<<<<<<< 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; // 导入文件操作类
@ -37,12 +79,115 @@ import com.alibaba.fastjson.*; // 导入FastJSON相关类
//@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
@ -134,10 +279,80 @@ 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,"永远不会进入");
@ -193,11 +408,62 @@ public class ForumController {
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){
@ -229,6 +495,7 @@ public class ForumController {
forumList.add(forumEntity); // 添加到列表
}
// 批量插入数据
>>>>>>> develop
forumService.insertBatch(forumList);
return R.ok();
}
@ -236,6 +503,19 @@ public class ForumController {
}
}catch (Exception e){
e.printStackTrace();
<<<<<<< HEAD
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
/**
*
*/
@IgnoreAuth
=======
return R.error(511,"批量插入数据异常,请联系管理员"); // 异常处理
}
}
@ -243,10 +523,74 @@ 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); // 查询分页数据
@ -304,10 +648,36 @@ 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
@ -327,4 +697,5 @@ public class ForumController {
return R.error(511,"表中有相同数据"); // 数据已存在返回错误
}
}
}
}
>>>>>>> develop

@ -1,3 +1,250 @@
<<<<<<< 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; // 导入文件操作类
@ -212,16 +459,107 @@ 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") // 处理列表请求
@ -292,4 +630,5 @@ public class JianshenkechengCollectionController {
return R.error(511,"您已经收藏过了"); // 已经收藏过返回错误
}
}
}
}
>>>>>>> develop

@ -1,3 +1,277 @@
<<<<<<< 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; // 导入文件操作类
@ -234,16 +508,177 @@ 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") // 处理个性推荐请求
@ -386,4 +821,5 @@ public class JianshenkechengController {
return R.error(511,"表中有相同数据"); // 数据已存在返回错误
}
}
}
}
>>>>>>> develop

@ -1,3 +1,248 @@
<<<<<<< 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; // 导入文件操作类,用于处理文件上传
@ -212,16 +457,95 @@ 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 // 忽略认证
@ -282,4 +606,5 @@ public class JianshenkechengLiuyanController {
jianshenkechengLiuyanService.insert(jianshenkechengLiuyan); // 调用服务层保存数据
return R.ok(); // 返回成功信息
}
}
}
>>>>>>> develop

@ -1,3 +1,45 @@
<<<<<<< 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
*/
=======
// 声明当前 Java 文件所属的包,此包一般用于存放控制器相关的类,负责处理 HTTP 请求和响应
package com.controller;
@ -66,6 +108,7 @@ import com.alibaba.fastjson.*;
//后端接口
//@author
//@email
>>>>>>> develop
@RestController
@Controller
@RequestMapping("/jiaolian")
@ -103,7 +146,13 @@ public class JiaolianController {
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));
@ -127,8 +176,14 @@ public class JiaolianController {
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);
@ -146,7 +201,13 @@ public class JiaolianController {
}
<<<<<<< HEAD
/**
*
*/
=======
//后端保存
>>>>>>> develop
@RequestMapping("/save")
public R save(@RequestBody JiaolianEntity jiaolian, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,jiaolian:{}",this.getClass().getName(),jiaolian.toString());
@ -176,8 +237,14 @@ 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());
@ -199,8 +266,14 @@ public class JiaolianController {
<<<<<<< HEAD
/**
*
*/
=======
//删除
>>>>>>> develop
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
@ -220,8 +293,14 @@ public class JiaolianController {
}
<<<<<<< HEAD
/**
*
*/
=======
//批量上传
>>>>>>> develop
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
@ -315,8 +394,14 @@ public class JiaolianController {
}
}
<<<<<<< HEAD
/**
*
*/
=======
//登录
>>>>>>> develop
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
@ -335,7 +420,13 @@ public class JiaolianController {
return r;
}
<<<<<<< HEAD
/**
*
*/
=======
//注册
>>>>>>> develop
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody JiaolianEntity jiaolian, HttpServletRequest request) {
@ -358,8 +449,14 @@ public class JiaolianController {
return R.ok();
}
<<<<<<< HEAD
/**
*
*/
=======
//重置密码
>>>>>>> develop
@GetMapping(value = "/resetPassword")
public R resetPassword(Integer id, HttpServletRequest request) {
JiaolianEntity jiaolian = jiaolianService.selectById(id);
@ -368,8 +465,14 @@ public class JiaolianController {
return R.ok();
}
<<<<<<< HEAD
/**
*
*/
=======
//修改密码
>>>>>>> develop
@GetMapping(value = "/updatePassword")
public R updatePassword(String oldPassword, String newPassword, HttpServletRequest request) {
JiaolianEntity jiaolian = jiaolianService.selectById((Integer)request.getSession().getAttribute("userId"));
@ -389,8 +492,14 @@ public class JiaolianController {
<<<<<<< HEAD
/**
*
*/
=======
//忘记密码
>>>>>>> develop
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request) {
@ -405,7 +514,13 @@ public class JiaolianController {
}
<<<<<<< HEAD
/**
* session
*/
=======
//获取用户的session用户信息
>>>>>>> develop
@RequestMapping("/session")
public R getCurrJiaolian(HttpServletRequest request){
Integer id = (Integer)request.getSession().getAttribute("userId");
@ -424,8 +539,14 @@ public class JiaolianController {
}
<<<<<<< HEAD
/**
* 退
*/
=======
//退出
>>>>>>> develop
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
@ -434,8 +555,14 @@ public class JiaolianController {
<<<<<<< HEAD
/**
*
*/
=======
//前端列表
>>>>>>> develop
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
@ -452,8 +579,14 @@ public class JiaolianController {
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);
@ -474,8 +607,14 @@ public class JiaolianController {
}
<<<<<<< HEAD
/**
*
*/
=======
//前端保存
>>>>>>> develop
@RequestMapping("/add")
public R add(@RequestBody JiaolianEntity jiaolian, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,jiaolian:{}",this.getClass().getName(),jiaolian.toString());

@ -1,3 +1,283 @@
<<<<<<< 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; // 导入文件操作类,用于处理文件上传
@ -244,6 +524,7 @@ 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<>();
@ -252,18 +533,115 @@ 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 // 忽略认证
@ -337,4 +715,5 @@ public class JiaolianYuyueController {
return R.error(511,"表中有相同数据"); // 返回错误信息
}
}
}
}
>>>>>>> develop

@ -1,3 +1,45 @@
<<<<<<< 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; // 文件操作类
@ -38,12 +80,94 @@ import com.alibaba.fastjson.*; // 阿里巴巴FastJSON库
//@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
@ -129,10 +253,104 @@ public class NewsController {
//@param news 资讯实体
//@param request HTTP请求对象
//@return 返回操作结果状态
>>>>>>> develop
@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,"永远不会进入");
@ -229,10 +447,22 @@ 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中
@ -241,26 +471,78 @@ 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
@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); // 分页查询
@ -301,10 +583,32 @@ public class NewsController {
//@param news 资讯实体
//@param request HTTP请求对象
//@return 返回操作结果状态
>>>>>>> develop
@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})
@ -321,4 +625,5 @@ public class NewsController {
return R.error(511,"表中有相同数据"); // 返回错误信息
}
}
}
}
>>>>>>> develop

@ -1,3 +1,241 @@
<<<<<<< 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;
@ -231,10 +469,73 @@ 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
@ -294,4 +595,5 @@ public class SingleSeachController {
return R.error(511,"该类型已经有存在的,请删除后重新新增"); // 返回错误信息
}
}
}
}
>>>>>>> develop

@ -1,3 +1,197 @@
<<<<<<< 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集合类
@ -233,4 +427,5 @@ public class UsersController {
}
return R.ok(); // 返回成功结果
}
}
}
>>>>>>> develop

@ -1,3 +1,415 @@
<<<<<<< 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类
@ -428,10 +840,30 @@ 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 用户信息
@ -446,10 +878,99 @@ 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 操作结果
@ -529,4 +1050,5 @@ public class YonghuController {
return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用"); // 返回错误信息
}
}
}
}
>>>>>>> develop

@ -1,4 +1,7 @@
package com;
package com; // 定义包名为com表示该文件位于com包下
// 导入Spring Boot和MyBatis相关的注解和类
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
@ -7,17 +10,21 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
@ServletComponentScan(value = "com.ServletContextListener")
@MapperScan(basePackages = {"com.dao"})
public class jianshenfangglApplication extends SpringBootServletInitializer{
@SpringBootApplication // 标识这是一个Spring Boot应用程序的主类包含自动配置、组件扫描等功能
@ServletComponentScan(value = "com.ServletContextListener") // 指定扫描Servlet组件的包路径用于注册Servlet、Filter等
@MapperScan(basePackages = {"com.dao"}) // 指定MyBatis的Mapper接口所在的包路径Spring会自动扫描并注册这些接口
public class jianshenfangglApplication extends SpringBootServletInitializer { // 主类继承SpringBootServletInitializer支持以WAR包形式部署
public static void main(String[] args) {
// 主方法启动Spring Boot应用程序
SpringApplication.run(jianshenfangglApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder) {
return applicationBuilder.sources(jianshenfangglApplication.class);
}
protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder) {
// 重写configure方法用于配置Spring Boot应用程序的启动源支持外部容器如Tomcat部署
return applicationBuilder.sources(jianshenfangglApplication.class);
}
}

@ -1,3 +1,97 @@
<<<<<<< HEAD
package com.utils; // 定义包名为com.utils表示该类位于com.utils包下
import java.util.HashMap; // 导入HashMap类用于实现键值对存储
import java.util.Map; // 导入Map接口用于处理键值对集合
// 返回数据工具类
//继承HashMap提供统一的API响应格式封装
public class R extends HashMap<String, Object> {
private static final long serialVersionUID = 1L; // 序列化版本ID保证序列化兼容性
// 默认构造函数
//初始化时默认设置code为0表示成功
public R() {
put("code", 0); // 默认成功状态码
}
// 创建错误响应(使用默认错误码和消息)
//@return 包含默认错误信息的R对象
public static R error() {
return error(500, "未知异常,请联系管理员"); // 默认服务器错误
}
// 创建带自定义消息的错误响应使用默认错误码500
//@param msg 错误消息
//@return 包含自定义错误消息的R对象
public static R error(String msg) {
return error(500, msg); // 使用默认错误码500
}
// 创建带自定义错误码和消息的错误响应
//@param code 错误码
//@param msg 错误消息
//@return 包含自定义错误信息的R对象
public static R error(int code, String msg) {
R r = new R();
r.put("code", code); // 设置错误码
r.put("msg", msg); // 设置错误消息
return r;
}
// 创建成功响应(带自定义消息)
//@param msg 成功消息
//@return 包含成功消息的R对象
public static R ok(String msg) {
R r = new R();
r.put("msg", msg); // 设置成功消息
return r;
}
// 创建成功响应(带多个数据)
//@param map 包含多个键值对的数据集合
//@return 包含所有数据的R对象
public static R ok(Map<String, Object> map) {
R r = new R();
r.putAll(map); // 添加所有数据到响应中
return r;
}
// 创建默认成功响应
//@return 只包含默认成功码的R对象
public static R ok() {
return new R(); // 使用默认构造函数
}
// 添加键值对到响应中(链式调用支持)
//@param key 键名
//@param value 键值
//@return 当前R对象支持链式调用
@Override
public R put(String key, Object value) {
super.put(key, value); // 调用父类HashMap的put方法
return this; // 返回当前对象以实现链式调用
}
}
=======
package com.utils;
import java.util.HashMap;
@ -49,3 +143,4 @@ public class R extends HashMap<String, Object> {
return this;
}
}
>>>>>>> develop

Loading…
Cancel
Save