main
tamguo 7 years ago
parent a57a347bef
commit af32ef53de

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

@ -0,0 +1 @@
/target/

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tamguo-modules-core</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

@ -0,0 +1,6 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

@ -0,0 +1,160 @@
<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.tamguo</groupId>
<artifactId>tamguo-modules-core</artifactId>
<version>1.0.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<mybatis-plus-boot-starter.version>2.1.9</mybatis-plus-boot-starter.version>
</properties>
<dependencies>
<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.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!-- mybatis-plus begin -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus-boot-starter.version}</version>
<exclusions>
<exclusion>
<artifactId>tomcat-jdbc</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- mybatis-plus end -->
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
<version>1.3.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.32</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>cn.songxinqiang</groupId>
<artifactId>com.baidu.ueditor</artifactId>
<version>1.1.2-edit-1.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.18</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.2.8</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>com.bladejava</groupId>
<artifactId>blade-patchca</artifactId>
<version>1.0.5</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>oms</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,30 @@
package com.tamguo.config.dao;
import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
import com.tamguo.modules.sys.utils.ShiroUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* ,
*/
//@Component
public class MyMetaObjectHandler extends MetaObjectHandler {
protected final static Logger logger = LoggerFactory.getLogger(MyMetaObjectHandler.class);
@Override
public void insertFill(MetaObject metaObject) {
Object testType = getFieldValByName("createBy", metaObject);
if (testType == null) {
setFieldValByName("createBy", ShiroUtils.getUser() , metaObject); //mybatis-plus版本2.0.9+
}
}
@Override
public void updateFill(MetaObject metaObject) {
logger.info("更新的时候干点不可描述的事情");
}
}

@ -0,0 +1,93 @@
package com.tamguo.config.dao;
import java.util.ArrayList;
import java.util.List;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.baomidou.mybatisplus.mapper.ISqlInjector;
import com.baomidou.mybatisplus.mapper.LogicSqlInjector;
import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.plugins.PerformanceInterceptor;
import com.baomidou.mybatisplus.plugins.parser.ISqlParser;
import com.baomidou.mybatisplus.plugins.parser.tenant.TenantHandler;
import com.baomidou.mybatisplus.plugins.parser.tenant.TenantSqlParser;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue;
@Configuration
@MapperScan("com.tamguo.modules.*.dao*")
public class MybatisPlusConfig {
@Bean
public PerformanceInterceptor performanceInterceptor() {
return new PerformanceInterceptor();
}
/**
* mybatis-plus<br>
* http://mp.baomidou.com<br>
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
paginationInterceptor.setLocalPage(true);// 开启 PageHelper 的支持
/*
* SQL <br>
* 1 cookie SQL <br>
*/
List<ISqlParser> sqlParserList = new ArrayList<>();
TenantSqlParser tenantSqlParser = new TenantSqlParser();
tenantSqlParser.setTenantHandler(new TenantHandler() {
@Override
public Expression getTenantId() {
return new LongValue(1L);
}
@Override
public String getTenantIdColumn() {
return "course_id";
}
@Override
public boolean doTableFilter(String tableName) {
// 这里可以判断是否过滤表
return true;
}
});
sqlParserList.add(tenantSqlParser);
paginationInterceptor.setSqlParserList(sqlParserList);
// 以下过滤方式与 @SqlParser(filter = true) 注解等效
// paginationInterceptor.setSqlParserFilter(new ISqlParserFilter() {
// @Override
// public boolean doFilter(MetaObject metaObject) {
// MappedStatement ms = PluginUtils.getMappedStatement(metaObject);
// // 过滤自定义查询此时无租户信息约束【 麻花藤 】出现
// if ("com.baomidou.springboot.mapper.UserMapper.selectListBySQL".equals(ms.getId())) {
// return true;
// }
// return false;
// }
// });
return paginationInterceptor;
}
@Bean
public MetaObjectHandler metaObjectHandler(){
return new MyMetaObjectHandler();
}
/**
* sql
*/
@Bean
public ISqlInjector sqlInjector(){
return new LogicSqlInjector();
}
}

