/target/ | |||||
!.mvn/wrapper/maven-wrapper.jar | |||||
### STS ### | |||||
.apt_generated | |||||
.classpath | |||||
.factorypath | |||||
.project | |||||
.settings | |||||
.springBeans | |||||
.sts4-cache | |||||
### IntelliJ IDEA ### | |||||
.idea | |||||
*.iws | |||||
*.iml | |||||
*.ipr | |||||
### NetBeans ### | |||||
/nbproject/private/ | |||||
/build/ | |||||
/nbbuild/ | |||||
/dist/ | |||||
/nbdist/ | |||||
/.nb-gradle/ |
/* | |||||
Navicat PGSQL Data Transfer | |||||
Source Server : 本地测试pos库 | |||||
Source Server Version : 90617 | |||||
Source Host : localhost:5432 | |||||
Source Database : pf | |||||
Source Schema : public | |||||
Target Server Type : PGSQL | |||||
Target Server Version : 90617 | |||||
File Encoding : 65001 | |||||
Date: 2020-04-25 23:34:46 | |||||
*/ | |||||
-- ---------------------------- | |||||
-- Table structure for sys_bag | |||||
-- ---------------------------- | |||||
DROP TABLE IF EXISTS "public"."sys_bag"; | |||||
CREATE TABLE "public"."sys_bag" ( | |||||
"id" int2 DEFAULT nextval('sys_id_seq'::regclass) NOT NULL, | |||||
"type" varchar(255) COLLATE "default", | |||||
"texture" varchar(255) COLLATE "default", | |||||
"gsprice" varchar(128) COLLATE "default", | |||||
"bagprice" varchar(128) COLLATE "default", | |||||
"gs" varchar(255) COLLATE "default", | |||||
"kc" varchar(255) COLLATE "default", | |||||
"kcyj" varchar(255) COLLATE "default", | |||||
"startdate" date, | |||||
"enddate" date | |||||
) | |||||
WITH (OIDS=FALSE) | |||||
; | |||||
-- ---------------------------- | |||||
-- Records of sys_bag | |||||
-- ---------------------------- | |||||
INSERT INTO "public"."sys_bag" VALUES ('1', 'dd', '硬塑', '700', '670', 'CA', '77', '5', '2020-05-11', '2020-05-03'); | |||||
INSERT INTO "public"."sys_bag" VALUES ('2', '美的', '硬塑', '40.58', '30.33', 'CZ', '70', '15', '2019-12-30', '2020-04-28'); | |||||
INSERT INTO "public"."sys_bag" VALUES ('3', '1', '1', '1', '1', 'MU', '1', '1', '2020-03-30', '2020-04-30'); | |||||
INSERT INTO "public"."sys_bag" VALUES ('5', '66', '66', '22', '2', 'ZA', '2', '2', '2020-03-30', '2020-05-03'); | |||||
INSERT INTO "public"."sys_bag" VALUES ('6', '66', '66', '1', '5', 'CA', '5', '5', '2020-03-30', '2020-05-02'); | |||||
INSERT INTO "public"."sys_bag" VALUES ('7', '99', '99', '3', '3', 'CA', '3', '1', '2020-03-30', '2020-05-01'); | |||||
INSERT INTO "public"."sys_bag" VALUES ('8', '11', '66', '88', '7', 'CA', '8', '8', '2020-03-30', '2020-03-29'); | |||||
INSERT INTO "public"."sys_bag" VALUES ('9', '66', '1', '2', '3', '5', '5', '5', '2020-03-30', '2020-04-16'); | |||||
INSERT INTO "public"."sys_bag" VALUES ('10', '66', '99', '55', '5', 'NH', '5', '5', '2020-03-30', '2020-04-30'); | |||||
INSERT INTO "public"."sys_bag" VALUES ('11', 'w', 'w', '4', '4', '4', '5', '5', '2020-03-30', '2020-04-30'); | |||||
INSERT INTO "public"."sys_bag" VALUES ('12', '皮', '软壳', '300', '200', ' CA', '50', '9', '2019-12-30', '2020-05-14'); | |||||
-- ---------------------------- | |||||
-- Alter Sequences Owned By | |||||
-- ---------------------------- | |||||
-- ---------------------------- | |||||
-- Primary Key structure for table sys_bag | |||||
-- ---------------------------- | |||||
ALTER TABLE "public"."sys_bag" ADD PRIMARY KEY ("id"); |
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
<modelVersion>4.0.0</modelVersion> | |||||
<groupId>com.2020test</groupId> | |||||
<artifactId>2020test</artifactId> | |||||
<version>1.0.59</version> | |||||
<packaging>jar</packaging> | |||||
<parent> | |||||
<groupId>org.springframework.boot</groupId> | |||||
<artifactId>spring-boot-starter-parent</artifactId> | |||||
<version>1.5.8.RELEASE</version> | |||||
</parent> | |||||
<name>2020test</name> | |||||
<url>http://maven.apache.org</url> | |||||
<properties> | |||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |||||
<weixin-java-mp.version>3.4.0</weixin-java-mp.version> | |||||
</properties> | |||||
<dependencies> | |||||
<dependency> | |||||
<groupId>com.google.code.gson</groupId> | |||||
<artifactId>gson</artifactId> | |||||
<version>2.6.1</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.springframework.boot</groupId> | |||||
<artifactId>spring-boot-starter-web</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.springframework.boot</groupId> | |||||
<artifactId>spring-boot-starter-thymeleaf</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.mybatis.spring.boot</groupId> | |||||
<artifactId>mybatis-spring-boot-starter</artifactId> | |||||
<version>1.3.1</version> | |||||
</dependency> | |||||
<!--postgresql --> | |||||
<!-- <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> | |||||
</dependency> --> | |||||
<dependency> | |||||
<groupId>org.postgresql</groupId> | |||||
<artifactId>postgresql</artifactId> | |||||
<scope>runtime</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>com.alibaba</groupId> | |||||
<artifactId>druid</artifactId> | |||||
<version>1.0.5</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>redis.clients</groupId> | |||||
<artifactId>jedis</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>com.alibaba</groupId> | |||||
<artifactId>fastjson</artifactId> | |||||
<version>1.2.38</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>commons-codec</groupId> | |||||
<artifactId>commons-codec</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.apache.commons</groupId> | |||||
<artifactId>commons-lang3</artifactId> | |||||
<version>3.6</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>commons-codec</groupId> | |||||
<artifactId>commons-codec</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.apache.commons</groupId> | |||||
<artifactId>commons-lang3</artifactId> | |||||
<version>3.6</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.springframework.boot</groupId> | |||||
<artifactId>spring-boot-starter-data-jpa</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.springframework.boot</groupId> | |||||
<artifactId>spring-boot-starter-validation</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>net.sf.json-lib</groupId> | |||||
<artifactId>json-lib</artifactId> | |||||
<version>2.4</version> | |||||
<classifier>jdk15</classifier> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>com.qiniu</groupId> | |||||
<artifactId>qiniu-java-sdk</artifactId> | |||||
<version>[7.2.0, 7.2.99]</version> | |||||
</dependency> | |||||
<!-- 处理Excel2003 --> | |||||
<!--<dependency> --> | |||||
<!--<groupId>org.apache.poi</groupId> --> | |||||
<!--<artifactId>poi</artifactId> --> | |||||
<!--<version>3.17</version> --> | |||||
<!--</dependency> --> | |||||
<!--<!– 处理Excel2007–> --> | |||||
<!--<dependency> --> | |||||
<!--<groupId>org.apache.poi</groupId> --> | |||||
<!--<artifactId>poi-ooxml</artifactId> --> | |||||
<!--<version>3.17</version> --> | |||||
<!--</dependency> --> | |||||
<dependency> | |||||
<groupId>org.apache.poi</groupId> | |||||
<artifactId>poi</artifactId> | |||||
<version>3.9</version> | |||||
</dependency> | |||||
<!-- 处理Excel2007 --> | |||||
<dependency> | |||||
<groupId>org.apache.poi</groupId> | |||||
<artifactId>poi-ooxml</artifactId> | |||||
<version>3.9</version> | |||||
</dependency> | |||||
<!-- shiro --> | |||||
<dependency> | |||||
<groupId>org.apache.shiro</groupId> | |||||
<artifactId>shiro-spring</artifactId> | |||||
<version>1.4.0</version> | |||||
</dependency> | |||||
<!-- http --> | |||||
<dependency> | |||||
<groupId>org.apache.httpcomponents</groupId> | |||||
<artifactId>httpclient</artifactId> | |||||
<version>4.5.3</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>net.sourceforge.nekohtml</groupId> | |||||
<artifactId>nekohtml</artifactId> | |||||
<version>1.9.22</version> | |||||
</dependency> | |||||
<!-- itext方式导出pdf --> | |||||
<dependency> | |||||
<groupId>com.lowagie</groupId> | |||||
<artifactId>itext</artifactId> | |||||
<version>4.2.2</version> | |||||
</dependency> | |||||
<!-- 发送短信 --> | |||||
<dependency> | |||||
<groupId>com.github.qcloudsms</groupId> | |||||
<artifactId>qcloudsms</artifactId> | |||||
<version>1.0.5</version> | |||||
</dependency> | |||||
<!--阿里云推送 --> | |||||
<dependency> | |||||
<groupId>com.aliyun.openservices</groupId> | |||||
<artifactId>ons-client</artifactId> | |||||
<version>1.8.0.Final</version> | |||||
</dependency> | |||||
<!-- https://mvnrepository.com/artifact/javax.mail/mail --> | |||||
<dependency> | |||||
<groupId>javax.mail</groupId> | |||||
<artifactId>mail</artifactId> | |||||
<version>1.4</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>com.googlecode.juniversalchardet</groupId> | |||||
<artifactId>juniversalchardet</artifactId> | |||||
<version>1.0.3</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>com.github.binarywang</groupId> | |||||
<artifactId>weixin-java-mp</artifactId> | |||||
<version>${weixin-java-mp.version}</version> | |||||
</dependency> | |||||
<!-- quartz 使用了该jar包PlatformTransactionManager类 --> | |||||
<dependency> | |||||
<groupId>org.springframework</groupId> | |||||
<artifactId>spring-tx</artifactId> | |||||
</dependency> | |||||
<!-- 该依赖里面有spring对schedule的支持 --> | |||||
<dependency> | |||||
<groupId>org.springframework</groupId> | |||||
<artifactId>spring-context-support</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.quartz-scheduler</groupId> | |||||
<artifactId>quartz</artifactId> | |||||
<version>2.2.1</version> | |||||
</dependency> | |||||
<!--wy 读取以.xls结尾的excel --> | |||||
<dependency> | |||||
<groupId>org.apache.poi</groupId> | |||||
<artifactId>poi</artifactId> | |||||
<version>3.11</version> | |||||
</dependency> | |||||
<!--wy h2 --> | |||||
<!-- <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> | |||||
<version>1.4.197</version> <scope>test</scope> </dependency> --> | |||||
</dependencies> | |||||
<build> | |||||
<plugins> | |||||
<plugin> | |||||
<groupId>org.springframework.boot</groupId> | |||||
<artifactId>spring-boot-maven-plugin</artifactId> | |||||
</plugin> | |||||
</plugins> | |||||
</build> | |||||
</project> |
Project PF10 |
package com.cbs.company; | |||||
import org.springframework.boot.SpringApplication; | |||||
import org.springframework.boot.autoconfigure.SpringBootApplication; | |||||
import org.springframework.boot.builder.SpringApplicationBuilder; | |||||
import org.springframework.boot.web.support.SpringBootServletInitializer; | |||||
@SpringBootApplication | |||||
public class MainApplication extends SpringBootServletInitializer { | |||||
public static void main(String[] args) { | |||||
SpringApplication.run(MainApplication.class, args); | |||||
} | |||||
@Override | |||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { | |||||
return builder.sources(MainApplication.class); | |||||
} | |||||
} |
package com.cbs.company.collectenum; | |||||
public enum TableEnum { | |||||
SHE_CBS_EVENT_SEARCH("she","she_cbs_event_search","沈阳机场"); | |||||
public String airportName;//键值 | |||||
public String value;//键值 | |||||
public String desc;//表名描述 | |||||
private TableEnum(String airportName,String value,String desc){ | |||||
this.airportName = airportName ; | |||||
this.value = value ; | |||||
this.desc = desc ; | |||||
} | |||||
public String getValue(){ | |||||
return value; | |||||
} | |||||
public String getairportName(){ | |||||
return airportName; | |||||
} | |||||
} |
package com.cbs.company.config; | |||||
import java.util.Set; | |||||
import org.apache.shiro.authc.AuthenticationException; | |||||
import org.apache.shiro.authc.AuthenticationInfo; | |||||
import org.apache.shiro.authc.AuthenticationToken; | |||||
import org.apache.shiro.authc.SimpleAuthenticationInfo; | |||||
import org.apache.shiro.authz.AuthorizationInfo; | |||||
import org.apache.shiro.authz.SimpleAuthorizationInfo; | |||||
import org.apache.shiro.crypto.hash.Hash; | |||||
import org.apache.shiro.crypto.hash.SimpleHash; | |||||
import org.apache.shiro.realm.AuthorizingRealm; | |||||
import org.apache.shiro.subject.PrincipalCollection; | |||||
import org.apache.shiro.util.SimpleByteSource; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import com.cbs.company.domain.UserDO; | |||||
import com.cbs.company.service.LoginService; | |||||
import com.cbs.company.service.MenuService; | |||||
public class MyShiroRealm extends AuthorizingRealm { | |||||
@Autowired | |||||
MenuService menuService; | |||||
@Autowired | |||||
LoginService loginService; | |||||
/*执行授权逻辑*/ | |||||
@Override | |||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { | |||||
System.out.println("权限配置-->MyShiroRealm.doGetAuthorizationInfo()"); | |||||
// SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo(); | |||||
// UserInfo userInfo = (UserInfo)principals.getPrimaryPrincipal(); | |||||
// for(SysRole role:userInfo.getRoleList()){ | |||||
// authorizationInfo.addRole(role.getRole()); | |||||
// for(SysPermission p:role.getPermissions()){ | |||||
// authorizationInfo.addStringPermission(p.getPermission()); | |||||
// } | |||||
// } | |||||
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo(); | |||||
UserDO userInfo = (UserDO)principals.getPrimaryPrincipal(); | |||||
Long userId = userInfo.getUserId(); | |||||
Set<String> perms = menuService.listPerms(userId); | |||||
authorizationInfo.setStringPermissions(perms); | |||||
return authorizationInfo; | |||||
} | |||||
/*主要是用来进行身份认证的,也就是说验证用户输入的账号和密码是否正确。*/ | |||||
// /*执行认证逻辑*/ | |||||
// @Override | |||||
// protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) | |||||
// throws AuthenticationException { | |||||
// System.out.println("MyShiroRealm.doGetAuthenticationInfo()"); | |||||
// //获取用户的输入的账号. | |||||
// String username = (String)token.getPrincipal(); | |||||
// System.out.println(token.getCredentials()); | |||||
// //通过username从数据库中查找 User对象,如果找到,没找到. | |||||
// //实际项目中,这里可以根据实际情况做缓存,如果不做,Shiro自己也是有时间间隔机制,2分钟内不会重复执行该方法 | |||||
// Login login = new Login(); | |||||
// login.setName(username); | |||||
// | |||||
// Login userInfo = null; | |||||
// try { | |||||
// userInfo = loginService.getLoginByName(login); | |||||
// } catch (Exception e) { | |||||
// e.printStackTrace(); | |||||
// } | |||||
// System.out.println("----->>userInfo="+userInfo); | |||||
// if(userInfo == null){ | |||||
// return null; | |||||
// } | |||||
// // ByteSource.Util.bytes(userInfo.getCredentialsSalt()),//salt=username+salt | |||||
// SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo( | |||||
// userInfo, //用户名 | |||||
// userInfo.getCode(), //密码 | |||||
// getName() //realm name | |||||
// ); | |||||
// return authenticationInfo; | |||||
// } | |||||
/*执行认证逻辑*/ | |||||
@Override | |||||
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) | |||||
throws AuthenticationException { | |||||
System.out.println("MyShiroRealm.doGetAuthenticationInfo()"); | |||||
//获取用户的输入的账号. | |||||
String username = (String)token.getPrincipal(); | |||||
System.out.println(token.getCredentials()); | |||||
//通过username从数据库中查找 User对象,如果找到,没找到. | |||||
//实际项目中,这里可以根据实际情况做缓存,如果不做,Shiro自己也是有时间间隔机制,2分钟内不会重复执行该方法 | |||||
//UserInfo userInfo = loginService.findByUsername(username); | |||||
UserDO userDo = loginService.getUserlist(username).get(0); | |||||
System.out.println("----->>userInfo="+userDo); | |||||
if(userDo == null){ | |||||
return null; | |||||
} | |||||
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo( | |||||
userDo, //用户名 | |||||
userDo.getPassword(), //密码 | |||||
getName() //realm name | |||||
); | |||||
// ByteSource.Util.bytes(userInfo.getCredentialsSalt()),//salt=username+salt | |||||
return authenticationInfo; | |||||
} | |||||
/* | |||||
** hash 算法测试 | |||||
*/ | |||||
public static void main(String[] args) { | |||||
Hash hash=new SimpleHash("MD5", new SimpleByteSource("1234"),new SimpleByteSource("test8d78869f470951332959580424d4bf4f"),2); | |||||
System.out.println(hash.toHex()); | |||||
} | |||||
} |
package com.cbs.company.config; | |||||
import org.springframework.boot.CommandLineRunner; | |||||
import org.springframework.core.annotation.Order; | |||||
import org.springframework.stereotype.Component; | |||||
import com.cbs.company.util.Base; | |||||
import java.io.IOException; | |||||
import java.io.InputStream; | |||||
import java.util.Properties; | |||||
@Component | |||||
@Order(value = 1) | |||||
public class MyStartupRunner implements CommandLineRunner{ | |||||
@Override | |||||
public void run(String... strings) throws Exception { | |||||
Properties properties = new Properties(); | |||||
InputStream in = MyStartupRunner.class.getResourceAsStream("/application.properties"); | |||||
try { | |||||
properties.load(in); | |||||
in.close(); | |||||
} catch (IOException e) { | |||||
// TODO Auto-generated catch block | |||||
e.printStackTrace(); | |||||
} | |||||
Base.version=properties.getProperty( "project.version"); | |||||
InputStream inJson = MyStartupRunner.class.getResourceAsStream("/static/data/pca-code.json"); | |||||
if(inJson==null){ | |||||
System.out.println("inJson null"); | |||||
}else{ | |||||
if(Base.parseAddressJson(inJson)){ | |||||
String s= Base.getAddressByCode("659003"); | |||||
System.out.println("inJson parse ok ["+s+"]"); | |||||
}else{ | |||||
System.out.println("inJson parse error"); | |||||
} | |||||
} | |||||
} | |||||
} |
package com.cbs.company.config; | |||||
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.springframework.context.annotation.Bean; | |||||
import org.springframework.context.annotation.Configuration; | |||||
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver; | |||||
import java.util.LinkedHashMap; | |||||
import java.util.Map; | |||||
import java.util.Properties; | |||||
@Configuration | |||||
public class ShiroConfig { | |||||
@Bean | |||||
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) { | |||||
System.out.println("ShiroConfiguration.shirFilter()"); | |||||
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); | |||||
shiroFilterFactoryBean.setSecurityManager(securityManager); | |||||
//拦截器. | |||||
Map<String,String> filterChainDefinitionMap = new LinkedHashMap<String,String>(); | |||||
/* | |||||
**说明: | |||||
* anon :无需认证(登录)可以访问 | |||||
* authc:必须认证才可以访问 | |||||
* user:如果使用remeberMe的功能可以直接访问 | |||||
* perms:该资源必须得到资源才可以访问 | |||||
* role:该资源必须得到角色权限才可以访问 | |||||
*/ | |||||
// 配置不会被拦截的链接 顺序判断 | |||||
// filterChainDefinitionMap.put("/static/**", "anon"); | |||||
filterChainDefinitionMap.put("/login.html", "anon"); | |||||
filterChainDefinitionMap.put("/image/**", "anon"); | |||||
filterChainDefinitionMap.put("/w_img/**", "anon"); | |||||
filterChainDefinitionMap.put("/js/**", "anon"); | |||||
filterChainDefinitionMap.put("/css/**", "anon"); | |||||
//wy | |||||
filterChainDefinitionMap.put("/p/bagquery.php", "anon"); | |||||
filterChainDefinitionMap.put("/p/bagadd.php", "anon"); | |||||
filterChainDefinitionMap.put("/p/bagupdate.php", "anon"); | |||||
filterChainDefinitionMap.put("/p/bagdelete.php", "anon"); | |||||
//配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了 | |||||
filterChainDefinitionMap.put("/logout", "logout"); | |||||
//<!-- 过滤链定义permissionsLookupEnabled,从上向下顺序执行,一般将/**放在最为下边 -->:这是一个坑呢,一不小心代码就不好使了; | |||||
//<!-- authc:所有url都必须认证通过才可以访问; anon:所有url都都可以匿名访问--> | |||||
filterChainDefinitionMap.put("/**", "authc"); | |||||
// 如果不设置默认会自动寻找Web工程根目录下的"/login.jsp"页面 | |||||
shiroFilterFactoryBean.setLoginUrl("/login.html"); | |||||
//shiroFilterFactoryBean.setLoginUrl("/p/unauth"); | |||||
// 登录成功后要跳转的链接 | |||||
//shiroFilterFactoryBean.setSuccessUrl(""); | |||||
//未授权界面; | |||||
//shiroFilterFactoryBean.setUnauthorizedUrl("/403"); | |||||
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | |||||
return shiroFilterFactoryBean; | |||||
} | |||||
/** | |||||
* 凭证匹配器 | |||||
* (由于我们的密码校验交给Shiro的SimpleAuthenticationInfo进行处理了 | |||||
* ) | |||||
* @return | |||||
*/ | |||||
@Bean | |||||
public HashedCredentialsMatcher hashedCredentialsMatcher(){ | |||||
HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher(); | |||||
hashedCredentialsMatcher.setHashAlgorithmName("md5");//散列算法:这里使用MD5算法; | |||||
//hashedCredentialsMatcher.setHashIterations(2);//散列的次数,比如散列两次,相当于 md5(md5("")); | |||||
return hashedCredentialsMatcher; | |||||
} | |||||
@Bean | |||||
public MyShiroRealm myShiroRealm(){ | |||||
MyShiroRealm myShiroRealm = new MyShiroRealm(); | |||||
// myShiroRealm.setCredentialsMatcher(hashedCredentialsMatcher()); | |||||
return myShiroRealm; | |||||
} | |||||
@Bean | |||||
public SecurityManager securityManager(){ | |||||
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); | |||||
securityManager.setRealm(myShiroRealm()); | |||||
return securityManager; | |||||
} | |||||
/** | |||||
* 开启shiro aop注解支持. | |||||
* 使用代理方式;所以需要开启代码支持; | |||||
* @param securityManager | |||||
* @return | |||||
*/ | |||||
@Bean | |||||
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager){ | |||||
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); | |||||
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager); | |||||
return authorizationAttributeSourceAdvisor; | |||||
} | |||||
@Bean(name="simpleMappingExceptionResolver") | |||||
public SimpleMappingExceptionResolver | |||||
createSimpleMappingExceptionResolver() { | |||||
SimpleMappingExceptionResolver r = new SimpleMappingExceptionResolver(); | |||||
Properties mappings = new Properties(); | |||||
mappings.setProperty("DatabaseException", "databaseError");//数据库异常处理 | |||||
mappings.setProperty("UnauthorizedException","403"); | |||||
r.setExceptionMappings(mappings); // None by default | |||||
r.setDefaultErrorView("error"); // No default | |||||
r.setExceptionAttribute("ex"); // Default is "exception" | |||||
//r.setWarnLogCategory("example.MvcLogger"); // No default | |||||
return r; | |||||
} | |||||
} |
package com.cbs.company.controller; | |||||
import java.util.ArrayList; | |||||
import java.util.HashSet; | |||||
import java.util.List; | |||||
import java.util.Set; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Controller; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.ResponseBody; | |||||
import com.cbs.company.domain.Bag; | |||||
import com.cbs.company.domain.UserDO; | |||||
import com.cbs.company.result.SearchResult; | |||||
import com.cbs.company.service.BagService; | |||||
import com.cbs.company.vo.BagVo; | |||||
import com.google.gson.Gson; | |||||
import net.sf.json.JSONObject; | |||||
@Controller | |||||
@RequestMapping("/p") | |||||
public class BagController { | |||||
@Autowired | |||||
BagService bagService; | |||||
//20.9 | |||||
//功能: 箱包管理 | |||||
//链接: /p/bagquery.php | |||||
@RequestMapping("/bagquery.php") | |||||
@ResponseBody | |||||
public SearchResult<List<JSONObject>> getBag(HttpServletRequest request) { | |||||
String page = request.getParameter("page"); | |||||
String total = request.getParameter("rows"); | |||||
int pageIndex; | |||||
int pageSize; | |||||
if (page != null && !page.equals("")){ | |||||
pageIndex = Integer.valueOf(page);// 第几页的数据 | |||||
}else { | |||||
pageIndex = 0; | |||||
} | |||||
if (total != null && !total.equals("")){ | |||||
pageSize = Integer.valueOf(total);//每页多少条数据 | |||||
}else { | |||||
pageSize = 0; | |||||
} | |||||
if(pageIndex==1){ | |||||
pageIndex = pageIndex -1; | |||||
} | |||||
else{ | |||||
pageIndex = pageSize*(pageIndex-1); | |||||
} | |||||
BagVo bagVo = new BagVo(); | |||||
bagVo.setType(request.getParameter("type")); | |||||
bagVo.setTexture(request.getParameter("texture")); | |||||
bagVo.setGs(request.getParameter("gsname")); | |||||
bagVo.setPageIndex(pageIndex); | |||||
bagVo.setPageSize(pageSize); | |||||
BagVo bagVoTotal = new BagVo(); | |||||
bagVoTotal.setType(request.getParameter("type")); | |||||
bagVoTotal.setTexture(request.getParameter("texture")); | |||||
bagVo.setGs(request.getParameter("gsname")); | |||||
try { | |||||
List<Bag> bagList = bagService.getBag(bagVo); | |||||
List<Bag> bagListTotal = bagService.getBag(bagVoTotal); | |||||
List<JSONObject> searchJsonList = new ArrayList<JSONObject>(); | |||||
for (int i = 0; i < bagList.size(); i++) { | |||||
JSONObject rows = new JSONObject(); | |||||
rows.put("id", bagList.get(i).getId()); | |||||
rows.put("type", bagList.get(i).getType()); | |||||
rows.put("texture", bagList.get(i).getTexture()); | |||||
rows.put("gsprice", bagList.get(i).getGsprice()); | |||||
rows.put("bagprice", bagList.get(i).getBagprice()); | |||||
rows.put("gs", bagList.get(i).getGs()); | |||||
rows.put("kc",bagList.get(i).getKc()); | |||||
rows.put("kcyj",bagList.get(i).getKcyj()); | |||||
rows.put("startdate",bagList.get(i).getStartdate()); | |||||
rows.put("enddate",bagList.get(i).getEnddate()); | |||||
searchJsonList.add(rows); | |||||
} | |||||
return SearchResult.success_byList(searchJsonList, bagListTotal.size()); | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
return SearchResult.error(); | |||||
} | |||||
} | |||||
//20.10 | |||||
//功能: 提交新建一条箱包信息 | |||||
//链接: /p/bagadd.php | |||||
@RequestMapping("/bagadd.php") | |||||
@ResponseBody | |||||
public String addBag(HttpServletRequest request) { | |||||
String type = request.getParameter("type"); | |||||
String texture = request.getParameter("texture"); | |||||
String gsprice = request.getParameter("gsprice"); | |||||
String bagprice = request.getParameter("bagprice"); | |||||
String gs = request.getParameter("gs").toUpperCase(); | |||||
String kc = request.getParameter("kc"); | |||||
String kcyj = request.getParameter("kcyj"); | |||||
Bag bag = new Bag(); | |||||
bag.setType(type); | |||||
bag.setTexture(texture); | |||||
bag.setGsprice(gsprice); | |||||
bag.setBagprice(bagprice); | |||||
bag.setStartdate(request.getParameter("startdate")); | |||||
bag.setEnddate(request.getParameter("enddate")); | |||||
bag.setGs(gs); | |||||
if("".equals(kc)){ | |||||
bag.setKc(0); | |||||
}else{ | |||||
bag.setKc(Integer.valueOf(kc)); | |||||
} | |||||
if("".equals(kcyj)){ | |||||
bag.setKcyj(0); | |||||
}else{ | |||||
bag.setKcyj(Integer.valueOf(kcyj)); | |||||
} | |||||
try { | |||||
int flag = bagService.addBag(bag); | |||||
return "{\"msg\":\"操作成功\",\"err\":\"1\"}"; | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
return "{\"msg\":\"操作失败\",\"err\":\"6\"}"; | |||||
} | |||||
} | |||||
//20.11 | |||||
//功能: 提交修改一条箱包信息 | |||||
//链接: /p/bagupdate.php | |||||
@RequestMapping("/bagupdate.php") | |||||
@ResponseBody | |||||
public String updateBag(HttpServletRequest request) { | |||||
String id = request.getParameter("id"); | |||||
String type = request.getParameter("type"); | |||||
String texture = request.getParameter("texture"); | |||||
String gsprice = request.getParameter("gsprice"); | |||||
String bagprice = request.getParameter("bagprice"); | |||||
String gs = request.getParameter("gs").toUpperCase(); | |||||
String kc = request.getParameter("kc"); | |||||
String kcyj = request.getParameter("kcyj"); | |||||
Bag bag = new Bag(); | |||||
bag.setId(Integer.valueOf(id)); | |||||
bag.setType(type); | |||||
bag.setTexture(texture); | |||||
bag.setGsprice(gsprice); | |||||
bag.setBagprice(bagprice); | |||||
bag.setGs(gs); | |||||
bag.setStartdate(request.getParameter("startdate")); | |||||
bag.setEnddate(request.getParameter("enddate")); | |||||
if("".equals(kc)){ | |||||
bag.setKc(0); | |||||
}else{ | |||||
bag.setKc(Integer.valueOf(kc)); | |||||
} | |||||
if("".equals(kcyj)){ | |||||
bag.setKcyj(0); | |||||
}else{ | |||||
bag.setKcyj(Integer.valueOf(kcyj)); | |||||
} | |||||
try { | |||||
int flag = bagService.updateBag(bag); | |||||
return "{\"msg\":\"操作成功\",\"err\":\"1\"}"; | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
return "{\"msg\":\"操作失败\",\"err\":\"6\"}"; | |||||
} | |||||
} | |||||
//20.12 | |||||
//功能: 删除一条箱包信息 | |||||
//链接: /p/bagdelete.php | |||||
@RequestMapping("/bagdelete.php") | |||||
@ResponseBody | |||||
public String deleteBag(HttpServletRequest request) { | |||||
String id = request.getParameter("id"); | |||||
try { | |||||
int flag = bagService.deleteBag(Integer.valueOf(id)); | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
return "{\"msg\":\"操作失败\",\"err\":\"6\"}"; | |||||
} | |||||
return "{\"msg\":\"操作成功\",\"err\":\"1\"}"; | |||||
} | |||||
} |
package com.cbs.company.controller; | |||||
import com.google.gson.Gson; | |||||
import org.apache.shiro.authc.AuthenticationException; | |||||
import org.apache.shiro.authz.AuthorizationException; | |||||
import org.apache.shiro.authz.UnauthenticatedException; | |||||
import org.apache.shiro.authz.UnauthorizedException; | |||||
import org.springframework.web.bind.annotation.ExceptionHandler; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.io.IOException; | |||||
import java.io.PrintWriter; | |||||
import java.util.HashMap; | |||||
import java.util.Map; | |||||
public abstract class BaseController { | |||||
/** | |||||
* 登录认证异常 | |||||
*/ | |||||
@ExceptionHandler({UnauthenticatedException.class, AuthenticationException.class}) | |||||
public String authenticationException(HttpServletRequest request, HttpServletResponse response) { | |||||
if (isAjaxRequest(request)) { | |||||
//输出JSON | |||||
Map<String, Object> map = new HashMap<String, Object>(); | |||||
map.put("err", "11"); | |||||
map.put("msg", "未登录"); | |||||
writeJson(map, response); | |||||
return null; | |||||
} else { | |||||
return "redirect:login"; | |||||
} | |||||
} | |||||
/** | |||||
* 权限异常 | |||||
*/ | |||||
@ExceptionHandler({UnauthorizedException.class, AuthorizationException.class}) | |||||
public String authorizationException(HttpServletRequest request, HttpServletResponse response) { | |||||
if (isAjaxRequest(request)) { | |||||
// 输出JSON | |||||
Map<String, Object> map = new HashMap<String, Object>(); | |||||
map.put("err", "7"); | |||||
map.put("msg", "无权限"); | |||||
writeJson(map, response); | |||||
return null; | |||||
} else { | |||||
return "redirect:/p/403"; | |||||
} | |||||
} | |||||
/** | |||||
* 输出JSON | |||||
* *@param response | |||||
* | |||||
* @author renxijun | |||||
* @create 2018 年11月13日 | |||||
*/ | |||||
private void writeJson(Map<String, Object> map, HttpServletResponse response) { | |||||
PrintWriter out = null; | |||||
try { | |||||
response.setCharacterEncoding("UTF-8"); | |||||
response.setContentType("application/json; charset=utf-8"); | |||||
out = response.getWriter(); | |||||
out.write(new Gson().toJson(map)); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} finally { | |||||
if (out != null) { | |||||
out.close(); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* 是否是Ajax请求 | |||||
* | |||||
* @param request | |||||
* @return | |||||
* @author SHANHY | |||||
* @create 2017年4月4日 | |||||
*/ | |||||
public static boolean isAjaxRequest(HttpServletRequest request) { | |||||
String requestedWith = request.getHeader("x-requested-with"); | |||||
if (requestedWith != null && requestedWith.equalsIgnoreCase("XMLHttpRequest")) { | |||||
return true; | |||||
} else { | |||||
return false; | |||||
} | |||||
} | |||||
} |
package com.cbs.company.controller; | |||||
import java.io.IOException; | |||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.Random; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import org.apache.shiro.SecurityUtils; | |||||
import org.apache.shiro.authc.AuthenticationException; | |||||
import org.apache.shiro.authc.IncorrectCredentialsException; | |||||
import org.apache.shiro.authc.LockedAccountException; | |||||
import org.apache.shiro.subject.Subject; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.stereotype.Controller; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RequestMethod; | |||||
import org.springframework.web.bind.annotation.ResponseBody; | |||||
import com.cbs.company.domain.DeptDO; | |||||
import com.cbs.company.domain.UserDO; | |||||
import com.cbs.company.service.LoginService; | |||||
import com.cbs.company.util.MD5Utils; | |||||
import com.github.qcloudsms.SmsMultiSender; | |||||
import com.github.qcloudsms.SmsMultiSenderResult; | |||||
@Controller | |||||
@RequestMapping("/p") | |||||
public class DoLoginController { | |||||
@Autowired | |||||
LoginService loginService; | |||||
public String sendSms(String phoneNumber){ | |||||
// 短信应用SDK AppID | |||||
int appid = 1400176574; // 1400开头 | |||||
String code = ""; | |||||
Random random = new Random(); | |||||
for (int i=0;i<6;i++) | |||||
{ | |||||
code+=random.nextInt(10); | |||||
} | |||||
System.out.println(code); | |||||
// 短信应用SDK AppKey | |||||
String appkey = "6ed16031afaf45270181dc9206d0c7c3"; | |||||
// 短信模板ID,需要在短信应用中申请 | |||||
// NOTE: 这里的模板ID`7839`只是一个示例, | |||||
// 真实的模板ID需要在短信控制台中申请 | |||||
int templateId = 262069; | |||||
String[] phoneNumbers = {phoneNumber}; | |||||
// 签名 | |||||
// NOTE: 这里的签名"腾讯云"只是一个示例, | |||||
// 真实的签名需要在短信控制台中申请,另外 | |||||
// 签名参数使用的是`签名内容`,而不是`签名ID` | |||||
String smsSign = ""; | |||||
// 指定模板ID单发短信 | |||||
try { | |||||
String[] params = {code,"1"}; | |||||
SmsMultiSender msender = new SmsMultiSender(appid, appkey); | |||||
SmsMultiSenderResult result = msender.sendWithParam("86", phoneNumbers, | |||||
templateId, params, smsSign, "", ""); // 签名参数未提供或者为空时,会使用默认签名发送短信 | |||||
System.out.print(result); | |||||
} catch (com.github.qcloudsms.httpclient.HTTPException e) { | |||||
// HTTP响应码错误 | |||||
e.printStackTrace(); | |||||
} catch (org.json.JSONException e) { | |||||
// json解析错误 | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
// 网络IO错误 | |||||
e.printStackTrace(); | |||||
} | |||||
return code; | |||||
} | |||||
@RequestMapping(value = "/airline.php", method = RequestMethod.GET) | |||||
@ResponseBody | |||||
public Map<String,Object> airline(HttpServletRequest request) throws Exception{ | |||||
Map<String,Object> param = new HashMap<String, Object>(); | |||||
try { | |||||
UserDO userDo = (UserDO)request.getSession().getAttribute("login"); | |||||
// List<DeptDO> deptDoList = loginService.getAllDeptInfo(); | |||||
List<DeptDO> deptDoList = loginService.getDeptByName(userDo.getUsername()); | |||||
List<Object> listData=new ArrayList<Object>(); | |||||
//1、获得机场信息 | |||||
if(deptDoList.size()>0) { | |||||
// DeptDO deptDO = deptDoList.get(0); | |||||
for(DeptDO deptDO:deptDoList){ | |||||
List<DeptDO> childdeptDoList = loginService.getParentDeptBydeptid(deptDO.getParentid()); | |||||
if (childdeptDoList.size() > 0) { | |||||
for(DeptDO childdeptDO:childdeptDoList){ | |||||
//2、获得航空公司信息->图片 | |||||
if(childdeptDO.getParentid()==0){ //如果用户在机场下 | |||||
Map<String,Object> data = new HashMap<String, Object>(); | |||||
data.put("id",childdeptDO.getDeptid()); | |||||
data.put("nm",childdeptDO.getName()); | |||||
data.put("img",childdeptDO.getPic()); | |||||
listData.add(data); | |||||
}else{ | |||||
List<DeptDO> companyDoList = loginService.getParentDeptBydeptid(childdeptDO.getParentid()); | |||||
if(companyDoList.size()>0){ | |||||
Map<String,Object> data = new HashMap<String, Object>(); | |||||
data.put("id",companyDoList.get(0).getDeptid()); | |||||
data.put("nm",companyDoList.get(0).getName()); | |||||
data.put("img",companyDoList.get(0).getPic()); | |||||
listData.add(data); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
// for(int i=0;i<deptDoList.size();i++){ | |||||
// Map<String,Object> data = new HashMap<String, Object>(); | |||||
// data.put("id",deptDoList.get(i).getDeptid()); | |||||
// data.put("nm",deptDoList.get(i).getName()); | |||||
// data.put("img",deptDoList.get(i).getPic()); | |||||
// listData.add(data); | |||||
// } | |||||
param.put("err","1"); | |||||
param.put("msg","操作成功"); | |||||
param.put("data",listData); | |||||
System.out.println("================================[list]============="+listData); | |||||
} catch (IncorrectCredentialsException e) { | |||||
System.out.println("IncorrectCredentialsException -- > 密码不正确:"); | |||||
param.put("err","4"); | |||||
param.put("msg","登录失败"); | |||||
} catch (LockedAccountException e) { | |||||
param.put("err","4"); | |||||
param.put("msg","登录失败"); | |||||
} catch (AuthenticationException e) { | |||||
System.out.println("UnknownAccountException -- > 账号不存在:"); | |||||
param.put("err","4"); | |||||
param.put("msg","登录失败"); | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
} | |||||
// 此方法不处理登录成功,由shiro进行处理 | |||||
System.out.println("==============param============="+param.toString()); | |||||
return param; | |||||
} | |||||
@RequestMapping(value = "/airport.php", method = RequestMethod.GET) | |||||
@ResponseBody | |||||
public Map<String,Object> airport(HttpServletRequest request) throws Exception{ | |||||
Map<String,Object> param = new HashMap<String, Object>(); | |||||
try { | |||||
UserDO userDo = (UserDO)request.getSession().getAttribute("login"); | |||||
List<DeptDO> deptDoList = loginService.getDeptByName(userDo.getUsername()); | |||||
List<Object> listData=new ArrayList<Object>(); | |||||
//1、获得机场信息 | |||||
if(deptDoList.size()>0) { | |||||
List<DeptDO> childdeptDoList = loginService.getParentDeptByChilddeptid(deptDoList.get(0).getDeptid()); | |||||
if (childdeptDoList.size() > 0) { | |||||
for(DeptDO childdeptDO:childdeptDoList){ | |||||
//2、获得航空公司信息->图片 | |||||
// if(childdeptDO.getParentid()==0){ //如果用户在机场下 | |||||
Map<String,Object> data = new HashMap<String, Object>(); | |||||
data.put("id",childdeptDO.getDeptid()); | |||||
data.put("nm",childdeptDO.getName()); | |||||
data.put("ia",childdeptDO.getShortname()); | |||||
listData.add(data); | |||||
// } | |||||
} | |||||
} | |||||
} | |||||
param.put("err","1"); | |||||
param.put("msg","操作成功"); | |||||
param.put("data",listData); | |||||
} catch (IncorrectCredentialsException e) { | |||||
System.out.println("IncorrectCredentialsException -- > 密码不正确:"); | |||||
param.put("err","4"); | |||||
param.put("msg","操作错误"); | |||||
} catch (LockedAccountException e) { | |||||
param.put("err","4"); | |||||
param.put("msg","操作错误"); | |||||
} catch (AuthenticationException e) { | |||||
System.out.println("UnknownAccountException -- > 账号不存在:"); | |||||
param.put("err","4"); | |||||
param.put("msg","操作错误"); | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
} | |||||
System.out.println("==============param============="+param.toString()); | |||||
return param; | |||||
} | |||||
@RequestMapping("/loginout.php") | |||||
@ResponseBody | |||||
public Map<String,String> loginout(HttpServletRequest request) throws Exception{ | |||||
System.out.println("HomeController.login()"); | |||||
Map<String,String> param = new HashMap<String, String>(); | |||||
// 登录失败从request中获取shiro处理的异常信息。 | |||||
// shiroLoginFailure:就是shiro异常类的全类名. | |||||
// UserInfo userInfo = (UserInfo)request.getSession().getAttribute("login"); | |||||
//request.getSession().invalidate(); | |||||
try { | |||||
Subject subject = SecurityUtils.getSubject(); | |||||
subject.logout(); | |||||
param.put("err","1"); | |||||
param.put("msg","注销成功"); | |||||
} catch (Exception e) { | |||||
param.put("err","4"); | |||||
param.put("msg","注销失败"); | |||||
e.printStackTrace(); | |||||
} | |||||
// 此方法不处理登录成功,由shiro进行处理 | |||||
return param; | |||||
} | |||||
/** | |||||
* 未登录,shiro应重定向到登录界面,此处返回未登录状态信息由前端控制跳转页面 | |||||
* @return | |||||
*/ | |||||
@RequestMapping(value = "/unauth") | |||||
@ResponseBody | |||||
public Object unauth() { | |||||
Map<String, Object> map = new HashMap<String, Object>(); | |||||
map.put("code", "1000000"); | |||||
map.put("msg", "未登录"); | |||||
return map; | |||||
} | |||||
@RequestMapping("/403") | |||||
public String unauthorizedRole(){ | |||||
System.out.println("------没有权限-------"); | |||||
return "403"; | |||||
} | |||||
public static void main(String[] args) { | |||||
String password = MD5Utils.encrypt("test1", "123456"); | |||||
System.out.println(password); | |||||
} | |||||
} |
package com.cbs.company.dao; | |||||
import java.util.List; | |||||
import org.apache.ibatis.annotations.Delete; | |||||
import org.apache.ibatis.annotations.Insert; | |||||
import org.apache.ibatis.annotations.Mapper; | |||||
import org.apache.ibatis.annotations.Param; | |||||
import org.apache.ibatis.annotations.Select; | |||||
import org.apache.ibatis.annotations.Update; | |||||
import com.cbs.company.domain.Bag; | |||||
import com.cbs.company.vo.BagVo; | |||||
@Mapper | |||||
public interface BagDao { | |||||
@Select("<script>" + | |||||
"select id,type,texture,gsprice,bagprice,gs,kc,kcyj,startdate,enddate " + | |||||
"from sys_bag " + | |||||
"where 1=1 " + | |||||
"<if test = 'bagVo.type != null && bagVo.type != '''>" + | |||||
" and type = #{bagVo.type} " +// 箱包类型 | |||||
"</if> " + | |||||
"<if test = 'bagVo.texture != null && bagVo.texture != '''>" + | |||||
" and texture = #{bagVo.texture} " +// 箱包材质 | |||||
"</if> " + | |||||
"<if test = 'bagVo.gs != null && bagVo.gs != '''>" + | |||||
" and gs like '%${bagVo.gs}%' " +// 机场名称 | |||||
"</if> " + | |||||
"<if test = 'bagVo.pageIndex gte 0 && bagVo.pageSize gt 0 '>" + | |||||
"limit #{bagVo.pageSize} "+ | |||||
"offset #{bagVo.pageIndex} " + | |||||
"</if> " + | |||||
"</script>") | |||||
public List<Bag> getBag(@Param("bagVo") BagVo bagVo); | |||||
@Insert("insert into sys_bag(type,texture,gsprice,bagprice,gs,kc,kcyj,startdate,enddate) " + | |||||
"values(#{type},#{texture},#{gsprice},#{bagprice},#{gs},#{kc},#{kcyj},to_date(#{startdate},'yyyy-MM-dd'),to_date(#{enddate},'yyyy-MM-dd'))") | |||||
public int addBag(Bag bag); | |||||
@Update("update sys_bag set type = #{type},texture = #{texture},gsprice = #{gsprice},bagprice = #{bagprice},kc = #{kc},kcyj = #{kcyj}," + | |||||
"gs = #{gs},startdate = to_date(#{startdate},'yyyy-MM-dd'),enddate = to_date(#{enddate},'yyyy-MM-dd') where id = #{id}") | |||||
public int updateBag(Bag bag); | |||||
@Delete("delete from sys_bag where id = #{id}") | |||||
public int deleteBag(int id); | |||||
} |
package com.cbs.company.dao; | |||||
import java.util.List; | |||||
import org.apache.ibatis.annotations.Insert; | |||||
import org.apache.ibatis.annotations.Mapper; | |||||
import org.apache.ibatis.annotations.Param; | |||||
import org.apache.ibatis.annotations.Select; | |||||
import org.apache.ibatis.annotations.Update; | |||||
import com.cbs.company.domain.DeptDO; | |||||
import com.cbs.company.domain.Login; | |||||
import com.cbs.company.domain.RoleDO; | |||||
import com.cbs.company.domain.UserDO; | |||||
@Mapper | |||||
public interface LoginDao { | |||||
@Select("select * from cbs_login where name = #{name} and code = #{code}") | |||||
public Login getLogin(Login login); | |||||
@Select("select * from cbs_login where name = #{name}") | |||||
public Login getLoginByName(Login login); | |||||
@Select("select * from sys_user where username = #{userName}") | |||||
List<UserDO> list(String userName); | |||||
@Select("select * from sys_user where phone = #{phone}") | |||||
List<UserDO> listByPhone(String phone); | |||||
@Select("select * from sys_user where openid = #{openid}") | |||||
List<UserDO> getlistByOpenid(String openid); | |||||
//==============登录获取部门信息开始========================= | |||||
@Select("select sys_dept.dept_id as deptid,sys_dept.parent_id as parentid,sys_dept.name,sys_dept.shortname,sys_dept.pic from sys_user LEFT JOIN sys_dept on sys_user.dept_id = sys_dept.dept_id where sys_user.username = #{name}") | |||||
List<DeptDO> getDeptByName(String name); | |||||
//==============登录获取部门信息开始========================= | |||||
@Select("SELECT\n" + | |||||
"\tsys_dept.dept_id AS deptid,\n" + | |||||
"\tsys_dept.parent_id AS parentid,\n" + | |||||
"\tsys_dept.name,\n" + | |||||
"\tsys_dept.shortname,\n" + | |||||
"\tsys_dept.pic\n" + | |||||
"FROM\n" + | |||||
"\tsys_dept\n" + | |||||
"WHERE\n" + | |||||
"\tsys_dept.parent_id = 0") | |||||
List<DeptDO> getAllDeptInfo(); | |||||
//==============登录获取部门信息开始========================= | |||||
@Select("SELECT\n" + | |||||
"\tsys_dept.dept_id AS deptid,\n" + | |||||
"\tsys_dept.parent_id AS parentid,\n" + | |||||
"\tsys_dept.name,\n" + | |||||
"\tsys_dept.shortname,\n" + | |||||
"\tsys_dept.pic,sys_dept.postcode,sys_dept.ename\n" + | |||||
"FROM\n" + | |||||
"\tsys_dept\n" + | |||||
"WHERE\n" + | |||||
"\t sys_dept.dept_id = #{id}") | |||||
DeptDO getDeptById(String id); | |||||
@Select("SELECT\n" + | |||||
"\tsys_dept.dept_id AS deptid,\n" + | |||||
"\tsys_dept.parent_id AS parentid,\n" + | |||||
"\tsys_dept.name,sys_dept.pic,sys_dept.shortname,sys_dept.postcode,sys_dept.ename\n" + | |||||
"FROM\n" + | |||||
"\tsys_dept \n" + | |||||
"WHERE\n" + | |||||
" sys_dept.dept_id = #{deptid}") | |||||
List<DeptDO> getParentDeptBydeptid(long deptid); //根据父部门查询子部门 | |||||
@Select("SELECT\n" + | |||||
"\tsys_dept.dept_id AS deptid,\n" + | |||||
"\tsys_dept.parent_id AS parentid,\n" + | |||||
"\tsys_dept.name,sys_dept.pic,sys_dept.shortname\n" + | |||||
"FROM\n" + | |||||
"\tsys_dept \n" + | |||||
"WHERE\n" + | |||||
" sys_dept.parent_id = #{deptid}") | |||||
List<DeptDO> getParentDeptByChilddeptid(long deptid); //根据父部门查询子部门 | |||||
@Select("SELECT\n" + | |||||
"\tsys_dept.dept_id AS deptid,\n" + | |||||
"\tsys_dept.parent_id AS parentid,\n" + | |||||
"\tsys_dept.name,sys_dept.pic,sys_dept.shortname\n" + | |||||
"FROM\n" + | |||||
"\tsys_dept \n" + | |||||
"WHERE\n" + | |||||
" sys_dept.parent_id = #{deptid} and sys_dept.name = #{lx} ") | |||||
DeptDO getZxzByChilddeptid(@Param("deptid")long deptid,@Param("lx") String lx); //查询装卸班组长部门 | |||||
//==============登录获取部门信息结束========================= | |||||
@Select("select sys_dept.dept_id as deptid,sys_dept.parent_id as parentid,sys_dept.name,sys_dept.shortname from sys_user LEFT JOIN sys_dept on sys_user.dept_id = sys_dept.dept_id where sys_user.openid = #{openid}") | |||||
List<DeptDO> getDeptByOpenid(String openid); | |||||
@Select("select sys_dept.dept_id as deptid,sys_dept.parent_id as parentid,sys_dept.name,sys_dept.shortname from sys_user LEFT JOIN sys_dept on sys_user.dept_id = sys_dept.dept_id where sys_user.phone = #{phone}") | |||||
List<DeptDO> getDeptByPhone(String phone); | |||||
@Select("SELECT\n" + | |||||
"\tsys_dept.dept_id AS deptid,\n" + | |||||
"\tsys_dept.parent_id AS parentid,\n" + | |||||
"\tsys_dept. NAME\n" + | |||||
"FROM\n" + | |||||
"\tsys_dept \n" + | |||||
"WHERE\n" + | |||||
" sys_dept.parent_id = #{deptid}") | |||||
List<DeptDO> getParentDeptByOpenid(long deptid); //根据父部门查询子部门 | |||||
@Select("SELECT\n" + | |||||
"\trole_id AS roleid,\n" + | |||||
"\trole_name AS name\n" + | |||||
" FROM\n" + | |||||
"\tsys_role\n" + | |||||
"WHERE\n" + | |||||
"\tsys_role.role_name like '%${name}%' ") | |||||
List<RoleDO> getRoleByDeptShortName(@Param("name") String name); //根据部门机场简称查询角色 | |||||
@Select("SELECT\n" + | |||||
"\t\t\tsys_role.role_name,\n" + | |||||
"\t\t\tsys_role.role_id,\n" + | |||||
" sys_user_role.user_id\n" + | |||||
"\t\tFROM\n" + | |||||
" sys_user_role\n" + | |||||
"\t\tLEFT JOIN sys_role ON sys_user_role.role_id = sys_role.role_id\n" + | |||||
"where sys_user_role.user_id = '${userid}' ") | |||||
List<RoleDO> getRoleByUserId(@Param("userid") Long userid); //获得自己的岗位信息 | |||||
@Select("select * from sys_user where phone = #{phone}") | |||||
List<UserDO> getlistByPhone(String phone); | |||||
@Update("update sys_user set openid = #{openid}" + | |||||
" where phone = #{phone} and type in (10,20) ") | |||||
public int updateUserByPhone(UserDO userDO); | |||||
@Update("update sys_user set password = #{password}" + | |||||
" where openid = #{openid}") | |||||
public int updatePasswordByOpenid(UserDO userDO); | |||||
@Update("update sys_user set phone = #{phone}" + | |||||
" where openid = #{openid}") | |||||
public int updatePhoneByOpenid(UserDO userDO); | |||||
@Select("select openid from sys_user" + | |||||
" where phone = #{phone} and type in (10,20,30) ") | |||||
public String getPhoneByOpenid(String phone); | |||||
@Insert("insert into sys_user(phone,name,username,dept_id,password,type,iata) values(#{phone},#{name},#{name},#{deptId},#{password},10,#{iata})") | |||||
public int addUser(UserDO userDO); | |||||
@Insert("insert into sys_user_role(user_id,role_id) values(${userid},${roleid})") | |||||
public int addUserRole(@Param("userid") Long userid,@Param("roleid") Long roleid); | |||||
@Update("update sys_user set phone = #{phone} , name = #{name},username = #{name}, dept_id = #{deptId}, iata = #{iata} where phone = #{phone}") | |||||
public int updateUser(UserDO userDO); | |||||
@Update("update sys_user_role set role_id = #{roleid} where user_id = #{userid}") | |||||
public int updateUserRole(@Param("userid") Long userid,@Param("roleid") Long roleid); | |||||
@Update("update ${tableName}_cbs_wx_sign set st = '已审核' where sn = #{sn} and rl =#{rl} ") | |||||
public int updateSignWxVo(@Param("rl") String rl,@Param("sn") String sn, @Param("tableName") String tableName); | |||||
//根据用户手机号查找用户角色 | |||||
@Select("SELECT\n" + | |||||
"\tsys_role.role_name,\n" + | |||||
"\tsys_user_role.role_id\n" + | |||||
"FROM\n" + | |||||
"\tsys_user\n" + | |||||
"LEFT JOIN sys_user_role ON sys_user.user_id = sys_user_role.user_id\n" + | |||||
"LEFT JOIN sys_role ON sys_user_role.role_id = sys_role.role_id\n" + | |||||
"where sys_user.phone = #{phone}") | |||||
public String getRolenameByPhone(@Param("phone") String phone); | |||||
} | |||||
package com.cbs.company.dao; | |||||
import org.apache.ibatis.annotations.*; | |||||
import java.util.List; | |||||
@Mapper | |||||
public interface MenuDao { | |||||
// count | |||||
@Select("select distinct m.perms from sys_menu m left join " + | |||||
"sys_role_menu rm on m.menu_id = rm.menu_id " + | |||||
"left join sys_user_role ur on rm.role_id = ur.role_id where ur.user_id = #{id} and m.perms like 'cbs%' ") | |||||
List<String> listUserPerms(Long id); | |||||
} |
package com.cbs.company.dao; | |||||
import org.apache.ibatis.annotations.Insert; | |||||
import org.apache.ibatis.annotations.Mapper; | |||||
import com.cbs.company.domain.User; | |||||
@Mapper | |||||
public interface UserDao { | |||||
@Insert("insert into cbs_user(id, name)values(#{id}, #{name})") | |||||
public int insert(User user); | |||||
} |
package com.cbs.company.dao; | |||||
import com.cbs.company.entity.UserInfo; | |||||
import org.springframework.data.repository.CrudRepository; | |||||
public interface UserInfoDao extends CrudRepository<UserInfo,Long> { | |||||
/**通过username查找用户信息;*/ | |||||
public UserInfo findByUsername(String username); | |||||
} |
package com.cbs.company.domain; | |||||
import java.util.Date; | |||||
public class Bag { | |||||
private int id; | |||||
private String type; | |||||
private String texture; | |||||
private String gsprice; | |||||
private String bagprice; | |||||
private String gs; | |||||
private String portname; | |||||
private int kc; | |||||
private int kcyj; | |||||
private String startdate; | |||||
private String enddate; | |||||
private int supplysum; | |||||
public int getSupplysum() { | |||||
return supplysum; | |||||
} | |||||
public void setSupplysum(int supplysum) { | |||||
this.supplysum = supplysum; | |||||
} | |||||
public String getStartdate() { | |||||
return startdate; | |||||
} | |||||
public void setStartdate(String startdate) { | |||||
this.startdate = startdate; | |||||
} | |||||
public String getEnddate() { | |||||
return enddate; | |||||
} | |||||
public void setEnddate(String enddate) { | |||||
this.enddate = enddate; | |||||
} | |||||
public int getKcyj() { | |||||
return kcyj; | |||||
} | |||||
public void setKcyj(int kcyj) { | |||||
this.kcyj = kcyj; | |||||
} | |||||
public int getId() { | |||||
return id; | |||||
} | |||||
public void setId(int id) { | |||||
this.id = id; | |||||
} | |||||
public String getType() { | |||||
return type; | |||||
} | |||||
public void setType(String type) { | |||||
this.type = type; | |||||
} | |||||
public String getTexture() { | |||||
return texture; | |||||
} | |||||
public int getKc() { | |||||
return kc; | |||||
} | |||||
public void setKc(int kc) { | |||||
this.kc = kc; | |||||
} | |||||
public void setTexture(String texture) { | |||||
this.texture = texture; | |||||
} | |||||
public String getGsprice() { | |||||
return gsprice; | |||||
} | |||||
public void setGsprice(String gsprice) { | |||||
this.gsprice = gsprice; | |||||
} | |||||
public String getBagprice() { | |||||
return bagprice; | |||||
} | |||||
public void setBagprice(String bagprice) { | |||||
this.bagprice = bagprice; | |||||
} | |||||
public String getGs() { | |||||
return gs; | |||||
} | |||||
public void setGs(String gs) { | |||||
this.gs = gs; | |||||
} | |||||
public String getPortname() { | |||||
return portname; | |||||
} | |||||
public void setPortname(String portname) { | |||||
this.portname = portname; | |||||
} | |||||
} |
package com.cbs.company.domain; | |||||
import org.springframework.format.annotation.DateTimeFormat; | |||||
import java.io.Serializable; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
public class DeptDO implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
private int deptid; | |||||
private int parentid; | |||||
private String name; | |||||
private String shortname; | |||||
private String ename; | |||||
private String pic; | |||||
private String postcode; | |||||
private String fax; | |||||
private String email; | |||||
private int order_num; | |||||
private int del_flag; | |||||
public int getDeptid() { | |||||
return deptid; | |||||
} | |||||
public void setDeptid(int deptid) { | |||||
this.deptid = deptid; | |||||
} | |||||
public int getParentid() { | |||||
return parentid; | |||||
} | |||||
public void setParentid(int parentid) { | |||||
this.parentid = parentid; | |||||
} | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
public String getShortname() { | |||||
return shortname; | |||||
} | |||||
public void setShortname(String shortname) { | |||||
this.shortname = shortname; | |||||
} | |||||
public String getEname() { | |||||
return ename; | |||||
} | |||||
public void setEname(String ename) { | |||||
this.ename = ename; | |||||
} | |||||
public String getPic() { | |||||
return pic; | |||||
} | |||||
public void setPic(String pic) { | |||||
this.pic = pic; | |||||
} | |||||
public String getPostcode() { | |||||
return postcode; | |||||
} | |||||
public void setPostcode(String postcode) { | |||||
this.postcode = postcode; | |||||
} | |||||
public String getFax() { | |||||
return fax; | |||||
} | |||||
public void setFax(String fax) { | |||||
this.fax = fax; | |||||
} | |||||
public String getEmail() { | |||||
return email; | |||||
} | |||||
public void setEmail(String email) { | |||||
this.email = email; | |||||
} | |||||
public int getOrder_num() { | |||||
return order_num; | |||||
} | |||||
public void setOrder_num(int order_num) { | |||||
this.order_num = order_num; | |||||
} | |||||
public int getDel_flag() { | |||||
return del_flag; | |||||
} | |||||
public void setDel_flag(int del_flag) { | |||||
this.del_flag = del_flag; | |||||
} | |||||
} |
package com.cbs.company.domain; | |||||
public class Login { | |||||
private int id; | |||||
private String name;// 用户名 | |||||
private String code;// 验证码 | |||||
private String type;// 所属类型(机场 10/航空公司 1) | |||||
public int getId() { | |||||
return id; | |||||
} | |||||
public void setId(int id) { | |||||
this.id = id; | |||||
} | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
public String getCode() { | |||||
return code; | |||||
} | |||||
public void setCode(String code) { | |||||
this.code = code; | |||||
} | |||||
public String getType() { | |||||
return type; | |||||
} | |||||
public void setType(String type) { | |||||
this.type = type; | |||||
} | |||||
} |
package com.cbs.company.domain; | |||||
import java.io.Serializable; | |||||
public class RoleDO implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
private int roleid; | |||||
private String name; | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
public int getRoleid() { | |||||
return roleid; | |||||
} | |||||
public void setRoleid(int roleid) { | |||||
this.roleid = roleid; | |||||
} | |||||
} |
package com.cbs.company.domain; | |||||
public class User { | |||||
private int id; | |||||
private String name; | |||||
public int getId() { | |||||
return id; | |||||
} | |||||
public void setId(int id) { | |||||
this.id = id; | |||||
} | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
} |
package com.cbs.company.domain; | |||||
import org.springframework.format.annotation.DateTimeFormat; | |||||
import java.io.Serializable; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
public class UserDO implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
// | |||||
private Long userId; | |||||
// 用户名 | |||||
private String username; | |||||
// 用户真实姓名 | |||||
private String name; | |||||
// 密码 | |||||
private String password; | |||||
// 部门 | |||||
private Long deptId; | |||||
private String deptName; | |||||
public String getCompanyShortName() { | |||||
return companyShortName; | |||||
} | |||||
public void setCompanyShortName(String companyShortName) { | |||||
this.companyShortName = companyShortName; | |||||
} | |||||
private String airportName; | |||||
private String airportEName; | |||||
private String companyName; | |||||
public String getAirportEName() { | |||||
return airportEName; | |||||
} | |||||
public void setAirportEName(String airportEName) { | |||||
this.airportEName = airportEName; | |||||
} | |||||
private String companyShortName; | |||||
private String airporPic; | |||||
private String airportShortName; | |||||
// 航空公司2字码 | |||||
private String iata; | |||||
public static long getSerialVersionUID() { | |||||
return serialVersionUID; | |||||
} | |||||
public String getIata() { | |||||
return iata; | |||||
} | |||||
public void setIata(String iata) { | |||||
this.iata = iata; | |||||
} | |||||
// 邮箱 | |||||
private String email; | |||||
// 手机号 | |||||
private String mobile; | |||||
// 状态 0:禁用,1:正常 | |||||
private Integer status; | |||||
// 创建用户id | |||||
private Long userIdCreate; | |||||
// 创建时间 | |||||
private Date gmtCreate; | |||||
// 修改时间 | |||||
private Date gmtModified; | |||||
//角色 | |||||
private List<Long> roleIds; | |||||
//性别 | |||||
private Long sex; | |||||
//出身日期 | |||||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||||
private Date birth; | |||||
//图片ID | |||||
private Long picId; | |||||
//现居住地 | |||||
private String liveAddress; | |||||
//爱好 | |||||
private String hobby; | |||||
//省份 | |||||
private String province; | |||||
//所在城市 | |||||
private String city; | |||||
//所在地区 | |||||
private String district; | |||||
public String getCompanyPic() { | |||||
return companyPic; | |||||
} | |||||
public void setCompanyPic(String companyPic) { | |||||
this.companyPic = companyPic; | |||||
} | |||||
//用户类型 | |||||
private String companyPic; | |||||
public String getPhone() { | |||||
return phone; | |||||
} | |||||
public void setPhone(String phone) { | |||||
this.phone = phone; | |||||
} | |||||
public String getPostcode() { | |||||
return postcode; | |||||
} | |||||
public void setPostcode(String postcode) { | |||||
this.postcode = postcode; | |||||
} | |||||
private String type; | |||||
private String openid; | |||||
private String phone; | |||||
private String postcode; | |||||
public Long getUserId() { | |||||
return userId; | |||||
} | |||||
public void setUserId(Long userId) { | |||||
this.userId = userId; | |||||
} | |||||
public String getCompanyName() { | |||||
return companyName; | |||||
} | |||||
public void setCompanyName(String companyName) { | |||||
this.companyName = companyName; | |||||
} | |||||
public String getUsername() { | |||||
return username; | |||||
} | |||||
public void setUsername(String username) { | |||||
this.username = username; | |||||
} | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
public String getPassword() { | |||||
return password; | |||||
} | |||||
public void setPassword(String password) { | |||||
this.password = password; | |||||
} | |||||
public Long getDeptId() { | |||||
return deptId; | |||||
} | |||||
public void setDeptId(Long deptId) { | |||||
this.deptId = deptId; | |||||
} | |||||
public String getDeptName() { | |||||
return deptName; | |||||
} | |||||
public void setDeptName(String deptName) { | |||||
this.deptName = deptName; | |||||
} | |||||
public String getEmail() { | |||||
return email; | |||||
} | |||||
public void setEmail(String email) { | |||||
this.email = email; | |||||
} | |||||
public String getMobile() { | |||||
return mobile; | |||||
} | |||||
public void setMobile(String mobile) { | |||||
this.mobile = mobile; | |||||
} | |||||
public Integer getStatus() { | |||||
return status; | |||||
} | |||||
public void setStatus(Integer status) { | |||||
this.status = status; | |||||
} | |||||
public Long getUserIdCreate() { | |||||
return userIdCreate; | |||||
} | |||||
public void setUserIdCreate(Long userIdCreate) { | |||||
this.userIdCreate = userIdCreate; | |||||
} | |||||
public Date getGmtCreate() { | |||||
return gmtCreate; | |||||
} | |||||
public void setGmtCreate(Date gmtCreate) { | |||||
this.gmtCreate = gmtCreate; | |||||
} | |||||
public Date getGmtModified() { | |||||
return gmtModified; | |||||
} | |||||
public void setGmtModified(Date gmtModified) { | |||||
this.gmtModified = gmtModified; | |||||
} | |||||
public List<Long> getRoleIds() { | |||||
return roleIds; | |||||
} | |||||
public void setRoleIds(List<Long> roleIds) { | |||||
this.roleIds = roleIds; | |||||
} | |||||
public Long getSex() { | |||||
return sex; | |||||
} | |||||
public void setSex(Long sex) { | |||||
this.sex = sex; | |||||
} | |||||
public Date getBirth() { | |||||
return birth; | |||||
} | |||||
public void setBirth(Date birth) { | |||||
this.birth = birth; | |||||
} | |||||
public Long getPicId() { | |||||
return picId; | |||||
} | |||||
public void setPicId(Long picId) { | |||||
this.picId = picId; | |||||
} | |||||
public String getLiveAddress() { | |||||
return liveAddress; | |||||
} | |||||
public void setLiveAddress(String liveAddress) { | |||||
this.liveAddress = liveAddress; | |||||
} | |||||
public String getHobby() { | |||||
return hobby; | |||||
} | |||||
public void setHobby(String hobby) { | |||||
this.hobby = hobby; | |||||
} | |||||
public String getProvince() { | |||||
return province; | |||||
} | |||||
public void setProvince(String province) { | |||||
this.province = province; | |||||
} | |||||
public String getCity() { | |||||
return city; | |||||
} | |||||
public void setCity(String city) { | |||||
this.city = city; | |||||
} | |||||
public String getDistrict() { | |||||
return district; | |||||
} | |||||
public void setDistrict(String district) { | |||||
this.district = district; | |||||
} | |||||
public String getType() { | |||||
return type; | |||||
} | |||||
public void setType(String type) { | |||||
this.type = type; | |||||
} | |||||
public String getAirportName() { | |||||
return airportName; | |||||
} | |||||
public void setAirportName(String airportName) { | |||||
this.airportName = airportName; | |||||
} | |||||
public String getAirportShortName() { | |||||
return airportShortName; | |||||
} | |||||
public void setAirportShortName(String airportShortName) { | |||||
this.airportShortName = airportShortName; | |||||
} | |||||
public String getOpenid() { | |||||
return openid; | |||||
} | |||||
public void setOpenid(String openid) { | |||||
this.openid = openid; | |||||
} | |||||
public String getAirporPic() { | |||||
return airporPic; | |||||
} | |||||
public void setAirporPic(String airporPic) { | |||||
this.airporPic = airporPic; | |||||
} | |||||
@Override | |||||
public String toString() { | |||||
return "UserDO{" + | |||||
"userId=" + userId + | |||||
", username='" + username + '\'' + | |||||
", name='" + name + '\'' + | |||||
", password='" + password + '\'' + | |||||
", deptId=" + deptId + | |||||
", deptName='" + deptName + '\'' + | |||||
", email='" + email + '\'' + | |||||
", mobile='" + mobile + '\'' + | |||||
", status=" + status + | |||||
", userIdCreate=" + userIdCreate + | |||||
", gmtCreate=" + gmtCreate + | |||||
", gmtModified=" + gmtModified + | |||||
", roleIds=" + roleIds + | |||||
", sex=" + sex + | |||||
", birth=" + birth + | |||||
", picId=" + picId + | |||||
", liveAddress='" + liveAddress + '\'' + | |||||
", hobby='" + hobby + '\'' + | |||||
", province='" + province + '\'' + | |||||
", city='" + city + '\'' + | |||||
", district='" + district + '\'' + | |||||
", type='" + type + '\'' + | |||||
'}'; | |||||
} | |||||
} |
package com.cbs.company.entity; | |||||
import javax.persistence.*; | |||||
import java.io.Serializable; | |||||
import java.util.List; | |||||
@Entity | |||||
public class SysPermission implements Serializable { | |||||
@Id@GeneratedValue | |||||
private Integer id;//主键. | |||||
private String name;//名称. | |||||
@Column(columnDefinition="enum('menu','button')") | |||||
private String resourceType;//资源类型,[menu|button] | |||||
private String url;//资源路径. | |||||
private String permission; //权限字符串,menu例子:role:*,button例子:role:create,role:update,role:delete,role:view | |||||
private Long parentId; //父编号 | |||||
private String parentIds; //父编号列表 | |||||
private Boolean available = Boolean.FALSE; | |||||
@ManyToMany | |||||
@JoinTable(name="SysRolePermission",joinColumns={@JoinColumn(name="permissionId")},inverseJoinColumns={@JoinColumn(name="roleId")}) | |||||
private List<SysRole> roles; | |||||
public Integer getId() { | |||||
return id; | |||||
} | |||||
public void setId(Integer id) { | |||||
this.id = id; | |||||
} | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
public String getResourceType() { | |||||
return resourceType; | |||||
} | |||||
public void setResourceType(String resourceType) { | |||||
this.resourceType = resourceType; | |||||
} | |||||
public String getUrl() { | |||||
return url; | |||||
} | |||||
public void setUrl(String url) { | |||||
this.url = url; | |||||
} | |||||
public String getPermission() { | |||||
return permission; | |||||
} | |||||
public void setPermission(String permission) { | |||||
this.permission = permission; | |||||
} | |||||
public Long getParentId() { | |||||
return parentId; | |||||
} | |||||
public void setParentId(Long parentId) { | |||||
this.parentId = parentId; | |||||
} | |||||
public String getParentIds() { | |||||
return parentIds; | |||||
} | |||||
public void setParentIds(String parentIds) { | |||||
this.parentIds = parentIds; | |||||
} | |||||
public Boolean getAvailable() { | |||||
return available; | |||||
} | |||||
public void setAvailable(Boolean available) { | |||||
this.available = available; | |||||
} | |||||
public List<SysRole> getRoles() { | |||||
return roles; | |||||
} | |||||
public void setRoles(List<SysRole> roles) { | |||||
this.roles = roles; | |||||
} | |||||
} |
package com.cbs.company.entity; | |||||
import javax.persistence.*; | |||||
import java.util.List; | |||||
@Entity | |||||
public class SysRole { | |||||
@Id@GeneratedValue | |||||
private Integer id; // 编号 | |||||
private String role; // 角色标识程序中判断使用,如"admin",这个是唯一的: | |||||
private String description; // 角色描述,UI界面显示使用 | |||||
private Boolean available = Boolean.FALSE; // 是否可用,如果不可用将不会添加给用户 | |||||
//角色 -- 权限关系:多对多关系; | |||||
@ManyToMany(fetch= FetchType.EAGER) | |||||
@JoinTable(name="SysRolePermission",joinColumns={@JoinColumn(name="roleId")},inverseJoinColumns={@JoinColumn(name="permissionId")}) | |||||
private List<SysPermission> permissions; | |||||
// 用户 - 角色关系定义; | |||||
@ManyToMany | |||||
@JoinTable(name="SysUserRole",joinColumns={@JoinColumn(name="roleId")},inverseJoinColumns={@JoinColumn(name="uid")}) | |||||
private List<UserInfo> userInfos;// 一个角色对应多个用户 | |||||
public Integer getId() { | |||||
return id; | |||||
} | |||||
public void setId(Integer id) { | |||||
this.id = id; | |||||
} | |||||
public String getRole() { | |||||
return role; | |||||
} | |||||
public void setRole(String role) { | |||||
this.role = role; | |||||
} | |||||
public String getDescription() { | |||||
return description; | |||||
} | |||||
public void setDescription(String description) { | |||||
this.description = description; | |||||
} | |||||
public Boolean getAvailable() { | |||||
return available; | |||||
} | |||||
public void setAvailable(Boolean available) { | |||||
this.available = available; | |||||
} | |||||
public List<SysPermission> getPermissions() { | |||||
return permissions; | |||||
} | |||||
public void setPermissions(List<SysPermission> permissions) { | |||||
this.permissions = permissions; | |||||
} | |||||
public List<UserInfo> getUserInfos() { | |||||
return userInfos; | |||||
} | |||||
public void setUserInfos(List<UserInfo> userInfos) { | |||||
this.userInfos = userInfos; | |||||
} | |||||
} |
package com.cbs.company.entity; | |||||
import javax.persistence.*; | |||||
import java.io.Serializable; | |||||
import java.util.List; | |||||
@Entity | |||||
public class UserInfo implements Serializable { | |||||
@Id | |||||
@GeneratedValue | |||||
private Integer uid; | |||||
@Column(unique =true) | |||||
private String username;//帐号 | |||||
private String name;//名称(昵称或者真实姓名,不同系统不同定义) | |||||
private String password; //密码; | |||||
private String salt;//加密密码的盐 | |||||
private String type;//1、航空公司 10、机场 | |||||
private byte state;//用户状态,0:创建未认证(比如没有激活,没有输入验证码等等)--等待验证的用户 , 1:正常状态,2:用户被锁定. | |||||
@ManyToMany(fetch= FetchType.EAGER)//立即从数据库中进行加载数据; | |||||
@JoinTable(name = "SysUserRole", joinColumns = { @JoinColumn(name = "uid") }, inverseJoinColumns ={@JoinColumn(name = "roleId") }) | |||||
private List<SysRole> roleList;// 一个用户具有多个角色 | |||||
public Integer getUid() { | |||||
return uid; | |||||
} | |||||
public void setUid(Integer uid) { | |||||
this.uid = uid; | |||||
} | |||||
public String getUsername() { | |||||
return username; | |||||
} | |||||
public void setUsername(String username) { | |||||
this.username = username; | |||||
} | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
public String getPassword() { | |||||
return password; | |||||
} | |||||
public void setPassword(String password) { | |||||
this.password = password; | |||||
} | |||||
public String getSalt() { | |||||
return salt; | |||||
} | |||||
public void setSalt(String salt) { | |||||
this.salt = salt; | |||||
} | |||||
public byte getState() { | |||||
return state; | |||||
} | |||||
public void setState(byte state) { | |||||
this.state = state; | |||||
} | |||||
public List<SysRole> getRoleList() { | |||||
return roleList; | |||||
} | |||||
public void setRoleList(List<SysRole> roleList) { | |||||
this.roleList = roleList; | |||||
} | |||||
public String getType() { | |||||
return type; | |||||
} | |||||
public void setType(String type) { | |||||
this.type = type; | |||||
} | |||||
/** | |||||
* 密码盐. | |||||
* @return | |||||
*/ | |||||
public String getCredentialsSalt(){ | |||||
return this.username+this.salt; | |||||
} | |||||
//重新对盐重新进行了定义,用户名+salt,这样就更加不容易被破解 | |||||
} |
package com.cbs.company.exception; | |||||
public class BusinessException extends Exception { | |||||
private static final long serialVersionUID = 1L; | |||||
// 提供无参数的构造方法 | |||||
public BusinessException() { | |||||
} | |||||
// 提供一个有参数的构造方法,可自动生成 | |||||
public BusinessException(String message) { | |||||
super(message);// 把参数传递给Throwable的带String参数的构造方法 | |||||
} | |||||
} | |||||
package com.cbs.company.exception; | |||||
import com.cbs.company.result.CodeMsg; | |||||
public class GlobalException extends RuntimeException{ | |||||
private static final long serialVersionUID = 1L; | |||||
private CodeMsg cm; | |||||
public GlobalException(CodeMsg cm) { | |||||
super(cm.toString()); | |||||
this.cm = cm; | |||||
} | |||||
public CodeMsg getCm() { | |||||
return cm; | |||||
} | |||||
} |
package com.cbs.company.exception; | |||||
import java.util.List; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import org.springframework.validation.BindException; | |||||
import org.springframework.validation.ObjectError; | |||||
import org.springframework.web.bind.annotation.ControllerAdvice; | |||||
import org.springframework.web.bind.annotation.ExceptionHandler; | |||||
import org.springframework.web.bind.annotation.ResponseBody; | |||||
import com.cbs.company.result.CodeMsg; | |||||
import com.cbs.company.result.Result; | |||||
@ControllerAdvice | |||||
@ResponseBody | |||||
public class GlobalExceptionHandler { | |||||
@ExceptionHandler(value=Exception.class) | |||||
public Result<String> exceptionHandler(HttpServletRequest request, Exception e){ | |||||
e.printStackTrace(); | |||||
if(e instanceof GlobalException) { | |||||
GlobalException ex = (GlobalException)e; | |||||
return Result.error(ex.getCm()); | |||||
}else if(e instanceof BindException) { | |||||
BindException ex = (BindException)e; | |||||
List<ObjectError> errors = ex.getAllErrors(); | |||||
ObjectError error = errors.get(0); | |||||
String msg = error.getDefaultMessage(); | |||||
return Result.error(CodeMsg.BIND_ERROR.fillArgs(msg)); | |||||
}else { | |||||
return Result.error(CodeMsg.SERVER_ERROR); | |||||
} | |||||
} | |||||
} |
package com.cbs.company.obtest; | |||||
public class Client { | |||||
public static void main(String[] args) { | |||||
//创建主题对象 | |||||
ConcreteSubject subject = new ConcreteSubject(); | |||||
//创建观察者对象 | |||||
Observer observer = new ConcreteObserver(); | |||||
Observer observer2 = new ConcreteObserver(); | |||||
//将观察者对象登记到主题对象上 | |||||
subject.attach(observer); | |||||
subject.attach(observer2); | |||||
//改变主题对象的状态 | |||||
subject.change("new state"); | |||||
} | |||||
} |
package com.cbs.company.obtest; | |||||
//具体观察者角色类 | |||||
/** | |||||
* 具体观察者(ConcreteObserver)角色:存储与主题的状态自恰的状态。 | |||||
* 具体观察者角色实现抽象观察者角色所要求的更新接口, | |||||
* 以便使本身的状态与主题的状态 像协调。如果需要,具体观察者角色可以保持一个指向具体主题对象的引用。 | |||||
*/ | |||||
public class ConcreteObserver implements Observer { | |||||
//观察者的状态 | |||||
private String observerState; | |||||
@Override | |||||
public void update(String state) { | |||||
/** | |||||
* 更新观察者的状态,使其与目标的状态保持一致 | |||||
*/ | |||||
observerState = state; | |||||
System.out.println("观察者状态为:"+observerState); | |||||
} | |||||
} |
package com.cbs.company.obtest; | |||||
//具体主题角色类 | |||||
/** | |||||
* 具体主题(ConcreteSubject)角色:将有关状态存入具体观察者对象; | |||||
* 在具体主题的内部状态改变时, | |||||
* 给所有登记过的观察者发出通知。 | |||||
* 具体主题角色又叫做具体被观察者(Concrete Observable)角色。 | |||||
*/ | |||||
public class ConcreteSubject extends Subject{ | |||||
private String state; | |||||
public String getState() { | |||||
return state; | |||||
} | |||||
public void change(String newState){ | |||||
state = newState; | |||||
System.out.println("主题状态为:" + state); | |||||
//状态发生改变,通知各个观察者 | |||||
this.nodifyObservers(state); | |||||
} | |||||
} |
package com.cbs.company.obtest; | |||||
//抽象观察者角色类 | |||||
/* | |||||
** | |||||
* 抽象观察者(Observer)角色:为所有的具体观察者定义一个接口, | |||||
* 在得到主题的通知时更新自己,这个接口叫做更新接口。 | |||||
*/ | |||||
public interface Observer { | |||||
/** | |||||
* 更新接口 | |||||
* @param state 更新的状态 | |||||
*/ | |||||
public void update(String state); | |||||
} |
package com.cbs.company.obtest; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
//抽象主题角色类 | |||||
/** | |||||
* 抽象主题(Subject)角色:抽象主题角色把所有对观察者对象的引用保存在一个聚集(比如ArrayList对象)里, | |||||
* 每个主题都可以有任何数量的观察者。 | |||||
* 抽象主题提供一个接口,可以增加和删除观察者对象, | |||||
* 抽象主题角色又叫做抽象被观察者(Observable)角色。 | |||||
*/ | |||||
public abstract class Subject { | |||||
/** | |||||
* 用来保存注册的观察者对象 | |||||
*/ | |||||
private List<Observer> list = new ArrayList<Observer>(); | |||||
/** | |||||
* 注册观察者对象 | |||||
* @param observer 观察者对象 | |||||
*/ | |||||
public void attach(Observer observer){ | |||||
list.add(observer); | |||||
System.out.println("Attached an observer"); | |||||
} | |||||
/** | |||||
* 删除观察者对象 | |||||
* @param observer 观察者对象 | |||||
*/ | |||||
public void detach(Observer observer){ | |||||
list.remove(observer); | |||||
} | |||||
/** | |||||
* 通知所有注册的观察者对象 | |||||
*/ | |||||
public void nodifyObservers(String newState){ | |||||
for(Observer observer : list){ | |||||
observer.update(newState); | |||||
} | |||||
} | |||||
} |
package com.cbs.company.obtest; | |||||
import java.io.FileInputStream; | |||||
import java.io.IOException; | |||||
public class code { | |||||
public static String getEncoding(String str) { | |||||
String encode = "GB2312"; | |||||
try { | |||||
if (str.equals(new String(str.getBytes(encode), encode))) { //判断是不是GB2312 | |||||
String s = encode; | |||||
return s; //是的话,返回“GB2312“,以下代码同理 | |||||
} | |||||
} catch (Exception exception) { | |||||
} | |||||
encode = "ISO-8859-1"; | |||||
try { | |||||
if (str.equals(new String(str.getBytes(encode), encode))) { //判断是不是ISO-8859-1 | |||||
String s1 = encode; | |||||
return s1; | |||||
} | |||||
} catch (Exception exception1) { | |||||
} | |||||
encode = "UTF-8"; | |||||
try { | |||||
if (str.equals(new String(str.getBytes(encode), encode))) { //判断是不是UTF-8 | |||||
String s2 = encode; | |||||
return s2; | |||||
} | |||||
} catch (Exception exception2) { | |||||
} | |||||
encode = "GBK"; | |||||
try { | |||||
if (str.equals(new String(str.getBytes(encode), encode))) { //判断是不是GBK | |||||
String s3 = encode; | |||||
return s3; | |||||
} | |||||
} catch (Exception exception3) { | |||||
} | |||||
return ""; //如果都不是,说明输入的内容不属于常见的编码格式。 | |||||
} | |||||
//任震: | |||||
public static void test1(){ | |||||
FileInputStream inputStream = null; | |||||
try{ | |||||
inputStream = new FileInputStream("src/main/resources/static/pca-code.json"); | |||||
int len = 0 ; | |||||
byte[] bys = new byte[80]; | |||||
len=inputStream.read(bys); | |||||
// String codeType=guessEncoding(bys); | |||||
// System.out.println("type="+codeType); | |||||
String str = new String(bys,"utf-8"); | |||||
System.out.println(str); | |||||
String clientStr = new String(str.getBytes("GBK"), "GBK"); | |||||
System.out.println(clientStr); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
}finally { | |||||
try { | |||||
inputStream.close(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
} | |||||
//任震: | |||||
public static String guessEncoding(byte[] bytes) { | |||||
String DEFAULT_ENCODING = "UTF-8"; | |||||
org.mozilla.universalchardet.UniversalDetector detector = | |||||
new org.mozilla.universalchardet.UniversalDetector(null); | |||||
detector.handleData(bytes, 0, bytes.length); | |||||
detector.dataEnd(); | |||||
String encoding = detector.getDetectedCharset(); | |||||
detector.reset(); | |||||
if (encoding == null) { | |||||
encoding = DEFAULT_ENCODING; | |||||
} | |||||
return encoding; | |||||
} | |||||
} |
package com.cbs.company.result; | |||||
public class CodeMsg { | |||||
private int code; | |||||
private String msg; | |||||
//通用的错误码 | |||||
public static CodeMsg SUCCESS = new CodeMsg(0, "success"); | |||||
public static CodeMsg SERVER_ERROR = new CodeMsg(500100, "服务端异常"); | |||||
public static CodeMsg BIND_ERROR = new CodeMsg(500101, "参数校验异常:%s"); | |||||
//登录模块 5002XX | |||||
public static CodeMsg SESSION_ERROR = new CodeMsg(500210, "Session不存在或者已经失效"); | |||||
public static CodeMsg PASSWORD_EMPTY = new CodeMsg(500211, "登录密码不能为空"); | |||||
public static CodeMsg MOBILE_EMPTY = new CodeMsg(500212, "手机号不能为空"); | |||||
public static CodeMsg MOBILE_ERROR = new CodeMsg(500213, "手机号格式错误"); | |||||
public static CodeMsg MOBILE_NOT_EXIST = new CodeMsg(500214, "手机号不存在"); | |||||
public static CodeMsg PASSWORD_ERROR = new CodeMsg(500215, "密码错误"); | |||||
public static CodeMsg IMG_NOT_EMPTY = new CodeMsg(500215, "图片不能为空"); | |||||
public static CodeMsg IMG_FORMAT_ERROR = new CodeMsg(500215, "图片格式错误"); | |||||
//商品模块 5003XX | |||||
//订单模块 5004XX | |||||
//秒杀模块 5005XX | |||||
public static CodeMsg MIAO_SHA_OVER = new CodeMsg(500500, "商品已经秒杀完毕"); | |||||
public static CodeMsg REPEATE_MIAOSHA = new CodeMsg(500501, "不能重复秒杀"); | |||||
private CodeMsg( ) { | |||||
} | |||||
private CodeMsg( int code,String msg ) { | |||||
this.code = code; | |||||
this.msg = msg; | |||||
} | |||||
public int getCode() { | |||||
return code; | |||||
} | |||||
public void setCode(int code) { | |||||
this.code = code; | |||||
} | |||||
public String getMsg() { | |||||
return msg; | |||||
} | |||||
public void setMsg(String msg) { | |||||
this.msg = msg; | |||||
} | |||||
public CodeMsg fillArgs(Object... args) { | |||||
int code = this.code; | |||||
String message = String.format(this.msg, args); | |||||
return new CodeMsg(code, message); | |||||
} | |||||
@Override | |||||
public String toString() { | |||||
return "CodeMsg [code=" + code + ", msg=" + msg + "]"; | |||||
} | |||||
} |
package com.cbs.company.result; | |||||
public class Result<T> { | |||||
private int code; | |||||
private String msg; | |||||
private T data; | |||||
private int total; | |||||
private int err; | |||||
/** | |||||
* 成功时候的调用 | |||||
* */ | |||||
public static <T> Result<T> success(T data){ | |||||
return new Result<T>(data); | |||||
} | |||||
/** | |||||
* 成功时候的调用 | |||||
* */ | |||||
public static <T> Result<T> success_byList(T data,int total){ | |||||
return new Result<T>(1,"操作成功",total,data); | |||||
} | |||||
public int getErr() { | |||||
return err; | |||||
} | |||||
public void setErr(int err) { | |||||
this.err = err; | |||||
} | |||||
/** | |||||
* 失败时候的调用 | |||||
* */ | |||||
public static <T> Result<T> error(CodeMsg codeMsg){ | |||||
return new Result<T>(codeMsg); | |||||
} | |||||
private Result(T data) { | |||||
this.data = data; | |||||
} | |||||
private Result(int code, String msg) { | |||||
this.code = code; | |||||
this.msg = msg; | |||||
} | |||||
private Result(int err, String msg,int total,T data) { | |||||
this.err = err; | |||||
this.msg = msg; | |||||
this.total = total; | |||||
this.data = data; | |||||
} | |||||
private Result(CodeMsg codeMsg) { | |||||
if(codeMsg != null) { | |||||
this.code = codeMsg.getCode(); | |||||
this.msg = codeMsg.getMsg(); | |||||
} | |||||
} | |||||
public int getTotal() { | |||||
return total; | |||||
} | |||||
public void setTotal(int total) { | |||||
this.total = total; | |||||
} | |||||
public int getCode() { | |||||
return code; | |||||
} | |||||
public void setCode(int code) { | |||||
this.code = code; | |||||
} | |||||
public String getMsg() { | |||||
return msg; | |||||
} | |||||
public void setMsg(String msg) { | |||||
this.msg = msg; | |||||
} | |||||
public T getData() { | |||||
return data; | |||||
} | |||||
public void setData(T data) { | |||||
this.data = data; | |||||
} | |||||
} |
package com.cbs.company.result; | |||||
public class SearchResult<T> { | |||||
private String msg; | |||||
private T rows; | |||||
private int total; | |||||
private int err; | |||||
/** | |||||
* 成功时候的调用 | |||||
* */ | |||||
public static <T> SearchResult<T> success(T data){ | |||||
return new SearchResult<T>(data); | |||||
} | |||||
/** | |||||
* 失败时候的调用 | |||||
* */ | |||||
public static <T> SearchResult<T> error(){ | |||||
return new SearchResult<T>(null); | |||||
} | |||||
/** | |||||
* 成功时候的调用 | |||||
* */ | |||||
public static <T> SearchResult<T> success_byList(T rows, int total){ | |||||
return new SearchResult<T>(1,"操作成功",total,rows); | |||||
} | |||||
public int getErr() { | |||||
return err; | |||||
} | |||||
public void setErr(int err) { | |||||
this.err = err; | |||||
} | |||||
/** | |||||
* 失败时候的调用 | |||||
* */ | |||||
// public static <T> SearchResult<T> error(CodeMsg codeMsg){ | |||||
// return new SearchResult<T>(codeMsg); | |||||
// } | |||||
private SearchResult(T rows) { | |||||
this.rows = rows; | |||||
} | |||||
private SearchResult(int err, String msg) { | |||||
this.err = err; | |||||
this.msg = msg; | |||||
} | |||||
private SearchResult(int err, String msg, int total, T rows) { | |||||
this.err = err; | |||||
this.msg = msg; | |||||
this.total = total; | |||||
this.rows = rows; | |||||
} | |||||
public int getTotal() { | |||||
return total; | |||||
} | |||||
public void setTotal(int total) { | |||||
this.total = total; | |||||
} | |||||
public String getMsg() { | |||||
return msg; | |||||
} | |||||
public void setMsg(String msg) { | |||||
this.msg = msg; | |||||
} | |||||
// public T getData() { | |||||
// return data; | |||||
// } | |||||
// public void setData(T data) { | |||||
// this.data = data; | |||||
// } | |||||
public T getRows() { | |||||
return rows; | |||||
} | |||||
public void setRows(T rows) { | |||||
this.rows = rows; | |||||
} | |||||
} |
package com.cbs.company.service; | |||||
import java.util.List; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import com.cbs.company.dao.BagDao; | |||||
import com.cbs.company.domain.Bag; | |||||
import com.cbs.company.vo.BagVo; | |||||
@Service | |||||
public class BagService { | |||||
@Autowired | |||||
BagDao bagDao; | |||||
public List<Bag> getBag(BagVo bagVo) throws Exception { | |||||
return bagDao.getBag(bagVo); | |||||
} | |||||
public int addBag(Bag bag) throws Exception{ | |||||
return bagDao.addBag(bag); | |||||
} | |||||
public int updateBag(Bag bag) throws Exception{ | |||||
return bagDao.updateBag(bag); | |||||
} | |||||
public int deleteBag(int id) throws Exception { | |||||
return bagDao.deleteBag(id); | |||||
} | |||||
} |
package com.cbs.company.service; | |||||
import java.util.List; | |||||
import javax.annotation.Resource; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import com.cbs.company.dao.LoginDao; | |||||
import com.cbs.company.dao.UserInfoDao; | |||||
import com.cbs.company.domain.DeptDO; | |||||
import com.cbs.company.domain.Login; | |||||
import com.cbs.company.domain.RoleDO; | |||||
import com.cbs.company.domain.UserDO; | |||||
import com.cbs.company.entity.UserInfo; | |||||
@Service | |||||
public class LoginService { | |||||
@Autowired | |||||
LoginDao loginDao; | |||||
//用户名,验证码登陆 | |||||
public Login getLogin(Login login) throws Exception{ | |||||
return loginDao.getLogin(login); | |||||
} | |||||
//用户名,验证码登陆 | |||||
public Login getLoginByName(Login login) throws Exception{ | |||||
return loginDao.getLoginByName(login); | |||||
} | |||||
//==============登录获取部门信息开始========================= | |||||
public List<DeptDO> getDeptByName(String name){ | |||||
return loginDao.getDeptByName(name); | |||||
} | |||||
public DeptDO getDeptById(String id){ | |||||
return loginDao.getDeptById(id); | |||||
} | |||||
public List<DeptDO> getAllDeptInfo(){ | |||||
return loginDao.getAllDeptInfo(); | |||||
} | |||||
public List<DeptDO> getParentDeptBydeptid(long deptid){ | |||||
return loginDao.getParentDeptBydeptid(deptid); | |||||
} | |||||
public List<DeptDO> getParentDeptByChilddeptid(long deptid){ | |||||
return loginDao.getParentDeptByChilddeptid(deptid); | |||||
} | |||||
//查询装卸班组长部门 | |||||
public DeptDO getZxzByChilddeptid(long deptid,String lx){ | |||||
return loginDao.getZxzByChilddeptid(deptid,lx); | |||||
} | |||||
//==============登录获取部门信息结束========================= | |||||
@Resource | |||||
private UserInfoDao userInfoDao; | |||||
public UserInfo findByUsername(String username) { | |||||
System.out.println("UserInfoServiceImpl.findByUsername()"); | |||||
return userInfoDao.findByUsername(username); | |||||
} | |||||
public List<UserDO> getUserlist(String userName){ | |||||
return loginDao.list(userName); | |||||
} | |||||
public List<UserDO> getUserlistByPhone(String phone){ | |||||
return loginDao.listByPhone(phone); | |||||
} | |||||
public List<UserDO> getlistByOpenid(String openid){ | |||||
return loginDao.getlistByOpenid(openid); | |||||
} | |||||
public List<DeptDO> getDeptByOpenid(String openid){ | |||||
return loginDao.getDeptByOpenid(openid); | |||||
} | |||||
public List<DeptDO> getDeptByPhone(String phone){ | |||||
return loginDao.getDeptByPhone(phone); | |||||
} | |||||
public List<DeptDO> getParentDeptByOpenid(long deptid){ | |||||
return loginDao.getParentDeptByOpenid(deptid); | |||||
} | |||||
public List<RoleDO> getRoleByDeptShortName(String name){ | |||||
return loginDao.getRoleByDeptShortName(name); | |||||
} | |||||
public List<RoleDO> getRoleByUserId(Long userid){ | |||||
return loginDao.getRoleByUserId(userid); | |||||
} | |||||
public List<UserDO> getlistByPhone(String phone){ | |||||
return loginDao.getlistByPhone(phone); | |||||
} | |||||
public int updateUserByPhone(UserDO userDO){ | |||||
return loginDao.updateUserByPhone(userDO); | |||||
} | |||||
public int updatePasswordByOpenid(UserDO userDO){ | |||||
return loginDao.updatePasswordByOpenid(userDO); | |||||
} | |||||
public int updatePhoneByOpenid(UserDO userDO){ | |||||
return loginDao.updatePhoneByOpenid(userDO); | |||||
} | |||||
public int addUser(UserDO userDO){ | |||||
return loginDao.addUser(userDO); | |||||
} | |||||
public int addUserRole(Long userid,Long roleid){ | |||||
return loginDao.addUserRole( userid, roleid); | |||||
} | |||||
public int updateUser(UserDO userDO){ | |||||
return loginDao.updateUser( userDO); | |||||
} | |||||
public int updateUserRole(Long userid,Long roleid){ | |||||
return loginDao.updateUserRole( userid, roleid); | |||||
} | |||||
public String getPhoneByOpenid(String phone){ | |||||
return loginDao.getPhoneByOpenid(phone); | |||||
} | |||||
public String getRolenameByPhone(String phone) { | |||||
return loginDao.getRolenameByPhone(phone); | |||||
} | |||||
} |
package com.cbs.company.service; | |||||
import com.cbs.company.dao.*; | |||||
import org.apache.commons.lang.StringUtils; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.*; | |||||
@Service | |||||
public class MenuService { | |||||
@Autowired | |||||
MenuDao menuDao; | |||||
public Set<String> listPerms(Long userId) { | |||||
List<String> perms = menuDao.listUserPerms(userId); | |||||
Set<String> permsSet = new HashSet<String>(); | |||||
for (String perm : perms) { | |||||
if (StringUtils.isNotBlank(perm)) { | |||||
permsSet.addAll(Arrays.asList(perm.trim().split(","))); | |||||
} | |||||
} | |||||
return permsSet; | |||||
} | |||||
} |
package com.cbs.company.service; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import org.springframework.transaction.annotation.Transactional; | |||||
import com.cbs.company.dao.UserDao; | |||||
import com.cbs.company.domain.User; | |||||
@Service | |||||
public class UserService { | |||||
@Autowired | |||||
UserDao userDao; | |||||
@Transactional | |||||
public boolean tx() { | |||||
User u1= new User(); | |||||
u1.setId(2); | |||||
u1.setName("2222"); | |||||
userDao.insert(u1); | |||||
User u2= new User(); | |||||
u2.setId(1); | |||||
u2.setName("11111"); | |||||
userDao.insert(u2); | |||||
return true; | |||||
} | |||||
public static void main(String[] args) { | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import java.io.InputStream; | |||||
import java.util.Date; | |||||
import java.util.Random; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.HashMap; | |||||
import java.io.BufferedReader; | |||||
import java.io.InputStreamReader; | |||||
import com.alibaba.fastjson.JSON; | |||||
import com.alibaba.fastjson.JSONObject; | |||||
import com.alibaba.fastjson.JSONArray; | |||||
public class Base { | |||||
public static Random m_random = new Random(); | |||||
public static String version=""; | |||||
public static HashMap<String, String> m_mapAddress = new HashMap<String, String>(); | |||||
public static void log(String msg) | |||||
{ | |||||
Date d = new Date(); | |||||
System.out.println("["+d+"] "+msg); | |||||
} | |||||
public static void dlog(String msg) | |||||
{ | |||||
System.out.println(">> "+msg); | |||||
} | |||||
public static void tlog(String msg) | |||||
{ | |||||
System.out.println("--> "+msg); | |||||
} | |||||
public static String getAddressByCode(String code){ | |||||
if(m_mapAddress.isEmpty()){ | |||||
return ""; | |||||
} | |||||
String ret = m_mapAddress.get(code); | |||||
if(ret==null){ | |||||
return ""; | |||||
} | |||||
return ret; | |||||
} | |||||
public static boolean parseAddressJson(InputStream inputStream){ | |||||
if(inputStream==null){ | |||||
return false; | |||||
} | |||||
StringBuilder sb = new StringBuilder(); | |||||
String line; | |||||
try{ | |||||
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); | |||||
while ((line = br.readLine()) != null) { | |||||
sb.append(line); | |||||
} | |||||
String str = sb.toString(); | |||||
Base.log(str.substring(0,100)); | |||||
try{ | |||||
JSONArray arr1= JSON.parseArray(str); | |||||
for(int i=0;i<arr1.size();i++) { | |||||
JSONObject object = (JSONObject) arr1.get(i); | |||||
String code = object.getString("code"); | |||||
String name = object.getString("name"); | |||||
//Base.tlog("code="+code+",name="+name); | |||||
m_mapAddress.put(code, name); | |||||
JSONArray arr2 = object.getJSONArray("childs"); | |||||
for (int j = 0; j < arr2.size(); j++){ | |||||
JSONObject object2 = (JSONObject) arr2.get(j); | |||||
String code2 = object2.getString("code"); | |||||
String name2 = object2.getString("name"); | |||||
//Base.tlog("code2="+code2+",name2="+name2); | |||||
m_mapAddress.put(code2, name2); | |||||
JSONArray arr3 =object2.getJSONArray("childs"); | |||||
for(int z=0;z<arr3.size();z++){ | |||||
JSONObject object3 = (JSONObject) arr3.get(z); | |||||
String code3 = object3.getString("code"); | |||||
String name3 = object3.getString("name"); | |||||
//Base.tlog("code3="+code3+",name3="+name3); | |||||
m_mapAddress.put(code3, name3); | |||||
} | |||||
} | |||||
} | |||||
}catch (Exception e2){ | |||||
e2.printStackTrace(); | |||||
return false; | |||||
} | |||||
return true; | |||||
}catch (Exception e){ | |||||
e.printStackTrace(); | |||||
} | |||||
return false; | |||||
} | |||||
public static long createCurrentTimeLong() | |||||
{ | |||||
long currentTime = System.currentTimeMillis()/1000; | |||||
return currentTime; | |||||
} | |||||
public static String getRandomString(int length){ | |||||
String str="$abcdefghijklmnopqrstuvwxyz!$ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789()"; | |||||
Random random=new Random(); | |||||
StringBuffer sb=new StringBuffer(); | |||||
int len=str.length(); | |||||
for(int i=0;i<length;i++){ | |||||
int number=random.nextInt(len); | |||||
sb.append(str.charAt(number)); | |||||
} | |||||
return sb.toString(); | |||||
} | |||||
public static int getRandom(int bound){ | |||||
Random random=new Random(); | |||||
return random.nextInt(bound); | |||||
} | |||||
public static boolean isRandom(int bound){ | |||||
Random random=new Random(); | |||||
if(random.nextInt(bound)==0){ | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
public static String getDateTimeNow(){ | |||||
Date dNow = new Date( ); | |||||
SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss"); | |||||
return ft.format(dNow); | |||||
} | |||||
public static void main(String[] args) { | |||||
String ss = Base.getAddressByCode("1503"); | |||||
System.out.println("======="+ss); | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
public class CalculateUtils { | |||||
/** | |||||
* get days in this year | |||||
* | |||||
* @param year | |||||
* @param month | |||||
* @param day | |||||
* @return | |||||
*/ | |||||
public static int getDaysInYear(int year, int month, int day) { | |||||
/*平年二月28天*/ | |||||
final int DAYS_28 = 28; | |||||
/*闰年二月29天*/ | |||||
final int DAYS_29 = 29; | |||||
/*除了31天的月份,4、6、9、11其他均为30天*/ | |||||
final int DAYS_30 = 30; | |||||
/*1、3、5、7、8、10、12月份31天*/ | |||||
final int DAYS_31 = 31; | |||||
int totalDays = 0; | |||||
switch (month) { | |||||
// 12 月份加的是11月份的天数,依次类推 | |||||
case 12: | |||||
totalDays += DAYS_30; | |||||
case 11: | |||||
totalDays += DAYS_31; | |||||
case 10: | |||||
totalDays += DAYS_30; | |||||
case 9: | |||||
totalDays += DAYS_31; | |||||
case 8: | |||||
totalDays += DAYS_31; | |||||
case 7: | |||||
totalDays += DAYS_30; | |||||
case 6: | |||||
totalDays += DAYS_31; | |||||
case 5: | |||||
totalDays += DAYS_30; | |||||
case 4: | |||||
totalDays += DAYS_31; | |||||
case 3: | |||||
// 判断是否是闰年 | |||||
if (((year / 4 == 0) && (year / 100 != 0)) || (year / 400 == 0)) { | |||||
totalDays += DAYS_29; | |||||
} else { | |||||
totalDays += DAYS_28; | |||||
} | |||||
case 2: | |||||
totalDays += DAYS_31; | |||||
case 1: // 如果是1月份就加上输入的天数 | |||||
totalDays += day; | |||||
} | |||||
return totalDays; | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import com.qiniu.common.Constants; | |||||
import com.qiniu.common.QiniuException; | |||||
import com.qiniu.common.Zone; | |||||
import com.qiniu.common.ZoneReqInfo; | |||||
import com.qiniu.http.Dns; | |||||
import com.qiniu.http.ProxyConfiguration; | |||||
/** | |||||
* 该类封装了SDK相关配置参数 | |||||
*/ | |||||
public final class Configuration implements Cloneable { | |||||
/** | |||||
* 使用的Zone | |||||
*/ | |||||
public Zone zone; | |||||
/** | |||||
* 空间相关上传管理操作是否使用 https , 默认 是 | |||||
*/ | |||||
public boolean useHttpsDomains = true; | |||||
/** | |||||
* 如果文件大小大于此值则使用断点上传, 否则使用Form上传 | |||||
*/ | |||||
public int putThreshold = Constants.BLOCK_SIZE; | |||||
/** | |||||
* 连接超时时间 单位秒(默认10s) | |||||
*/ | |||||
public int connectTimeout = Constants.CONNECT_TIMEOUT; | |||||
/** | |||||
* 写超时时间 单位秒(默认 0 , 不超时) | |||||
*/ | |||||
public int writeTimeout = Constants.WRITE_TIMEOUT; | |||||
/** | |||||
* 回复超时时间 单位秒(默认30s) | |||||
*/ | |||||
public int readTimeout = Constants.READ_TIMEOUT; | |||||
/** | |||||
* 底层HTTP库所有的并发执行的请求数量 | |||||
*/ | |||||
public int dispatcherMaxRequests = Constants.DISPATCHER_MAX_REQUESTS; | |||||
/** | |||||
* 底层HTTP库对每个独立的Host进行并发请求的数量 | |||||
*/ | |||||
public int dispatcherMaxRequestsPerHost = Constants.DISPATCHER_MAX_REQUESTS_PER_HOST; | |||||
/** | |||||
* 底层HTTP库中复用连接对象的最大空闲数量 | |||||
*/ | |||||
public int connectionPoolMaxIdleCount = Constants.CONNECTION_POOL_MAX_IDLE_COUNT; | |||||
/** | |||||
* 底层HTTP库中复用连接对象的回收周期(单位分钟) | |||||
*/ | |||||
public int connectionPoolMaxIdleMinutes = Constants.CONNECTION_POOL_MAX_IDLE_MINUTES; | |||||
/** | |||||
* 上传失败重试次数 | |||||
*/ | |||||
public int retryMax = 5; | |||||
/** | |||||
* 外部dns | |||||
*/ | |||||
public Dns dns; | |||||
/* | |||||
* 解析域名时,优先使用host配置,主要针对内部局域网配置 | |||||
*/ | |||||
public boolean useDnsHostFirst; | |||||
/** | |||||
* 代理对象 | |||||
*/ | |||||
public ProxyConfiguration proxy; | |||||
/** | |||||
* 特殊默认域名 | |||||
*/ | |||||
public static String defaultRsHost = "rs.qiniu.com"; | |||||
public static String defaultApiHost = "api.qiniu.com"; | |||||
public static String defaultUcHost = "uc.qbox.me"; | |||||
public Configuration() { | |||||
} | |||||
public Configuration(Zone zone) { | |||||
this.zone = zone; | |||||
} | |||||
public Configuration clone() { | |||||
try { | |||||
return (Configuration) super.clone(); | |||||
} catch (CloneNotSupportedException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
return null; | |||||
} | |||||
public String upHost(String upToken) throws QiniuException { | |||||
ZoneReqInfo zoneReqInfo = new ZoneReqInfo(upToken); | |||||
if (zone == null) { | |||||
zone = Zone.autoZone(); | |||||
} | |||||
return useHttpsDomains ? zone.getUpHttps(zoneReqInfo) | |||||
: zone.getUpHttp(zoneReqInfo); | |||||
} | |||||
public String upHostBackup(String upToken) throws QiniuException { | |||||
ZoneReqInfo zoneReqInfo = new ZoneReqInfo(upToken); | |||||
if (zone == null) { | |||||
zone = Zone.autoZone(); | |||||
} | |||||
return useHttpsDomains ? zone.getUpBackupHttps(zoneReqInfo) | |||||
: zone.getUpBackupHttp(zoneReqInfo); | |||||
} | |||||
public String ioHost(String ak, String bucket) { | |||||
ZoneReqInfo zoneReqInfo = new ZoneReqInfo(ak, bucket); | |||||
if (zone == null) { | |||||
zone = Zone.autoZone(); | |||||
} | |||||
return useHttpsDomains ? zone.getIovipHttps(zoneReqInfo) | |||||
: zone.getIovipHttp(zoneReqInfo); | |||||
} | |||||
public String apiHost(String ak, String bucket) { | |||||
ZoneReqInfo zoneReqInfo = new ZoneReqInfo(ak, bucket); | |||||
if (zone == null) { | |||||
zone = Zone.autoZone(); | |||||
} | |||||
return useHttpsDomains ? zone.getApiHttps(zoneReqInfo) | |||||
: zone.getApiHttp(zoneReqInfo); | |||||
} | |||||
public String rsHost() { | |||||
String scheme = "http://"; | |||||
if (useHttpsDomains) { | |||||
scheme = "https://"; | |||||
} | |||||
return scheme + defaultRsHost; | |||||
} | |||||
public String apiHost() { | |||||
String scheme = "http://"; | |||||
if (useHttpsDomains) { | |||||
scheme = "https://"; | |||||
} | |||||
return scheme + defaultApiHost; | |||||
} | |||||
public String rsHost(String ak, String bucket) { | |||||
ZoneReqInfo zoneReqInfo = new ZoneReqInfo(ak, bucket); | |||||
if (zone == null) { | |||||
zone = Zone.autoZone(); | |||||
} | |||||
return useHttpsDomains ? zone.getRsHttps(zoneReqInfo) | |||||
: zone.getRsHttp(zoneReqInfo); | |||||
} | |||||
public String rsfHost(String ak, String bucket) { | |||||
ZoneReqInfo zoneReqInfo = new ZoneReqInfo(ak, bucket); | |||||
if (zone == null) { | |||||
zone = Zone.autoZone(); | |||||
} | |||||
return useHttpsDomains ? zone.getRsfHttps(zoneReqInfo) | |||||
: zone.getRsfHttp(zoneReqInfo); | |||||
} | |||||
public String ucHost() { | |||||
String scheme = "http://"; | |||||
if (useHttpsDomains) { | |||||
scheme = "https://"; | |||||
} | |||||
return scheme + defaultUcHost; | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.Date; | |||||
/** | |||||
* date util | |||||
* | |||||
* @author Eric.Sung | |||||
* @date 2016.10.17 | |||||
* | |||||
*/ | |||||
public class DateUtil { | |||||
/** | |||||
* date to string | |||||
* | |||||
* @author Eric.Sung | |||||
* @date 2016.10.17 | |||||
*/ | |||||
public static String dateToString(Date date) { | |||||
// sdf | |||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||||
return sdf.format(date); | |||||
} | |||||
/** | |||||
* date to string 12h | |||||
* | |||||
* @author Eric.Sung | |||||
* @date 2016.10.17 | |||||
*/ | |||||
public static String dateToString12Hour(Date date) { | |||||
// sdf | |||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); | |||||
return sdf.format(date); | |||||
} | |||||
/** | |||||
* date to string | |||||
* | |||||
* @author Eric.Sung | |||||
* @date 2016.10.17 | |||||
*/ | |||||
public static String dateToStringYMD(Date date) { | |||||
// sdf | |||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |||||
return sdf.format(date); | |||||
} | |||||
/** | |||||
* string to date | |||||
* | |||||
* @author Eric.Sung | |||||
* @date 2016.10.17 | |||||
*/ | |||||
public static Date stringToDate(String date) throws Exception { | |||||
// sdf | |||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||||
return sdf.parse(date); | |||||
} | |||||
/** | |||||
* string to date | |||||
* | |||||
* @author Eric.Sung | |||||
* @date 2016.10.17 | |||||
*/ | |||||
public static String DateToStringMMddHHmmss(Date date) throws Exception { | |||||
// sdf | |||||
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm:ss"); | |||||
return sdf.format(date); | |||||
} | |||||
/** | |||||
* string to date | |||||
* | |||||
* @author Eric.Sung | |||||
* @date 2016.10.17 | |||||
*/ | |||||
public static Date stringToDateYMD(String date) throws Exception { | |||||
// sdf | |||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |||||
return sdf.parse(date); | |||||
} | |||||
/** | |||||
* string to date | |||||
* | |||||
* @author Eric.Sung | |||||
* @date 2016.10.17 | |||||
*/ | |||||
public static Date stringToMonth(String date) throws Exception { | |||||
// sdf | |||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); | |||||
return sdf.parse(date); | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import java.io.File; | |||||
import java.io.FileOutputStream; | |||||
public class FileUtil { | |||||
public static void uploadFile(byte[] file, String filePath, String fileName) throws Exception { | |||||
File targetFile = new File(filePath); | |||||
if(!targetFile.exists()){ | |||||
targetFile.mkdirs(); | |||||
} | |||||
FileOutputStream out = new FileOutputStream(filePath+fileName); | |||||
out.write(file); | |||||
out.flush(); | |||||
out.close(); | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import org.apache.http.*; | |||||
import org.apache.http.client.ClientProtocolException; | |||||
import org.apache.http.client.HttpClient; | |||||
import org.apache.http.client.config.RequestConfig; | |||||
import org.apache.http.client.config.RequestConfig.Builder; | |||||
import org.apache.http.client.entity.UrlEncodedFormEntity; | |||||
import org.apache.http.client.methods.CloseableHttpResponse; | |||||
import org.apache.http.client.methods.HttpGet; | |||||
import org.apache.http.client.methods.HttpPost; | |||||
import org.apache.http.client.protocol.HttpClientContext; | |||||
import org.apache.http.entity.ContentType; | |||||
import org.apache.http.entity.StringEntity; | |||||
import org.apache.http.impl.client.CloseableHttpClient; | |||||
import org.apache.http.impl.client.HttpClientBuilder; | |||||
import org.apache.http.impl.client.HttpClients; | |||||
import org.apache.http.message.BasicNameValuePair; | |||||
import org.apache.http.protocol.BasicHttpContext; | |||||
import org.apache.http.protocol.HttpContext; | |||||
import org.apache.http.util.EntityUtils; | |||||
import java.io.IOException; | |||||
import java.util.*; | |||||
import java.util.Map.Entry; | |||||
/** | |||||
* @author wangchen http请求工具类,用于通过java代码访问某支持http协议的服务端 | |||||
*/ | |||||
public class HttpUtils { | |||||
/** | |||||
* 结果key名称 | |||||
*/ | |||||
public static final String RESULT = "result"; | |||||
/** | |||||
* 状态key名称 | |||||
*/ | |||||
public static final String STATUS_CODE = "statusCode"; | |||||
public static String encoding = "UTF-8"; | |||||
public static int connTimeOut = 8; | |||||
public static int soTimeOut = 10; | |||||
public static List<NameValuePair> map2pairList(Map<String, String> map) { | |||||
List<NameValuePair> list = new ArrayList<NameValuePair>(); | |||||
Iterator<Entry<String, String>> it = map.entrySet().iterator(); | |||||
while (it.hasNext()) { | |||||
Entry<String, String> entry = it.next(); | |||||
NameValuePair pair = new BasicNameValuePair(entry.getKey(), entry.getValue()); | |||||
list.add(pair); | |||||
} | |||||
return list; | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 | |||||
*/ | |||||
public static Map<String, String> get(String url) { | |||||
return get(url, new BasicHttpContext(), encoding); | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @param charactor | |||||
* 字符集 | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 | |||||
*/ | |||||
public static Map<String, String> get(String url, String charactor) { | |||||
CloseableHttpClient httpClient = null; | |||||
CloseableHttpResponse response = null; | |||||
Builder builder = RequestConfig.custom(); | |||||
builder.setConnectionRequestTimeout(connTimeOut * 1000); | |||||
builder.setConnectTimeout(connTimeOut * 1000); | |||||
builder.setSocketTimeout(soTimeOut * 1000); | |||||
HttpGet httpGet = new HttpGet(url); | |||||
httpGet.setConfig(builder.build()); | |||||
String str = ""; | |||||
int code = 0; | |||||
Map<String, String> resultMap = new HashMap<String, String>(); | |||||
try { | |||||
httpClient = HttpClients.createDefault(); | |||||
response = httpClient.execute(httpGet, HttpClientContext.create()); | |||||
HttpEntity entity = response.getEntity(); | |||||
if (entity != null) { | |||||
str = EntityUtils.toString(entity, charactor); | |||||
code = response.getStatusLine().getStatusCode(); | |||||
resultMap.put(RESULT, str); | |||||
} | |||||
resultMap.put(STATUS_CODE, String.valueOf(code)); | |||||
} catch (ClientProtocolException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} finally { | |||||
try { | |||||
response.close(); | |||||
httpClient.close(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
return resultMap; | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @param context | |||||
* http请求上下文根,其中保存了cookie等信息 | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 | |||||
*/ | |||||
public static Map<String, String> get(String url, HttpContext context) { | |||||
return get(url, context, encoding); | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @param context | |||||
* http请求上下文根,其中保存了cookie等信息 | |||||
* @param charactor | |||||
* 字符集 | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 | |||||
*/ | |||||
public static Map<String, String> get(String url, HttpContext context, String charactor) { | |||||
CloseableHttpClient httpClient = null; | |||||
CloseableHttpResponse response = null; | |||||
Builder builder = RequestConfig.custom(); | |||||
builder.setConnectionRequestTimeout(connTimeOut * 1000); | |||||
builder.setConnectTimeout(connTimeOut * 1000); | |||||
builder.setSocketTimeout(soTimeOut * 1000); | |||||
HttpGet httpGet = new HttpGet(url); | |||||
httpGet.setConfig(builder.build()); | |||||
String str = ""; | |||||
int code = 0; | |||||
Map<String, String> resultMap = new HashMap<String, String>(); | |||||
try { | |||||
httpClient = HttpClients.createDefault(); | |||||
response = httpClient.execute(httpGet, context); | |||||
HttpEntity entity = response.getEntity(); | |||||
if (entity != null) { | |||||
str = EntityUtils.toString(entity, charactor); | |||||
code = response.getStatusLine().getStatusCode(); | |||||
resultMap.put(RESULT, str); | |||||
} | |||||
resultMap.put(STATUS_CODE, String.valueOf(code)); | |||||
} catch (ClientProtocolException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} finally { | |||||
try { | |||||
response.close(); | |||||
httpClient.close(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
return resultMap; | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 | |||||
*/ | |||||
public static Map<String, String> post(String url) { | |||||
return post(url, new HashMap<String, String>(), new BasicHttpContext(), encoding); | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @param params | |||||
* map类型参数 | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 | |||||
*/ | |||||
public static Map<String, String> post(String url, Map<String, String> params) { | |||||
return post(url, params, new BasicHttpContext(), encoding, connTimeOut, soTimeOut); | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @param params | |||||
* map类型参数 | |||||
* @param soTimeOut | |||||
* 数据传输超时时间(秒) | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 | |||||
*/ | |||||
public static Map<String, String> post(String url, Map<String, String> params, int soTimeOut) { | |||||
return post(url, params, new BasicHttpContext(), encoding, connTimeOut, soTimeOut); | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @param params | |||||
* map类型参数 | |||||
* @param connTimeOut | |||||
* 连接超时时间(秒) | |||||
* @param soTimeOut | |||||
* 数据传输超时时间(秒) | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 | |||||
*/ | |||||
public static Map<String, String> post(String url, Map<String, String> params, int conntimeOut, int soTimeOut) { | |||||
return post(url, params, new BasicHttpContext(), encoding, conntimeOut, soTimeOut); | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @param params | |||||
* map类型参数 | |||||
* @param context | |||||
* http请求上下文根,其中保存了cookie等信息 | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 | |||||
*/ | |||||
public static Map<String, String> post(String url, Map<String, String> params, HttpContext context) { | |||||
return post(url, params, context, encoding); | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @param params | |||||
* string类型参数 | |||||
* @param context | |||||
* http请求上下文根,其中保存了cookie等信息 | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 | |||||
*/ | |||||
public static Map<String, String> post(String url, String params, int connTimeOut, int soTimeOut) { | |||||
return post(url, params, new BasicHttpContext(), encoding, connTimeOut, soTimeOut); | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @param params | |||||
* map类型参数 | |||||
* @param charactor | |||||
* 字符集 | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 | |||||
*/ | |||||
public static Map<String, String> post(String url, Map<String, String> params, String charactor) { | |||||
CloseableHttpClient httpClient = null; | |||||
CloseableHttpResponse response = null; | |||||
Builder builder = RequestConfig.custom(); | |||||
builder.setConnectionRequestTimeout(connTimeOut * 1000); | |||||
builder.setConnectTimeout(connTimeOut * 1000); | |||||
builder.setSocketTimeout(soTimeOut * 1000); | |||||
HttpPost httpPost = new HttpPost(url); | |||||
httpPost.setConfig(builder.build()); | |||||
UrlEncodedFormEntity uefEntity; | |||||
String str = ""; | |||||
int code = 0; | |||||
Map<String, String> resultMap = new HashMap<String, String>(); | |||||
try { | |||||
httpClient = HttpClients.createDefault(); | |||||
uefEntity = new UrlEncodedFormEntity(map2pairList(params), charactor); | |||||
httpPost.setEntity(uefEntity); | |||||
response = httpClient.execute(httpPost, HttpClientContext.create()); | |||||
HttpEntity entity = response.getEntity(); | |||||
if (entity != null) { | |||||
str = EntityUtils.toString(entity, charactor); | |||||
code = response.getStatusLine().getStatusCode(); | |||||
resultMap.put(RESULT, str); | |||||
} | |||||
resultMap.put(STATUS_CODE, String.valueOf(code)); | |||||
} catch (ClientProtocolException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} finally { | |||||
try { | |||||
response.close(); | |||||
httpClient.close(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
return resultMap; | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @param params | |||||
* map类型参数 | |||||
* @param context | |||||
* http请求上下文根,其中保存了cookie等信息 | |||||
* @param charactor | |||||
* 字符集 | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 备注:通过map取值时建议使用如下方式: | |||||
* map.get(HttpUtils.RESULT) map.get(HttpUtils.STATUS_CODE) | |||||
*/ | |||||
public static Map<String, String> post(String url, Map<String, String> params, HttpContext context, String charactor) { | |||||
CloseableHttpClient httpClient = null; | |||||
CloseableHttpResponse response = null; | |||||
Builder builder = RequestConfig.custom(); | |||||
builder.setConnectionRequestTimeout(connTimeOut * 1000); | |||||
builder.setConnectTimeout(connTimeOut * 1000); | |||||
builder.setSocketTimeout(soTimeOut * 1000); | |||||
HttpPost httpPost = new HttpPost(url); | |||||
httpPost.setConfig(builder.build()); | |||||
UrlEncodedFormEntity uefEntity; | |||||
String str = ""; | |||||
int code = 0; | |||||
Map<String, String> resultMap = new HashMap<String, String>(); | |||||
try { | |||||
httpClient = HttpClients.createDefault(); | |||||
uefEntity = new UrlEncodedFormEntity(map2pairList(params), charactor); | |||||
httpPost.setEntity(uefEntity); | |||||
response = httpClient.execute(httpPost, context); | |||||
HttpEntity entity = response.getEntity(); | |||||
if (entity != null) { | |||||
str = EntityUtils.toString(entity, charactor); | |||||
code = response.getStatusLine().getStatusCode(); | |||||
resultMap.put(RESULT, str); | |||||
} | |||||
resultMap.put(STATUS_CODE, String.valueOf(code)); | |||||
} catch (ClientProtocolException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} finally { | |||||
try { | |||||
response.close(); | |||||
httpClient.close(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
return resultMap; | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @param params | |||||
* map类型参数 | |||||
* @param context | |||||
* http请求上下文根,其中保存了cookie等信息 | |||||
* @param charactor | |||||
* 字符集 | |||||
* @param connTimeOut | |||||
* 连接超时时间(秒) | |||||
* @param soTimeOut | |||||
* 数据传输超时时间(秒) | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 备注:通过map取值时建议使用如下方式: | |||||
* map.get(HttpUtils.RESULT) map.get(HttpUtils.STATUS_CODE) | |||||
*/ | |||||
public static Map<String, String> post(String url, Map<String, String> params, HttpContext context, String charactor, int connTimeOut, int soTimeOut) { | |||||
CloseableHttpClient httpClient = null; | |||||
CloseableHttpResponse response = null; | |||||
Builder builder = RequestConfig.custom(); | |||||
builder.setConnectionRequestTimeout(connTimeOut * 1000); | |||||
builder.setConnectTimeout(connTimeOut * 1000); | |||||
builder.setSocketTimeout(soTimeOut * 1000); | |||||
HttpPost httpPost = new HttpPost(url); | |||||
httpPost.setConfig(builder.build()); | |||||
UrlEncodedFormEntity uefEntity; | |||||
String str = ""; | |||||
int code = 0; | |||||
Map<String, String> resultMap = new HashMap<String, String>(); | |||||
try { | |||||
httpClient = HttpClients.createDefault(); | |||||
uefEntity = new UrlEncodedFormEntity(map2pairList(params), charactor); | |||||
httpPost.setEntity(uefEntity); | |||||
response = httpClient.execute(httpPost, context); | |||||
HttpEntity entity = response.getEntity(); | |||||
if (entity != null) { | |||||
str = EntityUtils.toString(entity, charactor); | |||||
code = response.getStatusLine().getStatusCode(); | |||||
resultMap.put(RESULT, str); | |||||
} | |||||
resultMap.put(STATUS_CODE, String.valueOf(code)); | |||||
} catch (ClientProtocolException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} finally { | |||||
try { | |||||
response.close(); | |||||
httpClient.close(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
return resultMap; | |||||
} | |||||
/** | |||||
* @param url | |||||
* 请求地址 | |||||
* @param params | |||||
* string类型参数 | |||||
* @param context | |||||
* http请求上下文根,其中保存了cookie等信息 | |||||
* @param charactor | |||||
* 字符集 | |||||
* @param connTimeOut | |||||
* 连接超时时间(秒) | |||||
* @param soTimeOut | |||||
* 数据传输超时时间(秒) | |||||
* @return 返回结果为map形式,目前包含两对键值对,消息与状态码 备注:通过map取值时建议使用如下方式: | |||||
* map.get(HttpUtils.RESULT) map.get(HttpUtils.STATUS_CODE) | |||||
*/ | |||||
public static Map<String, String> post(String url, String params, HttpContext context, String charactor, int connTimeOut, int soTimeOut) { | |||||
CloseableHttpClient httpClient = null; | |||||
CloseableHttpResponse response = null; | |||||
Builder builder = RequestConfig.custom(); | |||||
builder.setConnectionRequestTimeout(connTimeOut * 1000); | |||||
builder.setConnectTimeout(connTimeOut * 1000); | |||||
builder.setSocketTimeout(soTimeOut * 1000); | |||||
HttpPost httpPost = new HttpPost(url); | |||||
httpPost.setConfig(builder.build()); | |||||
String str = ""; | |||||
int code = 0; | |||||
Map<String, String> resultMap = new HashMap<String, String>(); | |||||
try { | |||||
httpClient = HttpClients.createDefault(); | |||||
httpPost.setEntity(new StringEntity(params, charactor)); | |||||
response = httpClient.execute(httpPost, context); | |||||
HttpEntity entity = response.getEntity(); | |||||
if (entity != null) { | |||||
str = EntityUtils.toString(entity, charactor); | |||||
code = response.getStatusLine().getStatusCode(); | |||||
resultMap.put(RESULT, str); | |||||
} | |||||
resultMap.put(STATUS_CODE, String.valueOf(code)); | |||||
} catch (ClientProtocolException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} finally { | |||||
try { | |||||
response.close(); | |||||
httpClient.close(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
return resultMap; | |||||
} | |||||
public static Map<String, String> post(String url, String params){ | |||||
HttpClient client = HttpClientBuilder.create().build(); | |||||
HttpPost post = new HttpPost(url); | |||||
String str = ""; | |||||
HttpEntity entity = new StringEntity(params, ContentType.APPLICATION_JSON); | |||||
post.setEntity(entity); | |||||
Map<String, String> resultMap = new HashMap<String, String>(); | |||||
try { | |||||
HttpResponse response = client.execute(post); | |||||
StatusLine line = response.getStatusLine(); | |||||
if (line.getStatusCode() == HttpStatus.SC_OK) { | |||||
str = EntityUtils.toString(response.getEntity()); | |||||
resultMap.put(RESULT, str); | |||||
} | |||||
resultMap.put(STATUS_CODE, String.valueOf(line.getStatusCode())); | |||||
return resultMap; | |||||
} catch (ClientProtocolException e) { | |||||
e.printStackTrace(); | |||||
return resultMap; | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
return resultMap; | |||||
} finally { | |||||
post.releaseConnection(); | |||||
} | |||||
} | |||||
@SuppressWarnings("null") | |||||
public static void main(String[] arg){ | |||||
String url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; | |||||
String params = "<xml>"+ | |||||
"<appid>wx2421b1c4370ec43b</appid>"+ | |||||
"<attach>支付测试</attach>"+ | |||||
"<body>JSAPI支付测试</body>"+ | |||||
"<mch_id>10000100</mch_id>"+ | |||||
"<detail><![CDATA[{ \"goods_detail\":[ { \"goods_id\":\"iphone6s_16G\", \"wxpay_goods_id\":\"1001\", \"goods_name\":\"iPhone6s 16G\", \"quantity\":1, \"price\":528800, \"goods_category\":\"123456\", \"body\":\"苹果手机\" }, { \"goods_id\":\"iphone6s_32G\", \"wxpay_goods_id\":\"1002\", \"goods_name\":\"iPhone6s 32G\", \"quantity\":1, \"price\":608800, \"goods_category\":\"123789\", \"body\":\"苹果手机\" } ] }]]></detail>"+ | |||||
"<nonce_str>1add1a30ac87aa2db72f57a2375d8fec</nonce_str>"+ | |||||
"<notify_url>http://wxpay.wxutil.com/pub_v2/pay/notify.v2.php</notify_url>"+ | |||||
"<openid>oUpF8uMuAJO_M2pxb1Q9zNjWeS6o</openid>"+ | |||||
"<out_trade_no>1415659990</out_trade_no>"+ | |||||
"<spbill_create_ip>14.23.150.211</spbill_create_ip>"+ | |||||
"<total_fee>1</total_fee>"+ | |||||
"<trade_type>JSAPI</trade_type>"+ | |||||
"<sign>0CB01533B8C1EF103065174F50BCA001</sign>"+ | |||||
"</xml>"; | |||||
Map<String , String> map = post(url, params,5,5); | |||||
System.out.println(map); | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import java.security.GeneralSecurityException; | |||||
import java.util.Map; | |||||
import javax.net.ssl.HttpsURLConnection; | |||||
import javax.net.ssl.SSLContext; | |||||
import javax.net.ssl.X509TrustManager; | |||||
import com.google.gson.JsonObject; | |||||
import org.apache.commons.lang.StringUtils; | |||||
import org.apache.commons.logging.Log; | |||||
import org.apache.commons.logging.LogFactory; | |||||
import javax.net.ssl.HostnameVerifier; | |||||
import javax.net.ssl.HttpsURLConnection; | |||||
import javax.net.ssl.SSLContext; | |||||
import javax.net.ssl.SSLSession; | |||||
import javax.net.ssl.X509TrustManager; | |||||
import java.security.cert.X509Certificate; | |||||
import org.springframework.stereotype.Component; | |||||
@Component("jzhHttpsSend") | |||||
public class JzhHttpsSend { | |||||
public String accessToken; | |||||
private static final Log log = LogFactory.getLog(JzhHttpsSend.class); | |||||
private myX509TrustManager xtm = new myX509TrustManager(); | |||||
private myHostnameVerifier hnv = new myHostnameVerifier(); | |||||
public String getAccessToken() { | |||||
return accessToken; | |||||
} | |||||
public void setAccessToken(String accessToken) { | |||||
this.accessToken = accessToken; | |||||
} | |||||
public JzhHttpsSend() { | |||||
SSLContext sslContext = null; | |||||
try { | |||||
sslContext = SSLContext.getInstance("TLS"); // 或SSL TLS | |||||
X509TrustManager[] xtmArray = new X509TrustManager[] { xtm }; | |||||
sslContext.init(null, xtmArray, new java.security.SecureRandom()); | |||||
} catch (GeneralSecurityException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
if (sslContext != null) { | |||||
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext | |||||
.getSocketFactory()); | |||||
} | |||||
HttpsURLConnection.setDefaultHostnameVerifier(hnv); | |||||
} | |||||
public String send(String url, String data) { | |||||
String sResult = ""; | |||||
Map<String, String> result = HttpUtils.post(url, data, 13, 14); | |||||
log.info("[---------------" + result + "----------------------------------------------]"+result.toString()); | |||||
if ("200".equals(result.get("statusCode"))) { | |||||
sResult = result.get("result"); | |||||
} | |||||
return sResult; | |||||
} | |||||
public String getToken() { | |||||
JsonObject json = new JsonObject(); | |||||
String access_token = jsSdkUtil.getToken(); | |||||
try { | |||||
json.addProperty("access_token",access_token); | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
} | |||||
return json.toString(); | |||||
} | |||||
public String getTokenByRedis() { | |||||
JsonObject json = new JsonObject(); | |||||
String access_token = jsSdkUtil.getToken(); | |||||
try { | |||||
json.addProperty("access_token",access_token); | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
} | |||||
return json.toString(); | |||||
} | |||||
/** | |||||
* | |||||
* 创建临时二维码ticket by scene_id | |||||
* 临时 action_name:QR_SCENE | |||||
* {"expire_seconds": 1800, "action_name": "QR_SCENE", "action_info": {"scene": {"scene_id": 123}}} | |||||
* 场景值ID,临时二维码时为32位非0整型,永久二维码时最大值为100000(目前参数只支持1--100000) | |||||
* //https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=** 查看二维码 | |||||
*/ | |||||
public String getTicketByStr(String scene_id,int time) { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token="+ accessToken; | |||||
String data = "{" + "\"expire_seconds\":"+time+"," | |||||
+ "\"action_name\":\"QR_STR_SCENE\"," | |||||
+"\"action_info\":{\"scene\":{\"scene_str\":"+scene_id+"}}}"; | |||||
String result = new JzhHttpsSend().send(url, data); | |||||
return result; | |||||
} | |||||
public String createMenu(String data) { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/menu/create" + "?" | |||||
+ "access_token=" + accessToken; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
public String delMenu() { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/menu/delete" + "?" | |||||
+ "access_token=" + accessToken; | |||||
String data = ""; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
public String getMenu() { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/menu/get" + "?" | |||||
+ "access_token=" + accessToken; | |||||
String data = ""; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
public String getUsers() { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/user/get" + "?" | |||||
+ "access_token=" + accessToken; | |||||
String data = ""; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
public String getGroupAll() { | |||||
// 查询所有分组 | |||||
String url = "https://api.weixin.qq.com/cgi-bin/groups/get" + "?" | |||||
+ "access_token=" + accessToken; | |||||
String data = ""; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
public String messageToUser(String openid, String content) { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" | |||||
+ accessToken; | |||||
String data = "{" + "\"touser\":\"" + openid + "\"," | |||||
+ "\"msgtype\":\"text\"," + "\"text\":" + "{" | |||||
+ "\"content\":\"" + content + "\"" + "}" + "}"; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
//获取关注用户的信息 | |||||
public String getAttentionUserInfo(String openid){ | |||||
String url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token="+accessToken+"&openid="+openid+"&lang=zh_CN"; | |||||
String data = ""; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
// 进入授权页面 | |||||
public String getOauth2Code(String appId, String redirect_uri) { | |||||
String url = "https://open.weixin.qq.com/connect/oauth2/authorize?" | |||||
+ "appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect"; | |||||
url = url.replace("APPID", appId); | |||||
url = url.replace("REDIRECT_URI", redirect_uri); | |||||
url = url.replace("SCOPE", "snsapi_base"); // scope参数 | |||||
// snsapi_base,snsapi_userinfo | |||||
String data = ""; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
// 换取网页授权 | |||||
public String getOauth2AccessToken(String appId, String appSecret, | |||||
String code) { | |||||
String url = "https://api.weixin.qq.com/sns/oauth2/access_token?" | |||||
+ "appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code"; | |||||
url = url.replace("APPID", appId); | |||||
url = url.replace("SECRET", appSecret); | |||||
url = url.replace("CODE", code); | |||||
String data = ""; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
// 拉取用户信息 | |||||
public String getOauth2UserInfo(String accessToken, String openId) { | |||||
String url = "https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID"; | |||||
url = url.replace("ACCESS_TOKEN", accessToken); | |||||
url = url.replace("OPENID", openId); | |||||
String data = ""; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
public String sendTemplate_bind(String openid,String mobile,String date) { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+ accessToken; | |||||
String data = "{" + "\"touser\":\"" + openid + "\"," | |||||
//+ "\"template_id\":\"oRIw5nzgtd5RCs0lfHKiEgRvKKB3kUe4UyDSTvUeJ70\"," | |||||
+ "\"template_id\":\"ykQ1r3pXVc0Llp_L5QhkL0mEUGrL-RdebG5xhVVx108\"," | |||||
//+ "\"url\":\"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx3c93ab6988954027&redirect_uri=http%3a%2f%2fweixin.linktech.hk%2FactUncondiLinkController.do%3Faction%3Dquanfen%26activityid%3D37%26fromid%3DFROMID&response_type=code&scope=snsapi_base&state=123#wechat_redirect\"," | |||||
+ "\"url\":\"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx15299598a10b5c34&redirect_uri=http%3a%2f%2flntest.linktech.hk%2fwxDev%2factAllLinkController.do%3faction%3donlineCustomerPackagesCenter&response_type=code&scope=snsapi_base&state=123&connect_redirect=1#wechat_redirect\"," | |||||
+"\"topcolor\":\"#FF0000\"," | |||||
+"\"data\":{\"first\":{\"value\":\"尊敬的用户,您好:\\r\\n自9月13日起,首次关注辽宁联通官方微信并绑定手机号码的辽宁省用户,即可参与领一元电子券活动,数量有限,先到先得哦!\\r\\n>>>点击参与活动吧!\\r\\n\",\"color\":\"#000000\"}," | |||||
+"\"keyword1\":{\"value\":\""+mobile+"\",\"color\":\"#173177\"}," | |||||
+"\"keyword2\":{\"value\":\"个人用户\",\"color\":\"#173177\"}," | |||||
+"\"keyword3\":{\"value\":\""+date+"\",\"color\":\"#173177\"}," | |||||
+"\"remark\":{\"value\":\"\",\"color\":\"#000000\"}}}"; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
/** | |||||
* 存量API推送模板 | |||||
* 发送模板消息 购买成功模板oRIw5nzgtd5RCs0lfHKiEgRvKKB3kUe4UyDSTvUeJ70(正式) | |||||
* 无(测试)ykQ1r3pXVc0Llp_L5QhkL0mEUGrL-RdebG5xhVVx108 | |||||
*/ | |||||
public String sendTemplate_api(String openid,String mobile,String date,String sendUrl,String template_id,String data) { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+ accessToken; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
log.info("rs:"+rs); | |||||
return rs; | |||||
} | |||||
/** | |||||
* 吉包 | |||||
* 发送模板消息 购买成功模板rHgE6cbNMVnqs0jO1AUskNKoaC0CdoEaQfcpDdEgKvs(正式) | |||||
* 无(测试) U3v49SY4iBPlsU8hx_Y4l5rHs6wbiws6hVblP7cEUIs | |||||
*/ | |||||
public String sendTemplate_activity(String openid,String msg,String date) { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+ accessToken; | |||||
String data = "{" + "\"touser\":\"" + openid + "\"," | |||||
+ "\"template_id\":\"rHgE6cbNMVnqs0jO1AUskNKoaC0CdoEaQfcpDdEgKvs\"," | |||||
+ "\"url\":\"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx3c93ab6988954027&redirect_uri=http%3A%2F%2Fweixin.linktech.hk%2FactAllLinkController.do%3Faction%3DturnTablejibao%26activityid%3D9&response_type=code&scope=snsapi_base&state=123#wechat_redirect\"," | |||||
+"\"topcolor\":\"#FF0000\"," | |||||
+"\"data\":{\"first\":{\"value\":\"已绑定的老用户及在活动期间关注并绑定的新用户均可获得一次抽取“吉包”的机会。点击本页即可参与活动。\\r\\n\",\"color\":\"#000000\"}," | |||||
+"\"keyword1\":{\"value\":\"本活动起止日期为2017年5月17日至5月23日,每名获得抽奖机会的用户可领取一次吉包,惊喜不断,奖励多多。持续关注辽宁联通,获取更多资讯。\",\"color\":\"#173177\"}," | |||||
+"\"keyword2\":{\"value\":\""+date+"\",\"color\":\"#173177\"}," | |||||
+"\"remark\":{\"value\":\"\\r\\n\",\"color\":\"#000000\"}}}"; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
/** | |||||
* 加一元购 | |||||
* 发送模板消息 购买成功模板rHgE6cbNMVnqs0jO1AUskNKoaC0CdoEaQfcpDdEgKvs(正式) | |||||
* 无(测试) U3v49SY4iBPlsU8hx_Y4l5rHs6wbiws6hVblP7cEUIs | |||||
*/ | |||||
public String sendTemplate_activityone(String openid,String msg1,String msg2,String date,String linkurl) { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+ accessToken; | |||||
String data = "{" + "\"touser\":\"" + openid + "\"," | |||||
+ "\"template_id\":\"rHgE6cbNMVnqs0jO1AUskNKoaC0CdoEaQfcpDdEgKvs\"," | |||||
+ "\"url\":\""+linkurl+"\"," | |||||
+"\"topcolor\":\"#FF0000\"," | |||||
+"\"data\":{\"first\":{\"value\":\""+msg1+"\\r\\n\",\"color\":\"#000000\"}," | |||||
+"\"keyword1\":{\"value\":\""+msg2+"\",\"color\":\"#173177\"}," | |||||
+"\"keyword2\":{\"value\":\""+date+"\",\"color\":\"#173177\"}," | |||||
+"\"remark\":{\"value\":\"\\r\\n\",\"color\":\"#000000\"}}}"; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
/** | |||||
* 操作成功通知 | |||||
* 发送模板消息 购买成功模板rHgE6cbNMVnqs0jO1AUskNKoaC0CdoEaQfcpDdEgKvs(正式) | |||||
* 无(测试) U3v49SY4iBPlsU8hx_Y4l5rHs6wbiws6hVblP7cEUIs | |||||
*/ | |||||
public String sendTemplate_doSuccess(String openid,String msg1,String msg2,String date,String linkurl, String test) { | |||||
String templateId = "rHgE6cbNMVnqs0jO1AUskNKoaC0CdoEaQfcpDdEgKvs"; | |||||
if(StringUtils.isNotEmpty(test)){ | |||||
templateId = "U3v49SY4iBPlsU8hx_Y4l5rHs6wbiws6hVblP7cEUIs"; | |||||
} | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+ accessToken; | |||||
String data = "{" + "\"touser\":\"" + openid + "\"," | |||||
+ "\"template_id\":\"" + templateId + "\"," | |||||
+ "\"url\":\""+linkurl+"\"," | |||||
+"\"topcolor\":\"#FF0000\"," | |||||
+"\"data\":{\"first\":{\"value\":\""+msg1+"\\r\\n\",\"color\":\"#000000\"}," | |||||
+"\"keyword1\":{\"value\":\""+msg2+"\",\"color\":\"#173177\"}," | |||||
+"\"keyword2\":{\"value\":\""+date+"\",\"color\":\"#173177\"}," | |||||
+"\"remark\":{\"value\":\"\\r\\n\",\"color\":\"#000000\"}}}"; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
/** | |||||
* 活动消息下发 | |||||
* 发送模板消息 购买成功模板rHgE6cbNMVnqs0jO1AUskNKoaC0CdoEaQfcpDdEgKvs(正式) | |||||
* 无(测试) U3v49SY4iBPlsU8hx_Y4l5rHs6wbiws6hVblP7cEUIs | |||||
*/ | |||||
public String sendTemplate_active(String openid,Map<String, String> msg,String date) { | |||||
log.info(accessToken); | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+ accessToken; | |||||
String data = "{" + "\"touser\":\"" + openid + "\"," | |||||
+ "\"template_id\":\"rHgE6cbNMVnqs0jO1AUskNKoaC0CdoEaQfcpDdEgKvs\"," | |||||
+ "\"url\":\"" + msg.get("url") + "\"," | |||||
+"\"topcolor\":\"#FF0000\"," | |||||
+"\"data\":{\"first\":{\"value\":\"" + msg.get("data") + "\",\"color\":\"#000000\"}," | |||||
+"\"keyword1\":{\"value\":\"" + msg.get("keyword1") + "\",\"color\":\"#173177\"}," | |||||
+"\"keyword2\":{\"value\":\""+date+"\",\"color\":\"#173177\"}," | |||||
+"\"remark\":{\"value\":\"" + msg.get("remark") + "\",\"color\":\"#000000\"}}}"; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
public String sendTemplate_active(String openid,Map<String, String> msg,String date, String test) { | |||||
String templeateId = "rHgE6cbNMVnqs0jO1AUskNKoaC0CdoEaQfcpDdEgKvs"; | |||||
if("test".equals(test)){ | |||||
templeateId = "U3v49SY4iBPlsU8hx_Y4l5rHs6wbiws6hVblP7cEUIs"; | |||||
} | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+ accessToken; | |||||
String data = "{" + "\"touser\":\"" + openid + "\"," | |||||
+ "\"template_id\":\""+ templeateId +"\"," | |||||
+ "\"url\":\"" + msg.get("url") + "\"," | |||||
+"\"topcolor\":\"#FF0000\"," | |||||
+"\"data\":{\"first\":{\"value\":\"" + msg.get("data") + "\",\"color\":\"#000000\"}," | |||||
+"\"keyword1\":{\"value\":\"" + msg.get("keyword1") + "\",\"color\":\"#173177\"}," | |||||
+"\"keyword2\":{\"value\":\""+date+"\",\"color\":\"#173177\"}," | |||||
+"\"remark\":{\"value\":\"" + msg.get("remark") + "\",\"color\":\"#000000\"}}}"; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
/** | |||||
* 流量银行 | |||||
* 发送模板消息 购买成功模板id:I5L6_Bp5OLMywS7jpOjLHyC6OEE3v1h7qg3KaIBc7aI(正式) | |||||
* ZyeELRbERvgy__Fnmr4svQmKQpGBVZDtpRgLLBhRkp4(测试) | |||||
*/ | |||||
public String sendTemplate_flowbuy_bank(String flowname,String openid,String datetime) { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+ accessToken; | |||||
String data = "{" + "\"touser\":\"" + openid + "\"," | |||||
+ "\"template_id\":\"I5L6_Bp5OLMywS7jpOjLHyC6OEE3v1h7qg3KaIBc7aI\"," | |||||
+"\"topcolor\":\"#FF0000\"," | |||||
+"\"data\":{\"first\":{\"value\":\"恭喜你流量包购买成功!\",\"color\":\"#173177\"}," | |||||
+"\"productType\":{\"value\":\"名称\",\"color\":\"#000000\"}," | |||||
+"\"name\":{\"value\":\""+flowname+"\",\"color\":\"#173177\"}," | |||||
+"\"number\":{\"value\":\"1个\",\"color\":\"#173177\"}," | |||||
+"\"expDate\":{\"value\":\""+datetime+"\",\"color\":\"#173177\"}," | |||||
+"\"remark\":{\"value\":\"请到流量银行查看!\",\"color\":\"#173177\"}}}"; | |||||
String rs = new JzhHttpsSend().send(url, data); | |||||
return rs; | |||||
} | |||||
/** | |||||
* | |||||
* 发送模板-预约模板id:E5liJZ5HX3Ua8ljqIr5VlEmMmP4c8DHQKimLP1fZYxI(正式) | |||||
* 2NORkMPmBzmQuvW9GDtENdCM7S-R0Y3s9WdVcUkGYHU(测试) | |||||
*/ | |||||
public String sendTemplate_contractHall(String verificationCode,String contractTime,String openid) { | |||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+ accessToken; | |||||
String data = "{" + "\"touser\":\"" + openid + "\"," | |||||
+ "\"template_id\":\"E5liJZ5HX3Ua8ljqIr5VlEmMmP4c8DHQKimLP1fZYxI\"," | |||||
+"\"topcolor\":\"#FF0000\"," | |||||
+"\"data\":{\"first\":{\"value\":\"欢迎使用营业厅预约排队系统!\",\"color\":\"#000000\"}," | |||||
+"\"keyword1\":{\"value\":\"预约成功\",\"color\":\"#173177\"}," | |||||
+"\"keyword2\":{\"value\":\""+verificationCode+"\",\"color\":\"#173177\"}," | |||||
+"\"remark\":{\"value\":\"您预约的时间为:"+contractTime+"\",\"color\":\"#173177\"}}}"; | |||||
String result = new JzhHttpsSend().send(url, data); | |||||
return result; | |||||
} | |||||
public static void main(String[] args) { | |||||
JzhHttpsSend a = new JzhHttpsSend (); | |||||
// System.out.println(a.getTicketByStr("MH_1008")); | |||||
} | |||||
} | |||||
/** */ | |||||
/** | |||||
* 重写三个方法 | |||||
* | |||||
* @author Administrator | |||||
* | |||||
*/ | |||||
class myX509TrustManager implements X509TrustManager { | |||||
public void checkClientTrusted(X509Certificate[] chain, String authType) { | |||||
} | |||||
public void checkServerTrusted(X509Certificate[] chain, String authType) { | |||||
// System.out.println("cert: " + chain[0].toString() + ", authType: " | |||||
// + authType); | |||||
// try { | |||||
// System.out.println("cert base64:" | |||||
// + RSACoder.encryptBASE64(chain[0].getEncoded())); | |||||
// } catch (Exception e) { | |||||
// e.printStackTrace(); | |||||
// } | |||||
} | |||||
public X509Certificate[] getAcceptedIssuers() { | |||||
return null; | |||||
} | |||||
/** */ | |||||
/** | |||||
* 重写一个方法 | |||||
* | |||||
* @author Administrator | |||||
* | |||||
*/ | |||||
class myHostnameVerifier implements HostnameVerifier { | |||||
public boolean verify(String hostname, SSLSession session) { | |||||
System.out.println("Warning: URL Host: " + hostname + " vs. " | |||||
+ session.getPeerHost()); | |||||
return true; | |||||
} | |||||
} | |||||
} | |||||
/** */ | |||||
/** | |||||
* 重写一个方法 | |||||
* | |||||
* @author Administrator | |||||
* | |||||
*/ | |||||
class myHostnameVerifier implements HostnameVerifier { | |||||
public boolean verify(String hostname, SSLSession session) { | |||||
System.out.println("Warning: URL Host: " + hostname + " vs. " | |||||
+ session.getPeerHost()); | |||||
return true; | |||||
} | |||||
} | |||||
package com.cbs.company.util; | |||||
import org.apache.commons.codec.digest.DigestUtils; | |||||
public class MD5Util { | |||||
public static String md5(String src) { | |||||
return DigestUtils.md5Hex(src); | |||||
} | |||||
private static final String salt = "1a2b3c4d"; | |||||
public static String inputPassToFormPass(String inputPass) { | |||||
String str = ""+salt.charAt(0)+salt.charAt(2) + inputPass +salt.charAt(5) + salt.charAt(4); | |||||
System.out.println(str); | |||||
return md5(str); | |||||
} | |||||
public static String formPassToDBPass(String formPass, String salt) { | |||||
String str = ""+salt.charAt(0)+salt.charAt(2) + formPass +salt.charAt(5) + salt.charAt(4); | |||||
return md5(str); | |||||
} | |||||
public static String inputPassToDbPass(String inputPass, String saltDB) { | |||||
String formPass = inputPassToFormPass(inputPass); | |||||
String dbPass = formPassToDBPass(formPass, saltDB); | |||||
return dbPass; | |||||
} | |||||
public static void main(String[] args) { | |||||
System.out.println(inputPassToFormPass("123456"));//d3b1294a61a07da9b49b6e22b2cbd7f9 | |||||
// System.out.println(formPassToDBPass(inputPassToFormPass("123456"), "1a2b3c4d")); | |||||
// System.out.println(inputPassToDbPass("123456", "1a2b3c4d"));//b7797cce01b4b131b433b6acf4add449 | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import org.apache.shiro.crypto.hash.SimpleHash; | |||||
import org.apache.shiro.util.ByteSource; | |||||
public class MD5Utils { | |||||
private static final String SALT = "1qazxsw2"; | |||||
private static final String ALGORITH_NAME = "md5"; | |||||
private static final int HASH_ITERATIONS = 2; | |||||
public static String encrypt(String pswd) { | |||||
String newPassword = new SimpleHash(ALGORITH_NAME, pswd, ByteSource.Util.bytes(SALT), HASH_ITERATIONS).toHex(); | |||||
return newPassword; | |||||
} | |||||
public static String encrypt(String username, String pswd) { | |||||
String newPassword = new SimpleHash(ALGORITH_NAME, pswd, ByteSource.Util.bytes(username + SALT), | |||||
HASH_ITERATIONS).toHex(); | |||||
return newPassword; | |||||
} | |||||
public static void main(String[] args) { | |||||
//System.out.println(MD5Utils.encrypt("admin", "1")); | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
public class MoneyUtil { | |||||
private static final String UNIT = "万千佰拾亿千佰拾万千佰拾元角分"; | |||||
private static final String DIGIT = "零壹贰叁肆伍陆柒捌玖"; | |||||
private static final double MAX_VALUE = 9999999999999.99D; | |||||
public static String change(double v) { | |||||
if (v < 0 || v > MAX_VALUE){ | |||||
return "参数非法!"; | |||||
} | |||||
long l = Math.round(v * 100); | |||||
if (l == 0){ | |||||
return "零元整"; | |||||
} | |||||
String strValue = l + ""; | |||||
// i用来控制数 | |||||
int i = 0; | |||||
// j用来控制单位 | |||||
int j = UNIT.length() - strValue.length(); | |||||
String rs = ""; | |||||
boolean isZero = false; | |||||
for (; i < strValue.length(); i++, j++) { | |||||
char ch = strValue.charAt(i); | |||||
if (ch == '0') { | |||||
isZero = true; | |||||
if (UNIT.charAt(j) == '亿' || UNIT.charAt(j) == '万' || UNIT.charAt(j) == '元') { | |||||
rs = rs + UNIT.charAt(j); | |||||
isZero = false; | |||||
} | |||||
} else { | |||||
if (isZero) { | |||||
rs = rs + "零"; | |||||
isZero = false; | |||||
} | |||||
rs = rs + DIGIT.charAt(ch - '0') + UNIT.charAt(j); | |||||
} | |||||
} | |||||
if (!rs.endsWith("分")) { | |||||
rs = rs + "整"; | |||||
} | |||||
rs = rs.replaceAll("亿万", "亿"); | |||||
return rs; | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import java.util.HashMap; | |||||
import java.util.Map; | |||||
import net.sf.json.JSONObject; | |||||
import org.apache.commons.logging.Log; | |||||
import org.apache.commons.logging.LogFactory; | |||||
import org.springframework.context.annotation.Scope; | |||||
import org.springframework.stereotype.Component; | |||||
@Scope("prototype") | |||||
@Component("oauthUtil") | |||||
public class OauthUtil { | |||||
private static final Log log = LogFactory.getLog(OauthUtil.class); | |||||
// 授权页面地址 | |||||
public Map<String, String> getOauth2Code(String appId, String redirect_uri) { | |||||
String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect"; | |||||
url = url.replace("APPID", appId); | |||||
url = url.replace("REDIRECT_URI", redirect_uri); | |||||
url = url.replace("SCOPE", "snsapi_base"); // scope参数 | |||||
// snsapi_base,snsapi_userinfo | |||||
return null; | |||||
} | |||||
// 换取网页授权 | |||||
public Map<String, String> getOauth2AccessToken(String appId, String appSecret, String code) { | |||||
String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code"; | |||||
url = url.replace("APPID", appId); | |||||
url = url.replace("SECRET", appSecret); | |||||
url = url.replace("CODE", code); | |||||
Map<String, String> data = HttpUtils.get(url); | |||||
JSONObject json = JSONObject.fromObject(data); | |||||
JSONObject jsonResult = null; | |||||
Map<String, String> map = new HashMap<String, String>(); | |||||
if ("200".equals(json.get("statusCode"))) { | |||||
jsonResult = JSONObject.fromObject(json.get("result")); | |||||
if (jsonResult.has("access_token")) { | |||||
log.info("[oauth2认证信息]access_token[" + jsonResult.getString("access_token") + "]"); | |||||
log.info("[oauth2认证信息]expires_in[" + jsonResult.getString("expires_in") + "]"); | |||||
log.info("[oauth2认证信息]refresh_token[" + jsonResult.getString("refresh_token") + "]"); | |||||
log.info("[oauth2认证信息]openid[" + jsonResult.getString("openid") + "]"); | |||||
log.info("[oauth2认证信息]scope[" + jsonResult.getString("scope") + "]"); | |||||
log.info("[oauth2认证信息]网页授权成功"); | |||||
map.put("access_token", jsonResult.getString("access_token")); | |||||
map.put("expires_in", jsonResult.getString("expires_in")); | |||||
map.put("refresh_token", jsonResult.getString("refresh_token")); | |||||
map.put("openid", jsonResult.getString("openid")); | |||||
map.put("scope", jsonResult.getString("scope")); | |||||
map.put("resultCode", "0000"); | |||||
map.put("resultDesc", "网页授权成功"); | |||||
} else { | |||||
log.info("[oauth2认证信息]网页授权失败"); | |||||
map.put("resultCode", "9999"); | |||||
map.put("resultDesc", "网页授权失败"); | |||||
} | |||||
} else { | |||||
map.put("resultCode", "201"); | |||||
map.put("resultDesc", "请求失败,请稍后再试"); | |||||
} | |||||
return map; | |||||
} | |||||
// 拉取用户信息 | |||||
public Map<String, String> getOauth2UserInfo(String accessToken, String openId) { | |||||
String url = "https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID"; | |||||
url = url.replace("ACCESS_TOKEN", accessToken); | |||||
url = url.replace("OPENID", openId); | |||||
Map<String, String> data = HttpUtils.get(url); | |||||
JSONObject json = JSONObject.fromObject(data); | |||||
JSONObject jsonResult = null; | |||||
Map<String, String> map = new HashMap<String, String>(); | |||||
if ("200".equals(json.get("statusCode"))) { | |||||
jsonResult = JSONObject.fromObject(json.get("result")); | |||||
if (jsonResult.has("openid")) { | |||||
map.put("openid", jsonResult.getString("openid")); | |||||
map.put("nickname", jsonResult.getString("nickname")); | |||||
map.put("sex", jsonResult.getString("sex")); | |||||
map.put("province", jsonResult.getString("province")); | |||||
map.put("city", jsonResult.getString("city")); | |||||
map.put("country", jsonResult.getString("country")); | |||||
map.put("headimgurl", jsonResult.getString("headimgurl")); | |||||
map.put("nickname", jsonResult.getString("nickname")); | |||||
log.info("[oauth2认证信息]拉取用户信息完毕"); | |||||
log.info("[oauth2认证信息]openid[" + jsonResult.getString("openid") + "]"); | |||||
map.put("resultCode", "0000"); | |||||
map.put("resultDesc", "拉取用户信息完毕"); | |||||
} else { | |||||
log.info("[oauth2认证信息]拉取用户信息失败:" + jsonResult.toString()); | |||||
map.put("resultCode", "9999"); | |||||
map.put("resultDesc", "拉取用户信息失败"); | |||||
} | |||||
} else { | |||||
map.put("resultCode", "201"); | |||||
map.put("resultDesc", "请求失败,请稍后再试"); | |||||
} | |||||
return map; | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import java.io.FileOutputStream; | |||||
import java.util.Properties; | |||||
import javax.activation.DataHandler; | |||||
import javax.activation.FileDataSource; | |||||
import javax.mail.Message; | |||||
import javax.mail.Session; | |||||
import javax.mail.Transport; | |||||
import javax.mail.internet.*; | |||||
/** | |||||
* @ClassName: Sendmail | |||||
* @Description: 发送Email | |||||
* @author: 孤傲苍狼 | |||||
* @date: 2015-1-12 下午9:42:56 | |||||
* | |||||
*/ | |||||
public class Sendmail { | |||||
// /** | |||||
// * @param args | |||||
// * @throws Exception | |||||
// */ | |||||
// public static void main(String[] args) throws Exception { | |||||
// | |||||
// Properties prop = new Properties(); | |||||
// prop.setProperty("mail.host", "smtp.qq.com"); | |||||
// prop.setProperty("mail.transport.protocol", "smtp"); | |||||
// prop.setProperty("mail.smtp.auth", "true"); | |||||
// //使用JavaMail发送邮件的5个步骤 | |||||
// //1、创建session | |||||
// Session session = Session.getInstance(prop); | |||||
// //开启Session的debug模式,这样就可以查看到程序发送Email的运行状态 | |||||
// session.setDebug(true); | |||||
// //2、通过session得到transport对象 | |||||
// Transport ts = session.getTransport(); | |||||
// //3、使用邮箱的用户名和密码连上邮件服务器,发送邮件时,发件人需要提交邮箱的用户名和密码给smtp服务器,用户名和密码都通过验证之后才能够正常发送邮件给收件人。 | |||||
// ts.connect("smtp.qq.com", "695079574", "lblugkhdoxcfbfhh");//sdadqdauounzbbah | |||||
// //4、创建邮件 | |||||
// Message message = createSimpleMail(session); | |||||
// //5、发送邮件 | |||||
// ts.sendMessage(message, message.getAllRecipients()); | |||||
// ts.close(); | |||||
// } | |||||
/** | |||||
* @Method: createSimpleMail | |||||
* @Description: 创建一封只包含文本的邮件 | |||||
* @Anthor:孤傲苍狼 | |||||
* | |||||
* @param session | |||||
* @return | |||||
* @throws Exception | |||||
*/ | |||||
public static MimeMessage createSimpleMail(Session session) | |||||
throws Exception { | |||||
//创建邮件对象 | |||||
MimeMessage message = new MimeMessage(session); | |||||
//指明邮件的发件人 | |||||
message.setFrom(new InternetAddress("695079574@qq.com")); | |||||
//指明邮件的收件人,现在发件人和收件人是一样的,那就是自己给自己发 | |||||
message.setRecipient(Message.RecipientType.TO, new InternetAddress("695079574@qq.com")); | |||||
//邮件的标题 | |||||
message.setSubject("只包含文本的简单邮件"); | |||||
//邮件的文本内容 | |||||
message.setContent("你好啊!", "text/html;charset=UTF-8"); | |||||
//返回创建好的邮件对象 | |||||
return message; | |||||
} | |||||
// /** | |||||
// * @param args | |||||
// * @throws Exception | |||||
// */ | |||||
// public static void main(String[] args) throws Exception { | |||||
// | |||||
// Properties prop = new Properties(); | |||||
// prop.setProperty("mail.host", "smtp.qq.com"); | |||||
// prop.setProperty("mail.transport.protocol", "smtp"); | |||||
// prop.setProperty("mail.smtp.auth", "true"); | |||||
// //使用JavaMail发送邮件的5个步骤 | |||||
// //1、创建session | |||||
// Session session = Session.getInstance(prop); | |||||
// //开启Session的debug模式,这样就可以查看到程序发送Email的运行状态 | |||||
// session.setDebug(true); | |||||
// //2、通过session得到transport对象 | |||||
// Transport ts = session.getTransport(); | |||||
// //3、连上邮件服务器,需要发件人提供邮箱的用户名和密码进行验证 | |||||
// ts.connect("smtp.qq.com", "695079574", "lblugkhdoxcfbfhh"); | |||||
// //4、创建邮件 | |||||
// Message message = createImageMail(session); | |||||
// //5、发送邮件 | |||||
// ts.sendMessage(message, message.getAllRecipients()); | |||||
// ts.close(); | |||||
// } | |||||
/** | |||||
* @Method: createImageMail | |||||
* @Description: 生成一封邮件正文带图片的邮件 | |||||
* @Anthor:孤傲苍狼 | |||||
* | |||||
* @param session | |||||
* @return | |||||
* @throws Exception | |||||
*/ | |||||
public static MimeMessage createImageMail(Session session) throws Exception { | |||||
//创建邮件 | |||||
MimeMessage message = new MimeMessage(session); | |||||
// 设置邮件的基本信息 | |||||
//发件人 | |||||
message.setFrom(new InternetAddress("695079574@qq.com")); | |||||
//收件人 | |||||
message.setRecipient(Message.RecipientType.TO, new InternetAddress("695079574@qq.com")); | |||||
//邮件标题 | |||||
message.setSubject("带图片的邮件"); | |||||
// 准备邮件数据 | |||||
// 准备邮件正文数据 | |||||
MimeBodyPart text = new MimeBodyPart(); | |||||
text.setContent("这是一封邮件正文带图片<img src='cid:xxx.jpg'>的邮件", "text/html;charset=UTF-8"); | |||||
// 准备图片数据 | |||||
MimeBodyPart image = new MimeBodyPart(); | |||||
// DataHandler dh = new DataHandler(new FileDataSource("/static/image/all.png")); | |||||
DataHandler dh = new DataHandler(new FileDataSource("C:\\Users\\69057\\Documents\\pf10\\src\\main\\resources\\static\\image\\a11.png")); | |||||
image.setDataHandler(dh); | |||||
image.setContentID("xxx.jpg"); | |||||
// 描述数据关系 | |||||
MimeMultipart mm = new MimeMultipart(); | |||||
mm.addBodyPart(text); | |||||
mm.addBodyPart(image); | |||||
mm.setSubType("related"); | |||||
message.setContent(mm); | |||||
message.saveChanges(); | |||||
//将创建好的邮件写入到E盘以文件的形式进行保存 | |||||
message.writeTo(new FileOutputStream("Z:\\ImageMail.eml")); | |||||
//返回创建好的邮件 | |||||
return message; | |||||
} | |||||
// /** | |||||
// * @param args | |||||
// * @throws Exception | |||||
// */ | |||||
// public static void main(String[] args) throws Exception { | |||||
// | |||||
// Properties prop = new Properties(); | |||||
// prop.setProperty("mail.host", "smtp.qq.com"); | |||||
// prop.setProperty("mail.transport.protocol", "smtp"); | |||||
// prop.setProperty("mail.smtp.auth", "true"); | |||||
// //使用JavaMail发送邮件的5个步骤 | |||||
// //1、创建session | |||||
// Session session = Session.getInstance(prop); | |||||
// //开启Session的debug模式,这样就可以查看到程序发送Email的运行状态 | |||||
// session.setDebug(true); | |||||
// //2、通过session得到transport对象 | |||||
// Transport ts = session.getTransport(); | |||||
// //3、连上邮件服务器 | |||||
// ts.connect("smtp.qq.com", "695079574", "lblugkhdoxcfbfhh"); | |||||
// //4、创建邮件 | |||||
// Message message = createAttachMail(session); | |||||
// //5、发送邮件 | |||||
// ts.sendMessage(message, message.getAllRecipients()); | |||||
// ts.close(); | |||||
// } | |||||
/** | |||||
* @Method: createAttachMail | |||||
* @Description: 创建一封带附件的邮件 | |||||
* @Anthor:孤傲苍狼 | |||||
* | |||||
* @param session | |||||
* @return | |||||
* @throws Exception | |||||
*/ | |||||
public static MimeMessage createAttachMail(Session session) throws Exception{ | |||||
MimeMessage message = new MimeMessage(session); | |||||
//设置邮件的基本信息 | |||||
//发件人 | |||||
message.setFrom(new InternetAddress("695079574@qq.com")); | |||||
//收件人 | |||||
message.setRecipient(Message.RecipientType.TO, new InternetAddress("695079574@qq.com")); | |||||
//邮件标题 | |||||
message.setSubject("JavaMail邮件发送测试"); | |||||
//创建邮件正文,为了避免邮件正文中文乱码问题,需要使用charset=UTF-8指明字符编码 | |||||
MimeBodyPart text = new MimeBodyPart(); | |||||
text.setContent("使用JavaMail创建的带附件的邮件", "text/html;charset=UTF-8"); | |||||
//创建邮件附件 | |||||
MimeBodyPart attach = new MimeBodyPart(); | |||||
DataHandler dh = new DataHandler(new FileDataSource("C:\\Users\\69057\\Documents\\pf10\\src\\main\\resources\\static\\image\\a11.png")); | |||||
attach.setDataHandler(dh); | |||||
attach.setFileName(dh.getName()); // | |||||
//创建容器描述数据关系 | |||||
MimeMultipart mp = new MimeMultipart(); | |||||
mp.addBodyPart(text); | |||||
mp.addBodyPart(attach); | |||||
mp.setSubType("mixed"); | |||||
message.setContent(mp); | |||||
message.saveChanges(); | |||||
//将创建的Email写入到E盘存储 | |||||
message.writeTo(new FileOutputStream("Z:\\attachMail.eml")); | |||||
//返回生成的邮件 | |||||
return message; | |||||
} | |||||
/** | |||||
* @param args | |||||
* @throws Exception | |||||
*/ | |||||
public static void main(String[] args) throws Exception { | |||||
Properties prop = new Properties(); | |||||
prop.setProperty("mail.host", "smtp.qq.com"); | |||||
prop.setProperty("mail.transport.protocol", "smtp"); | |||||
prop.setProperty("mail.smtp.auth", "true"); | |||||
//使用JavaMail发送邮件的5个步骤 | |||||
//1、创建session | |||||
Session session = Session.getInstance(prop); | |||||
//开启Session的debug模式,这样就可以查看到程序发送Email的运行状态 | |||||
session.setDebug(true); | |||||
//2、通过session得到transport对象 | |||||
Transport ts = session.getTransport(); | |||||
//3、连上邮件服务器 | |||||
ts.connect("smtp.qq.com", "695079574", "lblugkhdoxcfbfhh"); | |||||
//4、创建邮件 | |||||
Message message = createMixedMail(session); | |||||
//5、发送邮件 | |||||
ts.sendMessage(message, message.getAllRecipients()); | |||||
ts.close(); | |||||
} | |||||
/** | |||||
* @Method: createMixedMail | |||||
* @Description: 生成一封带附件和带图片的邮件 | |||||
* @Anthor:孤傲苍狼 | |||||
* | |||||
* @param session | |||||
* @return | |||||
* @throws Exception | |||||
*/ | |||||
public static MimeMessage createMixedMail(Session session) throws Exception { | |||||
//创建邮件 | |||||
MimeMessage message = new MimeMessage(session); | |||||
//设置邮件的基本信息 | |||||
message.setFrom(new InternetAddress("695079574@qq.com")); | |||||
message.setRecipient(Message.RecipientType.TO, new InternetAddress("695079574@qq.com")); | |||||
message.setSubject("带附件和带图片的的邮件"); | |||||
//正文 | |||||
MimeBodyPart text = new MimeBodyPart(); | |||||
text.setContent("xxx这是女的xxxx<br/><img src='cid:aaa.jpg'>","text/html;charset=UTF-8"); | |||||
//图片 | |||||
MimeBodyPart image = new MimeBodyPart(); | |||||
image.setDataHandler(new DataHandler(new FileDataSource("C:\\Users\\69057\\Documents\\pf10\\src\\main\\resources\\static\\image\\a11.png"))); | |||||
image.setContentID("aaa.jpg"); | |||||
//附件1 | |||||
MimeBodyPart attach = new MimeBodyPart(); | |||||
DataHandler dh = new DataHandler(new FileDataSource("C:\\Users\\69057\\Documents\\pf10\\src\\main\\resources\\static\\image\\arrow1.png")); | |||||
attach.setDataHandler(dh); | |||||
attach.setFileName(dh.getName()); | |||||
//附件2 | |||||
MimeBodyPart attach2 = new MimeBodyPart(); | |||||
DataHandler dh2 = new DataHandler(new FileDataSource("C:\\Users\\69057\\Documents\\pf10\\src\\main\\resources\\static\\avg\\error.wav")); | |||||
attach2.setDataHandler(dh2); | |||||
attach2.setFileName(MimeUtility.encodeText(dh2.getName())); | |||||
//描述关系:正文和图片 | |||||
MimeMultipart mp1 = new MimeMultipart(); | |||||
mp1.addBodyPart(text); | |||||
mp1.addBodyPart(image); | |||||
mp1.setSubType("related"); | |||||
//描述关系:正文和附件 | |||||
MimeMultipart mp2 = new MimeMultipart(); | |||||
mp2.addBodyPart(attach); | |||||
mp2.addBodyPart(attach2); | |||||
//代表正文的bodypart | |||||
MimeBodyPart content = new MimeBodyPart(); | |||||
content.setContent(mp1); | |||||
mp2.addBodyPart(content); | |||||
mp2.setSubType("mixed"); | |||||
message.setContent(mp2); | |||||
message.saveChanges(); | |||||
message.writeTo(new FileOutputStream("Z:\\MixedMail.eml")); | |||||
//返回创建好的的邮件 | |||||
return message; | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import com.github.qcloudsms.httpclient.HTTPClient; | |||||
import com.github.qcloudsms.httpclient.HTTPException; | |||||
import com.github.qcloudsms.httpclient.HTTPResponse; | |||||
public class SmsBase { | |||||
protected int appid; | |||||
protected String appkey; | |||||
protected HTTPClient httpclient; | |||||
/** | |||||
* SmsBase constructor | |||||
* | |||||
* @param appid sdk appid | |||||
* @param appkey sdk appkey | |||||
* @param httpclient http client | |||||
*/ | |||||
public SmsBase(int appid, String appkey, HTTPClient httpclient) { | |||||
this.appid = appid; | |||||
this.appkey = appkey; | |||||
this.httpclient = httpclient; | |||||
} | |||||
/** | |||||
* Handle http status error | |||||
* | |||||
* @param response raw http response | |||||
* @return response raw http response | |||||
* @throws HTTPException http status exception | |||||
*/ | |||||
public HTTPResponse handleError(HTTPResponse response) throws HTTPException { | |||||
if (response.statusCode < 200 || response.statusCode >= 300) { | |||||
throw new HTTPException(response.statusCode, response.reason); | |||||
} | |||||
return response; | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import com.github.qcloudsms.SmsSenderUtil; | |||||
import com.github.qcloudsms.SmsSingleSenderResult; | |||||
import com.github.qcloudsms.httpclient.*; | |||||
import org.json.JSONException; | |||||
import org.json.JSONObject; | |||||
import java.io.IOException; | |||||
import java.net.URISyntaxException; | |||||
import java.util.ArrayList; | |||||
import java.util.Arrays; | |||||
public class SmsSingleSender extends SmsBase { | |||||
private String url = "https://yun.tim.qq.com/v5/tlssmssvr/sendsms"; | |||||
public SmsSingleSender(int appid, String appkey) { | |||||
super(appid, appkey, new DefaultHTTPClient()); | |||||
} | |||||
public SmsSingleSender(int appid, String appkey, HTTPClient httpclient) { | |||||
super(appid, appkey, httpclient); | |||||
} | |||||
/** | |||||
* 普通单发 | |||||
* | |||||
* 普通单发短信接口,明确指定内容,如果有多个签名,请在内容中以【】的方式添加到信息内容中,否则系统将使用默认签名 | |||||
* | |||||
* @param type 短信类型,0 为普通短信,1 营销短信 | |||||
* @param nationCode 国家码,如 86 为中国 | |||||
* @param phoneNumber 不带国家码的手机号 | |||||
* @param msg 信息内容,必须与申请的模板格式一致,否则将返回错误 | |||||
* @param extend 扩展码,可填空 | |||||
* @param ext 服务端原样返回的参数,可填空 | |||||
* @return {@link}SmsSingleSenderResult | |||||
* @throws HTTPException http status exception | |||||
* @throws JSONException json parse exception | |||||
* @throws IOException network problem | |||||
*/ | |||||
public SmsSingleSenderResult send(int type, String nationCode, String phoneNumber, | |||||
String msg, String extend, String ext) | |||||
throws HTTPException, JSONException, IOException { | |||||
long random = SmsSenderUtil.getRandom(); | |||||
long now = SmsSenderUtil.getCurrentTime(); | |||||
JSONObject body = new JSONObject() | |||||
.put("tel", (new JSONObject()).put("nationcode", nationCode).put("mobile", phoneNumber)) | |||||
.put("type", type) | |||||
.put("msg", msg) | |||||
.put("sig", SmsSenderUtil.calculateSignature(this.appkey, random, now, phoneNumber)) | |||||
.put("time", now) | |||||
.put("extend", SmsSenderUtil.isNotEmpty(extend) ? extend : "") | |||||
.put("ext", SmsSenderUtil.isNotEmpty(ext) ? ext : ""); | |||||
HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url) | |||||
.addHeader("Conetent-Type", "application/json") | |||||
.addQueryParameter("sdkappid", this.appid) | |||||
.addQueryParameter("random", random) | |||||
.setConnectionTimeout(60 * 1000) | |||||
.setRequestTimeout(60 * 1000) | |||||
.setBody(body.toString()); | |||||
// TODO Handle timeout exception | |||||
try { | |||||
// May throw IOException and URISyntaxexception | |||||
HTTPResponse res = httpclient.fetch(req); | |||||
// May throw HTTPException | |||||
handleError(res); | |||||
// May throw JSONException | |||||
return (new SmsSingleSenderResult()).parseFromHTTPResponse(res); | |||||
} catch(URISyntaxException e) { | |||||
throw new RuntimeException("API url has been modified, current url: " + url); | |||||
} | |||||
} | |||||
/** | |||||
* 指定模板单发 | |||||
* | |||||
* @param nationCode 国家码,如 86 为中国 | |||||
* @param phoneNumber 不带国家码的手机号 | |||||
* @param templateId 信息内容 | |||||
* @param params 模板参数列表,如模板 {1}...{2}...{3},那么需要带三个参数 | |||||
* @param sign 签名,如果填空,系统会使用默认签名 | |||||
* @param extend 扩展码,可填空 | |||||
* @param ext 服务端原样返回的参数,可填空 | |||||
* @return {@link}SmsSingleSenderResult | |||||
* @throws HTTPException http status exception | |||||
* @throws JSONException json parse exception | |||||
* @throws IOException network problem | |||||
*/ | |||||
public SmsSingleSenderResult sendWithParam(String nationCode, String phoneNumber, int templateId, | |||||
ArrayList<String> params, String sign, String extend, String ext) | |||||
throws HTTPException, JSONException, IOException { | |||||
long random = SmsSenderUtil.getRandom(); | |||||
long now = SmsSenderUtil.getCurrentTime(); | |||||
JSONObject body = new JSONObject() | |||||
.put("tel", (new JSONObject()).put("nationcode", nationCode).put("mobile", phoneNumber)) | |||||
.put("sig", SmsSenderUtil.calculateSignature(appkey, random, now, phoneNumber)) | |||||
.put("tpl_id", templateId) | |||||
.put("params", params) | |||||
.put("sign", sign) | |||||
.put("time", now) | |||||
.put("extend", SmsSenderUtil.isNotEmpty(extend) ? extend : "") | |||||
.put("ext", SmsSenderUtil.isNotEmpty(ext) ? ext : ""); | |||||
HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url) | |||||
.addHeader("Conetent-Type", "application/json") | |||||
.addQueryParameter("sdkappid", this.appid) | |||||
.addQueryParameter("random", random) | |||||
.setConnectionTimeout(60 * 1000) | |||||
.setRequestTimeout(60 * 1000) | |||||
.setBody(body.toString()); | |||||
try { | |||||
// May throw IOException and URISyntaxexception | |||||
HTTPResponse res = httpclient.fetch(req); | |||||
// May throw HTTPException | |||||
handleError(res); | |||||
// May throw JSONException | |||||
return (new SmsSingleSenderResult()).parseFromHTTPResponse(res); | |||||
} catch(URISyntaxException e) { | |||||
throw new RuntimeException("API url has been modified, current url: " + url); | |||||
} | |||||
} | |||||
public SmsSingleSenderResult sendWithParam(String nationCode, String phoneNumber, int templateId, | |||||
String[] params, String sign, String extend, String ext) | |||||
throws HTTPException, JSONException, IOException { | |||||
return sendWithParam(nationCode, phoneNumber, templateId, | |||||
new ArrayList<String>(Arrays.asList(params)), sign, extend, ext); | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import java.util.UUID; | |||||
public class UUIDUtil { | |||||
public static String uuid() { | |||||
return UUID.randomUUID().toString().replace("-", ""); | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
import java.util.regex.Matcher; | |||||
import java.util.regex.Pattern; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
public class ValidatorUtil { | |||||
private static final Pattern mobile_pattern = Pattern.compile("1\\d{10}"); | |||||
public static boolean isMobile(String src) { | |||||
if(StringUtils.isEmpty(src)) { | |||||
return false; | |||||
} | |||||
Matcher m = mobile_pattern.matcher(src); | |||||
return m.matches(); | |||||
} | |||||
// public static void main(String[] args) { | |||||
// System.out.println(isMobile("18912341234")); | |||||
// System.out.println(isMobile("1891234123")); | |||||
// } | |||||
} |
package com.cbs.company.util; | |||||
import java.io.UnsupportedEncodingException; | |||||
import java.security.MessageDigest; | |||||
import java.security.NoSuchAlgorithmException; | |||||
import java.util.Formatter; | |||||
import java.util.HashMap; | |||||
import java.util.Map; | |||||
import java.util.UUID; | |||||
import net.sf.json.JSONObject; | |||||
import org.apache.commons.lang.StringUtils; | |||||
import org.apache.commons.logging.Log; | |||||
import org.apache.commons.logging.LogFactory; | |||||
public class jsSdkUtil { | |||||
// 商用环境 | |||||
// public static String appId = "wx3c93ab6988954027"; | |||||
// public static String appSecret = "b7e585801cd95608fb0dbb49d103a1dc"; | |||||
private static final Log log = LogFactory.getLog(jsSdkUtil.class); | |||||
// 测试机 | |||||
// public static String appId = "wx15299598a10b5c34"; | |||||
// public static String appSecret = "427776202a2fc46dcb579d103d6926fa"; | |||||
public jsSdkUtil() { | |||||
} | |||||
public static String getTokenJson() { | |||||
// if (JedisUtil.checkValue("weixin:accesstoken")) { | |||||
// return JedisUtil.getStringValue("weixin:accesstoken"); | |||||
// } else { | |||||
// String appId = StaticFinalParameters.map.get("WX_APPID"); | |||||
// String appSecret = StaticFinalParameters.map.get("WX_APPSECRET"); | |||||
String appId = "wxb0897b25d8fe350c"; | |||||
String appSecret = "0e42fa12dc80da974a7ca2a410a45cb2"; | |||||
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret; | |||||
Map<String, String> data = HttpUtils.get(url); | |||||
JSONObject json = JSONObject.fromObject(data); | |||||
System.out.println("========json======================"+json.toString()); | |||||
if ("200".equals(json.get("statusCode"))) { | |||||
String restr = (String) json.get("result"); | |||||
JSONObject jsonResult = JSONObject.fromObject(restr); | |||||
String access_token = jsonResult.getString("access_token"); | |||||
if (!StringUtils.isEmpty(access_token)) { | |||||
// JedisUtil.setStrTime("weixin:accesstoken", restr, 7000); | |||||
return restr; | |||||
} | |||||
} | |||||
return null; | |||||
// } | |||||
} | |||||
public static String getToken() { | |||||
String accessjson = getTokenJson(); | |||||
if(StringUtils.isNotEmpty(accessjson)){ | |||||
JSONObject jsonResult = JSONObject.fromObject(accessjson); | |||||
String access_token = jsonResult.getString("access_token"); | |||||
log.info("==========[access_token]==========="+access_token); | |||||
return access_token; | |||||
} | |||||
return null; | |||||
} | |||||
// //////////////////////////////////js_sdk/////////////////////////////////////////////////////////////// | |||||
/** | |||||
* | |||||
* 获得jsapi_ticket | |||||
* | |||||
*/ | |||||
public static String getJsapiTicket() { | |||||
// if (JedisUtil.checkValue("weixin:jsapiticket")) { | |||||
// | |||||
// return JedisUtil.getStringValue("weixin:jsapiticket"); | |||||
// | |||||
// } else { | |||||
String token = getToken(); | |||||
String url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" + token + "&type=jsapi"; | |||||
Map<String, String> data = HttpUtils.get(url); | |||||
JSONObject json = JSONObject.fromObject(data); | |||||
log.info("==========[json]==========="+json.toString()); | |||||
log.info("==========[statusCode]==========="+json.get("statusCode")); | |||||
if ("200".equals(json.get("statusCode"))) { | |||||
JSONObject jsonResult = JSONObject.fromObject(json.get("result")); | |||||
Integer errcode = (Integer) jsonResult.get("errcode"); | |||||
if(errcode==0){ | |||||
String ticket = (String) jsonResult.get("ticket"); | |||||
if (!StringUtils.isEmpty(ticket)) { | |||||
// JedisUtil.setStrTime("weixin:jsapiticket", ticket, 7000); | |||||
log.info("==========[ticket]==========="+ticket); | |||||
return ticket; | |||||
} | |||||
}else if(40001==errcode){ | |||||
log.info("[token失效重新获取]"); | |||||
// JedisUtil.delStringValue("weixin:accesstoken"); | |||||
token = getToken(); | |||||
url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" + token + "&type=jsapi"; | |||||
data = HttpUtils.get(url); | |||||
json = JSONObject.fromObject(data); | |||||
if ("200".equals(json.get("statusCode"))) { | |||||
jsonResult = JSONObject.fromObject(json.get("result")); | |||||
errcode = (Integer) jsonResult.get("errcode"); | |||||
if(errcode==0){ | |||||
String ticket = (String) jsonResult.get("ticket"); | |||||
if (!StringUtils.isEmpty(ticket)) { | |||||
// JedisUtil.setStrTime("weixin:jsapiticket", ticket, 7000); | |||||
return ticket; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
return null; | |||||
// } | |||||
} | |||||
public static Map<String, String> sign(String jsapi_ticket, String url) { | |||||
Map<String, String> ret = new HashMap<String, String>(); | |||||
String nonce_str = create_nonce_str(); | |||||
String timestamp = create_timestamp(); | |||||
String string1; | |||||
String signature = ""; | |||||
// 注意这里参数名必须全部小写,且必须有序 | |||||
string1 = "jsapi_ticket=" + jsapi_ticket + "&noncestr=" + nonce_str + "×tamp=" + timestamp + "&url=" + url; | |||||
try { | |||||
MessageDigest crypt = MessageDigest.getInstance("SHA-1"); | |||||
crypt.reset(); | |||||
crypt.update(string1.getBytes("UTF-8")); | |||||
signature = byteToHex(crypt.digest()); | |||||
} catch (NoSuchAlgorithmException e) { | |||||
e.printStackTrace(); | |||||
} catch (UnsupportedEncodingException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
ret.put("nonceStr", nonce_str); | |||||
ret.put("timestamp", timestamp); | |||||
ret.put("signature", signature); | |||||
return ret; | |||||
} | |||||
private static String byteToHex(final byte[] hash) { | |||||
Formatter formatter = new Formatter(); | |||||
for (byte b : hash) { | |||||
formatter.format("%02x", b); | |||||
} | |||||
String result = formatter.toString(); | |||||
formatter.close(); | |||||
return result; | |||||
} | |||||
private static String create_nonce_str() { | |||||
return UUID.randomUUID().toString(); | |||||
} | |||||
private static String create_timestamp() { | |||||
return Long.toString(System.currentTimeMillis() / 1000); | |||||
} | |||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
public static void main(String[] args) { | |||||
// System.out.println(getToken()); | |||||
// System.out.println(getJssdk("http://weixin.linktech.hk/jsp/login.jsp")); | |||||
System.out.println(getJsapiTicket()); | |||||
} | |||||
} |
package com.cbs.company.util; | |||||
public class test { | |||||
// public static void main(String[] args) { | |||||
// show(new Cat()); // 以 Cat 对象调用 show 方法 | |||||
// show(new Dog()); // 以 Dog 对象调用 show 方法 | |||||
// | |||||
//// Animal a = new Cat(); // 向上转型 | |||||
//// a.eat(); // 调用的是 Cat 的 eat | |||||
//// Cat b = new Cat(); // 向上转型 | |||||
//// b.eat(); // 调用的是 Cat 的 eat | |||||
// | |||||
// //Cat c = (Cat)a; // 向下转型 | |||||
// //c.work(); // 调用的是 Cat 的 work | |||||
// } | |||||
public static void main(String[] args) { | |||||
Integer num1 = new Integer(100); | |||||
Integer num2 = new Integer(100); | |||||
System.out.println("num1==num2 " + (num1 == num2)); | |||||
Integer num3 = 100; | |||||
Integer num4 = 100; | |||||
System.out.println("num3==num4 " +(num3 == num4)); | |||||
Integer num5 = 128; | |||||
Integer num6 = 128; | |||||
System.out.println("num5==num6 " + (num5 == num6)); | |||||
Integer num7 = 100; | |||||
Integer num8 = new Integer(100); | |||||
System.out.println("num7==num8 " + (num7 == num8)); | |||||
int num9 = 100; | |||||
Integer num10 = new Integer(100); | |||||
Integer num11 = 100; | |||||
System.out.println("num9==num10 " + (num9 == num10)); | |||||
System.out.println("num9==num11 " + (num9 == num11)); | |||||
} | |||||
public static void show(Animal a) { | |||||
a.eat(); | |||||
// 类型判断 | |||||
if (a instanceof Cat) { // 猫做的事情 | |||||
Cat c = (Cat)a; | |||||
c.work(); | |||||
} else if (a instanceof Dog) { // 狗做的事情 | |||||
Dog c = (Dog)a; | |||||
c.work(); | |||||
} | |||||
} | |||||
} | |||||
abstract class Animal { | |||||
abstract void eat(); | |||||
} | |||||
class Cat extends Animal { | |||||
public void eat() { | |||||
System.out.println("吃鱼"); | |||||
} | |||||
public void work() { | |||||
System.out.println("抓老鼠"); | |||||
} | |||||
} | |||||
class Dog extends Animal { | |||||
public void eat() { | |||||
System.out.println("吃骨头"); | |||||
} | |||||
public void work() { | |||||
System.out.println("看家"); | |||||
} | |||||
} |
package com.cbs.company.util.token; | |||||
public class GeneralToken { | |||||
private String expires_in; //成功有效时间 | |||||
private String access_token; // 普通Token | |||||
private String errcode; //失败ID | |||||
private String errmsg; //失败消息 | |||||
//get set 忽略 | |||||
public String getExpires_in() { | |||||
return expires_in; | |||||
} | |||||
public void setExpires_in(String expires_in) { | |||||
this.expires_in = expires_in; | |||||
} | |||||
public String getAccess_token() { | |||||
return access_token; | |||||
} | |||||
public void setAccess_token(String access_token) { | |||||
this.access_token = access_token; | |||||
} | |||||
public String getErrcode() { | |||||
return errcode; | |||||
} | |||||
public void setErrcode(String errcode) { | |||||
this.errcode = errcode; | |||||
} | |||||
public String getErrmsg() { | |||||
return errmsg; | |||||
} | |||||
public void setErrmsg(String errmsg) { | |||||
this.errmsg = errmsg; | |||||
} | |||||
} | |||||
package com.cbs.company.util.token; | |||||
public class Token { | |||||
private Token() {} | |||||
private String token; | |||||
private static Token instance = new Token(); | |||||
public static Token getInstance() { | |||||
return instance; | |||||
} | |||||
public String getToken() { | |||||
return token; | |||||
} | |||||
public void setToken(String token) { | |||||
this.token = token; | |||||
} | |||||
} |
package com.cbs.company.vo; | |||||
public class BagVo { | |||||
private int id; | |||||
private String type; | |||||
private String texture; | |||||
private String gsprice; | |||||
private String bagprice; | |||||
private String gs; | |||||
private int kc; | |||||
private int kcyj; | |||||
private int pageIndex;// 第几页的数据 | |||||
private int pageSize;// 每页多少条数据 | |||||
public int getKcyj() { | |||||
return kcyj; | |||||
} | |||||
public void setKcyj(int kcyj) { | |||||
this.kcyj = kcyj; | |||||
} | |||||
public int getId() { | |||||
return id; | |||||
} | |||||
public void setId(int id) { | |||||
this.id = id; | |||||
} | |||||
public String getType() { | |||||
return type; | |||||
} | |||||
public void setType(String type) { | |||||
this.type = type; | |||||
} | |||||
public String getTexture() { | |||||
return texture; | |||||
} | |||||
public void setTexture(String texture) { | |||||
this.texture = texture; | |||||
} | |||||
public String getGsprice() { | |||||
return gsprice; | |||||
} | |||||
public void setGsprice(String gsprice) { | |||||
this.gsprice = gsprice; | |||||
} | |||||
public int getKc() { | |||||
return kc; | |||||
} | |||||
public void setKc(int kc) { | |||||
this.kc = kc; | |||||
} | |||||
public String getBagprice() { | |||||
return bagprice; | |||||
} | |||||
public void setBagprice(String bagprice) { | |||||
this.bagprice = bagprice; | |||||
} | |||||
public String getGs() { | |||||
return gs; | |||||
} | |||||
public void setGs(String gs) { | |||||
this.gs = gs; | |||||
} | |||||
public int getPageIndex() { | |||||
return pageIndex; | |||||
} | |||||
public void setPageIndex(int pageIndex) { | |||||
this.pageIndex = pageIndex; | |||||
} | |||||
public int getPageSize() { | |||||
return pageSize; | |||||
} | |||||
public void setPageSize(int pageSize) { | |||||
this.pageSize = pageSize; | |||||
} | |||||
} |
package com.cbs.company.vo; | |||||
public class HuVo { | |||||
private String username; | |||||
private String sn; | |||||
private String date; | |||||
public String getUsername() { | |||||
return username; | |||||
} | |||||
public void setUsername(String username) { | |||||
this.username = username; | |||||
} | |||||
public String getSn() { | |||||
return sn; | |||||
} | |||||
public void setSn(String sn) { | |||||
this.sn = sn; | |||||
} | |||||
public String getDate() { | |||||
return date; | |||||
} | |||||
public void setDate(String date) { | |||||
this.date = date; | |||||
} | |||||
} |
package com.cbs.company.vo; | |||||
import javax.validation.constraints.NotNull; | |||||
import org.hibernate.validator.constraints.Length; | |||||
public class LoginVo { | |||||
@NotNull | |||||
private String mobile; | |||||
@NotNull | |||||
@Length(min=32) | |||||
private String password; | |||||
public String getMobile() { | |||||
return mobile; | |||||
} | |||||
public void setMobile(String mobile) { | |||||
this.mobile = mobile; | |||||
} | |||||
public String getPassword() { | |||||
return password; | |||||
} | |||||
public void setPassword(String password) { | |||||
this.password = password; | |||||
} | |||||
@Override | |||||
public String toString() { | |||||
return "LoginVo [mobile=" + mobile + ", password=" + password + "]"; | |||||
} | |||||
} |
server.port=8080 | |||||
#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/pf10?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false | |||||
#spring.datasource.username=root | |||||
#spring.datasource.password= | |||||
spring.datasource.url=jdbc:postgresql://localhost:5432/pf | |||||
spring.datasource.username=postgres | |||||
spring.datasource.password=123456 |
server.port=80 | |||||
#server.port=8080 | |||||
#server.port=9090 | |||||
# druid | |||||
#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/aircbs?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false | |||||
#spring.datasource.username=root | |||||
#spring.datasource.password=root | |||||
#fs服务器 | |||||
#spring.datasource.url=jdbc:mysql://211.159.170.201:3306/pf10?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false | |||||
#spring.datasource.username=root | |||||
#spring.datasource.password=cbs)(*&^ | |||||
#spring.datasource.url=jdbc:mysql://bj-cdb-phmvqpqi.sql.tencentcdb.com:62257/pf10?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&allowMultiQueries=true | |||||
#spring.datasource.username=aircbs | |||||
#spring.datasource.password=cbs)(*&^ | |||||
#正式 服务器配置 | |||||
spring.datasource.url=jdbc:mysql://140.143.59.96:3306/pf10?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false | |||||
spring.datasource.username=root | |||||
spring.datasource.password=I@uu7z39!159z | |||||
#测试服务器配置 | |||||
#spring.datasource.url=jdbc:mysql://123.57.183.127:3306/pf10?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false | |||||
#spring.datasource.username=root | |||||
#spring.datasource.password=I@uu7zSy7Ygzapp |
# pom.xml version | |||||
project.version=@project.version@ | |||||
spring.profiles.active=dev | |||||
#thymeleaf | |||||
spring.thymeleaf.prefix=classpath:/templates/ | |||||
spring.thymeleaf.suffix=.html | |||||
spring.thymeleaf.cache=false | |||||
spring.thymeleaf.content-type=text/html | |||||
spring.thymeleaf.enabled=true | |||||
spring.thymeleaf.encoding=UTF-8 | |||||
spring.thymeleaf.mode=LEGACYHTML5 | |||||
# mybatis | |||||
mybatis.type-aliases-package=com.cbs.company.domain | |||||
mybatis.configuration.map-underscore-to-camel-case=true | |||||
mybatis.configuration.default-fetch-size=100 | |||||
mybatis.configuration.default-statement-timeout=3000 | |||||
mybatis.mapperLocations = classpath:com/cbs/company/dao/*.xml | |||||
#cbsQWERT@09 | |||||
spring.datasource.driver-class-name=org.postgresql.Driver | |||||
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver | |||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource | |||||
spring.datasource.filters=stat | |||||
spring.datasource.maxActive=2 | |||||
spring.datasource.initialSize=1 | |||||
spring.datasource.maxWait=60000 | |||||
spring.datasource.minIdle=1 | |||||
spring.datasource.timeBetweenEvictionRunsMillis=60000 | |||||
spring.datasource.minEvictableIdleTimeMillis=300000 | |||||
spring.datasource.validationQuery=select 'x' | |||||
spring.datasource.testWhileIdle=true | |||||
spring.datasource.testOnBorrow=false | |||||
spring.datasource.testOnReturn=false | |||||
spring.datasource.poolPreparedStatements=true | |||||
spring.datasource.maxOpenPreparedStatements=20 | |||||
#ÎļþÉÏ´«ÅäÖà | |||||
spring.http.multipart.maxFileSize=100Mb | |||||
spring.http.multipart.maxRequestSize=100Mb | |||||
filePath=Z://logs//image// | |||||
apiName:"" | |||||
#apiName:"/aircbs" | |||||
logging.level.com.cbs.company.dao=debug | |||||
jpa: | |||||
database: postgresql | |||||
show-sql: true | |||||
hibernate: | |||||
ddl-auto: update | |||||
naming: | |||||
strategy: org.hibernate.cfg.DefaultComponentSafeNamingStrategy | |||||
properties: | |||||
hibernate: | |||||
dialect: org.hibernate.dialect.MySQL5Dialect | |||||
rVRYIft0UKW8CNcZ |
body,html{ | |||||
font-family:Calibri,\5b8b\4f53; | |||||
color:#333; | |||||
font-size:11pt; | |||||
} | |||||
.document_title{ | |||||
font-family: "宋体"; | |||||
font-size: 18pt; | |||||
} | |||||
.document_etitle{ | |||||
font-family:"Calibri"; | |||||
font-size:16pt; | |||||
} | |||||
.document_content{ | |||||
font-family: "宋体"; | |||||
font-size: 11pt; | |||||
} | |||||
.document_econtent{ | |||||
font-family:"Calibri"; | |||||
font-size:10pt; | |||||
} | |||||
ul,ol,body,html,p{ | |||||
padding:0; | |||||
margin:0 | |||||
} | |||||
ul,ol,li{ | |||||
list-style-type:none | |||||
} | |||||
img{ | |||||
border:0 | |||||
} | |||||
input[type='checkbox'] | |||||
{ | |||||
margin:0; | |||||
padding:0; | |||||
} | |||||
table{ | |||||
border-collapse:collapse; | |||||
border:0; | |||||
margin:0; | |||||
} | |||||
table td | |||||
{ | |||||
padding:0; | |||||
} | |||||
a,input,select{ | |||||
outline:0; | |||||
*zoom:1 | |||||
} | |||||
a{ | |||||
text-decoration:none; | |||||
cursor:pointer; | |||||
} | |||||
.left{ | |||||
float:left; | |||||
} | |||||
.right{ | |||||
float:right; | |||||
} | |||||
.clear | |||||
{ | |||||
clear:both; | |||||
} | |||||
.hide | |||||
{ | |||||
display:none; | |||||
} | |||||
.fs12 | |||||
{ | |||||
font-size:12px; | |||||
} | |||||
.fs14 | |||||
{ | |||||
font-size:14px; | |||||
} | |||||
.fs15 | |||||
{ | |||||
font-size:15px; | |||||
} | |||||
.fs16 | |||||
{ | |||||
font-size:18px; | |||||
} | |||||
.fCenter | |||||
{ | |||||
text-align:center; | |||||
} | |||||
.borderB | |||||
{ | |||||
border-bottom:solid 1px #000; | |||||
} | |||||
.borderR | |||||
{ | |||||
border-right:solid 1px #000; | |||||
} | |||||
.borderT | |||||
{ | |||||
border-top:solid 1px #000; | |||||
} | |||||
.border | |||||
{ | |||||
border:solid 1px #000; | |||||
} | |||||
.borderT1 | |||||
{ | |||||
border-top:solid 1px #3a5786; | |||||
} | |||||
.bgRed | |||||
{ | |||||
background:#f67272; | |||||
} | |||||
.blue | |||||
{ | |||||
color:#0b52c8; | |||||
} | |||||
.red | |||||
{ | |||||
color:#fa5959; | |||||
} | |||||
.green | |||||
{ | |||||
color:#2c9d19; | |||||
} | |||||
.org | |||||
{ | |||||
color:#d7a12e; | |||||
} | |||||
.black | |||||
{ | |||||
color:#000; | |||||
} | |||||
.gray | |||||
{ | |||||
color:#828281; | |||||
} | |||||
.tdw25 | |||||
{ | |||||
width:25%; | |||||
} | |||||
.tdw15 | |||||
{ | |||||
width:15%; | |||||
} | |||||
.tdw50 | |||||
{ | |||||
width:50%; | |||||
} | |||||
.tdw18 | |||||
{ | |||||
width:18%; | |||||
} | |||||
.tdw70p | |||||
{ | |||||
width:70px; | |||||
} | |||||
.tdw80p | |||||
{ | |||||
width:80px; | |||||
} | |||||
.tdw120p | |||||
{ | |||||
width:120px; | |||||
} | |||||
.tdw150p | |||||
{ | |||||
width:150px; | |||||
} | |||||
.tdw198p | |||||
{ | |||||
width:198px; | |||||
} | |||||
.tdw120p | |||||
{ | |||||
width:120px; | |||||
} | |||||
.tdw230p | |||||
{ | |||||
width:230px; | |||||
} | |||||
.tdw250p | |||||
{ | |||||
width:250px; | |||||
} | |||||
.tdw300p | |||||
{ | |||||
width:300px; | |||||
} | |||||
.tdw450p | |||||
{ | |||||
width:450px; | |||||
} | |||||
.ml5 | |||||
{ | |||||
margin-left:5px; | |||||
} | |||||
.ml10 | |||||
{ | |||||
margin-left:10px; | |||||
} | |||||
.ml20 | |||||
{ | |||||
margin-left:20px; | |||||
} | |||||
.ml25 | |||||
{ | |||||
margin-left:25px; | |||||
} | |||||
.ml28 | |||||
{ | |||||
margin-left:28px; | |||||
} | |||||
.ml31 | |||||
{ | |||||
margin-left:31px; | |||||
} | |||||
.ml35 | |||||
{ | |||||
margin-left:35px; | |||||
} | |||||
.ml60 | |||||
{ | |||||
margin-left:35px; | |||||
} | |||||
.ml50 | |||||
{ | |||||
margin-left:50px; | |||||
} | |||||
.ml100 | |||||
{ | |||||
margin-left:100px; | |||||
} | |||||
.ml200 | |||||
{ | |||||
margin-left:200px; | |||||
} | |||||
.mb2 | |||||
{ | |||||
margin-bottom:2px; | |||||
} | |||||
.mb5 | |||||
{ | |||||
margin-bottom:5px; | |||||
} | |||||
.mt3 | |||||
{ | |||||
margin-top:3px; | |||||
} | |||||
.mt5 | |||||
{ | |||||
margin-top:5px; | |||||
} | |||||
.mt7 | |||||
{ | |||||
margin-top:7px; | |||||
} | |||||
.mt9 | |||||
{ | |||||
margin-top:9px; | |||||
} | |||||
.mt10 | |||||
{ | |||||
margin-top:10px; | |||||
} | |||||
.mt20 | |||||
{ | |||||
margin-top:20px; | |||||
} | |||||
.mt30 | |||||
{ | |||||
margin-top:30px; | |||||
} | |||||
.mt40 | |||||
{ | |||||
margin-top:40px; | |||||
} | |||||
.mt50 | |||||
{ | |||||
margin-top:50px; | |||||
} | |||||
.mr10 | |||||
{ | |||||
margin-right:10px; | |||||
} | |||||
.mr80 | |||||
{ | |||||
margin-right:80px; | |||||
} | |||||
.pt30 | |||||
{ | |||||
padding-top:30px; | |||||
} | |||||
.pl5 | |||||
{ | |||||
padding-left:5px; | |||||
} | |||||
.bold | |||||
{ | |||||
font-weight:bold; | |||||
} | |||||
.lh12 | |||||
{ | |||||
line-height:12px; | |||||
} | |||||
.lh10 | |||||
{ | |||||
line-height:10px; | |||||
} | |||||
.infoDiv | |||||
{ | |||||
width:95%; | |||||
height:40px; | |||||
line-height:40px; | |||||
word-break:break-all; | |||||
word-wrap:break-word; | |||||
font-size:15px; | |||||
font-weight:bold; | |||||
} | |||||
.infoDiv1 | |||||
{ | |||||
height:20px; | |||||
word-break:break-all; | |||||
word-wrap:break-word; | |||||
float:left; | |||||
border-bottom:solid 1px #000; | |||||
font-size:15px; | |||||
font-weight:bold; | |||||
letter-spacing:normal; | |||||
} | |||||
.infoDiv3 | |||||
{ | |||||
height:30px; | |||||
word-break:break-all; | |||||
word-wrap:break-word; | |||||
float:left; | |||||
border-bottom:solid 1px #000; | |||||
margin-top:10px; | |||||
font-size:15px; | |||||
font-weight:bold; | |||||
} | |||||
.infoDivMul | |||||
{ | |||||
width:95%; | |||||
line-height:20px; | |||||
word-break:break-all; | |||||
word-wrap:break-word; | |||||
font-size:15px; | |||||
} | |||||
.infoIns | |||||
{ | |||||
height:25px; | |||||
padding-top:5px; | |||||
margin-left:5px; | |||||
} | |||||
.inputStyle | |||||
{ | |||||
width:80%; | |||||
border:solid 1px #000; | |||||
margin:5px 0 0 2px; | |||||
font-family:Calibri,\5b8b\4f53; | |||||
font-size: 11pt; | |||||
} | |||||
.inputStyle1 | |||||
{ | |||||
width:40px; | |||||
border:solid 1px #000; | |||||
margin:5px 0 0 2px; | |||||
} | |||||
.inputStyle2 | |||||
{ | |||||
width:80%; | |||||
height:15px; | |||||
border:solid 1px #000; | |||||
margin:-2px 0 0 2px; | |||||
} | |||||
.inputStyle3 | |||||
{ | |||||
width:80%; | |||||
height:28px; | |||||
border:solid 1px #000; | |||||
margin:5px 0 0 2px; | |||||
} | |||||
.inputStyle4 | |||||
{ | |||||
width:80%; | |||||
height:28px; | |||||
border:solid 1px #000; | |||||
margin:-2px 0 0 2px; | |||||
} | |||||
.inputStyle5 | |||||
{ | |||||
width:80%; | |||||
border:solid 1px #000; | |||||
margin:5px 0 0 0px; | |||||
} | |||||
.inputStyle6 | |||||
{ | |||||
width:100px; | |||||
border:solid 1px #000; | |||||
margin:5px 0 0 2px; | |||||
} | |||||
.inputStyle7 | |||||
{ | |||||
border:solid 1px #aaa; | |||||
height:25px; | |||||
line-height:25px; | |||||
padding-left:5px; | |||||
width:120px; | |||||
font-family:微软雅黑; | |||||
color:#aaa; | |||||
float:left; | |||||
} | |||||
.mulText | |||||
{ | |||||
width:80%; | |||||
height:54px; | |||||
line-height:18px; | |||||
border:solid 1px #000; | |||||
} | |||||
.mulText1 | |||||
{ | |||||
width:80%; | |||||
height:46px; | |||||
line-height:18px; | |||||
border:solid 1px #000; | |||||
} | |||||
.mulText2 | |||||
{ | |||||
width:80%; | |||||
height:36px; | |||||
line-height:18px; | |||||
border:solid 1px #000; | |||||
} | |||||
.selectStyle | |||||
{ | |||||
width:300px; | |||||
height:25px; | |||||
border:solid 1px #000; | |||||
margin:2px 0 0 2px; | |||||
} | |||||
.selectStyle1 | |||||
{ | |||||
width:108px; | |||||
height:30px; | |||||
border:solid 1px #ddd; | |||||
margin-top:10px; | |||||
} | |||||
.fvertical | |||||
{ | |||||
width:30px; | |||||
margin:0 auto; | |||||
line-height:25px; | |||||
text-align:center; | |||||
} | |||||
.leftNav | |||||
{ | |||||
width:120px; | |||||
position:absolute; | |||||
left:50px; | |||||
top:150px; | |||||
font-size:16px; | |||||
} | |||||
.leftNav .navList | |||||
{ | |||||
width:100%; | |||||
overflow:hidden; | |||||
border-left:solid 1px #ddd; | |||||
} | |||||
.navList .listItem | |||||
{ | |||||
width:90%; | |||||
position:relative; | |||||
height:40px; | |||||
line-height:40px; | |||||
padding-left:10%; | |||||
} | |||||
.navList .listItem | |||||
{ | |||||
display:block; | |||||
} | |||||
.navList .sideLine | |||||
{ | |||||
width:5px; | |||||
height:30px; | |||||
position:absolute; | |||||
bottom:4px; | |||||
left:0; | |||||
background:#345b9c; | |||||
display:none; | |||||
} | |||||
.current .sideLine | |||||
{ | |||||
display:block; | |||||
} | |||||
.listFont | |||||
{ | |||||
color:#345b9c; | |||||
} | |||||
.current .listFont | |||||
{ | |||||
color:#345b9c; | |||||
font-weight:bold; | |||||
} | |||||
.bgBlue | |||||
{ | |||||
background:#345b9c; | |||||
} | |||||
.hei220 | |||||
{ | |||||
height:220px; | |||||
} | |||||
.hei230 | |||||
{ | |||||
height:230px; | |||||
} | |||||
.hei180 | |||||
{ | |||||
height:180px; | |||||
} | |||||
.hei160 | |||||
{ | |||||
height:160px; | |||||
} | |||||
.hei140 | |||||
{ | |||||
height:140px; | |||||
} | |||||
.hei120 | |||||
{ | |||||
height:120px; | |||||
} | |||||
.hei105 | |||||
{ | |||||
height:105px; | |||||
} | |||||
.hei90 | |||||
{ | |||||
height:90px; | |||||
} | |||||
.hei80 | |||||
{ | |||||
height:80px; | |||||
} | |||||
.hei65 | |||||
{ | |||||
height:65px; | |||||
} | |||||
.hei40 | |||||
{ | |||||
height:40px; | |||||
} | |||||
.hei30 | |||||
{ | |||||
height:30px; | |||||
} | |||||
.lgWrap | |||||
{ | |||||
width:80px; | |||||
position:absolute; | |||||
top:50px; | |||||
left:50px; | |||||
} | |||||
.lgWrap a | |||||
{ | |||||
line-height:20px; | |||||
display:block; | |||||
text-decoration:underline; | |||||
} | |||||
.btnWrap | |||||
{ | |||||
clear:both; | |||||
width:100%; | |||||
text-align:center; | |||||
margin-bottom:20px; | |||||
} | |||||
.btn | |||||
{ | |||||
width:120px; | |||||
height:30px; | |||||
line-height:30px; | |||||
text-align:center; | |||||
border-radius:5px; | |||||
background:#345b9c; | |||||
color:#fff; | |||||
border:none; | |||||
} | |||||
/*signature*/ | |||||
.sigWrap | |||||
{ | |||||
position:absolute; | |||||
left:0; | |||||
bottom:2px; | |||||
width:100%; | |||||
height:45px; | |||||
text-align:center; | |||||
} | |||||
.signature | |||||
{ | |||||
width:90px; | |||||
height:45px; | |||||
} | |||||
.sigBtnWrap | |||||
{ | |||||
width:100%; | |||||
height:30px; | |||||
text-align:right; | |||||
position:absolute; | |||||
top:60px; | |||||
left:0; | |||||
} | |||||
.sigBtnWrap .btnStartSig,.sigBtnWrap .btnSaveSig | |||||
{ | |||||
width:90px; | |||||
height:28px; | |||||
background:#345B9C; | |||||
color:#fff; | |||||
text-align:center; | |||||
border:none; | |||||
} | |||||
.sigBtnWrap .btnSaveSig | |||||
{ | |||||
background:#d26464; | |||||
} | |||||
/*signature*/ | |||||
.info-title-form { | |||||
width:110px; | |||||
text-align:left; | |||||
} | |||||
.info-title-form-140 { | |||||
width:145px; | |||||
text-align:left; | |||||
} |
.listWrap | |||||
{ | |||||
width:800px; | |||||
margin:20px 20px 20px 100px; | |||||
overflow:hidden; | |||||
} | |||||
.listWrap_p | |||||
{ | |||||
margin:0 auto; | |||||
} | |||||
.version | |||||
{ | |||||
width:100%; | |||||
height:20px; | |||||
line-height:20px; | |||||
border-bottom:solid 1px #000; | |||||
} | |||||
.claimHeader | |||||
{ | |||||
width:100%; | |||||
height:100px; | |||||
position:relative; | |||||
} | |||||
.claimHeader .logoWrap | |||||
{ | |||||
float:left; | |||||
width:100px; | |||||
height:70px; | |||||
margin-left:40px; | |||||
position:relative; | |||||
font-size:12px; | |||||
} | |||||
.logoWrap .logo | |||||
{ | |||||
position:absolute; | |||||
top:0; | |||||
left:-10px; | |||||
width:160px; | |||||
height:60px; | |||||
} | |||||
.logoWrap .txFontC | |||||
{ | |||||
width:140px; | |||||
text-align:right; | |||||
display:block; | |||||
position:absolute; | |||||
bottom:0px; | |||||
right:0px; | |||||
font-weight:bold; | |||||
} | |||||
.logoWrap .txLine | |||||
{ | |||||
display:block; | |||||
width:2px; | |||||
height:28px; | |||||
background:#000; | |||||
position:absolute; | |||||
bottom:0px; | |||||
right:-5px; | |||||
} | |||||
.logoWrap .txFontE | |||||
{ | |||||
width:100px; | |||||
display:block; | |||||
position:absolute; | |||||
bottom:0px; | |||||
right:-110px; | |||||
line-height:10px; | |||||
font-size:10px; | |||||
} | |||||
.claimHeader .claimTitle | |||||
{ | |||||
float:left; | |||||
width:500px; | |||||
text-align:center; | |||||
margin:10px 0 0 100px; | |||||
font-size:18pt; | |||||
letter-spacing:3px; | |||||
font-weight:bold; | |||||
font-family: "宋体"; | |||||
} | |||||
.claimTitle .titleEn | |||||
{ | |||||
font-size:16pt; | |||||
line-height:20px; | |||||
letter-spacing:normal; | |||||
font-family: "Calibri"; | |||||
} | |||||
.lostCon | |||||
{ | |||||
line-height:28px; | |||||
} | |||||
.receiptInfo | |||||
{ | |||||
width:100%; | |||||
height:30px; | |||||
margin-top:10px; | |||||
margin-bottom:20px; | |||||
font-size: 12px; | |||||
} | |||||
.tbll | |||||
{ | |||||
width:50%; | |||||
text-align:center; | |||||
float:left; | |||||
border-top:solid 1px #000; | |||||
border-left:solid 1px #000; | |||||
margin-top:30px; | |||||
} | |||||
.tbll td | |||||
{ | |||||
height:40px; | |||||
border-bottom:solid 1px #000; | |||||
border-right:solid 1px #000; | |||||
} | |||||
.tblr | |||||
{ | |||||
width:50%; | |||||
float:left; | |||||
border-top:solid 1px #000; | |||||
margin-top:30px; | |||||
} | |||||
.tblr td | |||||
{ | |||||
padding:0 5px; | |||||
height:40px; | |||||
border-bottom:solid 1px #000; | |||||
border-right:solid 1px #000; | |||||
} | |||||
.itinerary | |||||
{ | |||||
width:100%; | |||||
border-top:solid 1px #000; | |||||
border-left:solid 1px #000; | |||||
text-align:center; | |||||
} | |||||
.itinerary td | |||||
{ | |||||
border-bottom:solid 1px #000; | |||||
border-right:solid 1px #000; | |||||
} |
/* | |||||
*create by zhounian on 2016/11/08 | |||||
*/ | |||||
body{color:#666;} | |||||
/*-------------------------新增商品分类-start-----------------------*/ | |||||
.classify-title{ | |||||
font-size:15px; | |||||
line-height:40px; | |||||
text-align:center; | |||||
background:#f0f0f0; | |||||
} | |||||
.classify-title .title-icon{ | |||||
float:right; | |||||
margin-top:-1px; | |||||
margin-right:10px; | |||||
} | |||||
.classify-content{ | |||||
height:500px; | |||||
border:1px solid #f0f0f0; | |||||
overflow-y:auto; | |||||
} | |||||
.classify-content li a{ | |||||
display:inline-block; | |||||
padding:0 10px; | |||||
width:100%; | |||||
color:#666; | |||||
line-height:40px; | |||||
} | |||||
.classify-content li a span{ | |||||
display:none; | |||||
float:right; | |||||
margin-left:5px; | |||||
} | |||||
.classify-content li a:hover, .classify-content li a.active{ | |||||
text-decoration:none; | |||||
background:#ccc; | |||||
} | |||||
.classify-content li a:hover span, .classify-content li a.active span{display:inline-block;} | |||||
/*----------------------新增商品分类-end---------------------*/ | |||||
/*-----------------------新增商品-start----------------------*/ | |||||
.goods-add-wrap{max-width:1100px;} | |||||
.toggle-content{display:none;} | |||||
.w200{width:200px;} | |||||
.w148{width:148px !important;} | |||||
.w417{width:417px !important;} | |||||
span.textbox{ | |||||
margin:0; | |||||
width:100% !important; | |||||
height:35px !important; | |||||
border-radius:0; | |||||
} | |||||
.bg-gray span.textbox{width:150px !important;} | |||||
.combo-panel{padding:0;} | |||||
.combobox-item, .combobox-group{line-height:25px;} | |||||
.combobox-item-selected{background:#0791fa;} | |||||
.row{margin:0;} | |||||
.goods-brand{ | |||||
padding:0; | |||||
padding-left:5px; | |||||
background:none; | |||||
border:0; | |||||
} | |||||
.bg-gray{ | |||||
padding:20px 15px; | |||||
background:#f0f0f0; | |||||
} | |||||
.bg-gray .select-group{width:150px;} | |||||
.bg-gray .form-group .mx-group-title.max-label{width:100px;} | |||||
.goods-car{ | |||||
padding:10px; | |||||
width:585px; | |||||
height:150px; | |||||
background:#fff; | |||||
border:1px solid #d6d6d6; | |||||
overflow-y:auto; | |||||
} | |||||
.goods-car label{margin-right:10px;} | |||||
.btn-toggle i{ | |||||
margin-top:-5px; | |||||
vertical-align:top; | |||||
cursor:pointer; | |||||
} | |||||
.update-goods li{ | |||||
float:left; | |||||
margin-left:65px; | |||||
width:180px; | |||||
text-align:center; | |||||
cursor:pointer; | |||||
} | |||||
.update-goods .none-img{ | |||||
height:100%; | |||||
background:url('../new-images/icon-pic.png') #e0e0e0 no-repeat center 60px; | |||||
} | |||||
.update-goods .none-img p{ | |||||
margin:0; | |||||
padding:20px 0 10px; | |||||
font-size:16px; | |||||
color:#999; | |||||
} | |||||
.update-goods li>div{ | |||||
height:180px; | |||||
border:1px solid #d6d6d6; | |||||
} | |||||
.update-goods li>div, .update-goods .avatar-view{position:relative;} | |||||
.update-goods .avatar-view, .update-goods .avatar-view img{ | |||||
width:178px; | |||||
height:178px; | |||||
} | |||||
.del-wrap{ | |||||
display:none; | |||||
position:absolute; | |||||
top:0; | |||||
right:0; | |||||
bottom:0; | |||||
left:0; | |||||
background:rgba(0,0,0,0.2); | |||||
z-index:1; | |||||
} | |||||
.img-del{ | |||||
display:none; | |||||
position:absolute; | |||||
top:-10px; | |||||
right:-10px; | |||||
height:22px; | |||||
border:3px solid #fff; | |||||
background:#fff; | |||||
border-radius:50%; | |||||
z-index:2; | |||||
} | |||||
.img-del i{vertical-align:top;} | |||||
.update-goods li:hover .del-wrap{display:block;} | |||||
.update-goods li:hover .img-del{display:inline-block;} | |||||
.ke-container{ | |||||
width:100% !important; | |||||
} | |||||
/*------------------------新增商品-end-----------------------*/ |
.icon{ | |||||
display:inline-block; | |||||
vertical-align:middle; | |||||
background:url("images/icon.png"); | |||||
} | |||||
.icon-btn{ | |||||
margin-top:-5px; | |||||
margin-right:5px; | |||||
} | |||||
.icon-btn-s{ | |||||
margin-top:-3px; | |||||
margin-right:10px; | |||||
} | |||||
.icon-12{ | |||||
width:12px; | |||||
height:12px; | |||||
} | |||||
.icon-14{ | |||||
width:14px; | |||||
height:14px; | |||||
} | |||||
.icon-16{ | |||||
width:16px; | |||||
height:16px; | |||||
} | |||||
.icon-18{ | |||||
width:18px; | |||||
height:18px; | |||||
} | |||||
.icon-20{ | |||||
width:20px; | |||||
height:20px; | |||||
} | |||||
.icon-20-21{ | |||||
width:20px; | |||||
height:21px; | |||||
} | |||||
.icon-22{ | |||||
width:22px; | |||||
height:22px; | |||||
} | |||||
.icon-20-40{ | |||||
width:20px; | |||||
height:40px; | |||||
} | |||||
.icon-24{ | |||||
width:24px; | |||||
height:24px; | |||||
} | |||||
.icon-26-20{ | |||||
width:26px; | |||||
height:20px; | |||||
} | |||||
.icon-26{ | |||||
width:26px; | |||||
height:26px; | |||||
} | |||||
.icon-28{ | |||||
width:28px; | |||||
height:28px; | |||||
} | |||||
.icon-30-28{ | |||||
width:30px; | |||||
height:28px; | |||||
} | |||||
.icon-34{ | |||||
width:34px; | |||||
height:34px; | |||||
} | |||||
.icon-36{ | |||||
width:36px; | |||||
height:36px; | |||||
} | |||||
.icon-40{ | |||||
width:40px; | |||||
height:40px; | |||||
} | |||||
.icon-50{ | |||||
width:50px; | |||||
height:50px; | |||||
} | |||||
.icon-54{ | |||||
width:54px; | |||||
height:54px; | |||||
} | |||||
/*28x28*/ | |||||
.icon-value-add{background-position:0 0;} | |||||
.icon-help{background-position:-28px 0;} | |||||
.icon-mobile{background-position:-56px 0;} | |||||
.icon-e-mall{background-position:-376px -293px;} | |||||
.icon-remind-w{background-position:-84px 0;} | |||||
.icon-remind-g{background-position:-112px 0;} | |||||
.icon-car-wash-g{background-position:-140px 0;} | |||||
.icon-num-plate-g{background-position:-168px 0;} | |||||
.icon-exit-login-g{background-position:-196px 0;} | |||||
.icon-pwd-g{background-position:-224px 0;} | |||||
.icon-lock-screen-g{background-position:-252px 0;} | |||||
.icon-customer-g{background-position:-280px 0;} | |||||
.icon-inventory-g{background-position:-308px 0;} | |||||
.icon-order{background-position:4px -202px;} | |||||
.icon-discount-g{background-position:-360px -216px;} | |||||
.icon-member-g{background-position:-388px -216px;} | |||||
.icon-recommend-g{background-position:-360px -244px;} | |||||
.icon-ordersettle-g{background-position:-388px -244px;} | |||||
/*30x28*/ | |||||
.icon-switch{background-position:-336px 0;} | |||||
.icon-switch-right{background-position:-366px 0;} | |||||
.icon-switch-left{background-position:-396px 0;} | |||||
/*40x40*/ | |||||
.icon-abs-o{background-position:0 -28px;} | |||||
.icon-abs-g{background-position:0 -68px;} | |||||
.icon-abs-b{background-position:0 -252px;} | |||||
.icon-fuel-quantit-o{background-position:-40px -28px;} | |||||
.icon-fuel-quantit-g{background-position:-40px -68px;} | |||||
.icon-fuel-quantit-b{background-position:-40px -252px;} | |||||
.icon-mains-electricity-o{background-position:-80px -28px;} | |||||
.icon-mains-electricity-g{background-position:-80px -68px;} | |||||
.icon-mains-electricity-b{background-position:-80px -252px;} | |||||
.icon-oil-pressure-o{background-position:-120px -28px;} | |||||
.icon-oil-pressure-g{background-position:-120px -68px;} | |||||
.icon-oil-pressure-b{background-position:-120px -252px;} | |||||
.icon-stoplight-o{background-position:-160px -28px;} | |||||
.icon-stoplight-g{background-position:-160px -68px;} | |||||
.icon-stoplight-b{background-position:-160px -252px;} | |||||
.icon-engine-o{background-position:-200px -28px;} | |||||
.icon-engine-g{background-position:-200px -68px;} | |||||
.icon-engine-b{background-position:-200px -252px;} | |||||
.icon-interior-lights-o{background-position:-240px -28px;} | |||||
.icon-interior-lights-g{background-position:-240px -68px;} | |||||
.icon-interior-lights-b{background-position:-240px -252px;} | |||||
.icon-coolant-o{background-position:-280px -28px;} | |||||
.icon-coolant-g{background-position:-280px -68px;} | |||||
.icon-coolant-b{background-position:-280px -252px;} | |||||
.icon-ebd-o{background-position:-320px -28px;} | |||||
.icon-ebd-g{background-position:-320px -68px;} | |||||
.icon-ebd-b{background-position:-320px -252px;} | |||||
.icon-disinfection-o{background-position:0 -332px;} | |||||
.icon-disinfection-g{background-position:0 -372px;} | |||||
.icon-disinfection-b{background-position:0 -412px;} | |||||
.icon-stability-o{background-position:-40px -332px;} | |||||
.icon-stability-g{background-position:-40px -372px;} | |||||
.icon-stability-b{background-position:-40px -412px;} | |||||
.icon-level-warning-o{background-position:-80px -332px;} | |||||
.icon-level-warning-g{background-position:-80px -372px;} | |||||
.icon-level-warning-b{background-position:-80px -412px;} | |||||
.icon-pressure-o{background-position:-120px -332px;} | |||||
.icon-pressure-g{background-position:-120px -372px;} | |||||
.icon-pressure-b{background-position:-120px -412px;} | |||||
.icon-eps-o{background-position:-160px -332px;} | |||||
.icon-eps-g{background-position:-160px -372px;} | |||||
.icon-eps-b{background-position:-160px -412px;} | |||||
.icon-pad-wear-o{background-position:-200px -332px;} | |||||
.icon-pad-wear-g{background-position:-200px -372px;} | |||||
.icon-pad-wear-b{background-position:-200px -412px;} | |||||
.icon-parking-brake-o{background-position:-240px -332px;} | |||||
.icon-parking-brake-g{background-position:-240px -372px;} | |||||
.icon-parking-brake-b{background-position:-240px -412px;} | |||||
.icon-airbag-fault-o{background-position:-280px -332px;} | |||||
.icon-airbag-fault-g{background-position:-280px -372px;} | |||||
.icon-airbag-fault-b{background-position:-280px -412px;} | |||||
.icon-sensor-o{background-position:-320px -332px;} | |||||
.icon-sensor-g{background-position:-320px -372px;} | |||||
.icon-sensor-b{background-position:-320px -412px;} | |||||
.icon-cruise-control-o{background-position:-360px -332px;} | |||||
.icon-cruise-control-g{background-position:-360px -372px;} | |||||
.icon-cruise-control-b{background-position:-360px -412px;} | |||||
.icon-switch-fault-o{background-position:0 -492px;} | |||||
.icon-switch-fault-g{background-position:0 -532px;} | |||||
.icon-switch-fault-b{background-position:0 -572px;} | |||||
.icon-video{background-position:-360px -28px;} | |||||
.icon-help-displays{background-position:-360px -68px;} | |||||
/*20x40*/ | |||||
.icon-three-menu1{background-position:0px -108px;} | |||||
.icon-three-menu2{background-position:-20px -108px;} | |||||
/*20x20*/ | |||||
.icon-check-abroad{background-position:-40px -108px;} | |||||
.icon-check-within{background-position:-40px -128px;} | |||||
.icon-edit{background-position:-60px -108px;} | |||||
.icon-set{background-position:-60px -128px;} | |||||
.icon-search{background-position:-80px -108px;} | |||||
.icon-customer1{background-position:-80px -128px;} | |||||
.icon-inventory1{background-position:-100px -108px;} | |||||
.icon-refresh{background-position:-100px -128px;} | |||||
.icon-help-g{background-position:-120px -108px;} | |||||
.icon-update-img{background-position:-120px -128px;} | |||||
.icon-delete-total{background-position:-360px -272px;} | |||||
.icon-refresh-total{background-position:-380px -272px;} | |||||
/*22x22*/ | |||||
.icon-reset-pwd{background-position:right -272px;} | |||||
.icon-exit-login{background-position:right -294px;} | |||||
.icon-wash-car{background-position:right -316px;} | |||||
.icon-lock-screen{background-position:right -338px;} | |||||
.icon-store{background-position:-404px -360px;} | |||||
.icon-pickup{background-position:right -382px;} | |||||
.icon-shopping{background-position:right -404px;} | |||||
.icon-user{background-position:right -426px;} | |||||
.icon-money{background-position:right -448px;} | |||||
.icon-attach{background-position:right -470px;} | |||||
.icon-system{background-position:right -492px;} | |||||
.icon-doubleGoods{background-position:right -628px;} | |||||
.icon-addGoods{background-position:right -603px;} | |||||
.icon-text{background-position:right -536px;} | |||||
.icon-line{background-position:right -558px;} | |||||
.icon-adv{background-position:right -580px;} | |||||
/*24*24*/ | |||||
.icon-add-round{background-position:-170px -228px;} | |||||
/*26x20*/ | |||||
.icon-one-menu1{background-position:-140px -108px;} | |||||
.icon-one-menu1-b{background-position:-140px -128px;} | |||||
.icon-one-menu2{background-position:-166px -108px;} | |||||
.icon-one-menu2-b{background-position:-166px -128px;} | |||||
/*26x26*/ | |||||
.icon-play{background-position:-170px -202px;} | |||||
.icon-pause{background-position:-196px -202px;} | |||||
.icon-fullscreen{background-position:-222px -202px;} | |||||
.icon-exit-fullscreen{background-position:-248px -202px;} | |||||
.icon-mute{background-position:-274px -202px;} | |||||
.icon-volume1{background-position:-300px -202px;} | |||||
.icon-volume2{background-position:-326px -202px;} | |||||
/*14x14*/ | |||||
.icon-triangle1-m{background-position:-192px -120px;} | |||||
.icon-triangle2-m{background-position:-206px -120px;} | |||||
.icon-triangle1{background-position:-192px -134px;} | |||||
.icon-triangle2{background-position:-206px -134px;} | |||||
.icon-close-g{background-position:-220px -120px;} | |||||
.icon-close-b{background-position:-220px -134px;} | |||||
.icon-first-page{background-position:-234px -120px;} | |||||
.icon-first-page1{background-position:-234px -134px;} | |||||
.icon-last-page{background-position:-248px -134px;} | |||||
.icon-last-page1{background-position:-248px -120px;} | |||||
.icon-triangle1-s{background-position:-262px -120px;} | |||||
.icon-triangle2-s{background-position:-262px -134px;} | |||||
.icon-arrow1{background-position:0 -228px;} | |||||
/*36x36*/ | |||||
.icon-help-document{background-position:-276px -108px;} | |||||
.icon-help-video{background-position:-313px -108px;} | |||||
.icon-help-setting{background-position:-350px -108px;} | |||||
/*54x54*/ | |||||
.icon-home-card{background-position:0 -148px;} | |||||
.icon-home-car{background-position:-54px -148px;} | |||||
.icon-home-money{background-position:-108px -148px;} | |||||
.icon-warning{background-position:-162px -148px;} | |||||
/*34x34*/ | |||||
.icon-qq{background-position:-216px -148px;} | |||||
.icon-tel{background-position:-250px -148px;} | |||||
.icon-verification{background-position:-352px -148px;} | |||||
.icon-password{background-position:-386px -148px;} | |||||
.icon-account{background-position:-386px -114px;} | |||||
.icon-bj-wrong{background-position:-318px -148px;} | |||||
.icon-bj-yes{background-position:-284px -148px;} | |||||
.icon-blue-wrong{background-position:-352px -182px;} | |||||
.icon-blue-yes{background-position:-386px -182px;} | |||||
/*50x50*/ | |||||
.icon-single-vehicle-yes{background-position:-20px -202px;} | |||||
.icon-single-vehicle{background-position:-70px -202px;} | |||||
.icon-single-vehicle-no{background-position:-120px -202px;} | |||||
.icon-prompt{background-position:-28px -47px;} | |||||
.icon-del-s{background-position:right -86px;} | |||||
.icon-img-del{background-position:-220px -120px;} | |||||
.icon-img-save{background-position:right -70px;} | |||||
.btn-icon{ | |||||
display:inline-block; | |||||
vertical-align:middle; | |||||
background:url("images/btn-icon.png"); | |||||
} | |||||
/*12*12*/ | |||||
.icon-toggle-left{background-position:0 -134px;} | |||||
.icon-toggle-right{background-position:-12px -134px;} | |||||
/*first 16x16*/ | |||||
.icon-delay{background-position:0 0;} | |||||
.icon-statistics{background-position:-16px 0;} | |||||
.icon-this-month{background-position:-32px 0;} | |||||
.icon-today{background-position:-48px 0;} | |||||
.icon-brand{background-position:-64px 0;} | |||||
.icon-commission{background-position:-80px 0;} | |||||
.icon-invalid{background-position:-96px 0;} | |||||
.icon-reward-and-penalty{background-position:-112px 0;} | |||||
.icon-withdrawal-car{background-position:-128px 0;} | |||||
.icon-recharge{background-position:-144px 0;} | |||||
/*second 16x16*/ | |||||
.icon-message{background-position:0 -16px;} | |||||
.icon-end{background-position:-16px -16px;} | |||||
.icon-apply-car{background-position:-32px -16px;} | |||||
.icon-revised{background-position:-48px -16px;} | |||||
.icon-binding{background-position:-64px -16px;} | |||||
.icon-payment-details{background-position:-80px -16px;} | |||||
.icon-print{background-position:-96px -16px;} | |||||
.icon-adviser{background-position:-112px -16px;} | |||||
.icon-purchaser{background-position:-128px -16px;} | |||||
.icon-warning1{background-position:-144px -16px;} | |||||
/*third 16x16*/ | |||||
.icon-remind{background-position:0 -32px;} | |||||
.icon-package{background-position:-16px -32px;} | |||||
.icon-screen-white{background-position:-32px -32px;} | |||||
.icon-off-the-shelf{background-position:-48px -32px;} | |||||
.icon-shelves{background-position:-62px -32px;} | |||||
.icon-select-date{background-position:-80px -32px;} | |||||
.icon-car-wash{background-position:-96px -32px;} | |||||
.icon-credit-settlement{background-position:-112px -32px;} | |||||
.icon-continue{background-position:-128px -32px;} | |||||
.icon-kill-an-order{background-position:-144px -32px;} | |||||
/*forth 16x16*/ | |||||
.icon-ascending{background-position:0 -48px;} | |||||
.icon-descending{background-position:-16px -48px;} | |||||
.icon-screen{background-position:-32px -48px;} | |||||
.icon-delete{background-position:-48px -48px;} | |||||
.icon-delete0{background-position:-64px -48px;} | |||||
.icon-establish{background-position:-80px -48px;} | |||||
.icon-establish-b{background-position:-96px -48px;} | |||||
.icon-disable{background-position:-112px -48px;} | |||||
.icon-discount{background-position:-128px -48px;} | |||||
.icon-purchaser-b{background-position:-144px -48px;} | |||||
/*fifth 16x16*/ | |||||
.icon-details{background-position:0 -64px;} | |||||
.icon-rework0{background-position:-16px -64px;} | |||||
.icon-expanxion{background-position:-32px -64px;} | |||||
.icon-hide{background-position:-48px -64px;} | |||||
.icon-more{background-position:-64px -64px;} | |||||
.icon-edit-s{background-position:-80px -64px;} | |||||
.icon-edit-g{background-position:-112px -146px;} | |||||
.icon-add-customer{background-position:-96px -64px;} | |||||
.icon-rework{background-position:-112px -64px;} | |||||
.icon-delete-w{background-position:-128px -64px;} | |||||
.icon-edit-w{background-position:-144px -64px;} | |||||
.icon-add1{background-position:0 -97px;} | |||||
.icon-delete-r{background-position:-16px -97px;} | |||||
.icon-card{background-position:-32px -97px;} | |||||
.icon-charge{background-position:-48px -97px;} | |||||
.icon-export-w{background-position:-64px -97px;} | |||||
.icon-page-left0{background-position:-80px -97px;} | |||||
.icon-page-right0{background-position:-96px -97px;} | |||||
.icon-page-right1{background-position:-112px -97px;} | |||||
.icon-page-left1{background-position:-128px -97px;} | |||||
.icon-refresh-s{background-position:-144px -97px;} | |||||
.icon-classification{background-position:0 -146px;} | |||||
.icon-refresh-w{background-position:-16px -146px;} | |||||
.icon-makecollections{background-position:-32px -146px;} | |||||
.icon-unshelve{background-position:-48px -146px;} | |||||
.icon-putaway{background-position:-64px -146px;} | |||||
.icon-retrieval{background-position:-80px -146px;} | |||||
.icon-sortingorder{background-position:-96px -146px;} | |||||
.icon-imports-w{background-position:-128px -146px;} | |||||
.icon-derive-w{background-position:-144px -146px;} | |||||
.icon-role{background-position:0 -162px;} | |||||
.icon-download{background-position:-16px -162px;} | |||||
.icon-synchronism{background-position:-32px -162px;} | |||||
.icon-publish{background-position:-48px -162px;} | |||||
.icon-receiving{background-position:-64px -162px;} | |||||
.icon-btn-down{background-position:-80px -162px;} | |||||
.icon-btn-up{background-position:-96px -162px;} | |||||
.icon-btn-img{background-position:-112px -162px;} | |||||
.icon-read { | |||||
display:inline-block; | |||||
background:url("../new-images/read.png"); | |||||
} | |||||
.icon-unread { | |||||
display:inline-block; | |||||
background:url("../new-images/unread.png"); | |||||
} | |||||
/*sixth 18x18*/ | |||||
.icon-template{background-position:0 -79px;} | |||||
.icon-export{background-position:-18px -79px;} | |||||
.icon-import{background-position:-36px -79px;} | |||||
.icon-export-w1{ | |||||
height:17px; | |||||
background-position:-54px -80px; | |||||
} | |||||
.icon-import-w{background-position:-72px -79px;} | |||||
.icon-href{ | |||||
height:17px; | |||||
background-position:-90px -80px; | |||||
} | |||||
/*20x21*/ | |||||
.icon-date-year{background-position:0px -113px;} | |||||
.icon-date{background-position:-20px -113px;} | |||||
.icon-date-month{background-position:-40px -113px;} | |||||
/*seven 22x22*/ | |||||
.icon-del{background-position:right -86px;} | |||||
/*loading*/ | |||||
.icon-loading{ | |||||
display:inline-block; | |||||
background:url("../new-images/loading.gif"); | |||||
} | |||||
.icon-loading1{ | |||||
display:inline-block; | |||||
background:url("../new-images/loading1.gif"); | |||||
} | |||||
.icon-upload{ | |||||
display:inline-block; | |||||
background:url("../new-images/upload.gif"); | |||||
} | |||||
.btn-loading{ | |||||
margin-left:10px; | |||||
margin-right:0 !important; | |||||
width:15px; | |||||
height:15px; | |||||
background-size:100%; | |||||
} |