Commit 59271442 authored by Administrator's avatar Administrator

添加查询主线API

parent c0495ad3
......@@ -2,6 +2,7 @@ package com.yxproject.start.api;
import com.yxproject.start.entity.SysPermission;
import com.yxproject.start.entity.UserInfo;
import com.yxproject.start.service.ProductionTaskListService;
import com.yxproject.start.service.SysPermissionService;
import com.yxproject.start.service.UserInfoService;
import com.yxproject.start.service.impl.UserInfoServiceImpl;
......@@ -35,6 +36,10 @@ public class UserInfoApi {
@Autowired
private SysPermissionService sysPermissionService;
@Autowired
private ProductionTaskListService productionTaskListService;
// @RequestMapping("login")
// @Produces(MediaType.APPLICATION_JSON)
// public Map<String, Object> submitLogin(@QueryParam("username") String username, @QueryParam("password") String password) {
......@@ -134,5 +139,15 @@ public class UserInfoApi {
// return i+"userInfoAdd";
// }
/**
* 查询任务单;
* @return
*/
@RequestMapping("/getProductionTaskListByID")
@RequiresPermissions("userInfo.del")//权限管理;
public String getProductionTaskListByID(@QueryParam("id") String id){
return productionTaskListService.findProductionTaskListEntityByID(id).toString();
}
}
package com.yxproject.start.config;
import com.yxproject.start.entity.ProductionTaskListEntity;
import com.yxproject.start.entity.SysPermission;
import com.yxproject.start.entity.SysRole;
import com.yxproject.start.entity.UserInfo;
import com.yxproject.start.service.ProductionTaskListService;
import com.yxproject.start.service.UserInfoService;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
......@@ -22,6 +24,10 @@ public class MyShiroRealm extends AuthorizingRealm {
@Autowired
private UserInfoService userInfoService;
@Autowired
private ProductionTaskListService productionTaskListService;
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
System.out.println(principals.getPrimaryPrincipal());
......@@ -65,4 +71,8 @@ public class MyShiroRealm extends AuthorizingRealm {
return authenticationInfo;
}
public ProductionTaskListEntity getProductionTaskListByID(String ID){
return productionTaskListService.findProductionTaskListEntityByID(ID);
}
}
\ No newline at end of file
package com.yxproject.start.config;
import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.yxproject.start.utils.DatabaseType;
import com.yxproject.start.utils.DynamicDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
......@@ -109,4 +122,74 @@ public class ShiroConfig {
public ShiroDialect shiroDialect(){
return new ShiroDialect();
}
// @Autowired
// private Environment env;
//
// /**
// * 创建数据源(数据源的名称:方法名可以取为XXXDataSource(),XXX为数据库名称,该名称也就是数据源的名称)
// */
// @Bean
// public DataSource prodDataSource() throws Exception {
// Properties props = new Properties();
// props.put("driverClassName", env.getProperty("jdbc.driverClassName"));
// props.put("url", env.getProperty("jdbc.url"));
// props.put("username", env.getProperty("jdbc.username"));
// props.put("password", env.getProperty("jdbc.password"));
// return DruidDataSourceFactory.createDataSource(props);
// }
//
// @Bean
// public DataSource accuDataSource() throws Exception {
// Properties props = new Properties();
// props.put("driverClassName", env.getProperty("jdbc2.driverClassName"));
// props.put("url", env.getProperty("jdbc2.url"));
// props.put("username", env.getProperty("jdbc2.username"));
// props.put("password", env.getProperty("jdbc2.password"));
// return DruidDataSourceFactory.createDataSource(props);
// }
//
// /**
// * @Primary 该注解表示在同一个接口有多个实现类可以注入的时候,默认选择哪一个,而不是让@autowire注解报错
// * @Qualifier 根据名称进行注入,通常是在具有相同的多个类型的实例的一个注入(例如有多个DataSource类型的实例)
// */
// @Bean
// @Primary
// public DynamicDataSource dataSource(@Qualifier("prodDataSource") DataSource myTestDbDataSource,
// @Qualifier("accuDataSource") DataSource myTestDb2DataSource) {
// Map<Object, Object> targetDataSources = new HashMap<>();
// targetDataSources.put(DatabaseType.mytestdb, myTestDbDataSource);
// targetDataSources.put(DatabaseType.mytestdb2, myTestDb2DataSource);
//
// DynamicDataSource dataSource = new DynamicDataSource();
// dataSource.setTargetDataSources(targetDataSources);// 该方法是AbstractRoutingDataSource的方法
// dataSource.setDefaultTargetDataSource(myTestDbDataSource);// 默认的datasource设置为myTestDbDataSource
//
// return dataSource;
// }
//
// /**
// * 根据数据源创建SqlSessionFactory
// */
// @Bean
// public SqlSessionFactory sqlSessionFactory(DynamicDataSource ds) throws Exception {
// SqlSessionFactoryBean fb = new SqlSessionFactoryBean();
// fb.setDataSource(ds);// 指定数据源(这个必须有,否则报错)
// // 下边两句仅仅用于*.xml文件,如果整个持久层操作不需要使用到xml文件的话(只用注解就可以搞定),则不加
// fb.setTypeAliasesPackage(env.getProperty("mybatis.typeAliasesPackage"));// 指定基包
// fb.setMapperLocations(
// new PathMatchingResourcePatternResolver().getResources(env.getProperty("mybatis.mapperLocations")));//
//
// return fb.getObject();
// }
//
// /**
// * 配置事务管理器
// */
// @Bean
// public DataSourceTransactionManager transactionManager(DynamicDataSource dataSource) throws Exception {
// return new DataSourceTransactionManager(dataSource);
// }
}
\ No newline at end of file
package com.yxproject.start.entity;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "GROUPINFO", schema = "DAHAI", catalog = "")
public class GroupinfoEntity {
private String groupid;
private String groupno;
private Long grouptype;
private Long vaildCount;
private Long invalidCount;
@Id
@Column(name = "GROUPID", nullable = false, length = 20)
public String getGroupid() {
return groupid;
}
public void setGroupid(String groupid) {
this.groupid = groupid;
}
@Basic
@Column(name = "GROUPNO", nullable = true, length = 20)
public String getGroupno() {
return groupno;
}
public void setGroupno(String groupno) {
this.groupno = groupno;
}
@Basic
@Column(name = "GROUPTYPE", nullable = true, precision = 0)
public Long getGrouptype() {
return grouptype;
}
public void setGrouptype(Long grouptype) {
this.grouptype = grouptype;
}
@Basic
@Column(name = "VAILD_COUNT", nullable = true, precision = 0)
public Long getVaildCount() {
return vaildCount;
}
public void setVaildCount(Long vaildCount) {
this.vaildCount = vaildCount;
}
@Basic
@Column(name = "INVALID_COUNT", nullable = true, precision = 0)
public Long getInvalidCount() {
return invalidCount;
}
public void setInvalidCount(Long invalidCount) {
this.invalidCount = invalidCount;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GroupinfoEntity that = (GroupinfoEntity) o;
return Objects.equals(groupid, that.groupid) &&
Objects.equals(groupno, that.groupno) &&
Objects.equals(grouptype, that.grouptype) &&
Objects.equals(vaildCount, that.vaildCount) &&
Objects.equals(invalidCount, that.invalidCount);
}
@Override
public int hashCode() {
return Objects.hash(groupid, groupno, grouptype, vaildCount, invalidCount);
}
}
package com.yxproject.start.entity;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "PRODUCTION_TASK_LIST", schema = "DAHAI", catalog = "")
public class ProductionTaskListEntity {
private String productionTaskListId;
private long makeType;
private Long oldMakeType;
private String workshop;
private String submitDate;
private String handoutDate;
private Long isPrint;
private String downloadDate;
private String printOut;
private String permanentPositionDate;
private String rollOutWorkshopDate;
private String qualityinspectionName;
private String qualityinspectionDate;
private String exceptionInformation;
private String outboundDate;
private String putinstorageDate;
@Id
@Column(name = "PRODUCTION_TASK_LIST_ID", nullable = false, length = 20)
public String getProductionTaskListId() {
return productionTaskListId;
}
public void setProductionTaskListId(String productionTaskListId) {
this.productionTaskListId = productionTaskListId;
}
@Basic
@Column(name = "MAKE_TYPE", nullable = false, precision = 0)
public long getMakeType() {
return makeType;
}
public void setMakeType(long makeType) {
this.makeType = makeType;
}
@Basic
@Column(name = "OLD_MAKE_TYPE", nullable = true, precision = 0)
public Long getOldMakeType() {
return oldMakeType;
}
public void setOldMakeType(Long oldMakeType) {
this.oldMakeType = oldMakeType;
}
@Basic
@Column(name = "WORKSHOP", nullable = true, length = 2)
public String getWorkshop() {
return workshop;
}
public void setWorkshop(String workshop) {
this.workshop = workshop;
}
@Basic
@Column(name = "SUBMIT_DATE", nullable = true, length = 8)
public String getSubmitDate() {
return submitDate;
}
public void setSubmitDate(String submitDate) {
this.submitDate = submitDate;
}
@Basic
@Column(name = "HANDOUT_DATE", nullable = true, length = 8)
public String getHandoutDate() {
return handoutDate;
}
public void setHandoutDate(String handoutDate) {
this.handoutDate = handoutDate;
}
@Basic
@Column(name = "IS_PRINT", nullable = true, precision = 0)
public Long getIsPrint() {
return isPrint;
}
public void setIsPrint(Long isPrint) {
this.isPrint = isPrint;
}
@Basic
@Column(name = "DOWNLOAD_DATE", nullable = true, length = 8)
public String getDownloadDate() {
return downloadDate;
}
public void setDownloadDate(String downloadDate) {
this.downloadDate = downloadDate;
}
@Basic
@Column(name = "PRINT_OUT", nullable = true, length = 8)
public String getPrintOut() {
return printOut;
}
public void setPrintOut(String printOut) {
this.printOut = printOut;
}
@Basic
@Column(name = "PERMANENT_POSITION_DATE", nullable = true, length = 8)
public String getPermanentPositionDate() {
return permanentPositionDate;
}
public void setPermanentPositionDate(String permanentPositionDate) {
this.permanentPositionDate = permanentPositionDate;
}
@Basic
@Column(name = "ROLL_OUT_WORKSHOP_DATE", nullable = true, length = 8)
public String getRollOutWorkshopDate() {
return rollOutWorkshopDate;
}
public void setRollOutWorkshopDate(String rollOutWorkshopDate) {
this.rollOutWorkshopDate = rollOutWorkshopDate;
}
@Basic
@Column(name = "QUALITYINSPECTION_NAME", nullable = true, length = 20)
public String getQualityinspectionName() {
return qualityinspectionName;
}
public void setQualityinspectionName(String qualityinspectionName) {
this.qualityinspectionName = qualityinspectionName;
}
@Basic
@Column(name = "QUALITYINSPECTION_DATE", nullable = true, length = 8)
public String getQualityinspectionDate() {
return qualityinspectionDate;
}
public void setQualityinspectionDate(String qualityinspectionDate) {
this.qualityinspectionDate = qualityinspectionDate;
}
@Basic
@Column(name = "EXCEPTION_INFORMATION", nullable = true, length = 120)
public String getExceptionInformation() {
return exceptionInformation;
}
public void setExceptionInformation(String exceptionInformation) {
this.exceptionInformation = exceptionInformation;
}
@Basic
@Column(name = "OUTBOUND_DATE", nullable = true, length = 8)
public String getOutboundDate() {
return outboundDate;
}
public void setOutboundDate(String outboundDate) {
this.outboundDate = outboundDate;
}
@Basic
@Column(name = "PUTINSTORAGE_DATE", nullable = true, length = 8)
public String getPutinstorageDate() {
return putinstorageDate;
}
public void setPutinstorageDate(String putinstorageDate) {
this.putinstorageDate = putinstorageDate;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ProductionTaskListEntity that = (ProductionTaskListEntity) o;
return makeType == that.makeType &&
Objects.equals(productionTaskListId, that.productionTaskListId) &&
Objects.equals(oldMakeType, that.oldMakeType) &&
Objects.equals(workshop, that.workshop) &&
Objects.equals(submitDate, that.submitDate) &&
Objects.equals(handoutDate, that.handoutDate) &&
Objects.equals(isPrint, that.isPrint) &&
Objects.equals(downloadDate, that.downloadDate) &&
Objects.equals(printOut, that.printOut) &&
Objects.equals(permanentPositionDate, that.permanentPositionDate) &&
Objects.equals(rollOutWorkshopDate, that.rollOutWorkshopDate) &&
Objects.equals(qualityinspectionName, that.qualityinspectionName) &&
Objects.equals(qualityinspectionDate, that.qualityinspectionDate) &&
Objects.equals(exceptionInformation, that.exceptionInformation) &&
Objects.equals(outboundDate, that.outboundDate) &&
Objects.equals(putinstorageDate, that.putinstorageDate);
}
@Override
public int hashCode() {
return Objects.hash(productionTaskListId, makeType, oldMakeType, workshop, submitDate, handoutDate, isPrint, downloadDate, printOut, permanentPositionDate, rollOutWorkshopDate, qualityinspectionName, qualityinspectionDate, exceptionInformation, outboundDate, putinstorageDate);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
version="2.0">
<entity class="com.yxproject.start.entity.ProductionTaskListEntity">
<table name="PRODUCTION_TASK_LIST" schema="DAHAI" catalog=""/>
<attributes>
<id name="productionTaskListId">
<column name="PRODUCTION_TASK_LIST_ID" length="20"/>
</id>
<basic name="makeType">
<column name="MAKE_TYPE" precision="2147483646"/>
</basic>
<basic name="oldMakeType">
<column name="OLD_MAKE_TYPE" nullable="false" precision="2147483646"/>
</basic>
<basic name="workshop">
<column name="WORKSHOP" nullable="false" length="2"/>
</basic>
<basic name="submitDate">
<column name="SUBMIT_DATE" nullable="false" length="8"/>
</basic>
<basic name="handoutDate">
<column name="HANDOUT_DATE" nullable="false" length="8"/>
</basic>
<basic name="isPrint">
<column name="IS_PRINT" nullable="false" precision="2147483646"/>
</basic>
<basic name="downloadDate">
<column name="DOWNLOAD_DATE" nullable="false" length="8"/>
</basic>
<basic name="printOut">
<column name="PRINT_OUT" nullable="false" length="8"/>
</basic>
<basic name="permanentPositionDate">
<column name="PERMANENT_POSITION_DATE" nullable="false" length="8"/>
</basic>
<basic name="rollOutWorkshopDate">
<column name="ROLL_OUT_WORKSHOP_DATE" nullable="false" length="8"/>
</basic>
<basic name="qualityinspectionName">
<column name="QUALITYINSPECTION_NAME" nullable="false" length="20"/>
</basic>
<basic name="qualityinspectionDate">
<column name="QUALITYINSPECTION_DATE" nullable="false" length="8"/>
</basic>
<basic name="exceptionInformation">
<column name="EXCEPTION_INFORMATION" nullable="false" length="120"/>
</basic>
<basic name="outboundDate">
<column name="OUTBOUND_DATE" nullable="false" length="8"/>
</basic>
<basic name="putinstorageDate">
<column name="PUTINSTORAGE_DATE" nullable="false" length="8"/>
</basic>
</attributes>
</entity>
</entity-mappings>
package com.yxproject.start.mapper;
import com.yxproject.start.entity.ProductionTaskListEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* @author Administrator
*/
@Mapper
@Repository
public interface ProductionTaskListMapper {
ProductionTaskListEntity findProductionTaskListEntity(String productionTaskListId);
}
package com.yxproject.start.mapper2;
import com.yxproject.start.entity.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
/**
* @author Administrator
*/
@Mapper
@Repository
public interface UserInfoMapper2 extends CrudRepository<UserInfo,Long> {
public UserInfo findUserByUsername(String username);
// public int addUserInfo(UserInfo userInfo);
// public int delUserInfo(int userInfoID);
// public int updateUserInfo(UserInfo userInfo);
}
package com.yxproject.start.service;
import com.yxproject.start.entity.ProductionTaskListEntity;
public interface ProductionTaskListService {
public ProductionTaskListEntity findProductionTaskListEntityByID(String productionTaskListId);
}
package com.yxproject.start.service.impl;
import com.yxproject.start.entity.ProductionTaskListEntity;
import com.yxproject.start.mapper.ProductionTaskListMapper;
import com.yxproject.start.service.ProductionTaskListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author Administrator
*/
@Service
public class ProductionTaskListServiceImpl implements ProductionTaskListService {
@Autowired
private ProductionTaskListMapper productionTaskListMapper;
@Override
public ProductionTaskListEntity findProductionTaskListEntityByID(String productionTaskListId) {
return productionTaskListMapper.findProductionTaskListEntity(productionTaskListId);
}
}
package com.yxproject.start.utils;
public class DatabaseContextHolder {
private static final ThreadLocal<DatabaseType> contextHolder = new ThreadLocal<>();
public static void setDatabaseType(DatabaseType type){
contextHolder.set(type);
}
public static DatabaseType getDatabaseType(){
return contextHolder.get();
}
}
package com.yxproject.start.utils;
/**
* 列出所有的数据源key(常用数据库名称来命名)
*/
public enum DatabaseType {
mytestdb,mytestdb2
}
package com.yxproject.start.utils;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
public class DynamicDataSource extends AbstractRoutingDataSource {
@Override
protected Object determineCurrentLookupKey() {
return DatabaseContextHolder.getDatabaseType();
}
}
package com.yxproject.start.utils;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;
public class encryptUtil {
private static final String ALGORITHM_NAME = "MD5";
private static final Integer HASH_ITERATIONS = 1024;
/**
* Md5加盐加密
* 加盐加密的策略非常多,根据实际业务来
*/
public static String entryptPassword(String password,String salt) {
// String salt = UUID.randomUUID().toString();
Object md5Password = new SimpleHash(ALGORITHM_NAME, password, ByteSource.Util.bytes(salt), HASH_ITERATIONS);
return md5Password.toString();
}
}
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