@ -0,0 +1,30 @@
package com.tamguo.config.dao;
import java.io.Serializable;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableId;
/**
*
*/
public class SuperEntity<T extends Model<?>> extends Model<T> {
private static final long serialVersionUID = 1L;
@TableId("id")
private String id;
@Override
protected Serializable pkVal() {
return this.getId();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}

@ -0,0 +1,11 @@
package com.tamguo.config.dao;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* mapper mp
*/
public interface SuperMapper<T> extends BaseMapper<T> {
// 这里可以放一些公共的方法
}

@ -0,0 +1,12 @@
package com.tamguo.modules.sys.dao;
import java.util.List;
import com.tamguo.config.dao.SuperMapper;
import com.tamguo.modules.sys.model.SysAreaEntity;
import com.tamguo.modules.sys.model.condition.SysAreaCondition;
public interface SysAreaMapper extends SuperMapper<SysAreaEntity>{
List<SysAreaEntity> listData(SysAreaCondition condition);
}

@ -0,0 +1,15 @@
package com.tamguo.modules.sys.dao;
import java.util.List;
import com.tamguo.config.dao.SuperMapper;
import com.tamguo.modules.sys.model.SysCompanyEntity;
import com.tamguo.modules.sys.model.condition.SysCompanyCondition;
public interface SysCompanyMapper extends SuperMapper<SysCompanyEntity>{
List<SysCompanyEntity> listData(SysCompanyCondition condition);
SysCompanyEntity selectByCode(String code);
}

@ -0,0 +1,14 @@
package com.tamguo.modules.sys.dao;
import java.util.List;
import com.tamguo.config.dao.SuperMapper;
import com.tamguo.modules.sys.model.SysMenuEntity;
import com.tamguo.modules.sys.model.condition.SysMenuCondition;
public interface SysMenuMapper extends SuperMapper<SysMenuEntity>{
List<SysMenuEntity> listData(SysMenuCondition condition);
List<SysMenuEntity> selectMenuByRoleId(String roleCode);
}

@ -0,0 +1,13 @@
package com.tamguo.modules.sys.dao;
import java.util.List;
import com.tamguo.config.dao.SuperMapper;
import com.tamguo.modules.sys.model.SysOfficeEntity;
import com.tamguo.modules.sys.model.condition.SysOfficeCondition;
public interface SysOfficeMapper extends SuperMapper<SysOfficeEntity>{
List<SysOfficeEntity> listData(SysOfficeCondition condition);
}

@ -0,0 +1,13 @@
package com.tamguo.modules.sys.dao;
import java.util.List;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.tamguo.config.dao.SuperMapper;
import com.tamguo.modules.sys.model.SysPostEntity;
import com.tamguo.modules.sys.model.condition.SysPostCondition;
public interface SysPostMapper extends SuperMapper<SysPostEntity>{
List<SysPostEntity> listData(SysPostCondition condition , Pagination page);
}

@ -0,0 +1,8 @@
package com.tamguo.modules.sys.dao;
import com.tamguo.config.dao.SuperMapper;
import com.tamguo.modules.sys.model.SysRoleDataScopeEntity;
public interface SysRoleDataScopeMapper extends SuperMapper<SysRoleDataScopeEntity>{
}

@ -0,0 +1,13 @@
package com.tamguo.modules.sys.dao;
import java.util.List;
import com.baomidou.mybatisplus.plugins.Page;
import com.tamguo.config.dao.SuperMapper;
import com.tamguo.modules.sys.model.SysRoleEntity;
import com.tamguo.modules.sys.model.condition.SysRoleCondition;
public interface SysRoleMapper extends SuperMapper<SysRoleEntity>{
List<SysRoleEntity> listData(SysRoleCondition condition, Page<SysRoleEntity> page);
}

@ -0,0 +1,8 @@
package com.tamguo.modules.sys.dao;
import com.tamguo.config.dao.SuperMapper;
import com.tamguo.modules.sys.model.SysRoleMenuEntity;
public interface SysRoleMenuMapper extends SuperMapper<SysRoleMenuEntity>{
}

@ -0,0 +1,8 @@
package com.tamguo.modules.sys.dao;
import com.tamguo.config.dao.SuperMapper;
import com.tamguo.modules.sys.model.SysUserDataScopeEntity;
public interface SysUserDataScopeMapper extends SuperMapper<SysUserDataScopeEntity>{
}

@ -0,0 +1,13 @@
package com.tamguo.modules.sys.dao;
import java.util.List;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.tamguo.config.dao.SuperMapper;
import com.tamguo.modules.sys.model.SysUserEntity;
import com.tamguo.modules.sys.model.condition.SysUserCondition;
public interface SysUserMapper extends SuperMapper<SysUserEntity>{
List<SysUserEntity> listData(SysUserCondition condition, Pagination page);
}

@ -0,0 +1,8 @@
package com.tamguo.modules.sys.dao;
import com.tamguo.config.dao.SuperMapper;
import com.tamguo.modules.sys.model.SysUserPostEntity;
public interface SysUserPostMapper extends SuperMapper<SysUserPostEntity>{
}

@ -0,0 +1,8 @@
package com.tamguo.modules.sys.dao;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.tamguo.modules.sys.model.SysUserRoleEntity;
public interface SysUserRoleMapper extends BaseMapper<SysUserRoleEntity>{
}

@ -0,0 +1,171 @@
package com.tamguo.modules.sys.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* The persistent class for the sys_area database table.
*
*/
@TableName(value="sys_area")
public class SysAreaEntity implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private String areaCode;
private String areaName;
private String areaType;
private String createBy;
private Date createDate;
private String parentCode;
private String parentCodes;
private String remarks;
private String status;
private Boolean treeLeaf;
private BigDecimal treeLevel;
private String treeNames;
private BigDecimal treeSort;
private String treeSorts;
private String updateBy;
private Date updateDate;
public SysAreaEntity() {
}
public String getAreaCode() {
return this.areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
public String getAreaName() {
return this.areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public String getAreaType() {
return this.areaType;
}
public void setAreaType(String areaType) {
this.areaType = areaType;
}
public String getCreateBy() {
return this.createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateDate() {
return this.createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getParentCode() {
return this.parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getParentCodes() {
return this.parentCodes;
}
public void setParentCodes(String parentCodes) {
this.parentCodes = parentCodes;
}
public String getRemarks() {
return this.remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
public BigDecimal getTreeLevel() {
return this.treeLevel;
}
public void setTreeLevel(BigDecimal treeLevel) {
this.treeLevel = treeLevel;
}
public String getTreeNames() {
return this.treeNames;
}
public void setTreeNames(String treeNames) {
this.treeNames = treeNames;
}
public BigDecimal getTreeSort() {
return this.treeSort;
}
public void setTreeSort(BigDecimal treeSort) {
this.treeSort = treeSort;
}
public String getTreeSorts() {
return this.treeSorts;
}
public void setTreeSorts(String treeSorts) {
this.treeSorts = treeSorts;
}
public String getUpdateBy() {
return this.updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateDate() {
return this.updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getId() {
return getAreaCode();
}
public Boolean getTreeLeaf() {
return treeLeaf;
}
public void setTreeLeaf(Boolean treeLeaf) {
this.treeLeaf = treeLeaf;
}
}

@ -0,0 +1,225 @@
package com.tamguo.modules.sys.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.KeySequence;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* The persistent class for the sys_company database table.
*
*/
@TableName(value="sys_company")
@KeySequence
public class SysCompanyEntity implements Serializable {
private static final long serialVersionUID = 1L;
public static final String ROOT_COMPANY_CODE = "0";
public static final String TREE_CODE_COMPANY_SEPARATE = ",";
public static final String TREE_NAME_COMPANY_SEPARATE = "/";
@TableId
private String companyCode;
private String areaCode;
private String companyName;
private String corpCode;
private String corpName;
private String createBy;
private Date createDate;
private String fullName;
private String parentCode;
private String parentCodes;
private String remarks;
private String status;
private Boolean treeLeaf;
private BigDecimal treeLevel;
private String treeNames;
private String treeSort;
private String treeSorts;
private String updateBy;
private Date updateDate;
private String viewCode;
@TableField(exist=false)
private String treeAreaNames;
public SysCompanyEntity() {
}
public String getAreaCode() {
return this.areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
public String getCompanyName() {
return this.companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getCorpCode() {
return this.corpCode;
}
public void setCorpCode(String corpCode) {
this.corpCode = corpCode;
}
public String getCorpName() {
return this.corpName;
}
public void setCorpName(String corpName) {
this.corpName = corpName;
}
public String getCreateBy() {
return this.createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateDate() {
return this.createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getFullName() {
return this.fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getParentCode() {
return this.parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getParentCodes() {
return this.parentCodes;
}
public void setParentCodes(String parentCodes) {
this.parentCodes = parentCodes;
}
public String getRemarks() {
return this.remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
public BigDecimal getTreeLevel() {
return this.treeLevel;
}
public void setTreeLevel(BigDecimal treeLevel) {
this.treeLevel = treeLevel;
}
public String getTreeNames() {
return this.treeNames;
}
public void setTreeNames(String treeNames) {
this.treeNames = treeNames;
}
public String getTreeSort() {
return this.treeSort;
}
public void setTreeSort(String treeSort) {
this.treeSort = treeSort;
}
public String getTreeSorts() {
return this.treeSorts;
}
public void setTreeSorts(String treeSorts) {
this.treeSorts = treeSorts;
}
public String getUpdateBy() {
return this.updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateDate() {
return this.updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getViewCode() {
return this.viewCode;
}
public void setViewCode(String viewCode) {
this.viewCode = viewCode;
}
public Boolean getTreeLeaf() {
return treeLeaf;
}
public void setTreeLeaf(Boolean treeLeaf) {
this.treeLeaf = treeLeaf;
}
public String getId() {
return this.getCompanyCode();
}
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public String getTreeAreaNames() {
return treeAreaNames;
}
public void setTreeAreaNames(String treeAreaNames) {
this.treeAreaNames = treeAreaNames;
}
}

@ -0,0 +1,255 @@
package com.tamguo.modules.sys.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.tamguo.modules.sys.model.enums.SysMenuStatusEnum;
/**
* The persistent class for the sys_menu database table.
*
*/
@TableName(value="sys_menu")
public class SysMenuEntity implements Serializable {
private static final long serialVersionUID = 1L;
public static final String ROOT_MENU_CODE = "0";
public static final String TREE_CODE_MENU_SEPARATE = ",";
public static final String TREE_NAME_MENU_SEPARATE = "/";
@TableId
private String menuCode;
private String createBy;
private Date createDate;
private String isShow;
private String menuColor;
private String menuHref;
private String menuIcon;
private String menuName;
private String menuTarget;
private String menuType;
private String parentCode;
private String parentCodes;
private String permission;
private String remarks;
@JSONField(serialzeFeatures= SerializerFeature.WriteEnumUsingToString)
private SysMenuStatusEnum status;
private String sysCode;
private Boolean treeLeaf;
private BigDecimal treeLevel;
private String treeNames;
private BigDecimal treeSort;
private String treeSorts;
private String updateBy;
private Date updateDate;
private BigDecimal weight;
public SysMenuEntity() {
}
public String getMenuCode() {
return this.menuCode;
}
public void setMenuCode(String menuCode) {
this.menuCode = menuCode;
}
public String getCreateBy() {
return this.createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateDate() {
return this.createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getIsShow() {
return this.isShow;
}
public void setIsShow(String isShow) {
this.isShow = isShow;
}
public String getMenuColor() {
return this.menuColor;
}
public void setMenuColor(String menuColor) {
this.menuColor = menuColor;
}
public String getMenuHref() {
return this.menuHref;
}
public void setMenuHref(String menuHref) {
this.menuHref = menuHref;
}
public String getMenuIcon() {
return this.menuIcon;
}
public void setMenuIcon(String menuIcon) {
this.menuIcon = menuIcon;
}
public String getMenuName() {
return this.menuName;
}
public void setMenuName(String menuName) {
this.menuName = menuName;
}
public String getMenuTarget() {
return this.menuTarget;
}
public void setMenuTarget(String menuTarget) {
this.menuTarget = menuTarget;
}
public String getMenuType() {
return this.menuType;
}
public void setMenuType(String menuType) {
this.menuType = menuType;
}
public String getParentCode() {
return this.parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getParentCodes() {
return this.parentCodes;
}
public void setParentCodes(String parentCodes) {
this.parentCodes = parentCodes;
}
public String getPermission() {
return this.permission;
}
public void setPermission(String permission) {
this.permission = permission;
}
public String getRemarks() {
return this.remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getSysCode() {
return this.sysCode;
}
public void setSysCode(String sysCode) {
this.sysCode = sysCode;
}
public BigDecimal getTreeLevel() {
return this.treeLevel;
}
public void setTreeLevel(BigDecimal treeLevel) {
this.treeLevel = treeLevel;
}
public String getTreeNames() {
return this.treeNames;
}
public void setTreeNames(String treeNames) {
this.treeNames = treeNames;
}
public BigDecimal getTreeSort() {
return this.treeSort;
}
public void setTreeSort(BigDecimal treeSort) {
this.treeSort = treeSort;
}
public String getTreeSorts() {
return this.treeSorts;
}
public void setTreeSorts(String treeSorts) {
this.treeSorts = treeSorts;
}
public String getUpdateBy() {
return this.updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateDate() {
return this.updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public BigDecimal getWeight() {
return this.weight;
}
public void setWeight(BigDecimal weight) {
this.weight = weight;
}
// grid tree
public String getId() {
return getMenuCode();
}
public SysMenuStatusEnum getStatus() {
return status;
}
public void setStatus(SysMenuStatusEnum status) {
this.status = status;
}
public Boolean getTreeLeaf() {
return treeLeaf;
}
public void setTreeLeaf(Boolean treeLeaf) {
this.treeLeaf = treeLeaf;
}
}

@ -0,0 +1,257 @@
package com.tamguo.modules.sys.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* The persistent class for the sys_office database table.
*
*/
@TableName(value="sys_office")
public class SysOfficeEntity implements Serializable {
private static final long serialVersionUID = 1L;
public static final String ROOT_OFFICE_CODE = "0";
public static final String TREE_CODE_OFFICE_SEPARATE = ",";
public static final String TREE_NAME_OFFICE_SEPARATE = "/";
@TableId
private String officeCode;
private String address;
private String corpCode;
private String corpName;
private String createBy;
private Date createDate;
private String email;
private String fullName;
private String leader;
private String officeName;
private String officeType;
private String parentCode;
private String parentCodes;
private String phone;
private String remarks;
private String status;
private Boolean treeLeaf;
private BigDecimal treeLevel;
private String treeNames;
private BigDecimal treeSort;
private String treeSorts;
private String updateBy;
private Date updateDate;
private String viewCode;
private String zipCode;
public SysOfficeEntity() {
}
public String getOfficeCode() {
return this.officeCode;
}
public void setOfficeCode(String officeCode) {
this.officeCode = officeCode;
}
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCorpCode() {
return this.corpCode;
}
public void setCorpCode(String corpCode) {
this.corpCode = corpCode;
}
public String getCorpName() {
return this.corpName;
}
public void setCorpName(String corpName) {
this.corpName = corpName;
}
public String getCreateBy() {
return this.createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateDate() {
return this.createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getFullName() {
return this.fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getLeader() {
return this.leader;
}
public void setLeader(String leader) {
this.leader = leader;
}
public String getOfficeName() {
return this.officeName;
}
public void setOfficeName(String officeName) {
this.officeName = officeName;
}
public String getOfficeType() {
return this.officeType;
}
public void setOfficeType(String officeType) {
this.officeType = officeType;
}
public String getParentCode() {
return this.parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getParentCodes() {
return this.parentCodes;
}
public void setParentCodes(String parentCodes) {
this.parentCodes = parentCodes;
}
public String getPhone() {
return this.phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getRemarks() {
return this.remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
public Boolean getTreeLeaf() {
return this.treeLeaf;
}
public void setTreeLeaf(Boolean treeLeaf) {
this.treeLeaf = treeLeaf;
}
public BigDecimal getTreeLevel() {
return this.treeLevel;
}
public void setTreeLevel(BigDecimal treeLevel) {
this.treeLevel = treeLevel;
}
public String getTreeNames() {
return this.treeNames;
}
public void setTreeNames(String treeNames) {
this.treeNames = treeNames;
}
public BigDecimal getTreeSort() {
return this.treeSort;
}
public void setTreeSort(BigDecimal treeSort) {
this.treeSort = treeSort;
}
public String getTreeSorts() {
return this.treeSorts;
}
public void setTreeSorts(String treeSorts) {
this.treeSorts = treeSorts;
}
public String getUpdateBy() {
return this.updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateDate() {
return this.updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getViewCode() {
return this.viewCode;
}
public void setViewCode(String viewCode) {
this.viewCode = viewCode;
}
public String getZipCode() {
return this.zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
// grid tree
public String getId() {
return this.getOfficeCode();
}
}

@ -0,0 +1,143 @@
package com.tamguo.modules.sys.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.tamguo.modules.sys.model.enums.SysPostStatusEnum;
/**
* The persistent class for the sys_post database table.
*
*/
@TableName(value="sys_post")
public class SysPostEntity extends Model<SysPostEntity> implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private String postCode;
private String corpCode;
private String corpName;
private String createBy;
private Date createDate;
private String postName;
private BigDecimal postSort;
private String postType;
private String remarks;
@JSONField(serialzeFeatures= SerializerFeature.WriteEnumUsingToString)
private SysPostStatusEnum status;
private String updateBy;
private Date updateDate;
public SysPostEntity() {
}
public String getPostCode() {
return this.postCode;
}
public void setPostCode(String postCode) {
this.postCode = postCode;
}
public String getCorpCode() {
return this.corpCode;
}
public void setCorpCode(String corpCode) {
this.corpCode = corpCode;
}
public String getCorpName() {
return this.corpName;
}
public void setCorpName(String corpName) {
this.corpName = corpName;
}
public String getCreateBy() {
return this.createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateDate() {
return this.createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getPostName() {
return this.postName;
}
public void setPostName(String postName) {
this.postName = postName;
}
public BigDecimal getPostSort() {
return this.postSort;
}
public void setPostSort(BigDecimal postSort) {
this.postSort = postSort;
}
public String getPostType() {
return this.postType;
}
public void setPostType(String postType) {
this.postType = postType;
}
public String getRemarks() {
return this.remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public SysPostStatusEnum getStatus() {
return this.status;
}
public void setStatus(SysPostStatusEnum status) {
this.status = status;
}
public String getUpdateBy() {
return this.updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateDate() {
return this.updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
@Override
protected Serializable pkVal() {
return getPostCode();
}
}

@ -0,0 +1,38 @@
package com.tamguo.modules.sys.model;
import com.baomidou.mybatisplus.annotations.TableName;
@TableName(value="sys_role_data_scope")
public class SysRoleDataScopeEntity {
private String roleCode;
private String ctrlType;
private String ctrlData;
private String ctrlPermi;
public String getRoleCode() {
return roleCode;
}
public void setRoleCode(String roleCode) {
this.roleCode = roleCode;
}
public String getCtrlType() {
return ctrlType;
}
public void setCtrlType(String ctrlType) {
this.ctrlType = ctrlType;
}
public String getCtrlData() {
return ctrlData;
}
public void setCtrlData(String ctrlData) {
this.ctrlData = ctrlData;
}
public String getCtrlPermi() {
return ctrlPermi;
}
public void setCtrlPermi(String ctrlPermi) {
this.ctrlPermi = ctrlPermi;
}
}

@ -0,0 +1,185 @@
package com.tamguo.modules.sys.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* The persistent class for the sys_role database table.
*
*/
@TableName(value="sys_role")
public class SysRoleEntity implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private String roleCode;
private String corpCode;
private String corpName;
private String createBy;
private Date createDate;
private String dataScope;
private String isSys;
private String remarks;
private String roleName;
private BigDecimal roleSort;
private String roleType;
private String status;
private String updateBy;
private Date updateDate;
private String userType;
@TableField(exist=false)
private String roleMenuListJson;
@TableField(exist=false)
private String roleDataScopeListJson;
public SysRoleEntity() {
}
public String getRoleCode() {
return this.roleCode;
}
public void setRoleCode(String roleCode) {
this.roleCode = roleCode;
}
public String getCorpCode() {
return this.corpCode;
}
public void setCorpCode(String corpCode) {
this.corpCode = corpCode;
}
public String getCorpName() {
return this.corpName;
}
public void setCorpName(String corpName) {
this.corpName = corpName;
}
public String getCreateBy() {
return this.createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateDate() {
return this.createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getDataScope() {
return this.dataScope;
}
public void setDataScope(String dataScope) {
this.dataScope = dataScope;
}
public String getIsSys() {
return this.isSys;
}
public void setIsSys(String isSys) {
this.isSys = isSys;
}
public String getRemarks() {
return this.remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getRoleName() {
return this.roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public BigDecimal getRoleSort() {
return this.roleSort;
}
public void setRoleSort(BigDecimal roleSort) {
this.roleSort = roleSort;
}
public String getRoleType() {
return this.roleType;
}
public void setRoleType(String roleType) {
this.roleType = roleType;
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
public String getUpdateBy() {
return this.updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateDate() {
return this.updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getUserType() {
return this.userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
public String getId() {
return getRoleCode();
}
public String getRoleMenuListJson() {
return roleMenuListJson;
}
public void setRoleMenuListJson(String roleMenuListJson) {
this.roleMenuListJson = roleMenuListJson;
}
public String getRoleDataScopeListJson() {
return roleDataScopeListJson;
}
public void setRoleDataScopeListJson(String roleDataScopeListJson) {
this.roleDataScopeListJson = roleDataScopeListJson;
}
}

@ -0,0 +1,24 @@
package com.tamguo.modules.sys.model;
import com.baomidou.mybatisplus.annotations.TableName;
@TableName(value="sys_role_menu")
public class SysRoleMenuEntity {
private String roleCode;
private String menuCode;
public String getRoleCode() {
return roleCode;
}
public void setRoleCode(String roleCode) {
this.roleCode = roleCode;
}
public String getMenuCode() {
return menuCode;
}
public void setMenuCode(String menuCode) {
this.menuCode = menuCode;
}
}

@ -0,0 +1,37 @@
package com.tamguo.modules.sys.model;
import com.baomidou.mybatisplus.annotations.TableName;
@TableName(value="sys_user_data_scope")
public class SysUserDataScopeEntity {
private String userCode;
private String ctrlType;
private String ctrlData;
private String ctrlPermi;
public String getUserCode() {
return userCode;
}
public void setUserCode(String userCode) {
this.userCode = userCode;
}
public String getCtrlType() {
return ctrlType;
}
public void setCtrlType(String ctrlType) {
this.ctrlType = ctrlType;
}
public String getCtrlData() {
return ctrlData;
}
public void setCtrlData(String ctrlData) {
this.ctrlData = ctrlData;
}
public String getCtrlPermi() {
return ctrlPermi;
}
public void setCtrlPermi(String ctrlPermi) {
this.ctrlPermi = ctrlPermi;
}
}

@ -0,0 +1,481 @@
package com.tamguo.modules.sys.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.tamguo.modules.sys.model.enums.SysUserMgrTypeEnum;
import com.tamguo.modules.sys.model.enums.SysUserStatusEnum;
import com.tamguo.modules.sys.model.enums.SysUserTypeEnum;
/**
* The persistent class for the sys_user database table.
*
*/
@TableName(value="sys_user")
public class SysUserEntity implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private String userCode;
private String officeCode;
private String officeName;
private String companyCode;
private String companyName;
private String avatar;
private String corpCode;
private String corpName;
private String createBy;
private Date createDate;
private String email;
private String freezeCause;
private Date freezeDate;
private Date lastLoginDate;
private String lastLoginIp;
private String loginCode;
@JSONField(serialzeFeatures= SerializerFeature.WriteEnumUsingToString)
private SysUserMgrTypeEnum mgrType;
private String mobile;
private String mobileImei;
private String password;
private String phone;
private Date pwdQuestUpdateDate;
private String pwdQuestion;
@TableField(value="pwd_question_2")
private String pwdQuestion2;
@TableField(value="pwd_question_3")
private String pwdQuestion3;
private String pwdQuestionAnswer;
@TableField(value="pwd_question_answer_2")
private String pwdQuestionAnswer2;
@TableField(value="pwd_question_answer_3")
private String pwdQuestionAnswer3;
private BigDecimal pwdSecurityLevel;
private Date pwdUpdateDate;
private String pwdUpdateRecord;
private String refCode;
private String refName;
private String remarks;
private String sex;
private String sign;
@JSONField(serialzeFeatures= SerializerFeature.WriteEnumUsingToString)
private SysUserStatusEnum status;
private String updateBy;
private Date updateDate;
private String userName;
private String empName;
@JSONField(serialzeFeatures= SerializerFeature.WriteEnumUsingToString)
private SysUserTypeEnum userType;
private BigDecimal userWeight;
private String wxOpenid;
private String userNameEn;
@TableField(exist=false)
private List<String> employeePosts;
@TableField(exist=false)
private String userRoleString;
@TableField(exist=false)
private String userDataScopeListJson;
public SysUserEntity() {
}
public String getUserCode() {
return this.userCode;
}
public void setUserCode(String userCode) {
this.userCode = userCode;
}
public String getAvatar() {
return this.avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getCorpCode() {
return this.corpCode;
}
public void setCorpCode(String corpCode) {
this.corpCode = corpCode;
}
public String getCorpName() {
return this.corpName;
}
public void setCorpName(String corpName) {
this.corpName = corpName;
}
public String getCreateBy() {
return this.createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateDate() {
return this.createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getFreezeCause() {
return this.freezeCause;
}
public void setFreezeCause(String freezeCause) {
this.freezeCause = freezeCause;
}
public Date getFreezeDate() {
return this.freezeDate;
}
public void setFreezeDate(Date freezeDate) {
this.freezeDate = freezeDate;
}
public Date getLastLoginDate() {
return this.lastLoginDate;
}
public void setLastLoginDate(Date lastLoginDate) {
this.lastLoginDate = lastLoginDate;
}
public String getLastLoginIp() {
return this.lastLoginIp;
}
public void setLastLoginIp(String lastLoginIp) {
this.lastLoginIp = lastLoginIp;
}
public String getLoginCode() {
return this.loginCode;
}
public void setLoginCode(String loginCode) {
this.loginCode = loginCode;
}
public String getMobile() {
return this.mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getMobileImei() {
return this.mobileImei;
}
public void setMobileImei(String mobileImei) {
this.mobileImei = mobileImei;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPhone() {
return this.phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Date getPwdQuestUpdateDate() {
return this.pwdQuestUpdateDate;
}
public void setPwdQuestUpdateDate(Date pwdQuestUpdateDate) {
this.pwdQuestUpdateDate = pwdQuestUpdateDate;
}
public String getPwdQuestion() {
return this.pwdQuestion;
}
public void setPwdQuestion(String pwdQuestion) {
this.pwdQuestion = pwdQuestion;
}
public String getPwdQuestion2() {
return this.pwdQuestion2;
}
public void setPwdQuestion2(String pwdQuestion2) {
this.pwdQuestion2 = pwdQuestion2;
}
public String getPwdQuestion3() {
return this.pwdQuestion3;
}
public void setPwdQuestion3(String pwdQuestion3) {
this.pwdQuestion3 = pwdQuestion3;
}
public String getPwdQuestionAnswer() {
return this.pwdQuestionAnswer;
}
public void setPwdQuestionAnswer(String pwdQuestionAnswer) {
this.pwdQuestionAnswer = pwdQuestionAnswer;
}
public String getPwdQuestionAnswer2() {
return this.pwdQuestionAnswer2;
}
public void setPwdQuestionAnswer2(String pwdQuestionAnswer2) {
this.pwdQuestionAnswer2 = pwdQuestionAnswer2;
}
public String getPwdQuestionAnswer3() {
return this.pwdQuestionAnswer3;
}
public void setPwdQuestionAnswer3(String pwdQuestionAnswer3) {
this.pwdQuestionAnswer3 = pwdQuestionAnswer3;
}
public BigDecimal getPwdSecurityLevel() {
return this.pwdSecurityLevel;
}
public void setPwdSecurityLevel(BigDecimal pwdSecurityLevel) {
this.pwdSecurityLevel = pwdSecurityLevel;
}
public Date getPwdUpdateDate() {
return this.pwdUpdateDate;
}
public void setPwdUpdateDate(Date pwdUpdateDate) {
this.pwdUpdateDate = pwdUpdateDate;
}
public String getPwdUpdateRecord() {
return this.pwdUpdateRecord;
}
public void setPwdUpdateRecord(String pwdUpdateRecord) {
this.pwdUpdateRecord = pwdUpdateRecord;
}
public String getRefCode() {
return this.refCode;
}
public void setRefCode(String refCode) {
this.refCode = refCode;
}
public String getRefName() {
return this.refName;
}
public void setRefName(String refName) {
this.refName = refName;
}
public String getRemarks() {
return this.remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getSign() {
return this.sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public SysUserStatusEnum getStatus() {
return this.status;
}
public void setStatus(SysUserStatusEnum status) {
this.status = status;
}
public String getUpdateBy() {
return this.updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateDate() {
return this.updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getUserName() {
return this.userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public BigDecimal getUserWeight() {
return this.userWeight;
}
public void setUserWeight(BigDecimal userWeight) {
this.userWeight = userWeight;
}
public String getWxOpenid() {
return this.wxOpenid;
}
public void setWxOpenid(String wxOpenid) {
this.wxOpenid = wxOpenid;
}
public String getOfficeCode() {
return officeCode;
}
public void setOfficeCode(String officeCode) {
this.officeCode = officeCode;
}
public String getOfficeName() {
return officeName;
}
public void setOfficeName(String officeName) {
this.officeName = officeName;
}
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public SysUserMgrTypeEnum getMgrType() {
return mgrType;
}
public void setMgrType(SysUserMgrTypeEnum mgrType) {
this.mgrType = mgrType;
}
public String getUserNameEn() {
return userNameEn;
}
public void setUserNameEn(String userNameEn) {
this.userNameEn = userNameEn;
}
public List<String> getEmployeePosts() {
return employeePosts;
}
public void setEmployeePosts(List<String> employeePosts) {
this.employeePosts = employeePosts;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public String getUserRoleString() {
return userRoleString;
}
public void setUserRoleString(String userRoleString) {
this.userRoleString = userRoleString;
}
public SysUserTypeEnum getUserType() {
return userType;
}
public void setUserType(SysUserTypeEnum userType) {
this.userType = userType;
}
public String getUserDataScopeListJson() {
return userDataScopeListJson;
}
public void setUserDataScopeListJson(String userDataScopeListJson) {
this.userDataScopeListJson = userDataScopeListJson;
}
}

@ -0,0 +1,23 @@
package com.tamguo.modules.sys.model;
import com.baomidou.mybatisplus.annotations.TableName;
@TableName(value="sys_user_post")
public class SysUserPostEntity {
private String userCode;
private String postCode;
public String getUserCode() {
return userCode;
}
public void setUserCode(String userCode) {
this.userCode = userCode;
}
public String getPostCode() {
return postCode;
}
public void setPostCode(String postCode) {
this.postCode = postCode;
}
}

@ -0,0 +1,23 @@
package com.tamguo.modules.sys.model;
import com.baomidou.mybatisplus.annotations.TableName;
@TableName(value="sys_user_role")
public class SysUserRoleEntity {
private String userCode;
private String roleCode;
public String getRoleCode() {
return roleCode;
}
public void setRoleCode(String roleCode) {
this.roleCode = roleCode;
}
public String getUserCode() {
return userCode;
}
public void setUserCode(String userCode) {
this.userCode = userCode;
}
}

@ -0,0 +1,29 @@
package com.tamguo.modules.sys.model.condition;
public class SysAreaCondition {
private String parentCode;
private Integer pageNo;
private Integer pageSize;
public Integer getPageNo() {
return pageNo;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
}

@ -0,0 +1,28 @@
package com.tamguo.modules.sys.model.condition;
public class SysCompanyCondition {
private String parentCode;
private String companyName;
private String fullName;
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
}

@ -0,0 +1,21 @@
package com.tamguo.modules.sys.model.condition;
public class SysMenuCondition {
private Integer pageNo;
private Integer pageSize;
public Integer getPageNo() {
return pageNo;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}

@ -0,0 +1,14 @@
package com.tamguo.modules.sys.model.condition;
public class SysOfficeCondition {
private String parentCode;
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
}

@ -0,0 +1,50 @@
package com.tamguo.modules.sys.model.condition;
public class SysPostCondition {
private String code;
private String name;
private String postType;
private String status;
private Integer pageNo;
private Integer pageSize;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPostType() {
return postType;
}
public void setPostType(String postType) {
this.postType = postType;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Integer getPageNo() {
return pageNo;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}

@ -0,0 +1,21 @@
package com.tamguo.modules.sys.model.condition;
public class SysRoleCondition {
private Integer pageNo;
private Integer pageSize;
public Integer getPageNo() {
return pageNo;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}

@ -0,0 +1,121 @@
package com.tamguo.modules.sys.model.condition;
public class SysUserCondition {
private Integer pageNo;
private Integer pageSize;
private String loginCode;
private String userName;
private String email;
private String mobile;
private String phone;
private String refName;
private String officeName;
private String officeCode;
private String companyCode;
private String companyName;
private String postCode;
private String status;
private String userType;
private String orderBy;
public Integer getPageNo() {
return pageNo;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public String getLoginCode() {
return loginCode;
}
public void setLoginCode(String loginCode) {
this.loginCode = loginCode;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
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 String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getRefName() {
return refName;
}
public void setRefName(String refName) {
this.refName = refName;
}
public String getOfficeName() {
return officeName;
}
public void setOfficeName(String officeName) {
this.officeName = officeName;
}
public String getOfficeCode() {
return officeCode;
}
public void setOfficeCode(String officeCode) {
this.officeCode = officeCode;
}
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getPostCode() {
return postCode;
}
public void setPostCode(String postCode) {
this.postCode = postCode;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
public String getOrderBy() {
return orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
}

@ -0,0 +1,34 @@
package com.tamguo.modules.sys.model.enums;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IEnum;
/**
*
*/
public enum SysCompanyStatusEnum implements IEnum {
NORMAL("normal", "正常"),
DELETE("delete", "删除"),
DISABLED("disabled" , "停用");
private String value;
private String desc;
SysCompanyStatusEnum(final String value, final String desc) {
this.value = value;
this.desc = desc;
}
public Serializable getValue() {
return this.value;
}
public String getDesc(){
return this.desc;
}
@Override
public String toString() {
return this.value;
}
}

@ -0,0 +1,34 @@
package com.tamguo.modules.sys.model.enums;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IEnum;
/**
*
*/
public enum SysMenuStatusEnum implements IEnum {
NORMAL("0", "正常"),
DELETE("1" , "删除"),
DISABLED("2" , "停用");
private String value;
private String desc;
SysMenuStatusEnum(final String value, final String desc) {
this.value = value;
this.desc = desc;
}
public Serializable getValue() {
return this.value;
}
public String getDesc(){
return this.desc;
}
@Override
public String toString() {
return this.value;
}
}

@ -0,0 +1,34 @@
package com.tamguo.modules.sys.model.enums;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IEnum;
/**
*
*/
public enum SysOfficeStatusEnum implements IEnum {
NORMAL("normal", "正常"),
DELETE("delete", "删除"),
DISABLED("disabled" , "停用");
private String value;
private String desc;
SysOfficeStatusEnum(final String value, final String desc) {
this.value = value;
this.desc = desc;
}
public Serializable getValue() {
return this.value;
}
public String getDesc(){
return this.desc;
}
@Override
public String toString() {
return this.value;
}
}

@ -0,0 +1,34 @@
package com.tamguo.modules.sys.model.enums;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IEnum;
/**
*
*/
public enum SysOfficeTypeEnum implements IEnum {
PROVINCE("province", "省级公司"),
CITY("city", "市级公司"),
DEPARTMENT("department" , "部门");
private String value;
private String desc;
SysOfficeTypeEnum(final String value, final String desc) {
this.value = value;
this.desc = desc;
}
public Serializable getValue() {
return this.value;
}
public String getDesc(){
return this.desc;
}
@Override
public String toString() {
return this.value;
}
}

@ -0,0 +1,33 @@
package com.tamguo.modules.sys.model.enums;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IEnum;
/**
*
*/
public enum SysPostStatusEnum implements IEnum {
NORMAL("normal", "正常"),
DISABLED("disable" , "停用");
private String value;
private String desc;
SysPostStatusEnum(final String value, final String desc) {
this.value = value;
this.desc = desc;
}
public Serializable getValue() {
return this.value;
}
public String getDesc(){
return this.desc;
}
@Override
public String toString() {
return this.value;
}
}

@ -0,0 +1,48 @@
package com.tamguo.modules.sys.model.enums;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IEnum;
/**
*
*/
public enum SysPostTypeEnum implements IEnum {
GAOGUAN("gaoguan", "高管"),
ZHONGCENG("zhongceng", "中层"),
JICENG("jiceng" , "基层"),
QITA("qita" , "其他");
private String value;
private String desc;
SysPostTypeEnum(final String value, final String desc) {
this.value = value;
this.desc = desc;
}
public static SysPostTypeEnum getPostType(String postType) {
if("gaoguan".equals(postType)) {
return SysPostTypeEnum.GAOGUAN;
}else if("zhongceng".equals(postType)) {
return SysPostTypeEnum.ZHONGCENG;
}else if("jiceng".equals(postType)) {
return SysPostTypeEnum.JICENG;
}else if("qita".equals(postType)) {
return SysPostTypeEnum.QITA;
}
return null;
}
public Serializable getValue() {
return this.value;
}
public String getDesc(){
return this.desc;
}
@Override
public String toString() {
return this.value;
}
}

@ -0,0 +1,34 @@
package com.tamguo.modules.sys.model.enums;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IEnum;
/**
*
*/
public enum SysUserMgrTypeEnum implements IEnum {
NONE_ADMIN("0", "非系统管理员"),
SYSTEM_ADMIN("1", "系统管理员"),
SEC_ADMIN("2" , "二级管理员");
private String value;
private String desc;
SysUserMgrTypeEnum(final String value, final String desc) {
this.value = value;
this.desc = desc;
}
public Serializable getValue() {
return this.value;
}
public String getDesc(){
return this.desc;
}
@Override
public String toString() {
return this.value;
}
}

@ -0,0 +1,35 @@
package com.tamguo.modules.sys.model.enums;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IEnum;
/**
*
*/
public enum SysUserStatusEnum implements IEnum {
NORMAL("0", "正常"),
DELETE("1" , "删除"),
DISABLED("2" , "禁用"),
LOCKED("3", "锁定"),;
private String value;
private String desc;
SysUserStatusEnum(final String value, final String desc) {
this.value = value;
this.desc = desc;
}
public Serializable getValue() {
return this.value;
}
public String getDesc(){
return this.desc;
}
@Override
public String toString() {
return this.value;
}
}

@ -0,0 +1,33 @@
package com.tamguo.modules.sys.model.enums;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IEnum;
/**
*
*/
public enum SysUserTypeEnum implements IEnum {
EMPLOYEE("employee", "雇员"),
NONE("none", "系统");
private String value;
private String desc;
SysUserTypeEnum(final String value, final String desc) {
this.value = value;
this.desc = desc;
}
public Serializable getValue() {
return this.value;
}
public String getDesc(){
return this.desc;
}
@Override
public String toString() {
return this.value;
}
}

@ -0,0 +1,16 @@
package com.tamguo.modules.sys.service;
import java.util.List;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.sys.model.SysAreaEntity;
import com.tamguo.modules.sys.model.condition.SysAreaCondition;
public interface ISysAreaService extends IService<SysAreaEntity>{
List<SysAreaEntity> listData(SysAreaCondition condition);
JSONArray treeData(String excludeId);
}

@ -0,0 +1,26 @@
package com.tamguo.modules.sys.service;
import java.util.List;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.sys.model.SysCompanyEntity;
import com.tamguo.modules.sys.model.condition.SysCompanyCondition;
public interface ISysCompanyService extends IService<SysCompanyEntity>{
/** 公司树形结构*/
JSONArray treeData(String excludeId);
/** 查询公司列表*/
List<SysCompanyEntity> listData(SysCompanyCondition condition);
/** 根据ID查询公司*/
SysCompanyEntity selectByCode(String code);
/** 新建公司*/
void save(SysCompanyEntity company);
/** 修改公司*/
void update(SysCompanyEntity company);
}

@ -0,0 +1,24 @@
package com.tamguo.modules.sys.service;
import java.util.List;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.sys.model.SysMenuEntity;
import com.tamguo.modules.sys.model.condition.SysMenuCondition;
public interface ISysMenuService extends IService<SysMenuEntity>{
/** 列表数据*/
List<SysMenuEntity> listData(SysMenuCondition condition);
/** 树形结构*/
JSONArray treeData(String excludeId);
/** 新增菜单*/
void save(SysMenuEntity menu);
/** 修改菜单*/
void update(SysMenuEntity menu);
}

@ -0,0 +1,20 @@
package com.tamguo.modules.sys.service;
import java.util.List;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.sys.model.SysOfficeEntity;
import com.tamguo.modules.sys.model.condition.SysOfficeCondition;
public interface ISysOfficeService extends IService<SysOfficeEntity>{
List<SysOfficeEntity> listData(SysOfficeCondition condition);
JSONArray treeData(String excludeId);
void save(SysOfficeEntity office);
void update(SysOfficeEntity office);
}

@ -0,0 +1,19 @@
package com.tamguo.modules.sys.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.sys.model.SysPostEntity;
import com.tamguo.modules.sys.model.condition.SysPostCondition;
public interface ISysPostService extends IService<SysPostEntity>{
/** 查询列表*/
Page<SysPostEntity> listData(SysPostCondition condition);
/** 添加数据*/
void add(SysPostEntity post);
/** 修改数据*/
void update(SysPostEntity post);
}

@ -0,0 +1,8 @@
package com.tamguo.modules.sys.service;
import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.sys.model.SysRoleDataScopeEntity;
public interface ISysRoleDataScopeService extends IService<SysRoleDataScopeEntity>{
}

@ -0,0 +1,28 @@
package com.tamguo.modules.sys.service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.sys.model.SysRoleEntity;
import com.tamguo.modules.sys.model.condition.SysRoleCondition;
public interface ISysRoleService extends IService<SysRoleEntity>{
/** 列表查询*/
Page<SysRoleEntity> listData(SysRoleCondition condition);
/** 属性菜单*/
Map<String, Object> menuTreeData(String roleCode);
/** 分配功能权限*/
void allowMenuPermission(SysRoleEntity role);
/** 授权数据权限*/
void allowDataScope(SysRoleEntity role);
/** 角色树形结构*/
List<SysRoleEntity> treeDate(String userType);
}

@ -0,0 +1,51 @@
package com.tamguo.modules.sys.service;
import java.util.List;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.sys.model.SysUserDataScopeEntity;
import com.tamguo.modules.sys.model.SysUserEntity;
import com.tamguo.modules.sys.model.SysUserRoleEntity;
import com.tamguo.modules.sys.model.condition.SysUserCondition;
import com.tamguo.modules.sys.utils.Result;
public interface ISysUserService extends IService<SysUserEntity>{
public SysUserEntity queryByLoginCode(String loginCode);
public Page<SysUserEntity> listData(SysUserCondition condition);
/** 用户岗位*/
public String queryUserPostByUserCode(String userCode);
/** 检查登录账号*/
public Boolean checkLoginCode(String oldLoginCode , String loginCode);
/** 更新用户信息*/
public void update(SysUserEntity user);
/** 添加用户信息*/
public void save(SysUserEntity user);
/** 分配角色*/
public void allowUserRole(SysUserEntity user);
/** 获取用户角色*/
public List<SysUserRoleEntity> findUserRole(String userCode);
/** 用户数据权限*/
public List<SysUserDataScopeEntity> selectUserDataScope(String userCode);
/** 保存用户数据权限*/
public void saveUserDataScope(SysUserEntity user);
/** 停用账号*/
public Result disable(String userCode);
/** 激活账号*/
public Result enable(String userCode);
/** 删除用户*/
public Result delete(String userCode);
}

@ -0,0 +1,57 @@
package com.tamguo.modules.sys.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.modules.sys.dao.SysAreaMapper;
import com.tamguo.modules.sys.model.SysAreaEntity;
import com.tamguo.modules.sys.model.condition.SysAreaCondition;
import com.tamguo.modules.sys.service.ISysAreaService;
@Service
public class SysAreaServiceImpl extends ServiceImpl<SysAreaMapper, SysAreaEntity> implements ISysAreaService{
@Autowired
SysAreaMapper sysAreaMapper;
@Override
public List<SysAreaEntity> listData(SysAreaCondition condition) {
return sysAreaMapper.listData(condition);
}
@SuppressWarnings("unchecked")
@Override
public JSONArray treeData(String excludeId) {
List<SysAreaEntity> areaList = null;
if(StringUtils.isEmpty(excludeId)) {
areaList = sysAreaMapper.selectList(Condition.EMPTY);
}else {
areaList = sysAreaMapper.selectList(Condition.create().notLike("parent_codes", excludeId).ne("area_code", excludeId));
}
return turnZTreeData(areaList);
}
private JSONArray turnZTreeData(List<SysAreaEntity> areaList) {
if(areaList != null) {
JSONArray nodes = new JSONArray();
for(int i=0 ; i<areaList.size() ; i++) {
JSONObject node = new JSONObject();
SysAreaEntity area = areaList.get(i);
node.put("name", area.getAreaName());
node.put("id", area.getId());
node.put("pId", area.getParentCode());
node.put("title", area.getAreaName());
nodes.add(node);
}
return nodes;
}
return null;
}
}

@ -0,0 +1,151 @@
package com.tamguo.modules.sys.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.modules.sys.dao.SysCompanyMapper;
import com.tamguo.modules.sys.model.SysCompanyEntity;
import com.tamguo.modules.sys.model.condition.SysCompanyCondition;
import com.tamguo.modules.sys.service.ISysCompanyService;
import com.tamguo.modules.sys.utils.ShiroUtils;
@Service
public class SysCompanyServiceImpl extends ServiceImpl<SysCompanyMapper, SysCompanyEntity> implements ISysCompanyService {
@Autowired
private SysCompanyMapper sysCompanyMapper;
@SuppressWarnings("unchecked")
@Override
public JSONArray treeData(String excludeId) {
List<SysCompanyEntity> companyList = null;
if(StringUtils.isEmpty(excludeId)) {
companyList = sysCompanyMapper.selectList(Condition.EMPTY);
}else {
companyList = sysCompanyMapper.selectList(Condition.create().notLike("parent_codes", excludeId).ne("company_code", excludeId));
}
return turnZTreeData(companyList);
}
@Override
public List<SysCompanyEntity> listData(SysCompanyCondition condition) {
return sysCompanyMapper.listData(condition);
}
@Override
public SysCompanyEntity selectByCode(String code) {
return sysCompanyMapper.selectByCode(code);
}
private JSONArray turnZTreeData(List<SysCompanyEntity> companyList) {
if(companyList != null) {
JSONArray nodes = new JSONArray();
for(int i=0 ; i<companyList.size() ; i++) {
JSONObject node = new JSONObject();
SysCompanyEntity company = companyList.get(i);
node.put("name", company.getCompanyName());
node.put("id", company.getId());
node.put("pId", company.getParentCode());
node.put("title", company.getFullName());
nodes.add(node);
}
return nodes;
}
return null;
}
@Transactional(readOnly=false)
@Override
public void save(SysCompanyEntity company) {
company.setCreateBy(ShiroUtils.getUserCode());
company.setCreateDate(new Date());
company.setUpdateBy(ShiroUtils.getUserCode());
company.setUpdateDate(new Date());
company.setCompanyCode(company.getViewCode());
// 更新树形结构
this.handleTreeData(company);
sysCompanyMapper.insert(company);
}
@SuppressWarnings("unchecked")
@Transactional(readOnly=false)
@Override
public void update(SysCompanyEntity company) {
SysCompanyEntity entity = sysCompanyMapper.selectByCode(company.getCompanyCode());
String oldParentCode = entity.getParentCode();
entity.setUpdateBy(ShiroUtils.getUserCode());
entity.setUpdateDate(new Date());
entity.setAreaCode(company.getAreaCode());
entity.setCompanyCode(company.getCompanyCode());
entity.setCompanyName(company.getCompanyName());
entity.setCorpCode(company.getCorpCode());
entity.setCorpName(company.getCorpName());
entity.setFullName(company.getFullName());
entity.setParentCode(company.getParentCode());
// 更新树形结构
this.handleTreeData(company);
sysCompanyMapper.updateById(entity);
// 更新旧的节点
Integer count = sysCompanyMapper.selectCount(Condition.create().eq("parent_code", oldParentCode).ne("company_code", oldParentCode));
if(count == 0) {
SysCompanyEntity oldParentCompany = sysCompanyMapper.selectById(oldParentCode);
oldParentCompany.setTreeLeaf(true);
sysCompanyMapper.updateById(oldParentCompany);
}
}
// 处理树形结构
@SuppressWarnings("unchecked")
private SysCompanyEntity handleTreeData(SysCompanyEntity company) {
if(StringUtils.isEmpty(company.getParentCode())) {
company.setParentCode(SysCompanyEntity.ROOT_COMPANY_CODE);
company.setParentCodes(SysCompanyEntity.ROOT_COMPANY_CODE + SysCompanyEntity.TREE_CODE_COMPANY_SEPARATE);
company.setTreeLeaf(true);
company.setTreeLevel(new BigDecimal(0));
company.setTreeNames(company.getCompanyName());
company.setTreeSorts("00000000" + company.getTreeSort() + SysCompanyEntity.ROOT_COMPANY_CODE);
} else {
SysCompanyEntity parentCompany = sysCompanyMapper.selectById(company.getParentCode());
company.setParentCodes(parentCompany.getParentCodes() + parentCompany.getCompanyCode() + SysCompanyEntity.TREE_CODE_COMPANY_SEPARATE);
company.setTreeLeaf(true);
company.setTreeLevel(parentCompany.getTreeLevel().add(new BigDecimal(1)));
company.setTreeNames(parentCompany.getTreeNames() + SysCompanyEntity.TREE_NAME_COMPANY_SEPARATE + parentCompany.getCompanyName());
company.setTreeSorts(parentCompany.getTreeSorts() + ("00000000" +company.getTreeSort()) + SysCompanyEntity.TREE_CODE_COMPANY_SEPARATE);
if(parentCompany.getTreeLeaf()) {
parentCompany.setTreeLeaf(false);
sysCompanyMapper.updateById(parentCompany);
}
}
Integer count = sysCompanyMapper.selectCount(Condition.create().eq("parent_code", company.getCompanyCode()));
if(count > 0) {
company.setTreeLeaf(false);
}else {
company.setTreeLeaf(true);
}
return company;
}
}

@ -0,0 +1,159 @@
package com.tamguo.modules.sys.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.modules.sys.dao.SysMenuMapper;
import com.tamguo.modules.sys.model.SysMenuEntity;
import com.tamguo.modules.sys.model.condition.SysMenuCondition;
import com.tamguo.modules.sys.model.enums.SysMenuStatusEnum;
import com.tamguo.modules.sys.service.ISysMenuService;
import com.tamguo.modules.sys.utils.ShiroUtils;
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenuEntity> implements ISysMenuService {
@Autowired
SysMenuMapper sysMenuMapper;
@Override
public List<SysMenuEntity> listData(SysMenuCondition condition) {
return sysMenuMapper.listData(condition);
}
@Transactional(readOnly=true)
@SuppressWarnings("unchecked")
@Override
public JSONArray treeData(String excludeId) {
List<SysMenuEntity> menus = null;
if(StringUtils.isEmpty(excludeId)) {
menus = sysMenuMapper.selectList(Condition.EMPTY);
}else {
menus = sysMenuMapper.selectList(Condition.create().notLike("parent_codes", excludeId).ne("menu_code", excludeId));
}
return turnZTreeData(menus);
}
private JSONArray turnZTreeData(List<SysMenuEntity> menus) {
if(menus != null) {
JSONArray nodes = new JSONArray();
for(int i=0 ; i<menus.size() ; i++) {
JSONObject node = new JSONObject();
SysMenuEntity menu = menus.get(i);
node.put("name", menu.getMenuName());
node.put("id", menu.getId());
node.put("pId", menu.getParentCode());
node.put("title", menu.getMenuName());
nodes.add(node);
}
return nodes;
}
return null;
}
@Transactional(readOnly=false)
@Override
public void save(SysMenuEntity menu) {
menu.setCreateBy(ShiroUtils.getUserCode());
menu.setCreateDate(new Date());
menu.setUpdateBy(ShiroUtils.getUserCode());
menu.setUpdateDate(new Date());
menu.setStatus(SysMenuStatusEnum.NORMAL);
// 父节点
if(StringUtils.isEmpty(menu.getParentCode())) {
menu.setTreeLeaf(true);
menu.setTreeLevel(new BigDecimal(0));
menu.setTreeNames(menu.getMenuName() + ",");
}else {
SysMenuEntity parentMenu = sysMenuMapper.selectById(menu.getParentCode());
menu.setTreeLeaf(true);
menu.setTreeLevel(parentMenu.getTreeLevel().add(new BigDecimal(1)));
menu.setTreeNames(parentMenu.getTreeNames() +"/"+ menu.getMenuName());
menu.setParentCodes(parentMenu.getParentCodes() + menu.getParentCode() + ",");
parentMenu.setTreeLeaf(false);
sysMenuMapper.updateById(parentMenu);
}
menu.setTreeSorts(menu.getTreeSort() + ",");
sysMenuMapper.insert(menu);
}
@SuppressWarnings("unchecked")
@Transactional(readOnly=false)
@Override
public void update(SysMenuEntity menu) {
SysMenuEntity entity = sysMenuMapper.selectById(menu.getMenuCode());
String oldParentCode = entity.getParentCode();
entity.setUpdateBy(ShiroUtils.getUserCode());
entity.setUpdateDate(new Date());
entity.setIsShow(menu.getIsShow());
entity.setMenuCode(menu.getMenuCode());
entity.setMenuColor(menu.getMenuColor());
entity.setMenuHref(menu.getMenuHref());
entity.setMenuIcon(menu.getMenuIcon());
entity.setMenuName(menu.getMenuName());
entity.setMenuTarget(menu.getMenuTarget());
entity.setMenuType(menu.getMenuType());
entity.setPermission(menu.getPermission());
entity.setRemarks(menu.getRemarks());
entity.setWeight(menu.getWeight());
entity.setParentCode(menu.getParentCode());
this.handleTreeData(entity);
sysMenuMapper.updateById(entity);
// 更新旧的节点
Integer count = sysMenuMapper.selectCount(Condition.create().eq("parent_code", oldParentCode).ne("menu_code", oldParentCode));
if(count == 0) {
SysMenuEntity oldParentMenu = sysMenuMapper.selectById(oldParentCode);
oldParentMenu.setTreeLeaf(true);
sysMenuMapper.updateById(oldParentMenu);
}
}
// 处理树形结构
@SuppressWarnings("unchecked")
private SysMenuEntity handleTreeData(SysMenuEntity menu) {
if(StringUtils.isEmpty(menu.getParentCode())) {
menu.setParentCode(SysMenuEntity.ROOT_MENU_CODE);
menu.setParentCodes(SysMenuEntity.ROOT_MENU_CODE + SysMenuEntity.TREE_CODE_MENU_SEPARATE);
menu.setTreeLeaf(true);
menu.setTreeLevel(new BigDecimal(0));
menu.setTreeNames(menu.getMenuName());
menu.setTreeSorts(menu.getTreeSort().multiply(new BigDecimal(10000000)).toString() + SysMenuEntity.TREE_CODE_MENU_SEPARATE);
} else {
SysMenuEntity parentMenu = sysMenuMapper.selectById(menu.getParentCode());
menu.setParentCodes(parentMenu.getParentCodes() + parentMenu.getMenuCode() + SysMenuEntity.TREE_CODE_MENU_SEPARATE);
menu.setTreeLeaf(true);
menu.setTreeLevel(parentMenu.getTreeLevel().add(new BigDecimal(1)));
menu.setTreeNames(parentMenu.getTreeNames() + SysMenuEntity.TREE_NAME_MENU_SEPARATE + parentMenu.getMenuName());
menu.setTreeSorts(parentMenu.getTreeSorts() + menu.getTreeSort().multiply(new BigDecimal(10000000)).toString() + SysMenuEntity.TREE_CODE_MENU_SEPARATE);
if(parentMenu.getTreeLeaf()) {
parentMenu.setTreeLeaf(false);
sysMenuMapper.updateById(parentMenu);
}
}
Integer count = sysMenuMapper.selectCount(Condition.create().eq("parent_code", menu.getMenuCode()));
if(count > 0) {
menu.setTreeLeaf(false);
}else {
menu.setTreeLeaf(true);
}
return menu;
}
}

@ -0,0 +1,144 @@
package com.tamguo.modules.sys.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.modules.sys.dao.SysOfficeMapper;
import com.tamguo.modules.sys.model.SysOfficeEntity;
import com.tamguo.modules.sys.model.condition.SysOfficeCondition;
import com.tamguo.modules.sys.service.ISysOfficeService;
import com.tamguo.modules.sys.utils.ShiroUtils;
@Service
public class SysOfficeServiceImpl extends ServiceImpl<SysOfficeMapper, SysOfficeEntity> implements ISysOfficeService {
@Autowired
private SysOfficeMapper sysOfficeMapper;
@Override
public List<SysOfficeEntity> listData(SysOfficeCondition condition) {
return sysOfficeMapper.listData(condition);
}
@SuppressWarnings("unchecked")
@Override
public JSONArray treeData(String excludeId) {
List<SysOfficeEntity> officeList = null;
if(StringUtils.isEmpty(excludeId)) {
officeList = sysOfficeMapper.selectList(Condition.EMPTY);
}else {
officeList = sysOfficeMapper.selectList(Condition.create().notLike("parent_codes", excludeId).ne("office_code", excludeId));
}
return turnZTreeData(officeList);
}
private JSONArray turnZTreeData(List<SysOfficeEntity> companyList) {
if(companyList != null) {
JSONArray nodes = new JSONArray();
for(int i=0 ; i<companyList.size() ; i++) {
JSONObject node = new JSONObject();
SysOfficeEntity office = companyList.get(i);
node.put("name", office.getOfficeName());
node.put("id", office.getId());
node.put("pId", office.getParentCode());
node.put("title", office.getFullName());
nodes.add(node);
}
return nodes;
}
return null;
}
@Transactional(readOnly=false)
@Override
public void save(SysOfficeEntity office) {
office.setCreateBy(ShiroUtils.getUserCode());
office.setCreateDate(new Date());
office.setUpdateBy(ShiroUtils.getUserCode());
office.setUpdateDate(new Date());
office.setOfficeCode(office.getViewCode());
// 处理属性结构
this.handleTreeData(office);
sysOfficeMapper.insert(office);
}
@SuppressWarnings("unchecked")
@Transactional(readOnly=false)
@Override
public void update(SysOfficeEntity office) {
SysOfficeEntity oldOffice = sysOfficeMapper.selectById(office.getOfficeCode());
String oldParentCode = oldOffice.getParentCode();
oldOffice.setAddress(office.getAddress());
oldOffice.setCorpCode(office.getCorpCode());
oldOffice.setCorpName(office.getCorpName());
oldOffice.setEmail(office.getEmail());
oldOffice.setFullName(office.getFullName());
oldOffice.setLeader(office.getLeader());
oldOffice.setOfficeCode(office.getOfficeCode());
oldOffice.setOfficeName(office.getOfficeName());
oldOffice.setOfficeType(office.getOfficeType());
oldOffice.setParentCode(office.getParentCode());
oldOffice.setRemarks(office.getRemarks());
oldOffice.setPhone(office.getPhone());
// 处理属性结构
this.handleTreeData(oldOffice);
sysOfficeMapper.updateById(oldOffice);
// 更新旧的节点
Integer count = sysOfficeMapper.selectCount(Condition.create().eq("parent_code", oldParentCode).ne("office_code", oldParentCode));
if(count == 0) {
SysOfficeEntity oldParentOffice = sysOfficeMapper.selectById(oldParentCode);
oldParentOffice.setTreeLeaf(true);
sysOfficeMapper.updateById(oldParentOffice);
}
}
// 处理树形结构
@SuppressWarnings("unchecked")
private SysOfficeEntity handleTreeData(SysOfficeEntity office) {
if(StringUtils.isEmpty(office.getParentCode())) {
office.setParentCode(SysOfficeEntity.ROOT_OFFICE_CODE);
office.setParentCodes(SysOfficeEntity.ROOT_OFFICE_CODE + SysOfficeEntity.TREE_CODE_OFFICE_SEPARATE);
office.setTreeLeaf(true);
office.setTreeLevel(new BigDecimal(0));
office.setTreeNames(office.getOfficeName());
office.setTreeSorts(office.getTreeSort().multiply(new BigDecimal(10000000)).toString() + SysOfficeEntity.TREE_CODE_OFFICE_SEPARATE);
} else {
SysOfficeEntity parentOffice = sysOfficeMapper.selectById(office.getParentCode());
office.setParentCodes(parentOffice.getParentCodes() + parentOffice.getOfficeCode() + SysOfficeEntity.TREE_CODE_OFFICE_SEPARATE);
office.setTreeLeaf(true);
office.setTreeLevel(parentOffice.getTreeLevel().add(new BigDecimal(1)));
office.setTreeNames(parentOffice.getTreeNames() + SysOfficeEntity.TREE_NAME_OFFICE_SEPARATE + parentOffice.getOfficeName());
office.setTreeSorts(parentOffice.getTreeSorts() + office.getTreeSort().multiply(new BigDecimal(10000000)).toString() + SysOfficeEntity.TREE_CODE_OFFICE_SEPARATE);
if(parentOffice.getTreeLeaf()) {
parentOffice.setTreeLeaf(false);
sysOfficeMapper.updateById(parentOffice);
}
}
Integer count = sysOfficeMapper.selectCount(Condition.create().eq("parent_code", office.getOfficeCode()));
if(count > 0) {
office.setTreeLeaf(false);
}else {
office.setTreeLeaf(true);
}
return office;
}
}

@ -0,0 +1,56 @@
package com.tamguo.modules.sys.service.impl;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.modules.sys.dao.SysPostMapper;
import com.tamguo.modules.sys.model.SysPostEntity;
import com.tamguo.modules.sys.model.condition.SysPostCondition;
import com.tamguo.modules.sys.model.enums.SysPostStatusEnum;
import com.tamguo.modules.sys.service.ISysPostService;
import com.tamguo.modules.sys.utils.ShiroUtils;
@Service
public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPostEntity> implements ISysPostService{
@Autowired
private SysPostMapper sysPostMapper;
@Override
public Page<SysPostEntity> listData(SysPostCondition condition) {
Page<SysPostEntity> page = new Page<>(condition.getPageNo(), condition.getPageSize());
return page.setRecords(sysPostMapper.listData(condition , page));
}
@Transactional(readOnly=false)
@Override
public void add(SysPostEntity post) {
post.setCreateDate(new Date());
post.setCreateBy(ShiroUtils.getUserCode());
post.setUpdateBy(ShiroUtils.getUserCode());
post.setUpdateDate(new Date());
post.setStatus(SysPostStatusEnum.NORMAL);
sysPostMapper.insert(post);
}
@Transactional(readOnly=false)
@Override
public void update(SysPostEntity post) {
SysPostEntity entity = sysPostMapper.selectById(post.getPostCode());
entity.setUpdateDate(new Date());
entity.setUpdateBy(ShiroUtils.getUserCode());
entity.setPostName(post.getPostName());
entity.setPostCode(post.getPostCode());
entity.setPostType(post.getPostType());
entity.setPostSort(post.getPostSort());
entity.setRemarks(post.getRemarks());
sysPostMapper.updateById(entity);
}
}

@ -0,0 +1,14 @@
package com.tamguo.modules.sys.service.impl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.modules.sys.dao.SysRoleDataScopeMapper;
import com.tamguo.modules.sys.model.SysRoleDataScopeEntity;
import com.tamguo.modules.sys.service.ISysRoleDataScopeService;
@Service
public class SysRoleDataScopeServiceImpl extends ServiceImpl<SysRoleDataScopeMapper, SysRoleDataScopeEntity> implements ISysRoleDataScopeService{
}

@ -0,0 +1,130 @@
package com.tamguo.modules.sys.service.impl;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.modules.sys.dao.SysMenuMapper;
import com.tamguo.modules.sys.dao.SysRoleDataScopeMapper;
import com.tamguo.modules.sys.dao.SysRoleMapper;
import com.tamguo.modules.sys.dao.SysRoleMenuMapper;
import com.tamguo.modules.sys.model.SysMenuEntity;
import com.tamguo.modules.sys.model.SysRoleDataScopeEntity;
import com.tamguo.modules.sys.model.SysRoleEntity;
import com.tamguo.modules.sys.model.SysRoleMenuEntity;
import com.tamguo.modules.sys.model.condition.SysRoleCondition;
import com.tamguo.modules.sys.service.ISysRoleService;
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRoleEntity> implements ISysRoleService {
@Autowired
private SysRoleMapper sysRoleMapper;
@Autowired
private SysMenuMapper sysMenuMapper;
@Autowired
private SysRoleMenuMapper sysRoleMenuMapper;
@Autowired
private SysRoleDataScopeMapper sysRoleDataScopeMapper;
@Transactional(readOnly=true)
@Override
public Page<SysRoleEntity> listData(SysRoleCondition condition) {
Page<SysRoleEntity> page = new Page<>(condition.getPageNo(), condition.getPageSize());
return page.setRecords(sysRoleMapper.listData(condition , page));
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> menuTreeData(String roleCode) {
List<SysMenuEntity> menus = sysMenuMapper.selectList(Condition.create().eq("is_show", "1"));
List<SysMenuEntity> roleMenus = sysMenuMapper.selectMenuByRoleId(roleCode);
JSONObject result = new JSONObject();
JSONObject menuInfo = transformZTree(menus);
result.put("menuMap", menuInfo);
result.put("roleMenuList", roleMenus);
return result;
}
private JSONObject transformZTree(List<SysMenuEntity> menus) {
JSONObject result = new JSONObject();
if(menus != null) {
JSONArray nodes = new JSONArray();
for(int i=0 ; i<menus.size() ; i++) {
SysMenuEntity menu = menus.get(i);
JSONObject node = new JSONObject();
node.put("name", menu.getMenuName() + "<font color=#888> &nbsp; &nbsp;   </font>");
if(!StringUtils.isEmpty(menu.getMenuHref())) {
node.put("name", menu.getMenuName() + "<font color=#888> &nbsp; &nbsp; "+menu.getMenuHref()+"  </font>");
}else if(!StringUtils.isEmpty(menu.getPermission())) {
node.put("name", menu.getMenuName() + "<font color=#888> &nbsp; &nbsp; "+menu.getPermission()+"  </font>");
}
node.put("pId", menu.getParentCode());
node.put("id", menu.getMenuCode());
node.put("title", menu.getMenuName());
nodes.add(node);
}
result.put("default", nodes);
}
return result;
}
@Transactional(readOnly=false)
@SuppressWarnings("unchecked")
@Override
public void allowMenuPermission(SysRoleEntity role) {
// 删除关联菜单
sysRoleMenuMapper.delete(Condition.create().eq("role_code", role.getRoleCode()));
if(!StringUtils.isEmpty(role.getRoleMenuListJson())) {
JSONArray roleMenus = JSONArray.parseArray(role.getRoleMenuListJson());
for(int i=0 ; i<roleMenus.size() ; i++) {
JSONObject menu = roleMenus.getJSONObject(i);
SysRoleMenuEntity roleMenu = new SysRoleMenuEntity();
roleMenu.setRoleCode(role.getRoleCode());
roleMenu.setMenuCode(menu.getString("menuCode"));
sysRoleMenuMapper.insert(roleMenu);
}
}
}
@SuppressWarnings("unchecked")
@Override
public void allowDataScope(SysRoleEntity role) {
// 删除权限
sysRoleDataScopeMapper.delete(Condition.create().eq("role_code", role.getRoleCode()));
// 插入权限
if(!StringUtils.isEmpty(role.getRoleDataScopeListJson())) {
JSONArray roleDataScopes = JSONArray.parseArray(role.getRoleDataScopeListJson());
for(int i=0 ; i<roleDataScopes.size() ; i++) {
JSONObject dataScope = roleDataScopes.getJSONObject(i);
SysRoleDataScopeEntity roleDataScope = new SysRoleDataScopeEntity();
roleDataScope.setRoleCode(role.getRoleCode());
roleDataScope.setCtrlPermi("1");
roleDataScope.setCtrlType(dataScope.getString("ctrlType"));
roleDataScope.setCtrlData(dataScope.getString("ctrlData"));
sysRoleDataScopeMapper.insert(roleDataScope);
}
}
}
@SuppressWarnings("unchecked")
@Override
public List<SysRoleEntity> treeDate(String userType) {
return sysRoleMapper.selectList(Condition.create().eq("user_type", userType));
}
}

@ -0,0 +1,236 @@
package com.tamguo.modules.sys.service.impl;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.tamguo.modules.sys.dao.SysUserDataScopeMapper;
import com.tamguo.modules.sys.dao.SysUserMapper;
import com.tamguo.modules.sys.dao.SysUserPostMapper;
import com.tamguo.modules.sys.dao.SysUserRoleMapper;
import com.tamguo.modules.sys.model.SysUserDataScopeEntity;
import com.tamguo.modules.sys.model.SysUserEntity;
import com.tamguo.modules.sys.model.SysUserPostEntity;
import com.tamguo.modules.sys.model.SysUserRoleEntity;
import com.tamguo.modules.sys.model.condition.SysUserCondition;
import com.tamguo.modules.sys.model.enums.SysUserMgrTypeEnum;
import com.tamguo.modules.sys.model.enums.SysUserStatusEnum;
import com.tamguo.modules.sys.model.enums.SysUserTypeEnum;
import com.tamguo.modules.sys.service.ISysRoleService;
import com.tamguo.modules.sys.service.ISysUserService;
import com.tamguo.modules.sys.utils.Result;
import com.tamguo.modules.sys.utils.ShiroUtils;
import com.tamguo.modules.sys.utils.TamguoConstant;
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUserEntity> implements ISysUserService{
@Autowired
public SysUserMapper sysUserMapper;
@Autowired
public SysUserPostMapper sysUserPostMapper;
@Autowired
public SysUserRoleMapper sysUserRoleMapper;
@Autowired
public ISysRoleService iSysRoleService;
@Autowired
public SysUserDataScopeMapper sysUserDataScopeMapper;
@Transactional(readOnly=false)
@Override
public SysUserEntity queryByLoginCode(String loginCode) {
SysUserEntity condition = new SysUserEntity();
condition.setLoginCode(loginCode);
return sysUserMapper.selectOne(condition);
}
@Transactional(readOnly=false)
@Override
public Page<SysUserEntity> listData(SysUserCondition condition) {
Page<SysUserEntity> page = new Page<>(condition.getPageNo() , condition.getPageSize());
return page.setRecords(sysUserMapper.listData(condition , page));
}
@SuppressWarnings("unchecked")
@Override
public String queryUserPostByUserCode(String userCode) {
Condition condition = Condition.create();
condition.eq("user_code", userCode);
List<SysUserPostEntity> userPostList = sysUserPostMapper.selectList(condition);
List<String> postCodes = new LinkedList<>();
for(int i=0 ; i<userPostList.size() ; i++) {
postCodes.add(userPostList.get(i).getPostCode());
}
return StringUtils.join(postCodes, ",");
}
@Transactional(readOnly=false)
@SuppressWarnings("unchecked")
@Override
public Boolean checkLoginCode(String oldLoginCode, String loginCode) {
Condition condition = Condition.create();
condition.eq("login_code", loginCode);
condition.ne("login_code", oldLoginCode);
List<SysUserEntity> userList = sysUserMapper.selectList(condition);
return CollectionUtils.isEmpty(userList);
}
@SuppressWarnings("unchecked")
@Transactional(readOnly=false)
@Override
public void update(SysUserEntity user) {
SysUserEntity entity = sysUserMapper.selectById(user.getUserCode());
entity.setOfficeCode(user.getOfficeCode());
entity.setOfficeName(user.getOfficeName());
entity.setCompanyCode(user.getCompanyCode());
entity.setCompanyName(user.getCompanyName());
entity.setLoginCode(user.getLoginCode());
entity.setUserName(user.getUserName());
entity.setEmail(user.getEmail());
entity.setMobile(user.getMobile());
entity.setPhone(user.getPhone());
entity.setUserWeight(user.getUserWeight());
entity.setRefName(user.getRefName());
entity.setUserNameEn(user.getUserNameEn());
entity.setRemarks(user.getRemarks());
sysUserMapper.updateById(entity);
// 删除记录
sysUserPostMapper.delete(Condition.create().eq("user_code", user.getUserCode()));
// 处理岗位
List<String> employeePosts = user.getEmployeePosts();
for(int i=0 ; i<employeePosts.size() ; i++) {
SysUserPostEntity userPost = new SysUserPostEntity();
userPost.setPostCode(employeePosts.get(i));
userPost.setUserCode(user.getUserCode());
sysUserPostMapper.insert(userPost);
}
}
@Transactional(readOnly=false)
@Override
public void save(SysUserEntity user) {
user.setCreateBy(ShiroUtils.getUserCode());
user.setCreateDate(new Date());
user.setStatus(SysUserStatusEnum.NORMAL);
// 设置初始密码
user.setPassword(TamguoConstant.INIT_PASSWORD);
user.setUserType(SysUserTypeEnum.EMPLOYEE);
user.setMgrType(SysUserMgrTypeEnum.NONE_ADMIN);
user.setUpdateBy(ShiroUtils.getUserCode());
user.setUpdateDate(new Date());
sysUserMapper.insert(user);
// 处理岗位
List<String> employeePosts = user.getEmployeePosts();
for(int i=0 ; i<employeePosts.size() ; i++) {
SysUserPostEntity userPost = new SysUserPostEntity();
userPost.setPostCode(employeePosts.get(i));
userPost.setUserCode(user.getUserCode());
sysUserPostMapper.insert(userPost);
}
// 处理角色
if(!StringUtils.isEmpty(user.getUserRoleString())) {
String[] roleCodes = user.getUserRoleString().split(",");
for(String roleCode : roleCodes) {
SysUserRoleEntity role = new SysUserRoleEntity();
role.setRoleCode(roleCode);
role.setUserCode(user.getUserCode());
sysUserRoleMapper.insert(role);
}
}
}
@SuppressWarnings("unchecked")
@Transactional(readOnly=false)
@Override
public void allowUserRole(SysUserEntity user) {
// 删除角色记录
sysUserRoleMapper.delete(Condition.create().eq("user_code", user.getUserCode()));
// 处理角色
if(!StringUtils.isEmpty(user.getUserRoleString())) {
String[] roleCodes = user.getUserRoleString().split(",");
for(String roleCode : roleCodes) {
SysUserRoleEntity role = new SysUserRoleEntity();
role.setRoleCode(roleCode);
role.setUserCode(user.getUserCode());
sysUserRoleMapper.insert(role);
}
}
}
@SuppressWarnings("unchecked")
@Transactional(readOnly=true)
@Override
public List<SysUserRoleEntity> findUserRole(String userCode) {
return sysUserRoleMapper.selectList(Condition.create().eq("user_code", userCode));
}
@SuppressWarnings("unchecked")
@Transactional(readOnly=true)
@Override
public List<SysUserDataScopeEntity> selectUserDataScope(String userCode) {
return sysUserDataScopeMapper.selectList(Condition.create().eq("user_code", userCode));
}
@SuppressWarnings("unchecked")
@Transactional(readOnly=false)
@Override
public void saveUserDataScope(SysUserEntity user) {
// 删除之前的数据权限
sysUserDataScopeMapper.delete(Condition.create().eq("user_code", user.getUserCode()));
if(!StringUtils.isEmpty(user.getUserDataScopeListJson())) {
JSONArray dataScopeList = JSONArray.parseArray(user.getUserDataScopeListJson());
for(int i=0 ; i<dataScopeList.size() ; i++) {
SysUserDataScopeEntity entity = new SysUserDataScopeEntity();
entity.setCtrlData(dataScopeList.getJSONObject(i).getString("ctrlData"));
entity.setCtrlType(dataScopeList.getJSONObject(i).getString("ctrlType"));
entity.setUserCode(user.getUserCode());
entity.setCtrlPermi("2");
sysUserDataScopeMapper.insert(entity);
}
}
}
@Transactional(readOnly=false)
@Override
public Result disable(String userCode) {
SysUserEntity user = sysUserMapper.selectById(userCode);
user.setStatus(SysUserStatusEnum.DISABLED);
sysUserMapper.updateById(user);
return Result.result(0, null, "停用成功!");
}
@Transactional(readOnly=false)
@Override
public Result enable(String userCode) {
SysUserEntity user = sysUserMapper.selectById(userCode);
user.setStatus(SysUserStatusEnum.NORMAL);
sysUserMapper.updateById(user);
return Result.result(0, null, "激活成功!");
}
@Transactional(readOnly=false)
@Override
public Result delete(String userCode) {
SysUserEntity user = sysUserMapper.selectById(userCode);
user.setStatus(SysUserStatusEnum.DELETE);
sysUserMapper.updateById(user);
return Result.result(0, null, "删除成功!");
}
}

@ -0,0 +1,114 @@
package com.tamguo.modules.sys.utils;
import java.io.InterruptedIOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public abstract class AbstractRunningLogHandler implements LogHandler {
private static Method getStackTraceMethod;
private static Method getClassNameMethod;
private static Method getMethodNameMethod;
private static Method getFileNameMethod;
private static Method getLineNumberMethod;
static {
try {
Class<?>[] noArgs = null;
getStackTraceMethod = Throwable.class.getMethod("getStackTrace", noArgs);
Class<?> stackTraceElementClass = Class.forName("java.lang.StackTraceElement");
getClassNameMethod = stackTraceElementClass.getMethod("getClassName", noArgs);
getMethodNameMethod = stackTraceElementClass.getMethod("getMethodName", noArgs);
getFileNameMethod = stackTraceElementClass.getMethod("getFileName", noArgs);
getLineNumberMethod = stackTraceElementClass.getMethod("getLineNumber", noArgs);
} catch (ClassNotFoundException ex) {
LogDebug.debug("will use pre-JDK 1.4 methods to determine location.");
} catch (NoSuchMethodException ex) {
LogDebug.debug("will use pre-JDK 1.4 methods to determine location.");
}
}
/**
* classStackTraceElement
*
* @param t
* @param fqnOfCallingClass
*
* @return
*/
protected StackTraceElement getRunningStackTrace(Throwable t, String fqnOfCallingClass) {
if (getLineNumberMethod != null) {
try {
Object[] noArgs = null;
Object[] elements = (Object[]) getStackTraceMethod.invoke(t, noArgs);
for (int i = elements.length - 1; i >= 0; i--) {
String thisClass = (String) getClassNameMethod.invoke(elements[i], noArgs);
if (fqnOfCallingClass.equals(thisClass)) {
// 执行class名称
String className = fqnOfCallingClass;
// 执行方法名称
String methodName = (String) getMethodNameMethod.invoke(elements[i], noArgs);
// 执行class文件名称
String fileName = (String) getFileNameMethod.invoke(elements[i], noArgs);
// 执行到行号
int lineNumber = ((Integer) getLineNumberMethod.invoke(elements[i], noArgs)).intValue();
return new StackTraceElement(className, methodName, fileName, lineNumber);
}
}
} catch (IllegalAccessException ex) {
LogDebug.debug("failed using JDK 1.4 methods", ex);
} catch (InvocationTargetException ex) {
if (ex.getTargetException() instanceof InterruptedException
|| ex.getTargetException() instanceof InterruptedIOException) {
Thread.currentThread().interrupt();
}
LogDebug.debug("failed using JDK 1.4 methods", ex);
} catch (RuntimeException ex) {
LogDebug.debug("failed using JDK 1.4 methods", ex);
}
}
return this.createDefaultStackTrace();
}
/**
* StackTraceElement
*
* @return
*/
private StackTraceElement createDefaultStackTrace() {
return new StackTraceElement(this.getClass().getName(), "log", this.getClass().getName(), 0);
}
@Override
public void info(String msg, String fqnOfCallingClass) {
}
@Override
public void info(String msg, Throwable t, String fqnOfCallingClass) {
}
@Override
public void error(String msg, String fqnOfCallingClass) {
}
@Override
public void error(String msg, Throwable t, String fqnOfCallingClass) {
}
@Override
public void debug(String msg, String fqnOfCallingClass) {
}
@Override
public void debug(String msg, Throwable t, String fqnOfCallingClass) {
}
@Override
public void warning(String msg, String fqnOfCallingClass) {
}
@Override
public void warning(String msg, Throwable t, String fqnOfCallingClass) {
}
}

@ -0,0 +1,23 @@
package com.tamguo.modules.sys.utils;
public class CException extends RuntimeException {
private static final long serialVersionUID = 6401592364022805815L;
public CException() {
super();
}
public CException(String message, Throwable cause) {
super(message, cause);
}
public CException(String message) {
super(message);
}
public CException(Throwable cause) {
super(cause);
}
}

@ -0,0 +1,524 @@
package com.tamguo.modules.sys.utils;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public final class DateUtil {
/**
* .
*/
private static final SimpleDateFormat NORMAL_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static final SimpleDateFormat NORMAL_DATE_FORMAT_YY_MM_DD = new SimpleDateFormat("yyyy-MM-dd");
private static final SimpleDateFormat NORMAL_DATE_FORMAT_YY_MM_DD_ = new SimpleDateFormat("yyyyMMdd");
private static final SimpleDateFormat NORMAL_DATE_FORMAT_YYMMDDHHMISS = new SimpleDateFormat("yyyyMMddHHmmss");
/**
* .
*
* @param date
* 197011
* @return (2011-11-24)
*/
public static String dateFormatYYMMDD(long date) {
return NORMAL_DATE_FORMAT_YY_MM_DD.format(new Date(date * 1000));
}
/**
* .
*
* @param date
* 197011
* @return (20111124)
*/
public static String getCurrentDateStr() {
return NORMAL_DATE_FORMAT_YY_MM_DD_.format(new Date());
}
public static String getCurrentDateYYYYMMDDStr() {
return NORMAL_DATE_FORMAT_YY_MM_DD.format(new Date());
}
public static String getNextDayYYYYMMDDStr() {
Calendar cal = Calendar.getInstance();
try {
cal.setTime(NORMAL_DATE_FORMAT_YY_MM_DD.parse(getCurrentTime()));
cal.add(Calendar.DATE, 1);
return NORMAL_DATE_FORMAT_YY_MM_DD.format(cal.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
public static long getNextDayYYYYMMDDLong() {
Calendar cal = Calendar.getInstance();
try {
cal.setTime(NORMAL_DATE_FORMAT_YY_MM_DD.parse(getCurrentTime()));
cal.add(Calendar.DATE, 1);
return cal.getTimeInMillis();
} catch (ParseException e) {
e.printStackTrace();
}
return 0l;
}
/**
* .
*
* @param date
* 197011
* @return (2011-11-24 16:46:38)
*/
public static String dateFormat(long date) {
return NORMAL_DATE_FORMAT.format(new Date(date * 1000));
}
/**
* .
*
* @param date
* 197011
* @return (2011-11-24)
*/
public static String dateFormatYYYYMMDD(long date) {
return NORMAL_DATE_FORMAT_YY_MM_DD.format(new Date(date * 1000));
}
/**
* .
*
* @param date
* 197011
* @return (2011-11-24 16:46:38)
*/
public static String dateFormat(Date date) {
return NORMAL_DATE_FORMAT.format(date);
}
/**
* .
*
* @param date
* 197011
* @return (20111124164638)
*/
public static String dateFormathhmmss(Date date) {
return NORMAL_DATE_FORMAT_YYMMDDHHMISS.format(date);
}
/**
* .
*
* @param date
* 197011
* @return (20111124164638)
*/
public static String dateFormatYYYYMMDD(Date date) {
return NORMAL_DATE_FORMAT_YY_MM_DD_.format(date);
}
/**
* .
*
* @param date
* 197011
* @return (2011-11-24 16:46:38)
*/
public static String getCurrentTime() {
return NORMAL_DATE_FORMAT_YY_MM_DD.format(new Date());
}
/**
* 197011.
*
* @return 197011.
*/
public static Long getTime() {
return new Date().getTime() / 1000;
}
/**
* 197011.
*
* @return .
*/
public static long getLastWeekTime() {
return new Date().getTime() / 1000 - 7 * 24 * 60 * 60;
}
/**
* 197011.
*
* @return .
*/
public static long getLastMonthTime() {
return new Date().getTime() / 1000 - 30 * 24 * 60 * 60;
}
/**
* .
*
* @return 2011-12-31 00:00:00 .
*/
public static long getFirstDayOfMonth(String year, String month) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, Integer.valueOf(year));
cal.set(Calendar.MONTH, Integer.valueOf(month) - 1);
cal.set(Calendar.DAY_OF_MONTH, cal.getMinimum(Calendar.DATE));
return parseDate(NORMAL_DATE_FORMAT_YY_MM_DD.format(cal.getTime()) + " 00:00:00").getTime() / 1000;
}
/**
* .
*
* @return 2011-12-31 23:59:59 .
*/
public static long getLastDayOfMonth(String year, String month) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, Integer.valueOf(year));
cal.set(Calendar.MONTH, Integer.valueOf(month) - 1);
cal.set(Calendar.DAY_OF_MONTH, 1);
int value = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, value);
return parseDate(NORMAL_DATE_FORMAT_YY_MM_DD.format(cal.getTime()) + " 23:59:59").getTime() / 1000;
}
/**
* Date.
*
* @param dateString
* 2011-12-17 17:41:18.843 CST.
* @return .null
*/
public static Date parseDate(String dateStr) {
try {
return NORMAL_DATE_FORMAT.parse(dateStr);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* .
*
* @param date
* 197011
* @return ()
*/
public static long parseLong(String date) {
return parseDate(date).getTime() / 1000;
}
/**
*
*
* @param date
* @return
*/
public static String parseString(Date date) {
return NORMAL_DATE_FORMAT_YY_MM_DD.format(date);
}
public static long getLastDayStartTime(long daytime) {
Calendar todayStart = Calendar.getInstance();
todayStart.setTimeInMillis(daytime * 1000);
todayStart.add(Calendar.DAY_OF_YEAR, -1);
todayStart.set(Calendar.HOUR_OF_DAY, 0);
todayStart.set(Calendar.MINUTE, 0);
todayStart.set(Calendar.SECOND, 0);
todayStart.set(Calendar.MILLISECOND, 0);
return todayStart.getTimeInMillis() / 1000;
}
public static long getLastDayEndTime(long daytime) {
Calendar todayEnd = Calendar.getInstance();
todayEnd.setTimeInMillis(daytime * 1000);
todayEnd.add(Calendar.DAY_OF_YEAR, -1);
todayEnd.set(Calendar.HOUR_OF_DAY, 23);
todayEnd.set(Calendar.MINUTE, 59);
todayEnd.set(Calendar.SECOND, 59);
todayEnd.set(Calendar.MILLISECOND, 999);
return todayEnd.getTimeInMillis() / 1000;
}
public static long getTime(long time) {
Calendar timeCalendar = Calendar.getInstance();
Calendar nowCalendar = Calendar.getInstance();
timeCalendar.setTimeInMillis(time * 1000);
timeCalendar.set(Calendar.HOUR_OF_DAY, nowCalendar.get(Calendar.HOUR_OF_DAY));
timeCalendar.set(Calendar.MINUTE, nowCalendar.get(Calendar.MINUTE));
timeCalendar.set(Calendar.SECOND, nowCalendar.get(Calendar.SECOND));
timeCalendar.set(Calendar.MILLISECOND, nowCalendar.get(Calendar.MILLISECOND));
return timeCalendar.getTimeInMillis() / 1000;
}
public static long getStartTime(long daytime) {
Calendar todayStart = Calendar.getInstance();
todayStart.setTimeInMillis(daytime * 1000);
// todayStart.add(Calendar.DAY_OF_YEAR, -1);
todayStart.set(Calendar.HOUR_OF_DAY, 0);
todayStart.set(Calendar.MINUTE, 0);
todayStart.set(Calendar.SECOND, 0);
todayStart.set(Calendar.MILLISECOND, 0);
return todayStart.getTime().getTime() / 1000;
}
public static long getEndTime(long daytime) {
Calendar todayEnd = Calendar.getInstance();
todayEnd.setTimeInMillis(daytime * 1000);
// todayEnd.add(Calendar.DAY_OF_YEAR, -1);
todayEnd.set(Calendar.HOUR_OF_DAY, 23);
todayEnd.set(Calendar.MINUTE, 59);
todayEnd.set(Calendar.SECOND, 59);
todayEnd.set(Calendar.MILLISECOND, 999);
return todayEnd.getTimeInMillis() / 1000;
}
/**
*
*
* @param d1
* @param d2
* @return
*/
public static boolean compareSameDate(Date d1, Date d2) {
Calendar c1 = Calendar.getInstance();
c1.setTime(d1);
Calendar c2 = Calendar.getInstance();
c2.setTime(d2);
boolean isSameYear = c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR);
boolean isSameMonth = isSameYear && c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH);
boolean isSameDate = isSameMonth && c1.get(Calendar.DAY_OF_MONTH) == c2.get(Calendar.DAY_OF_MONTH);
return isSameDate;
}
/**
* 197011.
*
* @param date
* @return long
* @author mengxm
*/
public static final long firstMonthDayTime() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 1);
return cal.getTime().getTime() / 1000;
}
/**
*
*
* @param dateString
* @param fmtString
* @return Date
* @author mengxm
*/
public static final Date parse(String dateString, String fmtString) {
Date date = null;
try {
DateFormat format = new SimpleDateFormat(fmtString);
date = format.parse(dateString);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/** 比较提现前后时间间隔秒数 */
public static boolean getDatePoor(Date endDate, Date nowDate) {
// 获得两个时间的毫秒时间差异
System.out.println(endDate.getTime());
System.out.println(nowDate.getTime());
long diff = (endDate.getTime() - nowDate.getTime()) / 1000;
if (diff < 30) {
return true;
}
return false;
}
/**
*
*
* @param day
*
* @return
*/
public static long currentDateAddDay(int day) {
Calendar cal = Calendar.getInstance();
try {
cal.setTime(NORMAL_DATE_FORMAT_YY_MM_DD.parse(getCurrentTime()));
cal.add(Calendar.DATE, day); // add N days
return cal.getTimeInMillis() / 1000;
} catch (ParseException e) {
e.printStackTrace();
}
return 0l;
}
public static long dateAddDay(long dateLong, int day) {
Calendar cal = Calendar.getInstance();
Date d = new Date(dateLong * 1000);
cal.setTime(d);
cal.add(Calendar.DATE, day);
return cal.getTimeInMillis() / 1000;
}
/**
*
*
* @param smdate
*
* @param bdate
*
* @return
* @throws ParseException
*/
public static int daysBetween(Date smdate, Date bdate) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
long between_days = 0L;
try {
smdate = sdf.parse(sdf.format(smdate));
bdate = sdf.parse(sdf.format(bdate));
Calendar cal = Calendar.getInstance();
cal.setTime(smdate);
long time1 = cal.getTimeInMillis();
cal.setTime(bdate);
long time2 = cal.getTimeInMillis();
between_days = (time2 - time1) / (1000 * 3600 * 24);
} catch (ParseException e) {
e.printStackTrace();
}
return Integer.parseInt(String.valueOf(between_days));
}
/** 日期转换为自定义格式输出 */
public static String DateToString(Date date, String formatType) {
if (date == null) {
return null;
}
if (formatType == null || "".equals(formatType)) {
return null;
}
String dateStr = "";
try {
SimpleDateFormat sdf = new SimpleDateFormat(formatType);
dateStr = sdf.format(date);
return dateStr;
} catch (Exception e) {
return null;
}
}
public static long getStartTimeCurrentDay() {
Calendar todayStart = Calendar.getInstance();
// todayStart.add(Calendar.DAY_OF_YEAR, -1);
todayStart.set(Calendar.HOUR_OF_DAY, 0);
todayStart.set(Calendar.MINUTE, 0);
todayStart.set(Calendar.SECOND, 0);
todayStart.set(Calendar.MILLISECOND, 0);
return todayStart.getTime().getTime() / 1000;
}
public static long getEndTimeCurrentDay() {
Calendar todayStart = Calendar.getInstance();
// todayStart.add(Calendar.DAY_OF_YEAR, -1);
todayStart.set(Calendar.HOUR_OF_DAY, 23);
todayStart.set(Calendar.MINUTE, 59);
todayStart.set(Calendar.SECOND, 59);
todayStart.set(Calendar.MILLISECOND, 59);
return todayStart.getTime().getTime() / 1000;
}
/** 日期转换为自定义格式输出 */
public static String fomatDate(Date date, String format) {
if (date == null) {
return "";
}
if (format == null || "".equals(format)) {
return "";
}
try {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(date);
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
public static String getLastDayFmtYYYYMMDD() {
Calendar todayStart = Calendar.getInstance();
todayStart.add(Calendar.DAY_OF_YEAR, -1);
todayStart.set(Calendar.HOUR_OF_DAY, 0);
todayStart.set(Calendar.MINUTE, 0);
todayStart.set(Calendar.SECOND, 0);
todayStart.set(Calendar.MILLISECOND, 0);
return NORMAL_DATE_FORMAT_YY_MM_DD_.format(todayStart.getTime());
}
/**
* @Title: getDateFormat
* @Description: yyyy-MM-dd
* @param str
* @return String
*/
public static String getDateFormat(String str) {
return dateFormatYYMMDD(Long.parseLong(str));
}
/**
* @Title: getTimeFormat
* @Description: yyyy-MM-dd HH:mm:ss
* @param str
* @return String
*/
public static String getTimeFormat(String str) {
return dateFormat(Long.parseLong(str));
}
public static void main(String[] args) {
System.out.println(dateFormat(1441036802));
System.out.println(getFirstDayOfMonth("2015", "9"));
System.out.println(getLastDayOfMonth("2015", "8"));
System.out.println(dateFormat(getLastMonthTime()));
System.out.println(dateFormat(getLastWeekTime()));
System.out.println(parseLong("2017-01-01 00:00:00"));
System.out.println(getTime());
System.out.println(dateFormat(1451624155));
System.out.println(parse("20151222", "yyyyMMdd"));
Calendar c = Calendar.getInstance();
Date nowDate = c.getTime();
c.set(Calendar.MINUTE, -1);
Date endDate = c.getTime();
System.out.println("nowDate--" + nowDate + ";endDate--" + endDate);
System.out.println(getDatePoor(nowDate, endDate));
System.out.println(dateFormatYYYYMMDD(new Date()));
System.out.println("args = [" + DateUtil.currentDateAddDay(0) + "]");
System.out.println("args = [" + DateUtil.parse("2016-01-19", "yyyy-MM-dd").getTime() + "]");
System.out.println(getTime());
System.out.println(getEndTimeCurrentDay());
System.out.println(getEndTimeCurrentDay() - getTime());
}
}

@ -0,0 +1,274 @@
package com.tamguo.modules.sys.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DateUtils {
public static final String DEFAULT_PATTERN = "yyyy-MM-dd";
public static String getOneDayFromNow(int day, String pattern) {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_MONTH, day);
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(cal.getTime());
}
public static String getOneDayFromNow(int day) {
return DateUtils.getOneDayFromNow(day, DEFAULT_PATTERN);
}
/**
*
*
* @param smdate
*
* @param bdate
*
* @return
* @throws ParseException
* @throws java.text.ParseException
*/
public static int daysBetween(Date smdate, Date bdate)
throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
smdate = sdf.parse(sdf.format(smdate));
bdate = sdf.parse(sdf.format(bdate));
Calendar cal = Calendar.getInstance();
cal.setTime(smdate);
long time1 = cal.getTimeInMillis();
cal.setTime(bdate);
long time2 = cal.getTimeInMillis();
long between_days = (time2 - time1) / (1000 * 3600 * 24);
return Integer.parseInt(String.valueOf(between_days));
}
public static void main(String[] args) throws ParseException {
System.out.println(daysBetween(null, null));
}
/**
* 2010-12-01
*/
public static String FORMAT_SHORT = "yyyy-MM-dd";
/**
* 2010-12-01 23:15:06
*/
public static String FORMAT_LONG = "yyyy-MM-dd HH:mm:ss";
/**
* yyyy-MM-dd HH:mm:ss.S
*/
public static String FORMAT_FULL = "yyyy-MM-dd HH:mm:ss.S";
/**
* 20101201
*/
public static String FORMAT_SHORT_CN = "yyyy年MM月dd";
/**
* 20101201 231506
*/
public static String FORMAT_LONG_CN = "yyyy年MM月dd日 HH时mm分ss秒";
/**
*
*/
public static String FORMAT_FULL_CN = "yyyy年MM月dd日 HH时mm分ss秒SSS毫秒";
/**
* date pattern
*/
public static String getDatePattern() {
return FORMAT_LONG;
}
/**
*
*
* @return
*/
public static String getNow() {
return format(new Date());
}
/**
*
*
* @param format
* @return
*/
public static String getNow(String format) {
return format(new Date(), format);
}
/**
* 使
*
* @param date
* @return
*/
public static String format(Date date) {
return format(date, getDatePattern());
}
/**
* 使
*
* @param date
*
* @param pattern
*
* @return
*/
public static String format(Date date, String pattern) {
String returnValue = "";
if (date != null) {
SimpleDateFormat df = new SimpleDateFormat(pattern);
returnValue = df.format(date);
}
return (returnValue);
}
/**
* 使
*
* @param timestamp
*
* @param pattern
*
* @return
*/
public static String format(String timestamp, String pattern) {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(new Date(Long.parseLong(timestamp)));
}
/**
* 使
*
* @param strDate
*
* @return
*/
public static Date parse(String strDate) {
return parse(strDate, getDatePattern());
}
/**
* 使
*
* @param strDate
*
* @param pattern
*
* @return
*/
public static Date parse(String strDate, String pattern) {
SimpleDateFormat df = new SimpleDateFormat(pattern);
try {
return df.parse(strDate);
} catch (ParseException e) {
e.printStackTrace();
return null;
}
}
/**
*
*
* @param date
*
* @param n
*
* @return
*/
public static Date addMonth(Date date, int n) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.MONTH, n);
return cal.getTime();
}
/**
*
*
* @param date
*
* @param n
*
* @return
*/
public static Date addDay(Date date, int n) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, n);
return cal.getTime();
}
/**
*
*/
public static String getTimeString() {
SimpleDateFormat df = new SimpleDateFormat(FORMAT_FULL);
Calendar calendar = Calendar.getInstance();
return df.format(calendar.getTime());
}
/**
*
*
* @param date
*
* @return
*/
public static String getYear(Date date) {
return format(date).substring(0, 4);
}
/**
*
*
* @param date
*
* @return
*/
public static int countDays(String date) {
long t = Calendar.getInstance().getTime().getTime();
Calendar c = Calendar.getInstance();
c.setTime(parse(date));
long t1 = c.getTime().getTime();
return (int) (t / 1000 - t1 / 1000) / 3600 / 24;
}
/**
*
*
* @param date
*
* @param format
*
* @return
*/
public static int countDays(String date, String format) {
long t = Calendar.getInstance().getTime().getTime();
Calendar c = Calendar.getInstance();
c.setTime(parse(date, format));
long t1 = c.getTime().getTime();
return (int) (t / 1000 - t1 / 1000) / 3600 / 24;
}
public static String timeFormat(Date date, String format, Boolean flag, int beforeDay, int nowDay) {
if(date == null) {
date = new Date();
}
Calendar cal = Calendar.getInstance();
cal.setTime(date);
if(flag) {
cal.add(Calendar.DATE,-30);
} else {
cal.add(Calendar.DATE,0);
}
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(cal.getTime());
}
}

@ -0,0 +1,32 @@
package com.tamguo.modules.sys.utils;
/**
*
*
*/
public class ExceptionSupport {
private final static Result failResult = Result.failResult("500");
private static LogHandler handler = new Log4jHandler();
private final static String LOG_INFO_PREFIX = "--info>> ";
private final static String LOG_ERROR_PREFIX = "--error>> ";
public static Result resolverResult(String methodInfo, Class<?> clazz, Exception e) {
if(e instanceof CException) {
handler.info(formatInfoLevelMsg(methodInfo, e.getMessage()), clazz.getName());
return Result.failResult(e.getMessage());
}
handler.error(formatErrorLevelMsg(methodInfo), e, clazz.getName());
return failResult;
}
private static String formatInfoLevelMsg(String methodInfo, String infoMsg) {
return LOG_INFO_PREFIX + methodInfo + ": " + infoMsg;
}
private static String formatErrorLevelMsg(String methodInfo) {
return LOG_ERROR_PREFIX + methodInfo;
}
}

@ -0,0 +1,99 @@
package com.tamguo.modules.sys.utils;
public class IdGen
{
private long workerId;
private long datacenterId;
private long sequence = 0L;
private long twepoch = 1288834974657L;
private long workerIdBits = 5L;
private long datacenterIdBits = 5L;
private long maxWorkerId = -1L ^ (-1L << workerIdBits);
private long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
private long sequenceBits = 12L;
private long workerIdShift = sequenceBits;
private long datacenterIdShift = sequenceBits + workerIdBits;
private long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
private long sequenceMask = -1L ^ (-1L << sequenceBits);
private long lastTimestamp = -1L;
private String suffix;
private boolean flag;
private static class IdGenHolder {
private static final IdGen instance = new IdGen();
}
public static IdGen get(){
return IdGenHolder.instance;
}
/**
* id
* @param suffix
* @param flag true: false:
* @return
*/
public static IdGen get(String suffix,boolean flag){
if(suffix == null || suffix.trim().length() == 0)
return IdGenHolder.instance;
else{
return new IdGen(suffix,flag);
}
}
public IdGen() {
this(0L, 0L);
}
public IdGen(String suffix,boolean flag){
this.suffix = suffix;
this.flag = flag;
}
public IdGen(long workerId, long datacenterId) {
if (workerId > maxWorkerId || workerId < 0) {
throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
}
if (datacenterId > maxDatacenterId || datacenterId < 0) {
throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
}
this.workerId = workerId;
this.datacenterId = datacenterId;
}
public synchronized String nextId() {
long timestamp = timeGen();
if (timestamp < lastTimestamp) {
throw new RuntimeException(String.format(
"Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
}
if (lastTimestamp == timestamp) {
sequence = (sequence + 1) & sequenceMask;
if (sequence == 0) {
timestamp = tilNextMillis(lastTimestamp);
}
} else {
sequence = 0L;
}
lastTimestamp = timestamp;
long serialNumber = ((timestamp - twepoch) << timestampLeftShift) | (datacenterId << datacenterIdShift)
| (workerId << workerIdShift) | sequence;
return (suffix == null || suffix.trim().length() == 0) ? serialNumber+"" : (flag ? (new StringBuffer()).append(suffix).append(serialNumber).toString() : (new StringBuffer()).append(serialNumber).append(suffix).toString());
}
protected long tilNextMillis(long lastTimestamp) {
long timestamp = timeGen();
while (timestamp <= lastTimestamp) {
timestamp = timeGen();
}
return timestamp;
}
protected long timeGen() {
return System.currentTimeMillis();
}
}

@ -0,0 +1,31 @@
package com.tamguo.modules.sys.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;
public class Log4jHandler extends AbstractRunningLogHandler {
private static final Logger logger = LoggerFactory.getLogger(Log4jHandler.class);
@Override
public void info(String msg, String fqnOfCallingClass) {
logger.info(fqnOfCallingClass, Level.INFO, msg, null);
}
@Override
public void info(String msg, Throwable t, String fqnOfCallingClass) {
logger.info(fqnOfCallingClass, Level.INFO, msg, t);
}
@Override
public void error(String msg, String fqnOfCallingClass) {
logger.error(fqnOfCallingClass, Level.ERROR, msg, null);
}
@Override
public void error(String msg, Throwable t, String fqnOfCallingClass) {
logger.error(fqnOfCallingClass, Level.ERROR, msg, t);
}
}

@ -0,0 +1,17 @@
package com.tamguo.modules.sys.utils;
public class LogDebug {
private final static String DEBUG_LOG_KEY = "-- LogHandler: ";
public static void debug(String msg) {
System.err.println(DEBUG_LOG_KEY + msg);
}
public static void debug(String msg, Throwable t) {
System.err.println(DEBUG_LOG_KEY + msg);
if (t != null)
t.printStackTrace(System.err);
}
}

@ -0,0 +1,21 @@
package com.tamguo.modules.sys.utils;
public interface LogHandler {
public void info(String msg, String fqnOfCallingClass);
public void info(String msg, Throwable t, String fqnOfCallingClass);
public void error(String msg, String fqnOfCallingClass);
public void error(String msg, Throwable t, String fqnOfCallingClass);
public void debug(String msg, String fqnOfCallingClass);
public void debug(String msg, Throwable t, String fqnOfCallingClass);
public void warning(String msg, String fqnOfCallingClass);
public void warning(String msg, Throwable t, String fqnOfCallingClass);
}

@ -0,0 +1,69 @@
package com.tamguo.modules.sys.utils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class ObjectUtil extends SerializeTranscoder {
@Override
public byte[] serialize(Object value) {
if (value == null) {
throw new NullPointerException("Can't serialize null");
}
byte[] result = null;
ByteArrayOutputStream bos = null;
ObjectOutputStream os = null;
try {
bos = new ByteArrayOutputStream();
os = new ObjectOutputStream(bos);
os.writeObject(value);
os.close();
bos.close();
result = bos.toByteArray();
} catch (IOException e) {
throw new IllegalArgumentException("Non-serializable object", e);
} finally {
close(os);
close(bos);
}
return result;
}
@Override
public Object deserialize(byte[] in) {
Object result = null;
ByteArrayInputStream bis = null;
ObjectInputStream is = null;
try {
if (in != null) {
bis = new ByteArrayInputStream(in);
is = new ObjectInputStream(bis);
result = is.readObject();
is.close();
bis.close();
}
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally {
close(is);
close(bis);
}
return result;
}
public static boolean equals(Object o1, Object o2) {
if (o1 == o2) {
return true;
} else if (o1 == null || o2 == null) {
return false;
} else {
return o1.equals(o2);
}
}
}

@ -0,0 +1,55 @@
package com.tamguo.modules.sys.utils;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RequestHelper {
private static Logger logger = LoggerFactory.getLogger(RequestHelper.class);
/**
* IP,IP;
*
* @param request
* @return
* @throws IOException
*/
public final static String getIpAddress(HttpServletRequest request) {
// 获取请求主机IP地址,如果通过代理进来则透过防火墙获取真实IP地址
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} else if (ip.length() > 15) {
String[] ips = ip.split(",");
for (int index = 0; index < ips.length; index++) {
String strIp = (String) ips[index];
if (!("unknown".equalsIgnoreCase(strIp))) {
ip = strIp;
break;
}
}
}
if (logger.isInfoEnabled()) {
logger.info("getIpAddress(HttpServletRequest) - Proxy-Client-IP - String ip=" + ip);
}
return ip;
}
}

@ -0,0 +1,108 @@
package com.tamguo.modules.sys.utils;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Result implements Serializable {
private static final long serialVersionUID = -1651614836984397356L;
private int code;
private Object result;
private String message;
public static final int SUCCESS_CODE = 0;
public static final int FAIL_CODE = 1;
private Result() {
}
private Result(int code, Object result, String message) {
this.code = code;
this.result = result;
this.message = message;
}
/**
*
*
* @param result
* @return
*/
public static Result successResult(Object result) {
return result(SUCCESS_CODE, result, "");
}
public static Result successResult(Object records, Long recordSum, Long rowsOfPage) {
return successResult(records, recordSum, rowsOfPage, null);
}
public static Result successResult(Object records, Long recordSum, Long rowsOfPage, Object userData) {
Map<String, Object> result = resultOfList(records, recordSum, rowsOfPage, userData);
return successResult(result);
}
public static Map<String, Object> resultOfList(Object records, Long recordSum, Long rowsOfPage) {
return resultOfList(records, recordSum, rowsOfPage, null);
}
public static Map<String, Object> resultOfList(Object Obj, Long records, Long rowsOfPage, Object userData) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("rows", Obj);
result.put("records", records);
result.put("total", rowsOfPage);
if (null != userData) {
result.put("userdata", userData);
}
;
return result;
}
public static Map<String, Object> jqGridResult(List<?> list, long totalCount, int pageSize, int currPage,
int totalPage) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("list", list);
result.put("count", totalCount);
result.put("next", currPage == totalPage ? currPage : currPage + 1);
result.put("prev", currPage == 1 ? 1 : currPage - 1);
result.put("first", 1);
result.put("last", totalPage);
result.put("pageSize", pageSize);
result.put("pageNo", currPage);
return result;
}
/**
*
*
* @param errorMsg
* @return
*/
public static Result failResult(String errorMsg) {
return result(FAIL_CODE, "", errorMsg);
}
public static Result result(int code, Object result, String message) {
Result res = new Result(code, result, message);
return res;
}
public int getCode() {
return code;
}
public Object getResult() {
return result;
}
public String getMessage() {
return message;
}
}

@ -0,0 +1,20 @@
package com.tamguo.modules.sys.utils;
import java.io.Closeable;
public abstract class SerializeTranscoder {
public abstract byte[] serialize(Object value);
public abstract Object deserialize(byte[] in);
public void close(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

@ -0,0 +1,32 @@
package com.tamguo.modules.sys.utils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* Setting -
*
* @author candy.tam
*
*/
@Component
public final class Setting {
/** 域名 */
@Value(value="${domain.name}")
public String domain;
/** 静态资源地址*/
@Value(value="${static.domain}")
public String staticDomain;
@Value(value="${version}")
public String version;
/** 真题 */
public final String PAPER_TYPE_ZHENTI = "1";
/** 模拟*/
public final String PAPER_TYPE_MONI = "2";
/** 押题*/
public final String PAPER_TYPE_YATI = "3";
/** 名校 */
public final String PAPER_TYPE_MINGXIAO = "4";
}

@ -0,0 +1,68 @@
package com.tamguo.modules.sys.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class ShaEncrypt {
/**
* SHA-256
*
* @param strText
* @return
*/
public static String SHA256(final String strText) {
return SHA(strText, "SHA-256");
}
/**
* SHA-512
*
* @param strText
* @return
*/
public static String SHA512(final String strText) {
return SHA(strText, "SHA-512");
}
/**
* SHA
*
* @param strSourceText
* @return
*/
private static String SHA(final String strText, final String strType) {
// 返回值
String strResult = null;
// 是否是有效字符串
if (strText != null && strText.length() > 0) {
try {
// SHA 加密开始
// 创建加密对象 并傳入加密類型
MessageDigest messageDigest = MessageDigest.getInstance(strType);
// 传入要加密的字符串
messageDigest.update(strText.getBytes());
// 得到 byte 類型结果
byte byteBuffer[] = messageDigest.digest();
// 將 byte 轉換爲 string
StringBuffer strHexString = new StringBuffer();
// 遍歷 byte buffer
for (int i = 0; i < byteBuffer.length; i++) {
String hex = Integer.toHexString(0xff & byteBuffer[i]);
if (hex.length() == 1) {
strHexString.append('0');
}
strHexString.append(hex);
}
// 得到返回結果
strResult = strHexString.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
return strResult;
}
}

@ -0,0 +1,49 @@
package com.tamguo.modules.sys.utils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import com.tamguo.modules.sys.model.SysUserEntity;
public class ShiroUtils {
public static Session getSession() {
return SecurityUtils.getSubject().getSession();
}
public static Subject getSubject() {
return SecurityUtils.getSubject();
}
public static SysUserEntity getUser() {
return (SysUserEntity)SecurityUtils.getSubject().getPrincipal();
}
public static String getUserCode() {
return getUser().getUserCode();
}
public static void setSessionAttribute(Object key, Object value) {
getSession().setAttribute(key, value);
}
public static Object getSessionAttribute(Object key) {
return getSession().getAttribute(key);
}
public static boolean isLogin() {
return SecurityUtils.getSubject().getPrincipal() != null;
}
public static void logout() {
SecurityUtils.getSubject().logout();
}
public static String getKaptcha(String key) {
String kaptcha = getSessionAttribute(key).toString();
// getSession().removeAttribute(key);
return kaptcha;
}
}

@ -0,0 +1,5 @@
package com.tamguo.modules.sys.utils;
public enum Status {
SUCCESS , ERROR
}

@ -0,0 +1,128 @@
package com.tamguo.modules.sys.utils;
public class TamguoConstant {
public static final String WEBSITE_NAME = "探果网";
public static final String REDIS_PRE_KEY = "TAMGUO:";
/** 高考SubjectId*/
public static final String GAOKAO_SUBJECT_ID = "13";
/** 高考专区缓存KEY*/
public static final String GAOKAO_COURSE_AREA = "GAOKAO_COURSE_AREA";
/** 首页菜单缓存KEY*/
public static final String INDEX_MENU = "index_menu";
/** 首页菜单缓存KEY*/
public static final String ALL_INDEX_MENU = "all_index_menu";
/** 首页左侧菜单缓存KEY*/
public static final String LEFT_INDEX_MENU = "left_index_menu";
/** 首页底部菜单缓存KEY*/
public static final String FOOTER_INDEX_MENU = "footer_index_menu";
/** 北京地区ID*/
public static final String BEIJING_AREA_ID = "1";
/** 真题类型ID*/
public static final String ZHENGTI_PAPER_ID = "1";
/** 模拟类型ID */
public static final String SIMULATION_PAPER_ID = "2";
/** 首页历年真题缓存KEY*/
public static final String HISTORY_PAPER = "HistoryPaper:";
/** 首页模拟试卷缓存KEY*/
public static final String SIMULATION_PAPER = "SimulationPaper:";
/** 首页热门试卷缓存KEY*/
public static final String HOT_PAPER = "HOT_PAPER";
/** 名校试卷缓存KEY*/
public static final String ELITE_SCHOOL_PAPER = "EliteSchoolPaper:";
/** 所有广告缓存KEY*/
public static final String ALL_AD = "AllAd:";
/** 名校缓存KEY*/
public static final String ELITE_PAPER = "ElitePaper:";
/** 章节科目为空*/
public static final String CHAPTER_COURSE_EMPTY = "all";
/** 默认分页大笑*/
public static final Integer DEFAULT_PAGE_SIZE = 10;
/** 单选题*/
public static final String QUESTION_TYOE_DANXUANTI = "1";
/** 简答题*/
public static final String QUESTION_TYOE_JIANDATI = "2";
/** 书面表达*/
public static final String QUESTION_TYOE_SHUMIANBIAODA = "3";
/** 默认会员头像*/
public static final String DEFAULT_MEMBER_AVATAR = "images/avatar.png";
/** 重置密码KEY*/
public static final String RESET_PASSWORD_KEY = "ResetPasswordKey";
/** ALIYUN */
public static final String ALIYUN_ACCESS_KEY_ID = "LTAINGkheMeWtxUR";
/** ALIYUN*/
public static final String ALIYUN_ACCESS_KEY_SECRET = "ONUKuCz85kU4In07y4dvpM28mfWOGa";
/** ALIYUN*/
public static final String ALIYUN_SMTP_HOST_NAME = "smtp.aliyun.com";
/** ALIYUN*/
public static final int ALIYUN_SMTP_HOST_PORT = 465;
/** ALIYUN*/
public static final String ALIYUN_MAIL_ACCOUNT = "candy.tam@aliyun.com";
/** ALIYUN*/
public static final String ALIYUN_MAIL_PASSWORD = "tanguo520pig";
/** 邮件主题*/
public static final String ALIYUN_MAIL_SUBJECT_FINDPASSWORD = "探果网找回密码";
/** 邮箱找回密码前缀*/
public static final String ALIYUN_MAIL_FIND_PASSWORD_PREFIX = "EMAIL_FIND_PASSWORD_";
/** 短信找回密码前缀*/
public static final String ALIYUN_MOBILE_SMS_PREFIX = "MOBILE_SMS_PREKEY_";
/** 安全验证前缀*/
public static final String SECURITY_CHECK_PREFIX = "securityCheck:";
/** 默认的章节根目录*/
public static final String CHAPTER_DEFAULT_ROOT_UID = "-1";
/** 登录错误次数*/
public static final String LOGIN_FAILURE_COUNT = "loginFailureCount:";
/** 题目未审核*/
public static final String QUESTION_NOTHING_AUDIT_STATUS = "0";
/** 题目审核成功*/
public static final String QUESTION_SUCCESS_AUDIT_STATUS = "1";
/** 题目审核失败*/
public static final String QUESTION_FAILED_AUDIT_STATUS = "2";
/** 题目审核失败*/
public static final String TEACHER_ROLE_ID = "2";
/** 初始密码*/
public static final String INIT_PASSWORD = "123456";
/** 验证码常数*/
public static final String KAPTCHA_SESSION_KEY = "KAPTCHA_SESSION_KEY";
}

@ -0,0 +1,260 @@
package com.tamguo.modules.sys.utils;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.FileUploadBase.InvalidContentTypeException;
import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException;
import org.apache.commons.fileupload.util.*;
import org.apache.commons.fileupload.servlet.*;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import javax.servlet.http.HttpServletRequest;
/**
* UEditor
*
*/
public class Uploader {
// 输出文件地址
private String url = "";
// 上传文件名
private String fileName = "";
// 状态
private String state = "";
// 文件类型
private String type = "";
// 原始文件名
private String originalName = "";
// 文件大小
private long size = 0;
private HttpServletRequest request = null;
private String title = "";
// 保存路径
private String savePath = "upload";
// 文件允许格式
private String[] allowFiles = { ".rar", ".doc", ".docx", ".zip", ".pdf",".txt", ".swf", ".wmv", ".gif", ".png", ".jpg", ".jpeg", ".bmp" };
// 文件大小限制单位KB
private int maxSize = 10000;
private HashMap<String, String> errorInfo = new HashMap<String, String>();
public Uploader(HttpServletRequest request) {
this.request = request;
HashMap<String, String> tmp = this.errorInfo;
tmp.put("SUCCESS", "SUCCESS"); //默认成功
tmp.put("NOFILE", "未包含文件上传域");
tmp.put("TYPE", "不允许的文件格式");
tmp.put("SIZE", "文件大小超出限制");
tmp.put("ENTYPE", "请求类型ENTYPE错误");
tmp.put("REQUEST", "上传请求异常");
tmp.put("IO", "IO异常");
tmp.put("DIR", "目录创建失败");
tmp.put("UNKNOWN", "未知错误");
}
public void upload() throws Exception {
boolean isMultipart = ServletFileUpload.isMultipartContent(this.request);
if (!isMultipart) {
this.state = this.errorInfo.get("NOFILE");
return;
}
DiskFileItemFactory dff = new DiskFileItemFactory();
String savePath = this.getFolder(this.savePath);
dff.setRepository(new File(savePath));
try {
ServletFileUpload sfu = new ServletFileUpload(dff);
sfu.setSizeMax(this.maxSize * 1024);
sfu.setHeaderEncoding("utf-8");
FileItemIterator fii = sfu.getItemIterator(this.request);
while (fii.hasNext()) {
FileItemStream fis = fii.next();
if (!fis.isFormField()) {
this.originalName = fis.getName().substring(fis.getName().lastIndexOf(System.getProperty("file.separator")) + 1);
if (!this.checkFileType(this.originalName)) {
this.state = this.errorInfo.get("TYPE");
continue;
}
this.fileName = this.getName(this.originalName);
this.type = this.getFileExt(this.fileName);
this.url = savePath + "/" + this.fileName;
BufferedInputStream in = new BufferedInputStream(fis.openStream());
File file = new File(this.getPhysicalPath(this.url));
FileOutputStream out = new FileOutputStream( file );
BufferedOutputStream output = new BufferedOutputStream(out);
Streams.copy(in, output, true);
this.state=this.errorInfo.get("SUCCESS");
this.size = file.length();
//UE中只会处理单张上传完成后即退出
break;
} else {
String fname = fis.getFieldName();
//只处理title其余表单请自行处理
if(!fname.equals("pictitle")){
continue;
}
BufferedInputStream in = new BufferedInputStream(fis.openStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuffer result = new StringBuffer();
while (reader.ready()) {
result.append((char)reader.read());
}
this.title = new String(result.toString().getBytes(),"utf-8");
reader.close();
}
}
} catch (SizeLimitExceededException e) {
this.state = this.errorInfo.get("SIZE");
} catch (InvalidContentTypeException e) {
this.state = this.errorInfo.get("ENTYPE");
} catch (FileUploadException e) {
this.state = this.errorInfo.get("REQUEST");
} catch (Exception e) {
this.state = this.errorInfo.get("UNKNOWN");
}
}
/**
* base64
* @param fieldName
*/
public void uploadBase64(String fieldName){
String savePath = this.getFolder(this.savePath);
String base64Data = this.request.getParameter(fieldName);
this.fileName = this.getName("test.png");
this.url = savePath + "/" + this.fileName;
try {
File outFile = new File(this.getPhysicalPath(this.url));
OutputStream ro = new FileOutputStream(outFile);
byte[] b = Base64.decodeBase64(base64Data);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {
b[i] += 256;
}
}
ro.write(b);
ro.flush();
ro.close();
this.state=this.errorInfo.get("SUCCESS");
} catch (Exception e) {
this.state = this.errorInfo.get("IO");
}
}
/**
*
*
* @param fileName
* @return
*/
private boolean checkFileType(String fileName) {
Iterator<String> type = Arrays.asList(this.allowFiles).iterator();
while (type.hasNext()) {
String ext = type.next();
if (fileName.toLowerCase().endsWith(ext)) {
return true;
}
}
return false;
}
/**
*
*
* @return string
*/
private String getFileExt(String fileName) {
return fileName.substring(fileName.lastIndexOf("."));
}
/**
*
* @return
*/
private String getName(String fileName) {
Random random = new Random();
return this.fileName = "" + random.nextInt(10000)
+ System.currentTimeMillis() + this.getFileExt(fileName);
}
/**
*
* @param path
* @return
*/
private String getFolder(String path) {
SimpleDateFormat formater = new SimpleDateFormat("yyyyMMdd");
path += "/" + formater.format(new Date());
File dir = new File(this.getPhysicalPath(path));
if (!dir.exists()) {
try {
dir.mkdirs();
} catch (Exception e) {
this.state = this.errorInfo.get("DIR");
return "";
}
}
return path;
}
/**
*
*
* @param path
* @return
*/
private String getPhysicalPath(String path) {
String servletPath = this.request.getServletPath();
String realPath = this.request.getSession().getServletContext()
.getRealPath(servletPath);
return new File(realPath).getParent() +"/" +path;
}
public void setSavePath(String savePath) {
this.savePath = savePath;
}
public void setAllowFiles(String[] allowFiles) {
this.allowFiles = allowFiles;
}
public void setMaxSize(int size) {
this.maxSize = size;
}
public long getSize() {
return this.size;
}
public String getUrl() {
return this.url;
}
public String getFileName() {
return this.fileName;
}
public String getState() {
return this.state;
}
public String getTitle() {
return this.title;
}
public String getType() {
return this.type;
}
public String getOriginalName() {
return this.originalName;
}
}

@ -0,0 +1,58 @@
package com.tamguo.modules.sys.utils;
import java.util.ArrayList;
public class UploaderMessage {
private Status status;
private String statusMsg = "";
private ArrayList<Integer> errorKys;
private String error = "";
private String filePath = "";
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public String getStatusMsg() {
return statusMsg;
}
public void setStatusMsg(String statusMsg) {
this.statusMsg = statusMsg;
}
public ArrayList<Integer> getErrorKys() {
return errorKys;
}
public void setErrorKys(ArrayList<Integer> errorKys) {
this.errorKys = errorKys;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
}

@ -0,0 +1,53 @@
package com.tamguo.modules.sys.utils;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
public class XMLConfiguration {
private Document document = null;
public boolean readConfigFile(String configFilename) {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
document = db.parse(configFilename);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
if (document == null) {
return false;
}
return true;
}
public boolean readConfigFile(InputStream stream) {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
document = db.parse(stream);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
if (document == null) {
return false;
}
return true;
}
public Document getDocument() {
return document;
}
protected void setDocument(Document document) {
this.document = document;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save