pull/1/head
commit
f12426ca27
@ -0,0 +1,182 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.2.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.jlwl</groupId>
|
||||
<!-- 导入项目的名称 -->
|
||||
<artifactId>yiyuanguanhaojiuzhen</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>yiyuanguanhaojiuzhen</name>
|
||||
<description>医院挂号就诊系统</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<fastjson.version>1.2.8</fastjson.version>
|
||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--访问静态资源-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--热部署-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-spring</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatisplus-spring-boot-starter</artifactId>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>3.10.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>2.0.1.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>4.0.12</version>
|
||||
</dependency>
|
||||
|
||||
<!-- FastJson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>sqljdbc4</artifactId>
|
||||
<scope>4.0</scope>
|
||||
<version>4.0</version>
|
||||
</dependency>-->
|
||||
|
||||
<!-- 百度人工智能 -->
|
||||
<dependency>
|
||||
<groupId>com.baidu.aip</groupId>
|
||||
<artifactId>java-sdk</artifactId>
|
||||
<version>4.4.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- poi高版本额外包 -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-examples</artifactId>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-excelant</artifactId>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,61 @@
|
||||
package com.ServletContextListener;
|
||||
|
||||
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||
import com.entity.DictionaryEntity;
|
||||
import com.service.DictionaryService;
|
||||
import com.thread.MyThreadMethod;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import javax.servlet.ServletContextListener;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.annotation.WebListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典初始化监视器 用的是服务器监听,每次项目启动,都会调用这个类
|
||||
*/
|
||||
@WebListener
|
||||
public class DictionaryServletContextListener implements ServletContextListener {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DictionaryServletContextListener.class);
|
||||
private MyThreadMethod myThreadMethod;
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
logger.info("----------服务器停止----------");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext());
|
||||
|
||||
logger.info("----------字典表初始化开始----------");
|
||||
DictionaryService dictionaryService = (DictionaryService)appContext.getBean("dictionaryService");
|
||||
List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
|
||||
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);
|
||||
}
|
||||
sce.getServletContext().setAttribute("dictionaryMap", map);
|
||||
logger.info("----------字典表初始化完成----------");
|
||||
|
||||
|
||||
|
||||
logger.info("----------线程执行开始----------");
|
||||
if (myThreadMethod == null) {
|
||||
myThreadMethod = new MyThreadMethod();
|
||||
myThreadMethod.start(); // servlet 上下文初始化时启动线程myThreadMethod
|
||||
}
|
||||
logger.info("----------线程执行结束----------");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
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 {
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 忽略Token验证
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface IgnoreAuth {
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
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 {
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
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) {
|
||||
// 关闭更新填充、这里不执行
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,326 @@
|
||||
|
||||
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("/chat")
|
||||
public class ChatController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ChatController.class);
|
||||
|
||||
@Autowired
|
||||
private ChatService chatService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@Autowired
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
//级联表service
|
||||
@Autowired
|
||||
private YonghuService yonghuService;
|
||||
|
||||
@Autowired
|
||||
private YishengService yishengService;
|
||||
|
||||
|
||||
/**
|
||||
* 后端列表
|
||||
*/
|
||||
@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("yishengId",request.getSession().getAttribute("userId"));
|
||||
if(params.get("orderBy")==null || params.get("orderBy")==""){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
PageUtils page = chatService.queryPage(params);
|
||||
|
||||
//字典表数据转换
|
||||
List<ChatView> list =(List<ChatView>)page.getList();
|
||||
for(ChatView 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);
|
||||
ChatEntity chat = chatService.selectById(id);
|
||||
if(chat !=null){
|
||||
//entity转view
|
||||
ChatView view = new ChatView();
|
||||
BeanUtils.copyProperties( chat , view );//把实体数据重构到view中
|
||||
|
||||
//级联表
|
||||
YonghuEntity yonghu = yonghuService.selectById(chat.getYonghuId());
|
||||
if(yonghu != null){
|
||||
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到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 ChatEntity chat, HttpServletRequest request){
|
||||
logger.debug("save方法:,,Controller:{},,chat:{}",this.getClass().getName(),chat.toString());
|
||||
|
||||
String role = String.valueOf(request.getSession().getAttribute("role"));
|
||||
if(false)
|
||||
return R.error(511,"永远不会进入");
|
||||
else if("用户".equals(role))
|
||||
chat.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
|
||||
|
||||
Wrapper<ChatEntity> queryWrapper = new EntityWrapper<ChatEntity>()
|
||||
.eq("yonghu_id", chat.getYonghuId())
|
||||
.eq("chat_issue", chat.getChatIssue())
|
||||
.eq("chat_reply", chat.getChatReply())
|
||||
.eq("zhuangtai_types", chat.getZhuangtaiTypes())
|
||||
.eq("chat_types", chat.getChatTypes())
|
||||
;
|
||||
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
ChatEntity chatEntity = chatService.selectOne(queryWrapper);
|
||||
if(chatEntity==null){
|
||||
chat.setInsertTime(new Date());
|
||||
chatService.insert(chat);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"表中有相同数据");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody ChatEntity chat, HttpServletRequest request){
|
||||
logger.debug("update方法:,,Controller:{},,chat:{}",this.getClass().getName(),chat.toString());
|
||||
|
||||
String role = String.valueOf(request.getSession().getAttribute("role"));
|
||||
// if(false)
|
||||
// return R.error(511,"永远不会进入");
|
||||
// else if("用户".equals(role))
|
||||
// chat.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
|
||||
//根据字段查询是否有相同数据
|
||||
Wrapper<ChatEntity> queryWrapper = new EntityWrapper<ChatEntity>()
|
||||
.notIn("id",chat.getId())
|
||||
.andNew()
|
||||
.eq("yonghu_id", chat.getYonghuId())
|
||||
.eq("chat_issue", chat.getChatIssue())
|
||||
.eq("chat_reply", chat.getChatReply())
|
||||
.eq("zhuangtai_types", chat.getZhuangtaiTypes())
|
||||
.eq("chat_types", chat.getChatTypes())
|
||||
;
|
||||
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
ChatEntity chatEntity = chatService.selectOne(queryWrapper);
|
||||
if(chatEntity==null){
|
||||
chatService.updateById(chat);//根据id更新
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"表中有相同数据");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
|
||||
chatService.deleteBatchIds(Arrays.asList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量上传
|
||||
*/
|
||||
@RequestMapping("/batchInsert")
|
||||
public R save( String fileName){
|
||||
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
|
||||
try {
|
||||
List<ChatEntity> chatList = 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){
|
||||
//循环
|
||||
ChatEntity chatEntity = new ChatEntity();
|
||||
// chatEntity.setYonghuId(Integer.valueOf(data.get(0))); //提问用户 要改的
|
||||
// chatEntity.setChatIssue(data.get(0)); //问题 要改的
|
||||
// chatEntity.setIssueTime(new Date(data.get(0))); //问题时间 要改的
|
||||
// chatEntity.setChatReply(data.get(0)); //回复 要改的
|
||||
// chatEntity.setReplyTime(new Date(data.get(0))); //回复时间 要改的
|
||||
// chatEntity.setZhuangtaiTypes(Integer.valueOf(data.get(0))); //状态 要改的
|
||||
// chatEntity.setChatTypes(Integer.valueOf(data.get(0))); //数据类型 要改的
|
||||
// chatEntity.setInsertTime(date);//时间
|
||||
chatList.add(chatEntity);
|
||||
|
||||
|
||||
//把要查询是否重复的字段放入map中
|
||||
}
|
||||
|
||||
//查询是否重复
|
||||
chatService.insertBatch(chatList);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return R.error(511,"批量插入数据异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 前端列表
|
||||
*/
|
||||
@IgnoreAuth
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
|
||||
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
|
||||
|
||||
// 没有指定排序字段就默认id倒序
|
||||
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
PageUtils page = chatService.queryPage(params);
|
||||
|
||||
//字典表数据转换
|
||||
List<ChatView> list =(List<ChatView>)page.getList();
|
||||
for(ChatView c:list)
|
||||
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
|
||||
return R.ok().put("data", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端详情
|
||||
*/
|
||||
@RequestMapping("/detail/{id}")
|
||||
public R detail(@PathVariable("id") Long id, HttpServletRequest request){
|
||||
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
|
||||
ChatEntity chat = chatService.selectById(id);
|
||||
if(chat !=null){
|
||||
|
||||
|
||||
//entity转view
|
||||
ChatView view = new ChatView();
|
||||
BeanUtils.copyProperties( chat , view );//把实体数据重构到view中
|
||||
|
||||
//级联表
|
||||
YonghuEntity yonghu = yonghuService.selectById(chat.getYonghuId());
|
||||
if(yonghu != null){
|
||||
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到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 ChatEntity chat, HttpServletRequest request){
|
||||
logger.debug("add方法:,,Controller:{},,chat:{}",this.getClass().getName(),chat.toString());
|
||||
Wrapper<ChatEntity> queryWrapper = new EntityWrapper<ChatEntity>()
|
||||
.eq("yonghu_id", chat.getYonghuId())
|
||||
.eq("chat_issue", chat.getChatIssue())
|
||||
.eq("chat_reply", chat.getChatReply())
|
||||
.eq("zhuangtai_types", chat.getZhuangtaiTypes())
|
||||
.eq("chat_types", chat.getChatTypes())
|
||||
;
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
ChatEntity chatEntity = chatService.selectOne(queryWrapper);
|
||||
if(chatEntity==null){
|
||||
chat.setInsertTime(new Date());
|
||||
chatService.insert(chat);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"表中有相同数据");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,277 @@
|
||||
|
||||
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);
|
||||
|
||||
@Autowired
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
//级联表service
|
||||
|
||||
@Autowired
|
||||
private YonghuService yonghuService;
|
||||
@Autowired
|
||||
private YishengService yishengService;
|
||||
|
||||
|
||||
/**
|
||||
* 后端列表
|
||||
*/
|
||||
@RequestMapping("/page")
|
||||
@IgnoreAuth
|
||||
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
|
||||
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
|
||||
if(params.get("orderBy")==null || params.get("orderBy")==""){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
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){
|
||||
logger.debug("update方法:,,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>()
|
||||
.notIn("id",dictionary.getId())
|
||||
.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){
|
||||
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();
|
||||
}else {
|
||||
return R.error(511,"表中有相同数据");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
|
||||
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 != null ){
|
||||
return R.ok().put("maxCodeIndex",dictionaryEntityList.get(0).getCodeIndex()+1);
|
||||
}else{
|
||||
return R.ok().put("maxCodeIndex",1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量上传
|
||||
*/
|
||||
@RequestMapping("/batchInsert")
|
||||
public R save( String fileName){
|
||||
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return R.error(511,"批量插入数据异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,363 @@
|
||||
|
||||
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("/guahao")
|
||||
public class GuahaoController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(GuahaoController.class);
|
||||
|
||||
@Autowired
|
||||
private GuahaoService guahaoService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@Autowired
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
//级联表service
|
||||
@Autowired
|
||||
private YishengService yishengService;
|
||||
@Autowired
|
||||
private YonghuService yonghuService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 后端列表
|
||||
*/
|
||||
@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("yishengId",request.getSession().getAttribute("userId"));
|
||||
if(params.get("orderBy")==null || params.get("orderBy")==""){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
PageUtils page = guahaoService.queryPage(params);
|
||||
|
||||
//字典表数据转换
|
||||
List<GuahaoView> list =(List<GuahaoView>)page.getList();
|
||||
for(GuahaoView 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);
|
||||
GuahaoEntity guahao = guahaoService.selectById(id);
|
||||
if(guahao !=null){
|
||||
//entity转view
|
||||
GuahaoView view = new GuahaoView();
|
||||
BeanUtils.copyProperties( guahao , view );//把实体数据重构到view中
|
||||
|
||||
//级联表
|
||||
YishengEntity yisheng = yishengService.selectById(guahao.getYishengId());
|
||||
if(yisheng != null){
|
||||
BeanUtils.copyProperties( yisheng , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
|
||||
view.setYishengId(yisheng.getId());
|
||||
}
|
||||
//级联表
|
||||
YonghuEntity yonghu = yonghuService.selectById(guahao.getYonghuId());
|
||||
if(yonghu != null){
|
||||
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到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 GuahaoEntity guahao, HttpServletRequest request){
|
||||
logger.debug("save方法:,,Controller:{},,guahao:{}",this.getClass().getName(),guahao.toString());
|
||||
|
||||
String role = String.valueOf(request.getSession().getAttribute("role"));
|
||||
if(false)
|
||||
return R.error(511,"永远不会进入");
|
||||
else if("医生".equals(role))
|
||||
guahao.setYishengId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
|
||||
else if("用户".equals(role))
|
||||
guahao.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
|
||||
|
||||
Wrapper<GuahaoEntity> queryWrapper = new EntityWrapper<GuahaoEntity>()
|
||||
.eq("yisheng_id", guahao.getYishengId())
|
||||
.eq("yonghu_id", guahao.getYonghuId())
|
||||
.eq("guahao_uuin_number", guahao.getGuahaoUuinNumber())
|
||||
.eq("guahao_time", new SimpleDateFormat("yyyy-MM-dd").format(guahao.getGuahaoTime()))
|
||||
.eq("guahao_types", guahao.getGuahaoTypes())
|
||||
.eq("guahao_status_types", guahao.getGuahaoStatusTypes())
|
||||
.eq("guahao_yesno_types", guahao.getGuahaoYesnoTypes())
|
||||
.eq("guahao_yesno_text", guahao.getGuahaoYesnoText())
|
||||
;
|
||||
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
GuahaoEntity guahaoEntity = guahaoService.selectOne(queryWrapper);
|
||||
if(guahaoEntity==null){
|
||||
guahao.setGuahaoYesnoTypes(1);
|
||||
guahao.setCreateTime(new Date());
|
||||
guahaoService.insert(guahao);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"表中有相同数据");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody GuahaoEntity guahao, HttpServletRequest request){
|
||||
logger.debug("update方法:,,Controller:{},,guahao:{}",this.getClass().getName(),guahao.toString());
|
||||
|
||||
String role = String.valueOf(request.getSession().getAttribute("role"));
|
||||
// if(false)
|
||||
// return R.error(511,"永远不会进入");
|
||||
// else if("医生".equals(role))
|
||||
// guahao.setYishengId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
|
||||
// else if("用户".equals(role))
|
||||
// guahao.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
|
||||
//根据字段查询是否有相同数据
|
||||
Wrapper<GuahaoEntity> queryWrapper = new EntityWrapper<GuahaoEntity>()
|
||||
.notIn("id",guahao.getId())
|
||||
.andNew()
|
||||
.eq("yisheng_id", guahao.getYishengId())
|
||||
.eq("yonghu_id", guahao.getYonghuId())
|
||||
.eq("guahao_uuin_number", guahao.getGuahaoUuinNumber())
|
||||
.eq("guahao_time", guahao.getGuahaoTime())
|
||||
.eq("guahao_types", guahao.getGuahaoTypes())
|
||||
.eq("guahao_status_types", guahao.getGuahaoStatusTypes())
|
||||
.eq("guahao_yesno_types", guahao.getGuahaoYesnoTypes())
|
||||
.eq("guahao_yesno_text", guahao.getGuahaoYesnoText())
|
||||
;
|
||||
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
GuahaoEntity guahaoEntity = guahaoService.selectOne(queryWrapper);
|
||||
if(guahaoEntity==null){
|
||||
guahaoService.updateById(guahao);//根据id更新
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"表中有相同数据");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
|
||||
guahaoService.deleteBatchIds(Arrays.asList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量上传
|
||||
*/
|
||||
@RequestMapping("/batchInsert")
|
||||
public R save( String fileName){
|
||||
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
|
||||
try {
|
||||
List<GuahaoEntity> guahaoList = 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){
|
||||
//循环
|
||||
GuahaoEntity guahaoEntity = new GuahaoEntity();
|
||||
// guahaoEntity.setYishengId(Integer.valueOf(data.get(0))); //医生 要改的
|
||||
// guahaoEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的
|
||||
// guahaoEntity.setGuahaoUuinNumber(Integer.valueOf(data.get(0))); //就诊识别码 要改的
|
||||
// guahaoEntity.setGuahaoTime(new Date(data.get(0))); //挂号时间 要改的
|
||||
// guahaoEntity.setGuahaoTypes(Integer.valueOf(data.get(0))); //时间类型 要改的
|
||||
// guahaoEntity.setGuahaoStatusTypes(Integer.valueOf(data.get(0))); //挂号状态 要改的
|
||||
// guahaoEntity.setGuahaoYesnoTypes(Integer.valueOf(data.get(0))); //挂号审核 要改的
|
||||
// guahaoEntity.setGuahaoYesnoText(data.get(0)); //审核结果 要改的
|
||||
// guahaoEntity.setCreateTime(date);//时间
|
||||
guahaoList.add(guahaoEntity);
|
||||
|
||||
|
||||
//把要查询是否重复的字段放入map中
|
||||
}
|
||||
|
||||
//查询是否重复
|
||||
guahaoService.insertBatch(guahaoList);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return R.error(511,"批量插入数据异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 前端列表
|
||||
*/
|
||||
@IgnoreAuth
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
|
||||
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
|
||||
|
||||
// 没有指定排序字段就默认id倒序
|
||||
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
PageUtils page = guahaoService.queryPage(params);
|
||||
|
||||
//字典表数据转换
|
||||
List<GuahaoView> list =(List<GuahaoView>)page.getList();
|
||||
for(GuahaoView c:list)
|
||||
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
|
||||
return R.ok().put("data", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端详情
|
||||
*/
|
||||
@RequestMapping("/detail/{id}")
|
||||
public R detail(@PathVariable("id") Long id, HttpServletRequest request){
|
||||
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
|
||||
GuahaoEntity guahao = guahaoService.selectById(id);
|
||||
if(guahao !=null){
|
||||
|
||||
|
||||
//entity转view
|
||||
GuahaoView view = new GuahaoView();
|
||||
BeanUtils.copyProperties( guahao , view );//把实体数据重构到view中
|
||||
|
||||
//级联表
|
||||
YishengEntity yisheng = yishengService.selectById(guahao.getYishengId());
|
||||
if(yisheng != null){
|
||||
BeanUtils.copyProperties( yisheng , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
|
||||
view.setYishengId(yisheng.getId());
|
||||
}
|
||||
//级联表
|
||||
YonghuEntity yonghu = yonghuService.selectById(guahao.getYonghuId());
|
||||
if(yonghu != null){
|
||||
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到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 GuahaoEntity guahao, HttpServletRequest request){
|
||||
logger.debug("add方法:,,Controller:{},,guahao:{}",this.getClass().getName(),guahao.toString());
|
||||
Wrapper<GuahaoEntity> queryWrapper = new EntityWrapper<GuahaoEntity>()
|
||||
.eq("yisheng_id", guahao.getYishengId())
|
||||
.eq("yonghu_id", guahao.getYonghuId())
|
||||
.eq("guahao_uuin_number", guahao.getGuahaoUuinNumber())
|
||||
.eq("guahao_types", guahao.getGuahaoTypes())
|
||||
.eq("guahao_status_types", guahao.getGuahaoStatusTypes())
|
||||
.eq("guahao_yesno_types", guahao.getGuahaoYesnoTypes())
|
||||
.eq("guahao_yesno_text", guahao.getGuahaoYesnoText())
|
||||
;
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
GuahaoEntity guahaoEntity = guahaoService.selectOne(queryWrapper);
|
||||
if(guahaoEntity==null){
|
||||
guahao.setGuahaoYesnoTypes(1);
|
||||
guahao.setCreateTime(new Date());
|
||||
YonghuEntity userId = yonghuService.selectById((Integer) request.getSession().getAttribute("userId"));
|
||||
YishengEntity yishengEntity = yishengService.selectById(guahao.getYishengId());
|
||||
if(userId.getNewMoney()<yishengEntity.getYishengNewMoney()){
|
||||
return R.error("余额不足请充值");
|
||||
}
|
||||
userId.setNewMoney(userId.getNewMoney()-yishengEntity.getYishengNewMoney());
|
||||
boolean b = yonghuService.updateById(userId);
|
||||
if(!b){
|
||||
return R.error();
|
||||
}
|
||||
guahaoService.insert(guahao);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"表中有相同数据");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,320 @@
|
||||
|
||||
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("/jiankangjiaoyu")
|
||||
public class JiankangjiaoyuController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(JiankangjiaoyuController.class);
|
||||
|
||||
@Autowired
|
||||
private JiankangjiaoyuService jiankangjiaoyuService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@Autowired
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
//级联表service
|
||||
|
||||
@Autowired
|
||||
private YonghuService yonghuService;
|
||||
@Autowired
|
||||
private YishengService yishengService;
|
||||
|
||||
|
||||
/**
|
||||
* 后端列表
|
||||
*/
|
||||
@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("yishengId",request.getSession().getAttribute("userId"));
|
||||
params.put("jiankangjiaoyuDeleteStart",1);params.put("jiankangjiaoyuDeleteEnd",1);
|
||||
if(params.get("orderBy")==null || params.get("orderBy")==""){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
PageUtils page = jiankangjiaoyuService.queryPage(params);
|
||||
|
||||
//字典表数据转换
|
||||
List<JiankangjiaoyuView> list =(List<JiankangjiaoyuView>)page.getList();
|
||||
for(JiankangjiaoyuView 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);
|
||||
JiankangjiaoyuEntity jiankangjiaoyu = jiankangjiaoyuService.selectById(id);
|
||||
if(jiankangjiaoyu !=null){
|
||||
//entity转view
|
||||
JiankangjiaoyuView view = new JiankangjiaoyuView();
|
||||
BeanUtils.copyProperties( jiankangjiaoyu , view );//把实体数据重构到view中
|
||||
|
||||
//修改对应字典表字段
|
||||
dictionaryService.dictionaryConvert(view, request);
|
||||
return R.ok().put("data", view);
|
||||
}else {
|
||||
return R.error(511,"查不到数据");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request){
|
||||
logger.debug("save方法:,,Controller:{},,jiankangjiaoyu:{}",this.getClass().getName(),jiankangjiaoyu.toString());
|
||||
|
||||
String role = String.valueOf(request.getSession().getAttribute("role"));
|
||||
if(false)
|
||||
return R.error(511,"永远不会进入");
|
||||
|
||||
Wrapper<JiankangjiaoyuEntity> queryWrapper = new EntityWrapper<JiankangjiaoyuEntity>()
|
||||
.eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName())
|
||||
.eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes())
|
||||
.eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete())
|
||||
;
|
||||
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
JiankangjiaoyuEntity jiankangjiaoyuEntity = jiankangjiaoyuService.selectOne(queryWrapper);
|
||||
if(jiankangjiaoyuEntity==null){
|
||||
jiankangjiaoyu.setInsertTime(new Date());
|
||||
jiankangjiaoyu.setJiankangjiaoyuDelete(1);
|
||||
jiankangjiaoyu.setCreateTime(new Date());
|
||||
jiankangjiaoyuService.insert(jiankangjiaoyu);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"表中有相同数据");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request){
|
||||
logger.debug("update方法:,,Controller:{},,jiankangjiaoyu:{}",this.getClass().getName(),jiankangjiaoyu.toString());
|
||||
|
||||
String role = String.valueOf(request.getSession().getAttribute("role"));
|
||||
// if(false)
|
||||
// return R.error(511,"永远不会进入");
|
||||
//根据字段查询是否有相同数据
|
||||
Wrapper<JiankangjiaoyuEntity> queryWrapper = new EntityWrapper<JiankangjiaoyuEntity>()
|
||||
.notIn("id",jiankangjiaoyu.getId())
|
||||
.andNew()
|
||||
.eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName())
|
||||
.eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes())
|
||||
.eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete())
|
||||
;
|
||||
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
JiankangjiaoyuEntity jiankangjiaoyuEntity = jiankangjiaoyuService.selectOne(queryWrapper);
|
||||
if("".equals(jiankangjiaoyu.getJiankangjiaoyuPhoto()) || "null".equals(jiankangjiaoyu.getJiankangjiaoyuPhoto())){
|
||||
jiankangjiaoyu.setJiankangjiaoyuPhoto(null);
|
||||
}
|
||||
if(jiankangjiaoyuEntity==null){
|
||||
jiankangjiaoyuService.updateById(jiankangjiaoyu);//根据id更新
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"表中有相同数据");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
|
||||
ArrayList<JiankangjiaoyuEntity> list = new ArrayList<>();
|
||||
for(Integer id:ids){
|
||||
JiankangjiaoyuEntity jiankangjiaoyuEntity = new JiankangjiaoyuEntity();
|
||||
jiankangjiaoyuEntity.setId(id);
|
||||
jiankangjiaoyuEntity.setJiankangjiaoyuDelete(2);
|
||||
list.add(jiankangjiaoyuEntity);
|
||||
}
|
||||
if(list != null && list.size() >0){
|
||||
jiankangjiaoyuService.updateBatchById(list);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量上传
|
||||
*/
|
||||
@RequestMapping("/batchInsert")
|
||||
public R save( String fileName){
|
||||
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
|
||||
try {
|
||||
List<JiankangjiaoyuEntity> jiankangjiaoyuList = 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){
|
||||
//循环
|
||||
JiankangjiaoyuEntity jiankangjiaoyuEntity = new JiankangjiaoyuEntity();
|
||||
// jiankangjiaoyuEntity.setJiankangjiaoyuName(data.get(0)); //健康教育标题 要改的
|
||||
// jiankangjiaoyuEntity.setJiankangjiaoyuTypes(Integer.valueOf(data.get(0))); //健康教育类型 要改的
|
||||
// jiankangjiaoyuEntity.setJiankangjiaoyuPhoto("");//照片
|
||||
// jiankangjiaoyuEntity.setInsertTime(date);//时间
|
||||
// jiankangjiaoyuEntity.setJiankangjiaoyuContent("");//照片
|
||||
// jiankangjiaoyuEntity.setJiankangjiaoyuDelete(1);//逻辑删除字段
|
||||
// jiankangjiaoyuEntity.setCreateTime(date);//时间
|
||||
jiankangjiaoyuList.add(jiankangjiaoyuEntity);
|
||||
|
||||
|
||||
//把要查询是否重复的字段放入map中
|
||||
}
|
||||
|
||||
//查询是否重复
|
||||
jiankangjiaoyuService.insertBatch(jiankangjiaoyuList);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return R.error(511,"批量插入数据异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 前端列表
|
||||
*/
|
||||
@IgnoreAuth
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
|
||||
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
|
||||
|
||||
// 没有指定排序字段就默认id倒序
|
||||
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
PageUtils page = jiankangjiaoyuService.queryPage(params);
|
||||
|
||||
//字典表数据转换
|
||||
List<JiankangjiaoyuView> list =(List<JiankangjiaoyuView>)page.getList();
|
||||
for(JiankangjiaoyuView c:list)
|
||||
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
|
||||
return R.ok().put("data", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端详情
|
||||
*/
|
||||
@RequestMapping("/detail/{id}")
|
||||
public R detail(@PathVariable("id") Long id, HttpServletRequest request){
|
||||
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
|
||||
JiankangjiaoyuEntity jiankangjiaoyu = jiankangjiaoyuService.selectById(id);
|
||||
if(jiankangjiaoyu !=null){
|
||||
|
||||
|
||||
//entity转view
|
||||
JiankangjiaoyuView view = new JiankangjiaoyuView();
|
||||
BeanUtils.copyProperties( jiankangjiaoyu , view );//把实体数据重构到view中
|
||||
|
||||
//修改对应字典表字段
|
||||
dictionaryService.dictionaryConvert(view, request);
|
||||
return R.ok().put("data", view);
|
||||
}else {
|
||||
return R.error(511,"查不到数据");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 前端保存
|
||||
*/
|
||||
@RequestMapping("/add")
|
||||
public R add(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request){
|
||||
logger.debug("add方法:,,Controller:{},,jiankangjiaoyu:{}",this.getClass().getName(),jiankangjiaoyu.toString());
|
||||
Wrapper<JiankangjiaoyuEntity> queryWrapper = new EntityWrapper<JiankangjiaoyuEntity>()
|
||||
.eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName())
|
||||
.eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes())
|
||||
.eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete())
|
||||
;
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
JiankangjiaoyuEntity jiankangjiaoyuEntity = jiankangjiaoyuService.selectOne(queryWrapper);
|
||||
if(jiankangjiaoyuEntity==null){
|
||||
jiankangjiaoyu.setInsertTime(new Date());
|
||||
jiankangjiaoyu.setJiankangjiaoyuDelete(1);
|
||||
jiankangjiaoyu.setCreateTime(new Date());
|
||||
jiankangjiaoyuService.insert(jiankangjiaoyu);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"表中有相同数据");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,304 @@
|
||||
|
||||
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("/news")
|
||||
public class NewsController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(NewsController.class);
|
||||
|
||||
@Autowired
|
||||
private NewsService newsService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@Autowired
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
//级联表service
|
||||
|
||||
@Autowired
|
||||
private YonghuService yonghuService;
|
||||
@Autowired
|
||||
private YishengService yishengService;
|
||||
|
||||
|
||||
/**
|
||||
* 后端列表
|
||||
*/
|
||||
@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("yishengId",request.getSession().getAttribute("userId"));
|
||||
if(params.get("orderBy")==null || params.get("orderBy")==""){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
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,"查不到数据");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody NewsEntity news, HttpServletRequest request){
|
||||
logger.debug("save方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString());
|
||||
|
||||
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){
|
||||
logger.debug("update方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString());
|
||||
|
||||
String role = String.valueOf(request.getSession().getAttribute("role"));
|
||||
// if(false)
|
||||
// return R.error(511,"永远不会进入");
|
||||
//根据字段查询是否有相同数据
|
||||
Wrapper<NewsEntity> queryWrapper = new EntityWrapper<NewsEntity>()
|
||||
.notIn("id",news.getId())
|
||||
.andNew()
|
||||
.eq("news_name", news.getNewsName())
|
||||
.eq("news_types", news.getNewsTypes())
|
||||
;
|
||||
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
NewsEntity newsEntity = newsService.selectOne(queryWrapper);
|
||||
if("".equals(news.getNewsPhoto()) || "null".equals(news.getNewsPhoto())){
|
||||
news.setNewsPhoto(null);
|
||||
}
|
||||
if(newsEntity==null){
|
||||
newsService.updateById(news);//根据id更新
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"表中有相同数据");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
|
||||
newsService.deleteBatchIds(Arrays.asList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量上传
|
||||
*/
|
||||
@RequestMapping("/batchInsert")
|
||||
public R save( String fileName){
|
||||
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
|
||||
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.setNewsPhoto("");//照片
|
||||
// newsEntity.setNewsTypes(Integer.valueOf(data.get(0))); //公告类型 要改的
|
||||
// newsEntity.setInsertTime(date);//时间
|
||||
// newsEntity.setNewsContent("");//照片
|
||||
// newsEntity.setCreateTime(date);//时间
|
||||
newsList.add(newsEntity);
|
||||
|
||||
|
||||
//把要查询是否重复的字段放入map中
|
||||
}
|
||||
|
||||
//查询是否重复
|
||||
newsService.insertBatch(newsList);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return R.error(511,"批量插入数据异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 前端列表
|
||||
*/
|
||||
@IgnoreAuth
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
|
||||
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
|
||||
|
||||
// 没有指定排序字段就默认id倒序
|
||||
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
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") Long 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,"查不到数据");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 前端保存
|
||||
*/
|
||||
@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>()
|
||||
.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,"表中有相同数据");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,475 @@
|
||||
|
||||
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("/yisheng")
|
||||
public class YishengController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(YishengController.class);
|
||||
|
||||
@Autowired
|
||||
private YishengService yishengService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@Autowired
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
//级联表service
|
||||
|
||||
@Autowired
|
||||
private YonghuService yonghuService;
|
||||
|
||||
|
||||
/**
|
||||
* 后端列表
|
||||
*/
|
||||
@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("yishengId",request.getSession().getAttribute("userId"));
|
||||
if(params.get("orderBy")==null || params.get("orderBy")==""){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
PageUtils page = yishengService.queryPage(params);
|
||||
|
||||
//字典表数据转换
|
||||
List<YishengView> list =(List<YishengView>)page.getList();
|
||||
for(YishengView 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);
|
||||
YishengEntity yisheng = yishengService.selectById(id);
|
||||
if(yisheng !=null){
|
||||
//entity转view
|
||||
YishengView view = new YishengView();
|
||||
BeanUtils.copyProperties( yisheng , view );//把实体数据重构到view中
|
||||
|
||||
//修改对应字典表字段
|
||||
dictionaryService.dictionaryConvert(view, request);
|
||||
return R.ok().put("data", view);
|
||||
}else {
|
||||
return R.error(511,"查不到数据");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody YishengEntity yisheng, HttpServletRequest request){
|
||||
logger.debug("save方法:,,Controller:{},,yisheng:{}",this.getClass().getName(),yisheng.toString());
|
||||
|
||||
String role = String.valueOf(request.getSession().getAttribute("role"));
|
||||
if(false)
|
||||
return R.error(511,"永远不会进入");
|
||||
|
||||
Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>()
|
||||
.eq("username", yisheng.getUsername())
|
||||
.or()
|
||||
.eq("yisheng_phone", yisheng.getYishengPhone())
|
||||
;
|
||||
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper);
|
||||
if(yishengEntity==null){
|
||||
yisheng.setCreateTime(new Date());
|
||||
yisheng.setPassword("123456");
|
||||
yishengService.insert(yisheng);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"账户或者联系方式已经被使用");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody YishengEntity yisheng, HttpServletRequest request){
|
||||
logger.debug("update方法:,,Controller:{},,yisheng:{}",this.getClass().getName(),yisheng.toString());
|
||||
|
||||
String role = String.valueOf(request.getSession().getAttribute("role"));
|
||||
// if(false)
|
||||
// return R.error(511,"永远不会进入");
|
||||
//根据字段查询是否有相同数据
|
||||
Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>()
|
||||
.notIn("id",yisheng.getId())
|
||||
.andNew()
|
||||
.eq("username", yisheng.getUsername())
|
||||
.or()
|
||||
.eq("yisheng_phone", yisheng.getYishengPhone())
|
||||
;
|
||||
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper);
|
||||
if("".equals(yisheng.getYishengPhoto()) || "null".equals(yisheng.getYishengPhoto())){
|
||||
yisheng.setYishengPhoto(null);
|
||||
}
|
||||
if(yishengEntity==null){
|
||||
yishengService.updateById(yisheng);//根据id更新
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"账户或者联系方式已经被使用");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
|
||||
yishengService.deleteBatchIds(Arrays.asList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量上传
|
||||
*/
|
||||
@RequestMapping("/batchInsert")
|
||||
public R save( String fileName){
|
||||
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
|
||||
try {
|
||||
List<YishengEntity> yishengList = 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){
|
||||
//循环
|
||||
YishengEntity yishengEntity = new YishengEntity();
|
||||
// yishengEntity.setYishengUuidNumber(data.get(0)); //医生工号 要改的
|
||||
// yishengEntity.setUsername(data.get(0)); //账户 要改的
|
||||
// //yishengEntity.setPassword("123456");//密码
|
||||
// yishengEntity.setYishengName(data.get(0)); //医生名称 要改的
|
||||
// yishengEntity.setYishengTypes(Integer.valueOf(data.get(0))); //科室 要改的
|
||||
// yishengEntity.setZhiweiTypes(Integer.valueOf(data.get(0))); //职位 要改的
|
||||
// yishengEntity.setYishengZhichneg(data.get(0)); //职称 要改的
|
||||
// yishengEntity.setYishengPhoto("");//照片
|
||||
// yishengEntity.setYishengPhone(data.get(0)); //联系方式 要改的
|
||||
// yishengEntity.setYishengGuahao(data.get(0)); //挂号须知 要改的
|
||||
// yishengEntity.setYishengEmail(data.get(0)); //邮箱 要改的
|
||||
// yishengEntity.setYishengNewMoney(data.get(0)); //挂号价格 要改的
|
||||
// yishengEntity.setYishengContent("");//照片
|
||||
// yishengEntity.setCreateTime(date);//时间
|
||||
yishengList.add(yishengEntity);
|
||||
|
||||
|
||||
//把要查询是否重复的字段放入map中
|
||||
//医生工号
|
||||
if(seachFields.containsKey("yishengUuidNumber")){
|
||||
List<String> yishengUuidNumber = seachFields.get("yishengUuidNumber");
|
||||
yishengUuidNumber.add(data.get(0));//要改的
|
||||
}else{
|
||||
List<String> yishengUuidNumber = new ArrayList<>();
|
||||
yishengUuidNumber.add(data.get(0));//要改的
|
||||
seachFields.put("yishengUuidNumber",yishengUuidNumber);
|
||||
}
|
||||
//账户
|
||||
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("yishengPhone")){
|
||||
List<String> yishengPhone = seachFields.get("yishengPhone");
|
||||
yishengPhone.add(data.get(0));//要改的
|
||||
}else{
|
||||
List<String> yishengPhone = new ArrayList<>();
|
||||
yishengPhone.add(data.get(0));//要改的
|
||||
seachFields.put("yishengPhone",yishengPhone);
|
||||
}
|
||||
}
|
||||
|
||||
//查询是否重复
|
||||
//医生工号
|
||||
List<YishengEntity> yishengEntities_yishengUuidNumber = yishengService.selectList(new EntityWrapper<YishengEntity>().in("yisheng_uuid_number", seachFields.get("yishengUuidNumber")));
|
||||
if(yishengEntities_yishengUuidNumber.size() >0 ){
|
||||
ArrayList<String> repeatFields = new ArrayList<>();
|
||||
for(YishengEntity s:yishengEntities_yishengUuidNumber){
|
||||
repeatFields.add(s.getYishengUuidNumber());
|
||||
}
|
||||
return R.error(511,"数据库的该表中的 [医生工号] 字段已经存在 存在数据为:"+repeatFields.toString());
|
||||
}
|
||||
//账户
|
||||
List<YishengEntity> yishengEntities_username = yishengService.selectList(new EntityWrapper<YishengEntity>().in("username", seachFields.get("username")));
|
||||
if(yishengEntities_username.size() >0 ){
|
||||
ArrayList<String> repeatFields = new ArrayList<>();
|
||||
for(YishengEntity s:yishengEntities_username){
|
||||
repeatFields.add(s.getUsername());
|
||||
}
|
||||
return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
|
||||
}
|
||||
//联系方式
|
||||
List<YishengEntity> yishengEntities_yishengPhone = yishengService.selectList(new EntityWrapper<YishengEntity>().in("yisheng_phone", seachFields.get("yishengPhone")));
|
||||
if(yishengEntities_yishengPhone.size() >0 ){
|
||||
ArrayList<String> repeatFields = new ArrayList<>();
|
||||
for(YishengEntity s:yishengEntities_yishengPhone){
|
||||
repeatFields.add(s.getYishengPhone());
|
||||
}
|
||||
return R.error(511,"数据库的该表中的 [联系方式] 字段已经存在 存在数据为:"+repeatFields.toString());
|
||||
}
|
||||
yishengService.insertBatch(yishengList);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return R.error(511,"批量插入数据异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
@IgnoreAuth
|
||||
@RequestMapping(value = "/login")
|
||||
public R login(String username, String password, String captcha, HttpServletRequest request) {
|
||||
YishengEntity yisheng = yishengService.selectOne(new EntityWrapper<YishengEntity>().eq("username", username));
|
||||
if(yisheng==null || !yisheng.getPassword().equals(password))
|
||||
return R.error("账号或密码不正确");
|
||||
// // 获取监听器中的字典表
|
||||
// ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
|
||||
// Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
|
||||
// Map<Integer, String> role_types = dictionaryMap.get("role_types");
|
||||
// role_types.get(.getRoleTypes());
|
||||
String token = tokenService.generateToken(yisheng.getId(),username, "yisheng", "医生");
|
||||
R r = R.ok();
|
||||
r.put("token", token);
|
||||
r.put("role","医生");
|
||||
r.put("username",yisheng.getYishengName());
|
||||
r.put("tableName","yisheng");
|
||||
r.put("userId",yisheng.getId());
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
@IgnoreAuth
|
||||
@PostMapping(value = "/register")
|
||||
public R register(@RequestBody YishengEntity yisheng){
|
||||
// ValidatorUtils.validateEntity(user);
|
||||
Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>()
|
||||
.eq("username", yisheng.getUsername())
|
||||
.or()
|
||||
.eq("yisheng_phone", yisheng.getYishengPhone())
|
||||
;
|
||||
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper);
|
||||
if(yishengEntity != null)
|
||||
return R.error("账户或者联系方式已经被使用");
|
||||
yisheng.setYishengNewMoney(0.0);
|
||||
yisheng.setCreateTime(new Date());
|
||||
yishengService.insert(yisheng);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
@GetMapping(value = "/resetPassword")
|
||||
public R resetPassword(Integer id){
|
||||
YishengEntity yisheng = new YishengEntity();
|
||||
yisheng.setPassword("123456");
|
||||
yisheng.setId(id);
|
||||
yishengService.updateById(yisheng);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 忘记密码
|
||||
*/
|
||||
@IgnoreAuth
|
||||
@RequestMapping(value = "/resetPass")
|
||||
public R resetPass(String username, HttpServletRequest request) {
|
||||
YishengEntity yisheng = yishengService.selectOne(new EntityWrapper<YishengEntity>().eq("username", username));
|
||||
if(yisheng!=null){
|
||||
yisheng.setPassword("123456");
|
||||
boolean b = yishengService.updateById(yisheng);
|
||||
if(!b){
|
||||
return R.error();
|
||||
}
|
||||
}else{
|
||||
return R.error("账号不存在");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户的session用户信息
|
||||
*/
|
||||
@RequestMapping("/session")
|
||||
public R getCurrYisheng(HttpServletRequest request){
|
||||
Integer id = (Integer)request.getSession().getAttribute("userId");
|
||||
YishengEntity yisheng = yishengService.selectById(id);
|
||||
if(yisheng !=null){
|
||||
//entity转view
|
||||
YishengView view = new YishengView();
|
||||
BeanUtils.copyProperties( yisheng , view );//把实体数据重构到view中
|
||||
|
||||
//修改对应字典表字段
|
||||
dictionaryService.dictionaryConvert(view, request);
|
||||
return R.ok().put("data", view);
|
||||
}else {
|
||||
return R.error(511,"查不到数据");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退出
|
||||
*/
|
||||
@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));
|
||||
|
||||
// 没有指定排序字段就默认id倒序
|
||||
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
PageUtils page = yishengService.queryPage(params);
|
||||
|
||||
//字典表数据转换
|
||||
List<YishengView> list =(List<YishengView>)page.getList();
|
||||
for(YishengView c:list)
|
||||
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
|
||||
return R.ok().put("data", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端详情
|
||||
*/
|
||||
@RequestMapping("/detail/{id}")
|
||||
public R detail(@PathVariable("id") Long id, HttpServletRequest request){
|
||||
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
|
||||
YishengEntity yisheng = yishengService.selectById(id);
|
||||
if(yisheng !=null){
|
||||
|
||||
|
||||
//entity转view
|
||||
YishengView view = new YishengView();
|
||||
BeanUtils.copyProperties( yisheng , view );//把实体数据重构到view中
|
||||
|
||||
//修改对应字典表字段
|
||||
dictionaryService.dictionaryConvert(view, request);
|
||||
return R.ok().put("data", view);
|
||||
}else {
|
||||
return R.error(511,"查不到数据");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 前端保存
|
||||
*/
|
||||
@RequestMapping("/add")
|
||||
public R add(@RequestBody YishengEntity yisheng, HttpServletRequest request){
|
||||
logger.debug("add方法:,,Controller:{},,yisheng:{}",this.getClass().getName(),yisheng.toString());
|
||||
Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>()
|
||||
.eq("username", yisheng.getUsername())
|
||||
.or()
|
||||
.eq("yisheng_phone", yisheng.getYishengPhone())
|
||||
;
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper);
|
||||
if(yishengEntity==null){
|
||||
yisheng.setCreateTime(new Date());
|
||||
yisheng.setPassword("123456");
|
||||
yishengService.insert(yisheng);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"账户或者联系方式已经被使用");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,503 @@
|
||||
|
||||
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);
|
||||
|
||||
@Autowired
|
||||
private YonghuService yonghuService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@Autowired
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
//级联表service
|
||||
|
||||
@Autowired
|
||||
private YishengService yishengService;
|
||||
|
||||
|
||||
/**
|
||||
* 后端列表
|
||||
*/
|
||||
@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("yishengId",request.getSession().getAttribute("userId"));
|
||||
params.put("yonghuDeleteStart",1);params.put("yonghuDeleteEnd",1);
|
||||
if(params.get("orderBy")==null || params.get("orderBy")==""){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
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())
|
||||
.andNew()
|
||||
.eq("yonghu_delete", 1)
|
||||
;
|
||||
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
|
||||
if(yonghuEntity==null){
|
||||
yonghu.setYonghuDelete(1);
|
||||
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){
|
||||
logger.debug("update方法:,,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>()
|
||||
.notIn("id",yonghu.getId())
|
||||
.andNew()
|
||||
.eq("username", yonghu.getUsername())
|
||||
.or()
|
||||
.eq("yonghu_phone", yonghu.getYonghuPhone())
|
||||
.or()
|
||||
.eq("yonghu_id_number", yonghu.getYonghuIdNumber())
|
||||
.andNew()
|
||||
.eq("yonghu_delete", 1)
|
||||
;
|
||||
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
|
||||
if("".equals(yonghu.getYonghuPhoto()) || "null".equals(yonghu.getYonghuPhoto())){
|
||||
yonghu.setYonghuPhoto(null);
|
||||
}
|
||||
if(yonghuEntity==null){
|
||||
yonghuService.updateById(yonghu);//根据id更新
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
|
||||
ArrayList<YonghuEntity> list = new ArrayList<>();
|
||||
for(Integer id:ids){
|
||||
YonghuEntity yonghuEntity = new YonghuEntity();
|
||||
yonghuEntity.setId(id);
|
||||
yonghuEntity.setYonghuDelete(2);
|
||||
list.add(yonghuEntity);
|
||||
}
|
||||
if(list != null && list.size() >0){
|
||||
yonghuService.updateBatchById(list);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量上传
|
||||
*/
|
||||
@RequestMapping("/batchInsert")
|
||||
public R save( String fileName){
|
||||
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
|
||||
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.setYonghuPhoto("");//照片
|
||||
// yonghuEntity.setYonghuPhone(data.get(0)); //用户手机号 要改的
|
||||
// yonghuEntity.setYonghuIdNumber(data.get(0)); //用户身份证号 要改的
|
||||
// yonghuEntity.setYonghuEmail(data.get(0)); //邮箱 要改的
|
||||
// yonghuEntity.setSexTypes(Integer.valueOf(data.get(0))); //性别 要改的
|
||||
// yonghuEntity.setNewMoney(data.get(0)); //余额 要改的
|
||||
// yonghuEntity.setYonghuDelete(1);//逻辑删除字段
|
||||
// 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("yonghu_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("yonghu_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("yonghu_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){
|
||||
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.getYonghuDelete() != 1)
|
||||
return R.error("账户已被删除");
|
||||
// // 获取监听器中的字典表
|
||||
// ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
|
||||
// Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
|
||||
// Map<Integer, String> role_types = dictionaryMap.get("role_types");
|
||||
// role_types.get(.getRoleTypes());
|
||||
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){
|
||||
// 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("yonghu_delete", 1)
|
||||
;
|
||||
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
|
||||
if(yonghuEntity != null)
|
||||
return R.error("账户或者用户手机号或者用户身份证号已经被使用");
|
||||
yonghu.setNewMoney(0.0);
|
||||
yonghu.setYonghuDelete(1);
|
||||
yonghu.setCreateTime(new Date());
|
||||
yonghuService.insert(yonghu);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
@GetMapping(value = "/resetPassword")
|
||||
public R resetPassword(Integer id){
|
||||
YonghuEntity yonghu = new YonghuEntity();
|
||||
yonghu.setPassword("123456");
|
||||
yonghu.setId(id);
|
||||
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");
|
||||
boolean b = yonghuService.updateById(yonghu);
|
||||
if(!b){
|
||||
return R.error();
|
||||
}
|
||||
}else{
|
||||
return R.error("账号不存在");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户的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,"查不到数据");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退出
|
||||
*/
|
||||
@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));
|
||||
|
||||
// 没有指定排序字段就默认id倒序
|
||||
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
|
||||
params.put("orderBy","id");
|
||||
}
|
||||
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") Long 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("yonghu_delete", 1)
|
||||
;
|
||||
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
||||
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
|
||||
if(yonghuEntity==null){
|
||||
yonghu.setYonghuDelete(1);
|
||||
yonghu.setCreateTime(new Date());
|
||||
yonghu.setPassword("123456");
|
||||
yonghuService.insert(yonghu);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.dao;
|
||||
|
||||
import com.entity.ChatEntity;
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.entity.view.ChatView;
|
||||
|
||||
/**
|
||||
* 在线咨询 Dao 接口
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
public interface ChatDao extends BaseMapper<ChatEntity> {
|
||||
|
||||
List<ChatView> selectListView(Pagination page,@Param("params")Map<String,Object> params);
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
|
||||
package com.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import com.entity.ConfigEntity;
|
||||
|
||||
/**
|
||||
* 配置
|
||||
*/
|
||||
public interface ConfigDao extends BaseMapper<ConfigEntity> {
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.dao;
|
||||
|
||||
import com.entity.DictionaryEntity;
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.entity.view.DictionaryView;
|
||||
|
||||
/**
|
||||
* 字典表 Dao 接口
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
public interface DictionaryDao extends BaseMapper<DictionaryEntity> {
|
||||
|
||||
List<DictionaryView> selectListView(Pagination page,@Param("params")Map<String,Object> params);
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.dao;
|
||||
|
||||
import com.entity.GuahaoEntity;
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.entity.view.GuahaoView;
|
||||
|
||||
/**
|
||||
* 挂号 Dao 接口
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
public interface GuahaoDao extends BaseMapper<GuahaoEntity> {
|
||||
|
||||
List<GuahaoView> selectListView(Pagination page,@Param("params")Map<String,Object> params);
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.dao;
|
||||
|
||||
import com.entity.JiankangjiaoyuEntity;
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.entity.view.JiankangjiaoyuView;
|
||||
|
||||
/**
|
||||
* 健康教育 Dao 接口
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
public interface JiankangjiaoyuDao extends BaseMapper<JiankangjiaoyuEntity> {
|
||||
|
||||
List<JiankangjiaoyuView> selectListView(Pagination page,@Param("params")Map<String,Object> params);
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.dao;
|
||||
|
||||
import com.entity.NewsEntity;
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.entity.view.NewsView;
|
||||
|
||||
/**
|
||||
* 公告信息 Dao 接口
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
public interface NewsDao extends BaseMapper<NewsEntity> {
|
||||
|
||||
List<NewsView> selectListView(Pagination page,@Param("params")Map<String,Object> params);
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
|
||||
package com.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.mapper.Wrapper;
|
||||
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
|
||||
import com.entity.TokenEntity;
|
||||
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
public interface TokenDao extends BaseMapper<TokenEntity> {
|
||||
|
||||
List<TokenEntity> selectListView(@Param("ew") Wrapper<TokenEntity> wrapper);
|
||||
|
||||
List<TokenEntity> selectListView(Pagination page,@Param("ew") Wrapper<TokenEntity> wrapper);
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
|
||||
package com.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.mapper.Wrapper;
|
||||
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
|
||||
import com.entity.UsersEntity;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
public interface UsersDao extends BaseMapper<UsersEntity> {
|
||||
|
||||
List<UsersEntity> selectListView(@Param("ew") Wrapper<UsersEntity> wrapper);
|
||||
|
||||
List<UsersEntity> selectListView(Pagination page, @Param("ew") Wrapper<UsersEntity> wrapper);
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.dao;
|
||||
|
||||
import com.entity.YishengEntity;
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.entity.view.YishengView;
|
||||
|
||||
/**
|
||||
* 医生 Dao 接口
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
public interface YishengDao extends BaseMapper<YishengEntity> {
|
||||
|
||||
List<YishengView> selectListView(Pagination page,@Param("params")Map<String,Object> params);
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.dao;
|
||||
|
||||
import com.entity.YonghuEntity;
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.entity.view.YonghuView;
|
||||
|
||||
/**
|
||||
* 用户 Dao 接口
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
public interface YonghuDao extends BaseMapper<YonghuEntity> {
|
||||
|
||||
List<YonghuView> selectListView(Pagination page,@Param("params")Map<String,Object> params);
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
|
||||
package com.entity;
|
||||
|
||||
/**
|
||||
* 自定义异常
|
||||
*/
|
||||
public class EIException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String msg;
|
||||
private int code = 500;
|
||||
|
||||
public EIException(String msg) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public EIException(String msg, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public EIException(String msg, int code) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public EIException(String msg, int code, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
package com.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotations.TableId;
|
||||
import com.baomidou.mybatisplus.annotations.TableName;
|
||||
import com.baomidou.mybatisplus.enums.IdType;
|
||||
|
||||
/**
|
||||
* token表
|
||||
*/
|
||||
@TableName("token")
|
||||
public class TokenEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer userid;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tablename;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
private String role;
|
||||
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private Date expiratedtime;
|
||||
|
||||
/**
|
||||
* 新增时间
|
||||
*/
|
||||
private Date addtime;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(Integer userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public String getTablename() {
|
||||
return tablename;
|
||||
}
|
||||
|
||||
public void setTablename(String tablename) {
|
||||
this.tablename = tablename;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public Date getExpiratedtime() {
|
||||
return expiratedtime;
|
||||
}
|
||||
|
||||
public void setExpiratedtime(Date expiratedtime) {
|
||||
this.expiratedtime = expiratedtime;
|
||||
}
|
||||
|
||||
public Date getAddtime() {
|
||||
return addtime;
|
||||
}
|
||||
|
||||
public void setAddtime(Date addtime) {
|
||||
this.addtime = addtime;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public TokenEntity(Integer userid, String username, String tablename,String role, String token, Date expiratedtime) {
|
||||
super();
|
||||
this.userid = userid;
|
||||
this.username = username;
|
||||
this.tablename = tablename;
|
||||
this.role = role;
|
||||
this.token = token;
|
||||
this.expiratedtime = expiratedtime;
|
||||
}
|
||||
|
||||
public TokenEntity() {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotations.TableId;
|
||||
import com.baomidou.mybatisplus.annotations.TableName;
|
||||
import com.baomidou.mybatisplus.enums.IdType;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
@TableName("users")
|
||||
public class UsersEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private String role;
|
||||
|
||||
private Date addtime;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public Date getAddtime() {
|
||||
return addtime;
|
||||
}
|
||||
|
||||
public void setAddtime(Date addtime) {
|
||||
this.addtime = addtime;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|