Commit dc3c791e by Suvalue

数据查询接口临时提交

parent 381f7cd4
......@@ -2,8 +2,8 @@ package com.bsoft.api.common.aspect;
import com.bsoft.api.common.Constants;
import com.bsoft.api.common.exceptions.InvalidTokenException;
import com.bsoft.api.common.utils.StringUtil;
import com.bsoft.api.common.utils.TokenUtil;
import com.bsoft.common.utils.StringUtil;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
......
package com.bsoft.api.controller;
import com.bsoft.api.common.Result;
import com.bsoft.api.common.annotations.Token;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import springfox.documentation.annotations.ApiIgnore;
@Api(tags = "板块数值Api")
@RequestMapping("/blockValues")
public class BlockValuesController {
/**
* 根据pageId查询板块数值
* @param pageId 页面id
* @param disease 病组
* @param doctor 医生
* @param department 科室
* @param time 时间
* @return
* @throws Exception
*/
@GetMapping("getBlockValuesByPageID")
@Token
public Object getBlockValuesByPageID(String pageId,String disease,String doctor,String department,String time)throws Exception{
return null;
}
}
......@@ -2,6 +2,7 @@ package com.bsoft.api.controller;
import com.bsoft.api.common.Result;
import com.bsoft.api.service.LoginService;
import com.bsoft.common.utils.HttpUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -25,8 +26,9 @@ public class LoginController {
@ApiImplicitParams({
@ApiImplicitParam(value = "登录名", name="loginName", required=true,paramType="query"),
@ApiImplicitParam(value = "密码", name="password", required = true,paramType="query")})
public Object login(String loginName, String password){
LoginService.LoginInfo loginInfo = loginServiceImpl.login(loginName, password);
public Object login(String loginName, String password,HttpServletRequest request){
String ip = HttpUtil.getIP(request);
LoginService.LoginInfo loginInfo = loginServiceImpl.login(loginName, password,ip);
return Result.success(loginInfo);
}
......
......@@ -17,7 +17,6 @@ import springfox.documentation.annotations.ApiIgnore;
@Api(tags = "用户API",produces="produces",consumes="consumes",protocols="protocols")
@RequestMapping("/user")
@RestController
public class UserController {
@Autowired
private SysUserRoleRsService sysUserRoleRsService;
......@@ -43,13 +42,13 @@ public class UserController {
}
/**
* 根据用户id查询用户角色
* 根据用户id查询菜单
* @param userId 用户id
* @return
*/
@GetMapping("getMenu")
// @Token
public Object getMenuByUser(Long userId)throws Exception{
@Token
public Object getMenuByUser(@ApiIgnore Long userId)throws Exception{
return Result.success(sysMenuService.getMenu(userId));
}
}
package com.bsoft.api.mapper;
import com.bsoft.api.model.DicDim;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DicDimMapper {
......@@ -36,6 +38,8 @@ public interface DicDimMapper {
*/
List<DicDim> selectAll();
List<DicDim> selectByPageid(@Param("pageID") String pageID);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table LL.DIC_DIM
......
package com.bsoft.api.mapper;
import com.bsoft.api.model.SerPageBlockRs;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface SerPageBlockRsMapper {
......@@ -43,4 +45,6 @@ public interface SerPageBlockRsMapper {
* @mbggenerated Tue Oct 22 14:44:12 CST 2019
*/
int updateByPrimaryKey(SerPageBlockRs record);
List<SerPageBlockRs> selectByPageId(@Param("pageID") String pageID);
}
\ No newline at end of file
package com.bsoft.api.service;
public class BlockValuesService {
}
package com.bsoft.api.service.Impl;
import com.bsoft.api.mapper.DicDimMapper;
import com.bsoft.api.mapper.SerPageBlockRsMapper;
import com.bsoft.api.model.DicDim;
import com.bsoft.api.model.SerPageBlockRs;
import com.bsoft.api.service.BlockValuesService;
import org.apache.ibatis.binding.MapperMethod;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Map;
public class BlockValuesServiceImpl extends BlockValuesService {
@Autowired
private SerPageBlockRsMapper serPageBlockRsMapper;
@Autowired
private DicDimMapper dicDimMapper;
private String disease = null;
private String doctor = null;
private String department = null;
private String time = null;
public List<Map<String,Object>> getBlockValuesByPageID(String pageId,String disease,String doctor,String department,String time){
//根据pageId查询所有板块
List<SerPageBlockRs> list =serPageBlockRsMapper.selectByPageId(pageId);
//根据pageId查询所有维度
List<DicDim> dimList = dicDimMapper.selectByPageid(pageId);
//循环获取需要添加的维度查询条件
for (DicDim data : dimList) {
if(data.getDimField().equals("disease")){
this.disease=data.getDimField();
}
if(data.getDimField().equals("doctor")){
this.doctor=data.getDimField();
}
if(data.getDimField().equals("department")){
this.department=data.getDimField();
}
if(data.getDimField().equals("time")){
this.time=data.getDimField();
}
}
//循环获取数据
for (SerPageBlockRs data : list) {
//获取表名
String tableName = "VAL_BLOCK_VALUES_"+data.getBlockId();
String selectSql = "select * from"+tableName;
String whereSql = "where 1=1";
//添加查询条件
if(disease!=null&&this.disease!=null){
whereSql+=String.format(" and disease='{0}'",disease);
}
if(doctor!=null&&this.doctor!=null){
whereSql+=String.format(" and doctor='{0}'",doctor);
}
if(department!=null&&this.department!=null){
whereSql+=String.format(" and department='{0}'",department);
}
if(time!=null&&this.time!=null){
whereSql+=String.format(" and time='{0}'",time);
}
}
return null;
}
}
package com.bsoft.api.service.Impl;
import com.bsoft.api.common.utils.TokenUtil;
import com.bsoft.api.mapper.SysUserMapper;
import com.bsoft.api.model.SysUser;
import com.bsoft.api.service.LoginService;
import com.bsoft.api.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.lang.annotation.Retention;
import java.util.Date;
@Service
public class LoginServiceImpl implements LoginService {
@Autowired
private UserService userServiceImpl;
@Resource
private SysUserMapper sysUserMapper;
@Override
public LoginInfo login(String logName, String password) {
public LoginInfo login(String logName, String password,String ip) {
LoginInfo loginInfo = new LoginInfo();
......@@ -24,6 +33,12 @@ public class LoginServiceImpl implements LoginService {
user.setPassword(null);
loginInfo.setToken(token);
loginInfo.setUser(user);
//修改ip以及最后登录时间
SysUser sysUser = loginInfo.getUser();
sysUser.setLastIp(ip);
sysUser.setLastTime(new Date());
sysUserMapper.updateByPrimaryKey(sysUser);
}
return loginInfo;
}
......
......@@ -5,7 +5,7 @@ import com.bsoft.api.model.SysUser;
public interface LoginService {
LoginInfo login(String loginName, String password);
LoginInfo login(String loginName, String password,String ip);
String refreshToken(String oldToken);
......
......@@ -70,4 +70,8 @@
select ID, CREATE_DATE, CREATE_USERID, STATE, DIM_NAME, DIM_FIELD
from LL.DIC_DIM
</select>
<select id="selectByPageid" resultMap="BaseResultMap">
select dd.* from SER_PAGE_DIM_RS spdr,DIC_DIM dd
where spdr.DIM_ID=dd.ID and spdr.PAGE_ID=#{pageID,jdbcType=DECIMAL}
</select>
</mapper>
\ No newline at end of file
......@@ -70,4 +70,9 @@
select ID, CREATE_DATE, CREATE_USERID, STATE, BLOCK_ID, PAGE_ID
from LL.SER_PAGE_BLOCK_RS
</select>
<select id="selectByPageId" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, STATE, BLOCK_ID, PAGE_ID
from LL.SER_PAGE_BLOCK_RS
where PAGE_ID=#{pageId,jdbcType=DECIMAL}
</select>
</mapper>
\ No newline at end of file
......@@ -43,5 +43,10 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.0-b07</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.bsoft.common.utils;
import javax.servlet.http.HttpServletRequest;
public class HttpUtil {
/**
* 获取IP
* @param request
* @return
*/
public static String getIP(HttpServletRequest request){
String ip = request.getRemoteAddr();
String headerIP = request.getHeader("x-real-ip");
if(headerIP == null || "".equals(headerIP) || "null".equals(headerIP)){
headerIP = request.getHeader("x-forwarded-for");
}
if(headerIP !=null && !"".equals(headerIP) && !"null".equals(headerIP)){
ip = headerIP;
}
return ip;
}
}
package com.bsoft.api.common.utils;
package com.bsoft.common.utils;
public class StringUtil {
public static boolean isNullOrEmpty(String str){
......
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.mybatis.generator:mybatis-generator-core:1.3.5" level="project" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.1.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.26" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.11.2" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.26" level="project" />
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.8" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.8" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.8" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.19" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.19" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.19" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.16.Final" level="project" />
<orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.4.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-configuration-processor:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjrt:1.9.4" level="project" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment