| @@ -0,0 +1,78 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <groupId>com.iformall</groupId> | |||||
| <artifactId>bjair-mybatis</artifactId> | |||||
| <version>1.0</version> | |||||
| <dependencies> | |||||
| <dependency> | |||||
| <groupId>com.github.jsqlparser</groupId> | |||||
| <artifactId>jsqlparser</artifactId> | |||||
| <version>2.0</version> | |||||
| <scope>compile</scope> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.baomidou</groupId> | |||||
| <artifactId>mybatis-plus-core</artifactId> | |||||
| <version>3.2.0</version> | |||||
| </dependency> | |||||
| <!--测试期间依赖--> | |||||
| <dependency> | |||||
| <scope>test</scope> | |||||
| <groupId>junit</groupId> | |||||
| <artifactId>junit</artifactId> | |||||
| <version>4.12</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>mysql</groupId> | |||||
| <artifactId>mysql-connector-java</artifactId> | |||||
| <version>8.0.19</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.alibaba</groupId> | |||||
| <artifactId>druid</artifactId> | |||||
| <version>1.1.22</version> | |||||
| </dependency> | |||||
| </dependencies> | |||||
| <build> | |||||
| <plugins> | |||||
| <plugin> | |||||
| <groupId>org.apache.maven.plugins</groupId> | |||||
| <artifactId>maven-compiler-plugin</artifactId> | |||||
| <version>2.3.2</version> | |||||
| <configuration> | |||||
| <source>1.8</source> | |||||
| <target>1.8</target> | |||||
| <encoding>utf-8</encoding> | |||||
| </configuration> | |||||
| </plugin> | |||||
| <plugin> | |||||
| <artifactId>maven-source-plugin</artifactId> | |||||
| <version>2.4</version> | |||||
| <executions> | |||||
| <execution> | |||||
| <phase>package</phase> | |||||
| <goals> | |||||
| <goal>jar-no-fork</goal> | |||||
| </goals> | |||||
| </execution> | |||||
| </executions> | |||||
| </plugin> | |||||
| <plugin> | |||||
| <artifactId>maven-surefire-plugin</artifactId> | |||||
| <version>2.9</version> | |||||
| <configuration> | |||||
| <!--跳过单元测试--> | |||||
| <skip>false</skip> | |||||
| <!--单元测试乱码--> | |||||
| <forkMode>once</forkMode> | |||||
| <argLine>-Dfile.encoding=UTF-8</argLine> | |||||
| </configuration> | |||||
| </plugin> | |||||
| </plugins> | |||||
| </build> | |||||
| </project> | |||||
| @@ -0,0 +1,69 @@ | |||||
| package com.iformall.plugin; | |||||
| import org.apache.ibatis.executor.statement.StatementHandler; | |||||
| import org.apache.ibatis.plugin.*; | |||||
| import org.apache.ibatis.session.ResultHandler; | |||||
| import com.iformall.plugin.entity.ChainValue; | |||||
| import java.sql.Connection; | |||||
| import java.util.ArrayList; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | |||||
| *共享数据库的多租户系统实现 | |||||
| * Created by Stormeye on 2018/10/22. | |||||
| */ | |||||
| @Intercepts({ | |||||
| //@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}), | |||||
| //@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}) | |||||
| @Signature( method = "prepare", type = StatementHandler.class,args = {Connection.class, Integer.class}), | |||||
| @Signature(method = "query", type = StatementHandler.class, args = {java.sql.Statement.class, ResultHandler.class}) | |||||
| }) | |||||
| public class MyBatisItercepters implements Interceptor { | |||||
| private List<MyBatisPlus> plugins; | |||||
| public MyBatisItercepters(){ | |||||
| } | |||||
| public void setPlugins(List<MyBatisPlus> plugins) { | |||||
| this.plugins = plugins; | |||||
| } | |||||
| public Object intercept(Invocation invocation) throws Throwable { | |||||
| if (null != plugins && plugins.size() > 0 ) { | |||||
| // 能从cookie或者session获取到tenantId | |||||
| Map<String,ChainValue> chainValues = new HashMap<String,ChainValue>(); | |||||
| for (int i = 0 ; i < plugins.size() ; i++) { | |||||
| MyBatisPlus plug = plugins.get(i); | |||||
| invokeIntercept(plug, invocation, chainValues); | |||||
| } | |||||
| } | |||||
| return invocation.proceed(); | |||||
| } | |||||
| private void invokeIntercept(MyBatisPlus plug,Invocation invocation,Map<String,ChainValue> chainMap) throws Throwable { | |||||
| Map<String,ChainValue> resultMap = plug.intercept(invocation, chainMap); | |||||
| if (null != resultMap) { | |||||
| chainMap.putAll(resultMap); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 生成代理对象 | |||||
| * | |||||
| * @param target | |||||
| * @return | |||||
| */ | |||||
| @Override | |||||
| public Object plugin(Object target) { | |||||
| if (target instanceof StatementHandler) { | |||||
| return Plugin.wrap(target, this); | |||||
| } else { | |||||
| return target; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,18 @@ | |||||
| package com.iformall.plugin; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import org.apache.ibatis.plugin.Invocation; | |||||
| import com.iformall.plugin.entity.ChainValue; | |||||
| public interface MyBatisPlus { | |||||
| /** | |||||
| * @param invocation | |||||
| * @return Map<coloumn,value> | |||||
| * @throws Throwable | |||||
| */ | |||||
| public Map<String,ChainValue> intercept(Invocation invocation,Map<String,ChainValue> chainMap) throws Throwable; | |||||
| } | |||||
| @@ -0,0 +1,662 @@ | |||||
| package com.iformall.plugin.autoTenantId; | |||||
| import net.sf.jsqlparser.JSQLParserException; | |||||
| import net.sf.jsqlparser.expression.Expression; | |||||
| import net.sf.jsqlparser.expression.Parenthesis; | |||||
| import net.sf.jsqlparser.expression.StringValue; | |||||
| import net.sf.jsqlparser.expression.operators.conditional.AndExpression; | |||||
| import net.sf.jsqlparser.expression.operators.conditional.OrExpression; | |||||
| import net.sf.jsqlparser.expression.operators.relational.EqualsTo; | |||||
| import net.sf.jsqlparser.expression.operators.relational.ExpressionList; | |||||
| import net.sf.jsqlparser.expression.operators.relational.ItemsList; | |||||
| import net.sf.jsqlparser.expression.operators.relational.MultiExpressionList; | |||||
| import net.sf.jsqlparser.parser.CCJSqlParserUtil; | |||||
| import net.sf.jsqlparser.schema.Column; | |||||
| import net.sf.jsqlparser.schema.Table; | |||||
| import net.sf.jsqlparser.statement.Statement; | |||||
| import net.sf.jsqlparser.statement.create.table.ColDataType; | |||||
| import net.sf.jsqlparser.statement.create.table.ColumnDefinition; | |||||
| import net.sf.jsqlparser.statement.create.table.CreateTable; | |||||
| import net.sf.jsqlparser.statement.delete.Delete; | |||||
| import net.sf.jsqlparser.statement.insert.Insert; | |||||
| import net.sf.jsqlparser.statement.select.*; | |||||
| import net.sf.jsqlparser.statement.update.Update; | |||||
| import net.sf.jsqlparser.util.TablesNamesFinder; | |||||
| import org.apache.ibatis.executor.statement.StatementHandler; | |||||
| import org.apache.ibatis.mapping.BoundSql; | |||||
| import org.apache.ibatis.mapping.MappedStatement; | |||||
| import org.apache.ibatis.mapping.SqlCommandType; | |||||
| import org.apache.ibatis.plugin.*; | |||||
| import org.apache.ibatis.reflection.MetaObject; | |||||
| import org.apache.ibatis.reflection.SystemMetaObject; | |||||
| import org.apache.ibatis.session.Configuration; | |||||
| import org.apache.ibatis.session.ResultHandler; | |||||
| import com.iformall.plugin.MyBatisPlus; | |||||
| import com.iformall.plugin.entity.ChainValue; | |||||
| import java.sql.Connection; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Arrays; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import java.util.Properties; | |||||
| /** | |||||
| *共享数据库的多租户系统实现 | |||||
| * Created by Stormeye on 2018/10/22. | |||||
| */ | |||||
| public class MultiTenancy implements MyBatisPlus { | |||||
| //获取tenantId的接口 | |||||
| private TenantInfo tenantInfo; | |||||
| private String tenantIdColumn = "tenant_id"; | |||||
| private String parentTenantIdColumn = "parent_tenant_id"; | |||||
| private String dialect = "mysql"; | |||||
| public TenantInfo getTenantInfo() { | |||||
| return tenantInfo; | |||||
| } | |||||
| public void setTenantInfo(TenantInfo tenantInfo) { | |||||
| this.tenantInfo = tenantInfo; | |||||
| } | |||||
| public String getTenantIdColumn() { | |||||
| return tenantIdColumn; | |||||
| } | |||||
| public void setTenantIdColumn(String tenantIdColumn) { | |||||
| this.tenantIdColumn = tenantIdColumn; | |||||
| } | |||||
| public String getParentTenantIdColumn() { | |||||
| return parentTenantIdColumn; | |||||
| } | |||||
| public void setParentTenantIdColumn(String parentTenantIdColumn) { | |||||
| this.parentTenantIdColumn = parentTenantIdColumn; | |||||
| } | |||||
| public String getDialect() { | |||||
| return dialect; | |||||
| } | |||||
| public void setDialect(String dialect) { | |||||
| this.dialect = dialect; | |||||
| } | |||||
| //属性参数信息 | |||||
| private Properties properties; | |||||
| public MultiTenancy(){ | |||||
| } | |||||
| @Override | |||||
| public Map<String,ChainValue> intercept(Invocation invocation,Map<String,ChainValue> chainMap) throws Throwable { | |||||
| if (getTenantInfo().getTenantId() != null || getTenantInfo().getParentTenantId() != null) { | |||||
| // 能从cookie或者session获取到tenantId | |||||
| //Map<String,Object> resultMap = new HashMap<String,Object>(); | |||||
| //resultMap.put(tenantIdColumn, getTenantInfo().getTenantId()); | |||||
| //resultMap.put(parentTenantIdColumn, getTenantInfo().getParentTenantId()); | |||||
| return mod(invocation); | |||||
| } | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * 更改MappedStatement为新的 | |||||
| * @param invocation | |||||
| * @throws Throwable | |||||
| */ | |||||
| public Map<String,ChainValue> mod(Invocation invocation) throws Throwable { | |||||
| StatementHandler statementHandler = (StatementHandler) invocation.getTarget(); | |||||
| MetaObject metaStatementHandler = SystemMetaObject.forObject(statementHandler); | |||||
| Configuration configuration = (Configuration) metaStatementHandler.getValue("delegate.configuration"); | |||||
| MappedStatement ms = (MappedStatement) metaStatementHandler.getValue("delegate.mappedStatement"); | |||||
| if (getTenantInfo().doMappedStatementFIlter(ms)) | |||||
| return null; | |||||
| SqlCommandType type = ms.getSqlCommandType(); | |||||
| BoundSql boundSql = statementHandler.getBoundSql(); | |||||
| String newSQL = addWhere(boundSql.getSql()); | |||||
| if (newSQL != null) { | |||||
| metaStatementHandler.setValue("delegate.boundSql.sql", newSQL); | |||||
| } | |||||
| Map<String,ChainValue> newchainMap = new HashMap<String,ChainValue>(); | |||||
| ChainValue tenantIdChain = new ChainValue(); | |||||
| tenantIdChain.setColumn(tenantIdColumn); | |||||
| tenantIdChain.setValue(getTenantInfo().getTenantId()); | |||||
| tenantIdChain.setIgnoreTables(getTenantInfo().filterTables()); | |||||
| newchainMap.put(tenantIdColumn,tenantIdChain); | |||||
| ChainValue parentTenantIdChain = new ChainValue(); | |||||
| parentTenantIdChain.setColumn(parentTenantIdColumn); | |||||
| parentTenantIdChain.setValue(getTenantInfo().getParentTenantId()); | |||||
| parentTenantIdChain.setIgnoreTables(getTenantInfo().filterSubTables()); | |||||
| newchainMap.put(parentTenantIdColumn,parentTenantIdChain); | |||||
| return newchainMap; | |||||
| } | |||||
| /** | |||||
| * 添加租户id条件 | |||||
| * @param sql | |||||
| * @return | |||||
| * @throws JSQLParserException | |||||
| */ | |||||
| private String addWhere(String sql) throws Exception { | |||||
| Statement stmt = CCJSqlParserUtil.parse(sql); | |||||
| if (stmt instanceof Insert) { | |||||
| return processInsert((Insert) stmt); | |||||
| } | |||||
| if (stmt instanceof Delete) { | |||||
| return processDelete((Delete) stmt); | |||||
| } | |||||
| if (stmt instanceof Update) { | |||||
| return processUpdate(sql, stmt); | |||||
| } | |||||
| if (stmt instanceof Select) { | |||||
| return processSelect(stmt); | |||||
| } | |||||
| if (stmt instanceof CreateTable) { | |||||
| return processCreateTable((CreateTable) stmt); | |||||
| } | |||||
| throw new RuntimeException("非法sql语句,请检查"+sql); | |||||
| } | |||||
| private String processCreateTable(CreateTable stmt) { | |||||
| CreateTable createTable = stmt; | |||||
| ColDataType colDataType = new ColDataType(); | |||||
| colDataType.setDataType("varchar(10)"); | |||||
| // add tenant_id | |||||
| ColumnDefinition columnDefinition = new ColumnDefinition(); | |||||
| columnDefinition.setColumnName(getTenantIdColumn()); | |||||
| columnDefinition.setColDataType(colDataType); | |||||
| createTable.getColumnDefinitions().add(columnDefinition); | |||||
| // add parent_tenant_id | |||||
| ColumnDefinition subColumnDefinition = new ColumnDefinition(); | |||||
| subColumnDefinition.setColumnName(getParentTenantIdColumn()); | |||||
| subColumnDefinition.setColDataType(colDataType); | |||||
| createTable.getColumnDefinitions().add(subColumnDefinition); | |||||
| return createTable.toString(); | |||||
| } | |||||
| private String processSelect(Statement stmt) throws Exception { | |||||
| //获得Select对象 | |||||
| Select select = (Select) stmt; | |||||
| PlainSelect ps = (PlainSelect) select.getSelectBody(); | |||||
| TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); | |||||
| List<String> tableList = tablesNamesFinder.getTableList(select); | |||||
| if (tableList.size() == 0) { | |||||
| return select.toString(); | |||||
| } | |||||
| for (String table : tableList) { | |||||
| if (getTenantInfo().doTableFilter(table)) | |||||
| continue; | |||||
| if (ps.getWhere() != null) { | |||||
| AndExpression where = addAndExpression(stmt, table, ps.getWhere()); | |||||
| // form 和 join 中加载的表 | |||||
| if (where != null) { | |||||
| ps.setWhere(where); | |||||
| } else { | |||||
| //子查询中的表 | |||||
| findSubSelect(stmt, ps.getWhere()); | |||||
| } | |||||
| } else { | |||||
| String aliasName = getTableAlias(stmt, table); | |||||
| EqualsTo equalsTo = addEqualsTo(stmt, table, aliasName); | |||||
| ps.setWhere(equalsTo); | |||||
| } | |||||
| } | |||||
| return select.toString(); | |||||
| } | |||||
| private String processUpdate(String sql, Statement stmt) throws Exception { | |||||
| //获得Update对象 | |||||
| Update updateStatement = (Update) stmt; | |||||
| TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); | |||||
| List<String> tableList = tablesNamesFinder.getTableList(stmt); | |||||
| if (tableList.size() == 0) { | |||||
| return updateStatement.toString(); | |||||
| } | |||||
| //获得where条件表达式 | |||||
| Expression where = updateStatement.getWhere(); | |||||
| for (String table: tableList) { | |||||
| if (getTenantInfo().doTableFilter(table)) | |||||
| continue; | |||||
| if (where != null) { | |||||
| AndExpression andE = addAndExpression(stmt, table, updateStatement.getWhere()); | |||||
| if (andE != null) { | |||||
| updateStatement.setWhere(andE); | |||||
| } | |||||
| } else { | |||||
| throw new Exception("update语句不能没有where条件:" + sql + Arrays.toString(Thread.currentThread().getStackTrace())); | |||||
| } | |||||
| } | |||||
| return updateStatement.toString(); | |||||
| } | |||||
| private String processDelete(Delete deleteStatement) { | |||||
| //获得Delete对象 | |||||
| if (getTenantInfo().doTableFilter(deleteStatement.getTable().getName())) | |||||
| return deleteStatement.toString(); | |||||
| Expression where = deleteStatement.getWhere(); | |||||
| EqualsTo equalsTo = new EqualsTo(); | |||||
| if (getTenantInfo().getTenantId() != null) { | |||||
| equalsTo.setLeftExpression(new Column(getTenantIdColumn())); | |||||
| equalsTo.setRightExpression(new StringValue(getTenantInfo().getTenantId())); | |||||
| } | |||||
| if (!getTenantInfo().doTableFilterSub(deleteStatement.getTable().getName())) { | |||||
| if (getTenantInfo().getParentTenantId() != null) { | |||||
| equalsTo.setLeftExpression(new Column(getParentTenantIdColumn())); | |||||
| equalsTo.setRightExpression(new StringValue(getTenantInfo().getParentTenantId())); | |||||
| } | |||||
| } | |||||
| if (null != where) { | |||||
| if (where instanceof OrExpression) { | |||||
| AndExpression andExpression = new AndExpression(equalsTo, new Parenthesis(where)); | |||||
| deleteStatement.setWhere(andExpression); | |||||
| } else { | |||||
| AndExpression andExpression = new AndExpression(equalsTo, where); | |||||
| deleteStatement.setWhere(andExpression); | |||||
| } | |||||
| } | |||||
| return deleteStatement.toString(); | |||||
| } | |||||
| /** | |||||
| * 插入处理 | |||||
| * @param insertStatement | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| private String processInsert(Insert insertStatement) throws Exception { | |||||
| // 非tenant表,直接返回 | |||||
| if (getTenantInfo().doTableFilter(insertStatement.getTable().getName())) { | |||||
| return insertStatement.toString(); | |||||
| } | |||||
| boolean bExist = insertStatement.getColumns().stream().anyMatch(col -> col.getColumnName().equalsIgnoreCase(getTenantIdColumn())); | |||||
| if (!bExist) { | |||||
| if (getTenantInfo().getTenantId() != null) { | |||||
| insertStatement.getColumns().add(new Column(getTenantIdColumn())); | |||||
| } | |||||
| if (!getTenantInfo().doTableFilterSub(insertStatement.getTable().getName())) { | |||||
| if (getTenantInfo().getParentTenantId() != null) { | |||||
| insertStatement.getColumns().add(new Column(getParentTenantIdColumn())); | |||||
| } | |||||
| } | |||||
| ItemsList itemsList = insertStatement.getItemsList(); | |||||
| if (itemsList instanceof MultiExpressionList){ | |||||
| ((MultiExpressionList) itemsList).getExprList().forEach(el -> { | |||||
| el.getExpressions().add(new StringValue(getTenantInfo().getTenantId())); | |||||
| if (!getTenantInfo().doTableFilterSub(insertStatement.getTable().getName())) { | |||||
| if (getTenantInfo().getParentTenantId() != null) { | |||||
| el.getExpressions().add(new StringValue(getTenantInfo().getParentTenantId())); | |||||
| } | |||||
| } | |||||
| }); | |||||
| }else { | |||||
| ((ExpressionList) itemsList).getExpressions().add(new StringValue(getTenantInfo().getTenantId())); | |||||
| if (!getTenantInfo().doTableFilterSub(insertStatement.getTable().getName())) { | |||||
| if (getTenantInfo().getParentTenantId() != null) { | |||||
| ((ExpressionList) itemsList).getExpressions().add(new StringValue(getTenantInfo().getParentTenantId())); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| return insertStatement.toString(); | |||||
| } | |||||
| /** | |||||
| * 获取配置信息 | |||||
| * {dialect=mysql, tenantInfo=org.xue.test.TenantInfoImpl, tenantIdColumn=tenant_id, parentTenantIdColumn=parent_tenant_id} | |||||
| * @param properties | |||||
| */ | |||||
| public void setProperties(Properties properties) { | |||||
| this.properties=properties; | |||||
| try { | |||||
| Class onwClass=Class.forName(this.properties.getProperty("tenantInfo")); | |||||
| this.tenantInfo = (TenantInfo)onwClass.newInstance(); | |||||
| this.tenantIdColumn = this.properties.getProperty("tenantIdColumn"); | |||||
| this.parentTenantIdColumn = this.properties.getProperty("parentTenantIdColumn"); | |||||
| this.dialect = this.properties.getProperty("dialect"); | |||||
| } catch (ClassNotFoundException e) { | |||||
| throw new RuntimeException(e); | |||||
| } catch (InstantiationException e) { | |||||
| throw new RuntimeException(e); | |||||
| } catch (IllegalAccessException e) { | |||||
| throw new RuntimeException(e); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 多条件情况下,使用AndExpression给where条件加上tenantid条件 | |||||
| * | |||||
| * @param table | |||||
| * @param where | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| public AndExpression addAndExpression(Statement stmt, String table, Expression where) throws Exception { | |||||
| String aliasName = getTableAlias(stmt, table); | |||||
| EqualsTo equalsTo = addEqualsTo(stmt, table, aliasName); | |||||
| if (equalsTo != null) { | |||||
| AndExpression right = new AndExpression(equalsTo, where); | |||||
| if (!getTenantInfo().doTableFilterSub(table)) { | |||||
| EqualsTo equalsToSub = addEqualsToForParentTenantId(stmt, table, aliasName); | |||||
| if (equalsToSub != null) { | |||||
| return new AndExpression(equalsToSub, right); | |||||
| } else { | |||||
| return right; | |||||
| } | |||||
| } else { | |||||
| return right; | |||||
| } | |||||
| } else { | |||||
| return null; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 创建一个 EqualsTo相同判断 条件 | |||||
| * | |||||
| * @param stmt 查询对象 | |||||
| * @param table 表名 | |||||
| * @return “A=B” 单个where条件表达式 | |||||
| * @throws Exception | |||||
| */ | |||||
| public EqualsTo addEqualsTo(Statement stmt, String table, String aliasName) throws Exception { | |||||
| if (aliasName != null) { | |||||
| if (getTenantInfo().getTenantId() != null) { | |||||
| EqualsTo equalsTo = new EqualsTo(); | |||||
| equalsTo.setLeftExpression(new Column(aliasName + '.' + getTenantIdColumn())); | |||||
| equalsTo.setRightExpression(new StringValue(getTenantInfo().getTenantId())); | |||||
| return equalsTo; | |||||
| } | |||||
| return null; | |||||
| } else { | |||||
| return null; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 创建一个 EqualsTo相同判断 条件 | |||||
| * | |||||
| * @param stmt 查询对象 | |||||
| * @param table 表名 | |||||
| * @return “A=B” 单个where条件表达式 | |||||
| * @throws Exception | |||||
| */ | |||||
| public EqualsTo addEqualsToForParentTenantId(Statement stmt, String table, String aliasName) throws Exception { | |||||
| if (aliasName != null) { | |||||
| if (getTenantInfo().getParentTenantId() != null) { | |||||
| EqualsTo equalsTo = new EqualsTo(); | |||||
| equalsTo.setLeftExpression(new Column(aliasName + '.' + getParentTenantIdColumn())); | |||||
| equalsTo.setRightExpression(new StringValue(getTenantInfo().getParentTenantId())); | |||||
| return equalsTo; | |||||
| } else { | |||||
| return null; | |||||
| } | |||||
| } else { | |||||
| return null; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 获取sql送指定表的别名你,没有别名则返回原表名 如果表名不存在返回null | |||||
| * 【仅查询from和join 不含 IN 子查询中的表 】 | |||||
| * | |||||
| * @param stmt | |||||
| * @param tableName | |||||
| * @return | |||||
| */ | |||||
| public String getTableAlias(Statement stmt, String tableName) { | |||||
| String alias = null; | |||||
| // 插入不做处理 | |||||
| if (stmt instanceof Insert) { | |||||
| return tableName; | |||||
| } | |||||
| if (stmt instanceof Delete) { | |||||
| //获得Delete对象 | |||||
| Delete deleteStatement = (Delete) stmt; | |||||
| if ((deleteStatement.getTable()).getName().equalsIgnoreCase(tableName)) { | |||||
| alias = deleteStatement.getTable().getAlias() != null ? deleteStatement.getTable().getAlias().getName() : tableName; | |||||
| } | |||||
| } | |||||
| if (stmt instanceof Update) { | |||||
| //获得Update对象 | |||||
| Update updateStatement = (Update) stmt; | |||||
| if ((updateStatement.getTables().get(0)).getName().equalsIgnoreCase(tableName)) { | |||||
| alias = updateStatement.getTables().get(0).getAlias() != null ? updateStatement.getTables().get(0).getAlias().getName() : tableName; | |||||
| } | |||||
| } | |||||
| if (stmt instanceof Select) { | |||||
| Select select = (Select) stmt; | |||||
| PlainSelect ps = (PlainSelect) select.getSelectBody(); | |||||
| FromItem item = ps.getFromItem(); | |||||
| // 判断主表的别名 | |||||
| if (item instanceof Table) { | |||||
| if (((Table) item).getName().equalsIgnoreCase(tableName)) { | |||||
| alias = item.getAlias() != null ? item.getAlias().getName() : tableName; | |||||
| } | |||||
| } else { | |||||
| } | |||||
| } | |||||
| return alias; | |||||
| } | |||||
| /** | |||||
| * 针对子查询中的表别名查询 | |||||
| * | |||||
| * @param subSelect | |||||
| * @param tableName | |||||
| * @return | |||||
| */ | |||||
| public String getTableAlias(SubSelect subSelect, String tableName) { | |||||
| PlainSelect ps = (PlainSelect) subSelect.getSelectBody(); | |||||
| // 判断主表的别名 | |||||
| String alias = null; | |||||
| FromItem item = ps.getFromItem(); | |||||
| if (item instanceof Table) { | |||||
| if (((Table) item).getName().equalsIgnoreCase(tableName)){ | |||||
| if (item.getAlias() != null) { | |||||
| alias = item.getAlias().getName(); | |||||
| } else { | |||||
| alias = tableName; | |||||
| } | |||||
| } | |||||
| } | |||||
| return alias; | |||||
| } | |||||
| /** | |||||
| * 递归处理 子查询中的tenantid-where | |||||
| * | |||||
| * @param stmt sql查询对象 | |||||
| * @param where 当前sql的where条件 where为AndExpression或OrExpression的实例,解析其中的rightExpression,然后检查leftExpression是否为空, | |||||
| * 不为空则是AndExpression或OrExpression,再次解析其中的rightExpression | |||||
| * 注意tenantid-where是加在子查询上的 | |||||
| */ | |||||
| void findSubSelect(Statement stmt, Expression where) throws Exception { | |||||
| // and 表达式 | |||||
| if (where instanceof AndExpression) { | |||||
| AndExpression andExpression = (AndExpression) where; | |||||
| if (andExpression.getRightExpression() instanceof SubSelect) { | |||||
| SubSelect subSelect = (SubSelect) andExpression.getRightExpression(); | |||||
| doSelect(stmt, subSelect); | |||||
| } | |||||
| if (andExpression.getLeftExpression() != null) { | |||||
| findSubSelect(stmt, andExpression.getLeftExpression()); | |||||
| } | |||||
| } else if (where instanceof OrExpression) { | |||||
| // or表达式 | |||||
| OrExpression orExpression = (OrExpression) where; | |||||
| if (orExpression.getRightExpression() instanceof SubSelect) { | |||||
| SubSelect subSelect = (SubSelect) orExpression.getRightExpression(); | |||||
| doSelect(stmt, subSelect); | |||||
| } | |||||
| if (orExpression.getLeftExpression() != null) { | |||||
| findSubSelect(stmt, orExpression.getLeftExpression()); | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 处理select 和 subSelect | |||||
| * | |||||
| * @param stmt 查询对象 | |||||
| * @param select | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| Expression doSelect(Statement stmt, Expression select) throws Exception { | |||||
| PlainSelect ps = null; | |||||
| boolean hasSubSelect = false; | |||||
| if (select instanceof SubSelect) { | |||||
| ps = (PlainSelect) ((SubSelect) select).getSelectBody(); | |||||
| } | |||||
| if (select instanceof Select) { | |||||
| ps = (PlainSelect) ((Select) select).getSelectBody(); | |||||
| } | |||||
| TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); | |||||
| List<String> tableList = tablesNamesFinder.getTableList(select); | |||||
| if (tableList.size() == 0) { | |||||
| return select; | |||||
| } | |||||
| for (String table : tableList) { | |||||
| // sql 包含 where 条件的情况 使用 addAndExpression 连接 已有的条件和新条件 | |||||
| if (ps.getWhere() == null) { | |||||
| AndExpression where = addAndExpression(stmt, table, ps.getWhere()); | |||||
| // form 和 join 中加载的表 | |||||
| if (where != null) { | |||||
| ps.setWhere(where); | |||||
| } else { | |||||
| // 如果在Statement中不存在这个表名,则存在于子查询中 | |||||
| hasSubSelect = true; | |||||
| } | |||||
| } else { | |||||
| // sql 不含 where条件 新建一个EqualsTo设置为where条件 | |||||
| String aliasName = getTableAlias(stmt, table); | |||||
| EqualsTo equalsTo = addEqualsTo(stmt, table, aliasName); | |||||
| ps.setWhere(equalsTo); | |||||
| } | |||||
| } | |||||
| if (hasSubSelect) { | |||||
| //子查询中的表 | |||||
| findSubSelect(stmt, ps.getWhere()); | |||||
| } | |||||
| return select; | |||||
| } | |||||
| private void processSelectBody(SelectBody selectBody) { | |||||
| if (selectBody instanceof PlainSelect) { | |||||
| processPlainSelect((PlainSelect) selectBody); | |||||
| } else if (selectBody instanceof WithItem) { | |||||
| WithItem withItem = (WithItem) selectBody; | |||||
| if (withItem.getSelectBody() != null) { | |||||
| processSelectBody(withItem.getSelectBody()); | |||||
| } | |||||
| } else { | |||||
| SetOperationList operationList = (SetOperationList) selectBody; | |||||
| if (operationList.getOperations() != null && operationList.getSelects().size() > 0) { | |||||
| List<SelectBody> plainSelects = operationList.getSelects(); | |||||
| for (SelectBody sub: plainSelects) { | |||||
| processSelectBody(sub); | |||||
| } | |||||
| } | |||||
| if (!orderByHashParameters(operationList.getOrderByElements())) { | |||||
| operationList.setOrderByElements(null); | |||||
| } | |||||
| } | |||||
| } | |||||
| private void processPlainSelect(PlainSelect plainSelect) { | |||||
| if (!orderByHashParameters(plainSelect.getOrderByElements())) { | |||||
| plainSelect.setOrderByElements(null); | |||||
| } | |||||
| if (plainSelect.getFromItem() != null) { | |||||
| processFromItem(plainSelect.getFromItem()); | |||||
| } | |||||
| if (plainSelect.getJoins() != null && plainSelect.getJoins().size() > 0) { | |||||
| List<Join> joins = plainSelect.getJoins(); | |||||
| for (Join join : joins) { | |||||
| if (join.getRightItem() != null) { | |||||
| processFromItem(join.getRightItem()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| public void processFromItem(FromItem fromItem) { | |||||
| if (fromItem instanceof SubJoin) { | |||||
| SubJoin subJoin = (SubJoin) fromItem; | |||||
| if (subJoin.getJoinList() != null) { | |||||
| for(Join tjoin: subJoin.getJoinList()) { | |||||
| if (tjoin.getRightItem() != null) { | |||||
| processFromItem(tjoin.getRightItem()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } else if (fromItem instanceof SubSelect) { | |||||
| SubSelect subSelect = (SubSelect) fromItem; | |||||
| if (subSelect.getSelectBody() != null) { | |||||
| processSelectBody(subSelect.getSelectBody()); | |||||
| } | |||||
| } else if (fromItem instanceof ValuesList) { | |||||
| } else if (fromItem instanceof LateralSubSelect) { | |||||
| LateralSubSelect lateralSubSelect = (LateralSubSelect) fromItem; | |||||
| if (lateralSubSelect.getSubSelect() != null) { | |||||
| SubSelect subSelect = (SubSelect) (lateralSubSelect.getSubSelect()); | |||||
| if (subSelect.getSelectBody() != null) { | |||||
| processSelectBody(subSelect.getSelectBody()); | |||||
| } | |||||
| } | |||||
| } | |||||
| //Table时不用处理 | |||||
| } | |||||
| public boolean orderByHashParameters(List<OrderByElement> orderByElements) { | |||||
| if (orderByElements == null) { | |||||
| return false; | |||||
| } | |||||
| for (OrderByElement orderByElement : orderByElements) { | |||||
| if (orderByElement.toString().toUpperCase().contains("?")) { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,26 @@ | |||||
| package com.iformall.plugin.autoTenantId; | |||||
| import java.util.List; | |||||
| import org.apache.ibatis.mapping.MappedStatement; | |||||
| /** | |||||
| * 需要实现该接口用于获取租户id | |||||
| * Created by Stormeye on 2018/10/22. | |||||
| */ | |||||
| public interface TenantInfo { | |||||
| String getTenantId(); | |||||
| String getParentTenantId(); | |||||
| boolean doTableFilter(String tableName); | |||||
| List<String> filterTables(); | |||||
| boolean doTableFilterSub(String tableName); | |||||
| List<String> filterSubTables(); | |||||
| boolean doMappedStatementFIlter(MappedStatement ms); | |||||
| } | |||||
| @@ -0,0 +1,41 @@ | |||||
| package com.iformall.plugin.entity; | |||||
| import java.io.Serializable; | |||||
| import java.util.ArrayList; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import java.util.Set; | |||||
| /** | |||||
| * 链里的值 | |||||
| * @author alascor | |||||
| * {column:"tennat_id", value:"789", ignoreTables:"wx_c_user","wx_c_user_basic_info"...} | |||||
| * | |||||
| */ | |||||
| public class ChainValue implements Serializable{ | |||||
| private static final long serialVersionUID = 6290377774649358950L; | |||||
| private String column; | |||||
| private Object value; | |||||
| private List<String> ignoreTables; | |||||
| public String getColumn() { | |||||
| return column; | |||||
| } | |||||
| public void setColumn(String column) { | |||||
| this.column = column; | |||||
| } | |||||
| public Object getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setValue(Object value) { | |||||
| this.value = value; | |||||
| } | |||||
| public List<String> getIgnoreTables() { | |||||
| return ignoreTables; | |||||
| } | |||||
| public void setIgnoreTables(List<String> ignoreTables) { | |||||
| this.ignoreTables = ignoreTables; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,30 @@ | |||||
| package com.iformall.plugin.entity; | |||||
| import java.util.Map; | |||||
| public class ChainValueHelper { | |||||
| public static Object getValue(String table,String column,Map<String,ChainValue> parentChainMap) { | |||||
| if (null != parentChainMap && parentChainMap.containsKey(column)) { | |||||
| ChainValue chainvalue = parentChainMap.get(column); | |||||
| if (null != chainvalue) { | |||||
| if (null != chainvalue.getIgnoreTables()) { | |||||
| if (!chainvalue.getIgnoreTables().contains(table)) { | |||||
| Object o = chainvalue.getValue(); | |||||
| if (null != o) { | |||||
| return o; | |||||
| } | |||||
| } | |||||
| }else { | |||||
| Object o = chainvalue.getValue(); | |||||
| if (null != o) { | |||||
| return o; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.plugin.shard.annotation; | |||||
| import java.lang.annotation.Documented; | |||||
| import java.lang.annotation.ElementType; | |||||
| import java.lang.annotation.Retention; | |||||
| import java.lang.annotation.RetentionPolicy; | |||||
| import java.lang.annotation.Target; | |||||
| /** | |||||
| * 在mapper方法上面用 | |||||
| */ | |||||
| @Documented | |||||
| @Retention(RetentionPolicy.RUNTIME) | |||||
| @Target(ElementType.METHOD) | |||||
| public @interface IgnoreSharding { | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| package com.iformall.plugin.shard.impl; | |||||
| public enum EnumShardingRule { | |||||
| HASH(1,"哈希值分表"); | |||||
| private Integer code; | |||||
| private String name; | |||||
| private EnumShardingRule(Integer code, String name) { | |||||
| this.code = code; | |||||
| this.name = name; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public void setCode(Integer code) { | |||||
| this.code = code; | |||||
| } | |||||
| public String getName() { | |||||
| return name; | |||||
| } | |||||
| public void setName(String name) { | |||||
| this.name = name; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,29 @@ | |||||
| package com.iformall.plugin.shard.impl; | |||||
| import java.util.Map; | |||||
| import java.util.concurrent.ConcurrentHashMap; | |||||
| import com.alibaba.druid.util.StringUtils; | |||||
| import com.iformall.plugin.shard.impl.rule.ShardingRuleDefaultService; | |||||
| import com.iformall.plugin.shard.impl.rule.ShardingRuleService; | |||||
| public class ShardingRuleExcuter { | |||||
| private static Map<Integer,ShardingRuleService> serviceMap = null; | |||||
| private static Map<Integer,ShardingRuleService> getServiceMap() { | |||||
| if (null == serviceMap) { | |||||
| serviceMap = new ConcurrentHashMap<Integer, ShardingRuleService>(); | |||||
| serviceMap.put(EnumShardingRule.HASH.getCode(), new ShardingRuleDefaultService()); | |||||
| } | |||||
| return serviceMap; | |||||
| } | |||||
| public static String getTableIndex(Integer rule,Object value,int tableCount) { | |||||
| String index = getServiceMap().get(rule).getTableIndex(value, tableCount); | |||||
| if (StringUtils.isEmpty(index)) { | |||||
| throw new RuntimeException("Sharding Rule["+rule+"] not support. column value:"+value+" tableCount:"+tableCount) ; | |||||
| } | |||||
| return index; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,38 @@ | |||||
| package com.iformall.plugin.shard.impl; | |||||
| public class ShardingSphere { | |||||
| public static final String TABLE_SUFFIX = "_"; | |||||
| /*表名,不用带下划线**/ | |||||
| private String tableName; | |||||
| /*分表列名**/ | |||||
| private String column; | |||||
| /*分表规则**/ | |||||
| private Integer rule; | |||||
| /*表数量**/ | |||||
| private Integer count; | |||||
| public String getTableName() { | |||||
| return tableName; | |||||
| } | |||||
| public void setTableName(String tableName) { | |||||
| this.tableName = tableName; | |||||
| } | |||||
| public String getColumn() { | |||||
| return column; | |||||
| } | |||||
| public void setColumn(String column) { | |||||
| this.column = column; | |||||
| } | |||||
| public Integer getRule() { | |||||
| return rule; | |||||
| } | |||||
| public void setRule(Integer rule) { | |||||
| this.rule = rule; | |||||
| } | |||||
| public Integer getCount() { | |||||
| return count; | |||||
| } | |||||
| public void setCount(Integer count) { | |||||
| this.count = count; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,33 @@ | |||||
| package com.iformall.plugin.shard.impl; | |||||
| import java.util.Map; | |||||
| import java.util.concurrent.ConcurrentHashMap; | |||||
| public class ShardingTableExcuter { | |||||
| private static Map<String,ShardingSphere> tableMap = new ConcurrentHashMap<String, ShardingSphere>(); | |||||
| public static Map<String,ShardingSphere> setTableSharding(String table ,ShardingSphere ss) { | |||||
| tableMap.put(table, ss); | |||||
| return tableMap; | |||||
| } | |||||
| public static ShardingSphere getShardingSphere(String table) { | |||||
| return tableMap.get(table); | |||||
| } | |||||
| public static boolean isShardingTable(String table) { | |||||
| ShardingSphere ss = getShardingSphere(table); | |||||
| if (null == ss) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| public static boolean hasShardingConfig() { | |||||
| if (null == tableMap || tableMap.size() <= 0) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,32 @@ | |||||
| package com.iformall.plugin.shard.impl.rule; | |||||
| public class ShardingRuleDefaultService implements ShardingRuleService { | |||||
| @Override | |||||
| public String getTableIndex(Object value, int count) { | |||||
| if (null == value || count <= 0 ) { | |||||
| return null; | |||||
| } | |||||
| int hash = 9999999; | |||||
| //如果是整数,则直接变为Long,好查询 | |||||
| if (value instanceof String) { | |||||
| try { | |||||
| Long lvalue = Long.parseLong((String)value); | |||||
| hash = getHashCode(lvalue); | |||||
| }catch(Exception e) { | |||||
| hash = getHashCode(value); | |||||
| } | |||||
| }else { | |||||
| hash = getHashCode(value); | |||||
| } | |||||
| return String.valueOf(hash%count); | |||||
| } | |||||
| private int getHashCode(Object value) { | |||||
| int hash = value.hashCode(); | |||||
| if (hash < 0 ) { | |||||
| hash = Math.abs(hash); | |||||
| } | |||||
| return hash; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,6 @@ | |||||
| package com.iformall.plugin.shard.impl.rule; | |||||
| public interface ShardingRuleService { | |||||
| public String getTableIndex(Object value,int count); | |||||
| } | |||||
| @@ -0,0 +1,301 @@ | |||||
| package com.iformall.plugin.shard.plugin; | |||||
| import net.sf.jsqlparser.JSQLParserException; | |||||
| import net.sf.jsqlparser.parser.CCJSqlParserUtil; | |||||
| import net.sf.jsqlparser.schema.Table; | |||||
| import net.sf.jsqlparser.statement.Statement; | |||||
| import net.sf.jsqlparser.statement.create.table.CreateTable; | |||||
| import net.sf.jsqlparser.statement.delete.Delete; | |||||
| import net.sf.jsqlparser.statement.insert.Insert; | |||||
| import net.sf.jsqlparser.statement.select.*; | |||||
| import net.sf.jsqlparser.statement.update.Update; | |||||
| import net.sf.jsqlparser.util.TablesNamesFinder; | |||||
| import org.apache.ibatis.executor.statement.StatementHandler; | |||||
| import org.apache.ibatis.logging.LogFactory; | |||||
| import org.apache.ibatis.mapping.BoundSql; | |||||
| import org.apache.ibatis.mapping.MappedStatement; | |||||
| import org.apache.ibatis.mapping.StatementType; | |||||
| import org.apache.ibatis.plugin.*; | |||||
| import org.apache.ibatis.reflection.MetaObject; | |||||
| import org.apache.ibatis.reflection.SystemMetaObject; | |||||
| import com.alibaba.druid.wall.violation.ErrorCode; | |||||
| import com.iformall.plugin.MyBatisPlus; | |||||
| import com.iformall.plugin.entity.ChainValue; | |||||
| import com.iformall.plugin.entity.ChainValueHelper; | |||||
| import com.iformall.plugin.shard.annotation.IgnoreSharding; | |||||
| import com.iformall.plugin.shard.impl.ShardingRuleExcuter; | |||||
| import com.iformall.plugin.shard.impl.ShardingSphere; | |||||
| import com.iformall.plugin.shard.impl.ShardingTableExcuter; | |||||
| import java.lang.reflect.Method; | |||||
| import java.math.BigDecimal; | |||||
| import java.sql.Date; | |||||
| import java.sql.Time; | |||||
| import java.sql.Timestamp; | |||||
| import java.util.HashMap; | |||||
| import java.util.Iterator; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import java.util.Properties; | |||||
| /** | |||||
| *分表 | |||||
| */ | |||||
| public class ShardingSpherePlugin implements MyBatisPlus { | |||||
| public ShardingSpherePlugin(){ | |||||
| } | |||||
| //属性参数信息 | |||||
| private Properties properties; | |||||
| private String dialect = "mysql"; | |||||
| private List<ShardingSphere> ShardingSpheres; | |||||
| public String getDialect() { | |||||
| return dialect; | |||||
| } | |||||
| public void setDialect(String dialect) { | |||||
| this.dialect = dialect; | |||||
| } | |||||
| public List<ShardingSphere> getShardingSpheres() { | |||||
| return ShardingSpheres; | |||||
| } | |||||
| public void setShardingSpheres(List<ShardingSphere> shardingSpheres) { | |||||
| ShardingSpheres = shardingSpheres; | |||||
| } | |||||
| /** | |||||
| * 获取配置信息 | |||||
| * {dialect=mysql, tenantInfo=org.xue.test.TenantInfoImpl, tenantIdColumn=tenant_id, parentTenantIdColumn=parent_tenant_id} | |||||
| * @param properties | |||||
| */ | |||||
| public void setProperties(Properties properties) { | |||||
| this.properties=properties; | |||||
| this.dialect = this.properties.getProperty("dialect"); | |||||
| if (null != this.ShardingSpheres) { | |||||
| for (ShardingSphere ss : this.ShardingSpheres) { | |||||
| ShardingTableExcuter.setTableSharding(ss.getTableName(), ss); | |||||
| } | |||||
| } | |||||
| } | |||||
| public Map<String,ChainValue> intercept(Invocation invocation,Map<String,ChainValue> chainMap) throws Throwable { | |||||
| if (!ShardingTableExcuter.hasShardingConfig()) { | |||||
| return null; | |||||
| } | |||||
| StatementHandler statementHandler = (StatementHandler) invocation.getTarget(); | |||||
| MetaObject metaStatementHandler = SystemMetaObject.forObject(statementHandler); | |||||
| MappedStatement ms = (MappedStatement) metaStatementHandler.getValue("delegate.mappedStatement"); | |||||
| if(ms.getStatementType().equals(StatementType.CALLABLE)){ | |||||
| return chainMap; | |||||
| } | |||||
| //String id = ms.getId(); | |||||
| //String className = id.substring(0, id.lastIndexOf(".")); | |||||
| //String methodName = id.substring(id.lastIndexOf(".") + 1); | |||||
| //Class<?> clazz = Class.forName(className); | |||||
| //Method method = getMethodFromAllParent(clazz, methodName); | |||||
| //if (method != null) { | |||||
| // IgnoreSharding ignore = method.getAnnotation(IgnoreSharding.class); | |||||
| // if (null == ignore) { | |||||
| Object parameterObject = metaStatementHandler.getValue("delegate.boundSql.parameterObject"); | |||||
| BoundSql boundSql = statementHandler.getBoundSql(); | |||||
| String newSQL = buildTable(boundSql,parameterObject,chainMap); | |||||
| metaStatementHandler.setValue("delegate.boundSql.sql", newSQL); | |||||
| // } | |||||
| //} | |||||
| //没有添加字段,只是根据字段分表,没有别的需要返回 | |||||
| return chainMap; | |||||
| } | |||||
| private String buildTable(BoundSql boundSql,Object parameterObject,Map<String,ChainValue> chainMap) throws JSQLParserException { | |||||
| String oldSql = boundSql.getSql(); | |||||
| Statement stmt = CCJSqlParserUtil.parse(oldSql); | |||||
| if (stmt instanceof Insert) { | |||||
| return buildInsert((Insert) stmt,oldSql,parameterObject,chainMap); | |||||
| } | |||||
| if (stmt instanceof Delete) { | |||||
| return buildDelete((Delete) stmt,oldSql,parameterObject,chainMap); | |||||
| } | |||||
| if (stmt instanceof Update) { | |||||
| return buildUpdate((Update) stmt,oldSql,parameterObject,chainMap); | |||||
| } | |||||
| if (stmt instanceof Select) { | |||||
| return buildSelect((Select) stmt,oldSql,parameterObject,chainMap); | |||||
| } | |||||
| if (stmt instanceof CreateTable) { | |||||
| return oldSql; | |||||
| } | |||||
| throw new RuntimeException("非法sql语句,请检查"+oldSql); | |||||
| } | |||||
| private String buildInsert(Insert stmt,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||||
| return buildTable(stmt.getTable(), oldSql, parameterObject,chainMap); | |||||
| } | |||||
| private String buildDelete(Delete stmt,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||||
| return buildTable(stmt.getTable(), oldSql, parameterObject,chainMap); | |||||
| } | |||||
| private String buildUpdate(Update stmt,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||||
| return buildListTables(stmt.getTables(), oldSql, parameterObject,chainMap); | |||||
| } | |||||
| private String buildSelect(Select stmt,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||||
| TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); | |||||
| List<String> tableList = tablesNamesFinder.getTableList(stmt); | |||||
| return buildByListTableNames(tableList, oldSql, parameterObject,chainMap); | |||||
| } | |||||
| private String buildTable(Table table,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||||
| return buildByTableName(table.getName(), oldSql, parameterObject,chainMap); | |||||
| } | |||||
| private String buildByTableName(String table,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||||
| if (!ShardingTableExcuter.isShardingTable(table)) { | |||||
| return oldSql; | |||||
| } | |||||
| String newtable = getShareTable(table,parameterObject,chainMap); | |||||
| //此处处理前缀相似的表,如wx_c_user, wx_c_user_basic_info, 直接替换wx_c_user会有问题 | |||||
| return oldSql.replaceAll(table+"_", "########").replaceAll(table, newtable).replaceAll("########", table+"_"); | |||||
| } | |||||
| private String buildListTables(List<Table> tables,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||||
| for (Table t : tables) { | |||||
| oldSql = buildTable(t,oldSql,parameterObject,chainMap); | |||||
| } | |||||
| return oldSql; | |||||
| } | |||||
| private String buildByListTableNames(List<String> tables,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||||
| for (String t : tables) { | |||||
| oldSql = buildByTableName(t,oldSql,parameterObject,chainMap); | |||||
| } | |||||
| return oldSql; | |||||
| } | |||||
| private String getShareTable(String table,Object parameterObject,Map<String,ChainValue> chainMap) { | |||||
| ShardingSphere ss = ShardingTableExcuter.getShardingSphere(table); | |||||
| return ss.getTableName()+ShardingSphere.TABLE_SUFFIX+ShardingRuleExcuter.getTableIndex(ss.getRule(), getValue(table,ss.getColumn(),parameterObject,chainMap), ss.getCount()); | |||||
| } | |||||
| private Object getValue(String table,String column,Object parameterObject,Map<String,ChainValue> parentChainMap) { | |||||
| Object ov = ChainValueHelper.getValue(table, column, parentChainMap); | |||||
| if (null != ov ) { | |||||
| return ov; | |||||
| } | |||||
| if (parameterObject instanceof Map) { | |||||
| String field = getField(column); | |||||
| field = field.substring(0,1).toLowerCase()+field.substring(1); | |||||
| Object o = parameterObject; | |||||
| if (((Map) parameterObject).containsKey("et")) { | |||||
| o = ((Map) parameterObject).get("et"); | |||||
| }else if(((Map) parameterObject).containsKey("ew")) { | |||||
| Object ew = ((Map) parameterObject).get("ew"); | |||||
| if (ew instanceof com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) { | |||||
| o = ((com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ew).getEntity(); | |||||
| } | |||||
| }else if(((Map) parameterObject).containsKey(column)) { | |||||
| o = ((Map) parameterObject).get(column); | |||||
| }else if (((Map) parameterObject).containsKey(field)) { | |||||
| o = ((Map) parameterObject).get(field); | |||||
| }else { | |||||
| Map m = (Map) parameterObject; | |||||
| for (Iterator it = m.keySet().iterator();it.hasNext();) { | |||||
| Object ito = it.next(); | |||||
| Object value = m.get(ito); | |||||
| if(isBasicTypeValue(value)) { | |||||
| if (ito instanceof String) { | |||||
| String itoStr = (String) ito; | |||||
| if( itoStr.equals(column) || itoStr.equals(field)) { | |||||
| return value; | |||||
| }else { | |||||
| continue; | |||||
| } | |||||
| }else { | |||||
| continue; | |||||
| } | |||||
| } | |||||
| Object v = getValue(table,column,value,parentChainMap); | |||||
| if (null != v) { | |||||
| return v; | |||||
| } | |||||
| } | |||||
| } | |||||
| return getValue(table,column,o,parentChainMap); | |||||
| }else if (isBasicTypeValue(parameterObject)) { | |||||
| return parameterObject; | |||||
| //认为是实体 | |||||
| }else { | |||||
| return getEntityValue(column, parameterObject, parentChainMap); | |||||
| } | |||||
| } | |||||
| private String getField(String column) { | |||||
| if (null == column) { | |||||
| throw new RuntimeException("table sharinding error column is null"); | |||||
| } | |||||
| try { | |||||
| if (column.contains("_") && (!column.endsWith("_")) && (!column.startsWith("_"))) { | |||||
| String[] field = column.split("_"); | |||||
| String fieldName = ""; | |||||
| if (null != field && field.length > 0) { | |||||
| for (String f : field) { | |||||
| fieldName = fieldName + f.substring(0,1).toUpperCase()+f.substring(1); | |||||
| } | |||||
| }else { | |||||
| fieldName = column.substring(0,1).toUpperCase()+column.substring(1); | |||||
| } | |||||
| return fieldName; | |||||
| }else { | |||||
| return column.substring(0,1).toUpperCase()+column.substring(1); | |||||
| } | |||||
| }catch(Exception e) { | |||||
| throw new RuntimeException(e); | |||||
| } | |||||
| } | |||||
| private boolean isBasicTypeValue(Object parameterObject) { | |||||
| if( parameterObject instanceof Integer || parameterObject instanceof Long || parameterObject instanceof Short || parameterObject instanceof Float | |||||
| || parameterObject instanceof Double || parameterObject instanceof BigDecimal || parameterObject instanceof Character || parameterObject instanceof String | |||||
| || parameterObject instanceof Byte || parameterObject instanceof Date || parameterObject instanceof Time || parameterObject instanceof Timestamp ) { | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| private Object getEntityValue(String column,Object parameterObject,Map<String,ChainValue> chainMap) { | |||||
| try { | |||||
| Method method = getMethodFromAllParent(parameterObject.getClass(),"get"+getField(column)); | |||||
| Object o = method.invoke(parameterObject); | |||||
| return o; | |||||
| }catch(Exception e) { | |||||
| e.printStackTrace(); | |||||
| throw new RuntimeException(e); | |||||
| } | |||||
| } | |||||
| private Method getMethodFromAllParent(Class<?> currentClazz,String methodName) { | |||||
| Method method = null; | |||||
| for(Class<?> clazz = currentClazz ; clazz != Object.class ; clazz = clazz.getSuperclass()) { | |||||
| try { | |||||
| method = clazz.getDeclaredMethod(methodName) ; | |||||
| } catch (Exception e) { | |||||
| //这里甚么都不要做!并且这里的异常必须这样写,不能抛出去。 | |||||
| //如果这里的异常打印或者往外抛,则就不会执行clazz = clazz.getSuperclass(),最后就不会进入到父类中了 | |||||
| } | |||||
| } | |||||
| if (null == method) { | |||||
| throw new RuntimeException(currentClazz+" has no method:"+methodName+"()"); | |||||
| } | |||||
| return method; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,28 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <parent> | |||||
| <artifactId>bjair</artifactId> | |||||
| <groupId>com.iformall</groupId> | |||||
| <version>1.0</version> | |||||
| </parent> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <artifactId>bjair-swagger</artifactId> | |||||
| <dependencies> | |||||
| <!--swagger 相关依赖--> | |||||
| <dependency> | |||||
| <groupId>io.springfox</groupId> | |||||
| <artifactId>springfox-swagger2</artifactId> | |||||
| <version>2.9.2</version> | |||||
| </dependency> | |||||
| <!--doc.html模式--> | |||||
| <dependency> | |||||
| <groupId>com.github.xiaoymin</groupId> | |||||
| <artifactId>swagger-bootstrap-ui</artifactId> | |||||
| <version>1.9.3</version> | |||||
| </dependency> | |||||
| </dependencies> | |||||
| </project> | |||||
| @@ -0,0 +1,19 @@ | |||||
| package com.iformall.annotation; | |||||
| import java.lang.annotation.ElementType; | |||||
| import java.lang.annotation.Retention; | |||||
| import java.lang.annotation.RetentionPolicy; | |||||
| import java.lang.annotation.Target; | |||||
| @Target(ElementType.METHOD) | |||||
| @Retention(RetentionPolicy.RUNTIME) | |||||
| public @interface ApiVersion { | |||||
| /** | |||||
| * 接口版本号(对应swagger中的group) | |||||
| * | |||||
| * @return String[] | |||||
| */ | |||||
| String[] group(); | |||||
| } | |||||
| @@ -0,0 +1,14 @@ | |||||
| package com.iformall.annotation; | |||||
| import com.iformall.config.SwaggerConfiguration; | |||||
| import org.springframework.context.annotation.Import; | |||||
| import java.lang.annotation.*; | |||||
| @Target({ElementType.TYPE}) | |||||
| @Retention(RetentionPolicy.RUNTIME) | |||||
| @Documented | |||||
| @Inherited | |||||
| @Import({SwaggerConfiguration.class}) | |||||
| public @interface BaseEnableSwagger { | |||||
| } | |||||
| @@ -0,0 +1,94 @@ | |||||
| package com.iformall.config; | |||||
| import com.google.common.base.Predicate; | |||||
| import com.google.common.base.Predicates; | |||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | |||||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | |||||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import springfox.documentation.builders.ApiInfoBuilder; | |||||
| import springfox.documentation.builders.PathSelectors; | |||||
| import springfox.documentation.builders.RequestHandlerSelectors; | |||||
| import springfox.documentation.service.ApiInfo; | |||||
| import springfox.documentation.service.Contact; | |||||
| import springfox.documentation.spi.DocumentationType; | |||||
| import springfox.documentation.spring.web.plugins.Docket; | |||||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| import javax.servlet.ServletContext; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Arrays; | |||||
| import java.util.List; | |||||
| @Configuration | |||||
| @EnableSwagger2 | |||||
| @EnableAutoConfiguration | |||||
| @EnableConfigurationProperties(SwaggerProperties.class) | |||||
| @ConditionalOnProperty(name = "swagger.enabled", matchIfMissing = true) | |||||
| public class SwaggerConfiguration { | |||||
| private static final List<String> DEFAULT_EXCLUDE_PATH = Arrays.asList("/error"); | |||||
| private static final String BASE_PATH = "/**"; | |||||
| @Autowired | |||||
| private SwaggerProperties swaggerProperties; | |||||
| /** | |||||
| * 1、分组 | |||||
| * 2、切换分组,修改访问/v2/api-docs/ 接口的路径 | |||||
| * https://admintest.malls.iformall.com/v2/api-docs/ | |||||
| * https://admintest.malls.iformall.com/B/v2/api-docs/ | |||||
| * | |||||
| * @param servletContext | |||||
| * @return {@link Docket} | |||||
| */ | |||||
| @Bean | |||||
| public Docket docket(ServletContext servletContext) { | |||||
| // base-path处理 | |||||
| if (swaggerProperties.getBasePath().isEmpty()) { | |||||
| swaggerProperties.getBasePath().add(BASE_PATH); | |||||
| } | |||||
| List<Predicate<String>> basePath = new ArrayList<>(swaggerProperties.getBasePath().size()); | |||||
| swaggerProperties.getBasePath().forEach(path -> basePath.add(PathSelectors.ant(path))); | |||||
| // exclude-path处理 | |||||
| if (swaggerProperties.getExcludePath().isEmpty()) { | |||||
| swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH); | |||||
| } | |||||
| List<Predicate<String>> excludePath = new ArrayList<>(); | |||||
| swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path))); | |||||
| return new Docket(DocumentationType.SWAGGER_2) | |||||
| .host(swaggerProperties.getHost()) | |||||
| .apiInfo(apiInfo(swaggerProperties)).select() | |||||
| .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage())) | |||||
| .apis(input -> { | |||||
| ApiVersion apiVersion = input.getHandlerMethod().getMethodAnnotation(ApiVersion.class); | |||||
| return apiVersion != null && Arrays.asList(apiVersion.group()).contains(SwaggerConstant.V_1_0_0); | |||||
| }) | |||||
| .paths( | |||||
| Predicates.and( | |||||
| Predicates.not(Predicates.or(excludePath)), | |||||
| Predicates.or(basePath) | |||||
| ) | |||||
| ) | |||||
| .build(); | |||||
| } | |||||
| private ApiInfo apiInfo(SwaggerProperties swaggerProperties) { | |||||
| return new ApiInfoBuilder() | |||||
| .title(swaggerProperties.getTitle()) | |||||
| .description(swaggerProperties.getDescription()) | |||||
| .license(swaggerProperties.getLicense()) | |||||
| .licenseUrl(swaggerProperties.getLicenseUrl()) | |||||
| .termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl()) | |||||
| .contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), swaggerProperties.getContact().getEmail())) | |||||
| .version(swaggerProperties.getVersion()) | |||||
| .build(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,123 @@ | |||||
| package com.iformall.config; | |||||
| import lombok.Data; | |||||
| import lombok.NoArgsConstructor; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @Data | |||||
| @ConfigurationProperties("swagger") | |||||
| public class SwaggerProperties { | |||||
| private Map<String, String> services; | |||||
| private String prePath; | |||||
| /** | |||||
| * 是否开启swagger | |||||
| */ | |||||
| private Boolean enabled; | |||||
| /** | |||||
| * swagger会解析的包路径 | |||||
| **/ | |||||
| private String basePackage = ""; | |||||
| /** | |||||
| * swagger会解析的url规则 | |||||
| **/ | |||||
| private List<String> basePath = new ArrayList<>(); | |||||
| /** | |||||
| * 在basePath基础上需要排除的url规则 | |||||
| **/ | |||||
| private List<String> excludePath = new ArrayList<>(); | |||||
| /** | |||||
| * 标题 | |||||
| **/ | |||||
| private String title = ""; | |||||
| /** | |||||
| * 描述 | |||||
| **/ | |||||
| private String description = ""; | |||||
| /** | |||||
| * 版本 | |||||
| **/ | |||||
| private String version = ""; | |||||
| /** | |||||
| * 许可证 | |||||
| **/ | |||||
| private String license = ""; | |||||
| /** | |||||
| * 许可证URL | |||||
| **/ | |||||
| private String licenseUrl = ""; | |||||
| /** | |||||
| * 服务条款URL | |||||
| **/ | |||||
| private String termsOfServiceUrl = ""; | |||||
| /** | |||||
| * host信息 | |||||
| **/ | |||||
| private String host = ""; | |||||
| /** | |||||
| * 联系人信息 | |||||
| */ | |||||
| private Contact contact = new Contact(); | |||||
| /** | |||||
| * 全局统一鉴权配置 | |||||
| **/ | |||||
| private Authorization authorization = new Authorization(); | |||||
| @Data | |||||
| public static class Contact { | |||||
| /** | |||||
| * 联系人 | |||||
| **/ | |||||
| private String name = ""; | |||||
| /** | |||||
| * 联系人url | |||||
| **/ | |||||
| private String url = ""; | |||||
| /** | |||||
| * 联系人email | |||||
| **/ | |||||
| private String email = ""; | |||||
| } | |||||
| @Data | |||||
| @NoArgsConstructor | |||||
| public static class Authorization { | |||||
| /** | |||||
| * 鉴权策略ID,需要和SecurityReferences ID保持一致 | |||||
| */ | |||||
| private String name = ""; | |||||
| /** | |||||
| * 需要开启鉴权URL的正则 | |||||
| */ | |||||
| private String authRegex = "^.*$"; | |||||
| /** | |||||
| * 鉴权作用域列表 | |||||
| */ | |||||
| private List<AuthorizationScope> authorizationScopeList = new ArrayList<>(); | |||||
| private List<String> tokenUrlList = new ArrayList<>(); | |||||
| } | |||||
| @Data | |||||
| @NoArgsConstructor | |||||
| public static class AuthorizationScope { | |||||
| /** | |||||
| * 作用域名称 | |||||
| */ | |||||
| private String scope = ""; | |||||
| /** | |||||
| * 作用域描述 | |||||
| */ | |||||
| private String description = ""; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,8 @@ | |||||
| package com.iformall.constant; | |||||
| public interface SwaggerConstant { | |||||
| /** | |||||
| * | |||||
| */ | |||||
| String V_1_0_0 = "v1.0.0"; | |||||
| } | |||||
| @@ -0,0 +1,192 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <parent> | |||||
| <artifactId>bjair</artifactId> | |||||
| <groupId>com.iformall</groupId> | |||||
| <version>1.0</version> | |||||
| </parent> | |||||
| <artifactId>bjairAdmin</artifactId> | |||||
| <properties> | |||||
| <weixin-java-mp.version>3.7.0.B</weixin-java-mp.version> | |||||
| <weixin-java-open.version>3.7.0.B</weixin-java-open.version> | |||||
| </properties> | |||||
| <dependencies> | |||||
| <dependency> | |||||
| <groupId>com.iformall</groupId> | |||||
| <artifactId>bjairService</artifactId> | |||||
| <version>1.0</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.iformall</groupId> | |||||
| <artifactId>bjairVideo</artifactId> | |||||
| <version>1.0</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>commons-fileupload</groupId> | |||||
| <artifactId>commons-fileupload</artifactId> | |||||
| <version>1.3.3</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.google.zxing</groupId> | |||||
| <artifactId>core</artifactId> | |||||
| <version>3.3.3</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.github.axet</groupId> | |||||
| <artifactId>kaptcha</artifactId> | |||||
| <version>0.0.9</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>org.flywaydb</groupId> | |||||
| <artifactId>flyway-core</artifactId> | |||||
| <version>5.2.4</version> | |||||
| </dependency> | |||||
| </dependencies> | |||||
| <build> | |||||
| <plugins> | |||||
| <plugin> | |||||
| <groupId>org.springframework.boot</groupId> | |||||
| <artifactId>spring-boot-maven-plugin</artifactId> | |||||
| <configuration> | |||||
| <executable>true</executable> | |||||
| <layout>ZIP</layout> | |||||
| <excludeGroupIds> | |||||
| antlr, | |||||
| ch.qos.logback, | |||||
| com.alibaba, | |||||
| com.amazonaws, | |||||
| com.baomidou, | |||||
| com.mchange, | |||||
| com.fasterxml.jackson.core, | |||||
| com.fasterxml.jackson.dataformat, | |||||
| com.fasterxml.jackson.datatype, | |||||
| com.fasterxml.jackson.module, | |||||
| com.fasterxml.uuid, | |||||
| com.fasterxml, | |||||
| com.github.axet, | |||||
| com.github.jsqlparser, | |||||
| com.github.pagehelper, | |||||
| com.github.ulisesbocchio, | |||||
| com.github.virtuald, | |||||
| com.google.code.findbugs, | |||||
| com.google.code.gson, | |||||
| com.google.errorprone, | |||||
| com.google.guava, | |||||
| com.google.protobuf, | |||||
| com.google.zxing, | |||||
| com.jayway.jsonpath, | |||||
| com.jhlabs, | |||||
| com.puppycrawl.tools, | |||||
| com.rabbitmq, | |||||
| com.squareup.okhttp3, | |||||
| com.squareup.okio, | |||||
| com.sun, | |||||
| com.sun.mail, | |||||
| com.thoughtworks.xstream, | |||||
| com.zaxxer, | |||||
| commons-beanutils, | |||||
| commons-cli, | |||||
| commons-codec, | |||||
| commons-collections, | |||||
| commons-fileupload, | |||||
| commons-io, | |||||
| commons-logging, | |||||
| io.lettuce, | |||||
| io.netty, | |||||
| io.projectreactor, | |||||
| io.springfox, | |||||
| io.swagger, | |||||
| io.undertow, | |||||
| javax.activation, | |||||
| javax.annotation, | |||||
| javax.mail, | |||||
| javax.persistence, | |||||
| javax.servlet, | |||||
| javax.validation, | |||||
| javax.xml.bind, | |||||
| javax.xml.soap, | |||||
| javax.xml.ws, | |||||
| joda-time, | |||||
| junit, | |||||
| mysql, | |||||
| net.bytebuddy, | |||||
| net.minidev, | |||||
| net.sf.dozer, | |||||
| net.sf.saxon, | |||||
| ognl, | |||||
| org.antlr, | |||||
| org.apache.commons, | |||||
| org.apache.httpcomponents, | |||||
| org.apache.logging.log4j, | |||||
| org.apache.poi, | |||||
| org.apache.poi.wso2, | |||||
| org.apache.rocketmq, | |||||
| org.apache.shiro, | |||||
| org.apache.tomcat.embed, | |||||
| org.apache.xmlbeans, | |||||
| org.aspectj, | |||||
| org.assertj, | |||||
| org.bouncycastle, | |||||
| org.checkerframework, | |||||
| org.codehaus.mojo, | |||||
| org.crazycake, | |||||
| org.dom4j, | |||||
| org.flowable, | |||||
| org.flywaydb, | |||||
| org.glassfish, | |||||
| org.hibernate.validator, | |||||
| org.jasypt, | |||||
| org.javassist, | |||||
| org.jboss.logging, | |||||
| org.jboss.spec.javax.annotation, | |||||
| org.jboss.spec.javax.websocket, | |||||
| org.jboss.xnio, | |||||
| org.jdom, | |||||
| org.jodd, | |||||
| org.jvnet.mimepull, | |||||
| org.jvnet.staxex, | |||||
| org.mapstruct, | |||||
| org.mockito, | |||||
| org.mybatis, | |||||
| org.mybatis.generator, | |||||
| org.mybatis.spring.boot, | |||||
| org.ow2.asm, | |||||
| org.projectlombok, | |||||
| org.quartz-scheduler, | |||||
| org.reactivestreams, | |||||
| org.reflections, | |||||
| org.rocketmq.spring.boot, | |||||
| org.slf4j, | |||||
| org.springframework, | |||||
| org.springframework.amqp, | |||||
| org.springframework.boot, | |||||
| org.springframework.data, | |||||
| org.springframework.retry, | |||||
| org.springframework.ws, | |||||
| org.yaml, | |||||
| redis.clients, | |||||
| software.amazon.ion, | |||||
| tk.mybatis, | |||||
| xmlpull, | |||||
| xpp3 | |||||
| </excludeGroupIds> | |||||
| </configuration> | |||||
| </plugin> | |||||
| </plugins> | |||||
| </build> | |||||
| </project> | |||||
| @@ -0,0 +1,80 @@ | |||||
| package com.iformall; | |||||
| import com.iformall.annotation.BaseEnableSwagger; | |||||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | |||||
| import org.mybatis.spring.annotation.MapperScan; | |||||
| import org.rocketmq.starter.annotation.EnableRocketMQ; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.boot.SpringApplication; | |||||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.EnableAspectJAutoProxy; | |||||
| import org.springframework.scheduling.annotation.EnableAsync; | |||||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| /** | |||||
| * @author chenkx | |||||
| * @date 2017-12-26 | |||||
| */ | |||||
| @SpringBootApplication | |||||
| @MapperScan(basePackages = {"com.iformall.mapper"}) | |||||
| @BaseEnableSwagger | |||||
| @EnableEncryptableProperties | |||||
| @EnableAsync | |||||
| @EnableRocketMQ | |||||
| @EnableAspectJAutoProxy(exposeProxy = true) | |||||
| public class AdminApplication { | |||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Value("${fm.exception_emails}") | |||||
| private String fmExceptionEmails; | |||||
| @Value("${fm.open}") | |||||
| private boolean fmOpen; | |||||
| @Value("${fm.upload_dir}") | |||||
| private String uploadDir; | |||||
| @Value("${fm.ocr_data}") | |||||
| private String ocrData; | |||||
| @Value("${fm.videoType}") | |||||
| private String videoType; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| @Bean | |||||
| public String fmExceptionEmails() { | |||||
| return fmExceptionEmails; | |||||
| } | |||||
| @Bean | |||||
| public boolean isFmOpen() { | |||||
| return fmOpen; | |||||
| } | |||||
| @Bean | |||||
| public String fmUploadDir() { | |||||
| return uploadDir; | |||||
| } | |||||
| @Bean | |||||
| public String ocrData() { | |||||
| return ocrData; | |||||
| } | |||||
| @Bean | |||||
| public String videoType() { | |||||
| return videoType; | |||||
| } | |||||
| public static void main(String[] args) { | |||||
| SpringApplication.run(AdminApplication.class, args); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,10 @@ | |||||
| package com.iformall.annotation; | |||||
| import java.lang.annotation.*; | |||||
| @Target({ElementType.PARAMETER, ElementType.METHOD}) | |||||
| @Retention(RetentionPolicy.RUNTIME) | |||||
| @Documented | |||||
| public @interface SystemControllerLog { | |||||
| String description() default ""; | |||||
| } | |||||
| @@ -0,0 +1,10 @@ | |||||
| package com.iformall.annotation; | |||||
| import java.lang.annotation.*; | |||||
| @Target({ElementType.PARAMETER, ElementType.METHOD}) | |||||
| @Retention(RetentionPolicy.RUNTIME) | |||||
| @Documented | |||||
| public @interface SystemServiceLog { | |||||
| String description() default ""; | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.annotation; | |||||
| import java.lang.annotation.*; | |||||
| /** | |||||
| * api接口,忽略Token验证 | |||||
| * @author stormeye.wu | |||||
| * @email wuguoqiang@iformall.com | |||||
| * @date 2017-03-23 15:44 | |||||
| */ | |||||
| @Target(ElementType.METHOD) | |||||
| @Retention(RetentionPolicy.RUNTIME) | |||||
| @Documented | |||||
| public @interface TenantIgnore { | |||||
| } | |||||
| @@ -0,0 +1,14 @@ | |||||
| package com.iformall.annotation; | |||||
| import java.lang.annotation.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Target({ElementType.METHOD}) | |||||
| @Retention(RetentionPolicy.RUNTIME) | |||||
| @Documented | |||||
| public @interface UserDataRuleAnnotation { | |||||
| String value() default ""; | |||||
| } | |||||
| @@ -0,0 +1,52 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import org.springframework.stereotype.Component; | |||||
| /** | |||||
| * @author Stormeye | |||||
| */ | |||||
| @Component | |||||
| @ConfigurationProperties(prefix = "aws") | |||||
| public class AwsProperty { | |||||
| // AWS ACCESS KEY | |||||
| private String access; | |||||
| private String secret; | |||||
| private String clientRegion; | |||||
| private String bucketName; | |||||
| public String getAccess() { | |||||
| return access; | |||||
| } | |||||
| public void setAccess(String access) { | |||||
| this.access = access; | |||||
| } | |||||
| public String getSecret() { | |||||
| return secret; | |||||
| } | |||||
| public void setSecret(String secret) { | |||||
| this.secret = secret; | |||||
| } | |||||
| public String getClientRegion() { | |||||
| return clientRegion; | |||||
| } | |||||
| public void setClientRegion(String clientRegion) { | |||||
| this.clientRegion = clientRegion; | |||||
| } | |||||
| public String getBucketName() { | |||||
| return bucketName; | |||||
| } | |||||
| public void setBucketName(String bucketName) { | |||||
| this.bucketName = bucketName; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,32 @@ | |||||
| package com.iformall.config; | |||||
| import com.google.code.kaptcha.impl.DefaultKaptcha; | |||||
| import com.google.code.kaptcha.util.Config; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import java.util.Properties; | |||||
| /** | |||||
| * 生成验证码配置 | |||||
| * | |||||
| * @author stormeye.wu | |||||
| * @email wugq@mippoint.com | |||||
| * @date 2017-04-20 19:22 | |||||
| */ | |||||
| @Configuration | |||||
| public class KaptchaConfig { | |||||
| @Bean | |||||
| public DefaultKaptcha producer() { | |||||
| Properties properties = new Properties(); | |||||
| properties.put("kaptcha.border", "no"); | |||||
| properties.put("kaptcha.textproducer.font.color", "black"); | |||||
| properties.put("kaptcha.textproducer.char.space", "5"); | |||||
| Config config = new Config(properties); | |||||
| DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); | |||||
| defaultKaptcha.setConfig(config); | |||||
| return defaultKaptcha; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,52 @@ | |||||
| package com.iformall.config; | |||||
| import java.io.File; | |||||
| import javax.servlet.MultipartConfigElement; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.boot.web.servlet.MultipartConfigFactory; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.util.unit.DataSize; | |||||
| import lombok.extern.slf4j.Slf4j; | |||||
| @Slf4j | |||||
| @Configuration | |||||
| public class MultipartConfig { | |||||
| @Value("${spring.servlet.multipart.location}") | |||||
| private String fileTempDir; | |||||
| @Value("${spring.servlet.multipart.max-file-size}") | |||||
| private String maxFileSize; | |||||
| @Value("${spring.servlet.multipart.max-request-size}") | |||||
| private String maxRequestSize; | |||||
| @Bean | |||||
| MultipartConfigElement mulitipartConfigElement() { | |||||
| String os = System.getProperty("os.name"); | |||||
| if (os.toLowerCase().startsWith("win")) { | |||||
| fileTempDir = "C:" + fileTempDir; | |||||
| } | |||||
| log.info("fileTempDir:{}",fileTempDir); | |||||
| MultipartConfigFactory factory = new MultipartConfigFactory(); | |||||
| File tmpDirFile = new File(fileTempDir); | |||||
| if (!tmpDirFile.exists()) { | |||||
| boolean mkdirSuccess = tmpDirFile.mkdirs(); | |||||
| log.info(" create temp dir, result:{}",mkdirSuccess); | |||||
| } | |||||
| factory.setLocation(fileTempDir); | |||||
| factory.setMaxFileSize(DataSize.parse(maxFileSize)); | |||||
| factory.setMaxRequestSize(DataSize.parse(maxRequestSize)); | |||||
| return factory.createMultipartConfig(); | |||||
| } | |||||
| public static void main(String[] args) { | |||||
| System.out.println(DataSize.parse("50MB")); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,55 @@ | |||||
| package com.iformall.config; | |||||
| import org.apache.shiro.authc.AuthenticationToken; | |||||
| public class MyAuthenticationToken implements AuthenticationToken{ | |||||
| private Integer projectType; | |||||
| private String username; | |||||
| private char[] password; | |||||
| public Integer getProjectType() { | |||||
| return projectType; | |||||
| } | |||||
| public void setProjectType(Integer projectType) { | |||||
| this.projectType = projectType; | |||||
| } | |||||
| public String getUsername() { | |||||
| return username; | |||||
| } | |||||
| public void setUsername(String username) { | |||||
| this.username = username; | |||||
| } | |||||
| public char[] getPassword() { | |||||
| return password; | |||||
| } | |||||
| public void setPassword(char[] password) { | |||||
| this.password = password; | |||||
| } | |||||
| @Override | |||||
| public Object getPrincipal() { | |||||
| return getUsername(); | |||||
| } | |||||
| @Override | |||||
| public Object getCredentials() { | |||||
| return getPassword(); | |||||
| } | |||||
| public MyAuthenticationToken() { | |||||
| } | |||||
| public MyAuthenticationToken(Integer projectType, String username, char[] password) { | |||||
| this.projectType = projectType; | |||||
| this.username = username; | |||||
| this.password = password; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,31 @@ | |||||
| package com.iformall.config; | |||||
| import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor; | |||||
| import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; | |||||
| import com.iformall.plugin.MyBatisItercepters; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.transaction.annotation.EnableTransactionManagement; | |||||
| @EnableTransactionManagement | |||||
| @Configuration | |||||
| public class MyBatisConfiguration extends BaseMyBatisConfiguration{ | |||||
| @Bean | |||||
| public MyBatisItercepters intercepters() { | |||||
| return allIntercepters(); | |||||
| } | |||||
| @Bean | |||||
| public PaginationInterceptor paginationInterceptor() { | |||||
| PaginationInterceptor page = new PaginationInterceptor(); | |||||
| page.setDialectType("mysql"); | |||||
| return page; | |||||
| } | |||||
| @Bean | |||||
| public OptimisticLockerInterceptor optimisticLockerInterceptor() { | |||||
| return new OptimisticLockerInterceptor(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,26 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.core.task.AsyncTaskExecutor; | |||||
| import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | |||||
| import java.util.concurrent.ThreadPoolExecutor; | |||||
| @Configuration | |||||
| public class MyExecutorConfig { | |||||
| /** | |||||
| * 自定义异步线程池 | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| @Bean | |||||
| public AsyncTaskExecutor taskExecutor() { | |||||
| ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | |||||
| executor.setThreadNamePrefix("Anno-Executor"); | |||||
| executor.setMaxPoolSize(100); | |||||
| executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); | |||||
| return executor; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,347 @@ | |||||
| package com.iformall.config; | |||||
| import com.fasterxml.jackson.annotation.JsonAutoDetect; | |||||
| import com.fasterxml.jackson.annotation.PropertyAccessor; | |||||
| import com.fasterxml.jackson.databind.DeserializationFeature; | |||||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | |||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.cache.CacheManager; | |||||
| import org.springframework.cache.annotation.CachingConfigurerSupport; | |||||
| import org.springframework.cache.annotation.EnableCaching; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.data.redis.cache.RedisCacheConfiguration; | |||||
| import org.springframework.data.redis.cache.RedisCacheManager; | |||||
| import org.springframework.data.redis.connection.RedisConnectionFactory; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; | |||||
| import org.springframework.data.redis.serializer.StringRedisSerializer; | |||||
| import java.time.Duration; | |||||
| import java.util.*; | |||||
| /** | |||||
| * Created by Stormeye on 2018/10/1. | |||||
| */ | |||||
| @Configuration | |||||
| @EnableCaching | |||||
| public class RedisConfig extends CachingConfigurerSupport { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| //缓存管理器 | |||||
| @Bean | |||||
| public CacheManager cacheManager(RedisConnectionFactory connectionFactory) { | |||||
| /* | |||||
| //user信息缓存配置 | |||||
| RedisCacheConfiguration userCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(10)).disableCachingNullValues().prefixKeysWith("user"); | |||||
| Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>(); | |||||
| redisCacheConfigurationMap.put("user", userCacheConfiguration); | |||||
| //初始化一个RedisCacheWriter | |||||
| RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory); | |||||
| // 设置CacheManager的值序列化方式为JdkSerializationRedisSerializer,但其实RedisCacheConfiguration默认就是使用StringRedisSerializer序列化key,JdkSerializationRedisSerializer序列化value,所以以下注释代码为默认实现 | |||||
| // ClassLoader loader = this.getClass().getClassLoader(); | |||||
| // JdkSerializationRedisSerializer jdkSerializer = new JdkSerializationRedisSerializer(loader); | |||||
| // RedisSerializationContext.SerializationPair<Object> pair = RedisSerializationContext.SerializationPair.fromSerializer(jdkSerializer); | |||||
| // RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair); | |||||
| RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig(); | |||||
| //设置默认超过期时间是30秒 | |||||
| defaultCacheConfig.entryTtl(Duration.ofSeconds(30)); | |||||
| //初始化RedisCacheManager | |||||
| RedisCacheManager cacheManager = new RedisCacheManager(redisCacheWriter, defaultCacheConfig, redisCacheConfigurationMap); | |||||
| return cacheManager; | |||||
| */ | |||||
| RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig(); // 生成一个默认配置,通过config对象即可对缓存进行自定义配置 | |||||
| config = config.entryTtl(Duration.ofMinutes(1)) // 设置缓存的默认过期时间,也是使用Duration设置 | |||||
| .disableCachingNullValues(); // 不缓存空值 | |||||
| // 设置一个初始化的缓存空间set集合 | |||||
| Set<String> cacheNames = new HashSet<>(); | |||||
| cacheNames.add("my-redis-cache1"); | |||||
| cacheNames.add("my-redis-cache2"); | |||||
| // 对每个缓存空间应用不同的配置 | |||||
| Map<String, RedisCacheConfiguration> configMap = new HashMap<>(); | |||||
| configMap.put("my-redis-cache1", config); | |||||
| configMap.put("my-redis-cache2", config.entryTtl(Duration.ofSeconds(120))); | |||||
| RedisCacheManager cacheManager = RedisCacheManager.builder(connectionFactory) // 使用自定义的缓存配置初始化一个cacheManager | |||||
| .initialCacheNames(cacheNames) // 注意这两句的调用顺序,一定要先调用该方法设置初始化的缓存名,再初始化相关的配置 | |||||
| .withInitialCacheConfigurations(configMap) | |||||
| .build(); | |||||
| return cacheManager; | |||||
| } | |||||
| @Bean("pushLimitRedisTemplate") | |||||
| public RedisTemplate<String, PushLimit> getPushLimitRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, PushLimit> template = new RedisTemplate<String, PushLimit>(); | |||||
| Jackson2JsonRedisSerializer<PushLimit> j = new Jackson2JsonRedisSerializer<PushLimit>(PushLimit.class); | |||||
| ObjectMapper om = new ObjectMapper(); | |||||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
| j.setObjectMapper(om); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("scoreRuleRedisTemplate") | |||||
| public RedisTemplate<String, WxScoreRules> getScoreRuleRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, WxScoreRules> template = new RedisTemplate<String, WxScoreRules>(); | |||||
| Jackson2JsonRedisSerializer<WxScoreRules> j = new Jackson2JsonRedisSerializer<WxScoreRules>(WxScoreRules.class); | |||||
| ObjectMapper om = new ObjectMapper(); | |||||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
| j.setObjectMapper(om); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("openRedisTemplate") | |||||
| public RedisTemplate<String, String> getWeChatOpen(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, String> template = new RedisTemplate<String, String>(); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(new StringRedisSerializer()); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("cuserTokenRedisTemplate") | |||||
| public RedisTemplate<String, WxCUser> getCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, WxCUser> template = new RedisTemplate<String, WxCUser>(); | |||||
| Jackson2JsonRedisSerializer<WxCUser> j = new Jackson2JsonRedisSerializer<WxCUser>(WxCUser.class); | |||||
| ObjectMapper om = new ObjectMapper(); | |||||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
| j.setObjectMapper(om); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("baseCUserTokenRedisTemplate") | |||||
| public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||||
| Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||||
| ObjectMapper om = new ObjectMapper(); | |||||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
| j.setObjectMapper(om); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("mallRedisTemplate") | |||||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | |||||
| Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class); | |||||
| ObjectMapper om = new ObjectMapper(); | |||||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
| j.setObjectMapper(om); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("subMallListRedisTemplate") | |||||
| public RedisTemplate<String, List<WxMall>> getSubMallListRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, List<WxMall>> template = new RedisTemplate<String, List<WxMall>>(); | |||||
| Jackson2JsonRedisSerializer<List> j = new Jackson2JsonRedisSerializer<List>(List.class); | |||||
| ObjectMapper om = new ObjectMapper(); | |||||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
| j.setObjectMapper(om); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("couponChannelRedisTemplate") | |||||
| public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||||
| Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||||
| ObjectMapper om = new ObjectMapper(); | |||||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
| j.setObjectMapper(om); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("buserTokenRedisTemplate") | |||||
| public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, WxBuser> template = new RedisTemplate(); | |||||
| Jackson2JsonRedisSerializer<WxBuser> j = new Jackson2JsonRedisSerializer(WxBuser.class); | |||||
| ObjectMapper om = new ObjectMapper(); | |||||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
| j.setObjectMapper(om); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("couponDetailRedisTemplate") | |||||
| public RedisTemplate<String, WxCouponCVo> getCouponDetailRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, WxCouponCVo> template = new RedisTemplate<String, WxCouponCVo>(); | |||||
| Jackson2JsonRedisSerializer<WxCouponCVo> j = new Jackson2JsonRedisSerializer<WxCouponCVo>(WxCouponCVo.class); | |||||
| ObjectMapper om = new ObjectMapper(); | |||||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
| j.setObjectMapper(om); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("cUserBasicInfoRedisTemplate") | |||||
| public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | |||||
| Jackson2JsonRedisSerializer<WxCUserBasicInfo> j = new Jackson2JsonRedisSerializer<WxCUserBasicInfo>(WxCUserBasicInfo.class); | |||||
| ObjectMapper om = new ObjectMapper(); | |||||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
| j.setObjectMapper(om); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("objectCommonRedisTemplate") | |||||
| public RedisTemplate<String, Object> getObjectValueOperations(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, Object> template = new RedisTemplate<>(); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| Jackson2JsonRedisSerializer<Object> j = new Jackson2JsonRedisSerializer<Object>(Object.class); | |||||
| ObjectMapper om = new ObjectMapper(); | |||||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
| j.setObjectMapper(om); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashValueSerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.afterPropertiesSet(); | |||||
| return template; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,58 @@ | |||||
| package com.iformall.config; | |||||
| import java.io.IOException; | |||||
| import java.util.Optional; | |||||
| import javax.servlet.Filter; | |||||
| import javax.servlet.FilterChain; | |||||
| import javax.servlet.FilterConfig; | |||||
| import javax.servlet.ServletException; | |||||
| import javax.servlet.ServletRequest; | |||||
| import javax.servlet.ServletResponse; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| /** | |||||
| * 前后端分离RESTful接口过滤器 | |||||
| * | |||||
| * @author xuguoqin | |||||
| * | |||||
| */ | |||||
| public class RestFilter implements Filter { | |||||
| @Override | |||||
| public void init(FilterConfig filterConfig) throws ServletException { | |||||
| } | |||||
| @Override | |||||
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) | |||||
| throws IOException, ServletException { | |||||
| HttpServletRequest req = null; | |||||
| if (request instanceof HttpServletRequest) { | |||||
| req = (HttpServletRequest) request; | |||||
| } | |||||
| HttpServletResponse res = null; | |||||
| if (response instanceof HttpServletResponse) { | |||||
| res = (HttpServletResponse) response; | |||||
| } | |||||
| if (req != null && res != null) { | |||||
| //设置允许传递的参数 | |||||
| res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization"); | |||||
| //设置允许带上cookie | |||||
| res.setHeader("Access-Control-Allow-Credentials", "true"); | |||||
| String origin = Optional.ofNullable(req.getHeader("Origin")).orElse(req.getHeader("Referer")); | |||||
| //设置允许的请求来源 | |||||
| res.setHeader("Access-Control-Allow-Origin", origin); | |||||
| //设置允许的请求方法 | |||||
| res.setHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, PUT, DELETE, OPTIONS"); | |||||
| } | |||||
| chain.doFilter(request, response); | |||||
| } | |||||
| @Override | |||||
| public void destroy() { | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,24 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.http.client.ClientHttpRequestFactory; | |||||
| import org.springframework.http.client.SimpleClientHttpRequestFactory; | |||||
| import org.springframework.web.client.RestTemplate; | |||||
| @Configuration | |||||
| public class RestTemplateConfig { | |||||
| @Bean | |||||
| public RestTemplate restTemplate(ClientHttpRequestFactory factory) { | |||||
| return new RestTemplate(factory); | |||||
| } | |||||
| @Bean | |||||
| public ClientHttpRequestFactory simpleClientHttpRequestFactory() { | |||||
| SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); | |||||
| factory.setReadTimeout(5000);//ms | |||||
| factory.setConnectTimeout(10000);//ms | |||||
| return factory; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,319 @@ | |||||
| package com.iformall.config; | |||||
| import com.iformall.service.MallPermissionService; | |||||
| import com.iformall.shiro.MyRetryLimitCredentialsMatcher; | |||||
| import com.iformall.shiro.MyShiroRealm; | |||||
| import org.apache.shiro.mgt.SecurityManager; | |||||
| import org.apache.shiro.spring.LifecycleBeanPostProcessor; | |||||
| import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; | |||||
| import org.apache.shiro.spring.web.ShiroFilterFactoryBean; | |||||
| import org.apache.shiro.web.mgt.DefaultWebSecurityManager; | |||||
| import org.apache.shiro.web.servlet.SimpleCookie; | |||||
| import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; | |||||
| import org.crazycake.shiro.RedisCacheManager; | |||||
| import org.crazycake.shiro.RedisManager; | |||||
| import org.crazycake.shiro.RedisSessionDAO; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import javax.servlet.Filter; | |||||
| import javax.servlet.ServletRequest; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import java.util.LinkedHashMap; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * Created by yangqj on 2017/4/23. | |||||
| */ | |||||
| @Configuration | |||||
| public class ShiroConfig { | |||||
| @Value("${spring.redis.host}") | |||||
| private String host; | |||||
| @Value("${spring.redis.port}") | |||||
| private int port; | |||||
| @Value("${spring.redis.timeout}") | |||||
| private int timeout; | |||||
| @Value("${spring.redis.expire}") | |||||
| private int expire; | |||||
| @Value("${spring.redis.password}") | |||||
| private String password; | |||||
| @Bean | |||||
| public static LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() { | |||||
| return new LifecycleBeanPostProcessor(); | |||||
| } | |||||
| /** | |||||
| * ShiroDialect,为了在thymeleaf里使用shiro的标签的bean | |||||
| * @return | |||||
| */ | |||||
| // @Bean | |||||
| // public ShiroDialect shiroDialect() { | |||||
| // return new ShiroDialect(); | |||||
| // } | |||||
| /** | |||||
| * ShiroFilterFactoryBean 处理拦截资源文件问题。 | |||||
| * 注意:单独一个ShiroFilterFactoryBean配置是或报错的,因为在 | |||||
| * 初始化ShiroFilterFactoryBean的时候需要注入:SecurityManager | |||||
| * <p> | |||||
| * Filter Chain定义说明 | |||||
| * 1、一个URL可以配置多个Filter,使用逗号分隔 | |||||
| * 2、当设置多个过滤器时,全部验证通过,才视为通过 | |||||
| * 3、部分过滤器可指定参数,如perms,roles | |||||
| */ | |||||
| @Bean | |||||
| public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) { | |||||
| System.out.println("ShiroConfiguration.shirFilter()"); | |||||
| ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); | |||||
| // 必须设置 SecurityManager | |||||
| shiroFilterFactoryBean.setSecurityManager(securityManager); | |||||
| Map<String, Filter> filters = new LinkedHashMap<String, Filter>(); | |||||
| filters.put("token", new ShiroLoginFilter()); | |||||
| filters.put("corsFilter", new RestFilter()); | |||||
| //filters.put("authc", new MyFormAuthenticationFilter()); | |||||
| shiroFilterFactoryBean.setFilters(filters); | |||||
| // 如果不设置默认会自动寻找Web工程根目录下的"/login.jsp"页面 | |||||
| shiroFilterFactoryBean.setLoginUrl("/#/"); | |||||
| // 登录成功后要跳转的链接 | |||||
| shiroFilterFactoryBean.setSuccessUrl("/usersPage"); | |||||
| //未授权界面; | |||||
| shiroFilterFactoryBean.setUnauthorizedUrl("/403"); | |||||
| //拦截器. | |||||
| Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>(); | |||||
| //filterChainDefinitionMap.put("/ue/**", "anon"); | |||||
| //filterChainDefinitionMap.put("/config.json", "anon"); | |||||
| // login | |||||
| filterChainDefinitionMap.put("/doLogin/**", "anon"); | |||||
| filterChainDefinitionMap.put("/bHidLogin/**", "anon"); | |||||
| filterChainDefinitionMap.put("/sendLoginPhoneCode/**", "anon"); | |||||
| filterChainDefinitionMap.put("/doLoginByPhone/**", "anon"); | |||||
| filterChainDefinitionMap.put("/wechat/login", "anon"); // 微信第三方登录callback | |||||
| filterChainDefinitionMap.put("/wechat/callback", "anon"); // 微信网页登录回调 | |||||
| filterChainDefinitionMap.put("/wechat/weChatUserLogin", "anon"); // 微信第三方登录 | |||||
| // 验证码 | |||||
| filterChainDefinitionMap.put("/captcha.jpg", "anon"); | |||||
| // 官网 | |||||
| filterChainDefinitionMap.put("/wxMallApply/add", "anon"); | |||||
| // callback | |||||
| filterChainDefinitionMap.put("/wxPay/notify/**", "anon"); // 支付回调 | |||||
| filterChainDefinitionMap.put("/wxPayBill/notify/**", "anon"); | |||||
| filterChainDefinitionMap.put("/wxMsgCallback/**", "anon"); | |||||
| filterChainDefinitionMap.put("/user/sendvalidationcode", "anon"); | |||||
| filterChainDefinitionMap.put("/user/updatepwd", "anon"); | |||||
| filterChainDefinitionMap.put("/carCallback/**", "anon"); | |||||
| filterChainDefinitionMap.put("/wxMallApply/sendvalidationcode", "anon"); | |||||
| // 补发消息 | |||||
| filterChainDefinitionMap.put("/wxCoupon/updateStokeAndValidDate", "anon"); | |||||
| // static files | |||||
| filterChainDefinitionMap.put("/css/**", "anon"); | |||||
| filterChainDefinitionMap.put("/js/**", "anon"); | |||||
| filterChainDefinitionMap.put("/img/**", "anon"); | |||||
| filterChainDefinitionMap.put("/font-awesome/**", "anon"); | |||||
| //<!-- 过滤链定义,从上向下顺序执行,一般将 /**放在最为下边 -->:这是一个坑呢,一不小心代码就不好使了; | |||||
| //<!-- authc:所有url都必须认证通过才可以访问; anon:所有url都都可以匿名访问--> | |||||
| //自定义加载权限资源关系 | |||||
| // Map<String,Object> map = new HashMap<>(); | |||||
| // List<SysPermission> resourcesList = resourcesService.list(map); | |||||
| // for(SysPermission resources:resourcesList){ | |||||
| // | |||||
| // if (StringUtil.isNotEmpty(resources.getUrl())) { | |||||
| // String permission = "perms[" + resources.getUrl()+ "]"; | |||||
| // filterChainDefinitionMap.put(resources.getUrl(),permission); | |||||
| // } | |||||
| // } | |||||
| // swagger-ui | |||||
| filterChainDefinitionMap.put("/swagger-ui.html", "anon"); | |||||
| filterChainDefinitionMap.put("/doc.html", "anon"); | |||||
| filterChainDefinitionMap.put("/v2/**", "anon"); | |||||
| filterChainDefinitionMap.put("/swagger-resources/**", "anon"); | |||||
| filterChainDefinitionMap.put("/webjars/**", "anon"); | |||||
| filterChainDefinitionMap.put("/version", "anon"); | |||||
| //配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了 | |||||
| filterChainDefinitionMap.put("/logout", "authc"); | |||||
| filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||||
| // filterChainDefinitionMap.put("/**", "anon"); | |||||
| shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | |||||
| return shiroFilterFactoryBean; | |||||
| } | |||||
| public static boolean isAjax(ServletRequest request) { | |||||
| String header = ((HttpServletRequest) request).getHeader("X-Requested-With"); | |||||
| if ("XMLHttpRequest".equalsIgnoreCase(header)) { | |||||
| System.out.println("当前请求为Ajax请求"); | |||||
| return Boolean.TRUE; | |||||
| } | |||||
| System.out.println("当前请求非Ajax请求"); | |||||
| return Boolean.FALSE; | |||||
| } | |||||
| @Bean | |||||
| public SecurityManager securityManager() { | |||||
| DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); | |||||
| //设置realm. | |||||
| securityManager.setRealm(myShiroRealm()); | |||||
| // 自定义缓存实现 使用redis | |||||
| //securityManager.setCacheManager(cacheManager()); | |||||
| // 自定义session管理 使用redis | |||||
| securityManager.setSessionManager(sessionManager()); | |||||
| return securityManager; | |||||
| } | |||||
| @Bean | |||||
| public MyShiroRealm myShiroRealm() { | |||||
| MyShiroRealm myShiroRealm = new MyShiroRealm(); | |||||
| myShiroRealm.setCredentialsMatcher(hashedCredentialsMatcher()); | |||||
| return myShiroRealm; | |||||
| } | |||||
| /** | |||||
| * 密码匹配凭证管理器 凭证匹配器 | |||||
| * (由于我们的密码校验交给Shiro的SimpleAuthenticationInfo进行处理了 | |||||
| * 所以我们需要修改下doGetAuthenticationInfo中的代码; | |||||
| * ) | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| public MyRetryLimitCredentialsMatcher hashedCredentialsMatcher() { | |||||
| MyRetryLimitCredentialsMatcher hashedCredentialsMatcher = new MyRetryLimitCredentialsMatcher(); | |||||
| hashedCredentialsMatcher.setHashAlgorithmName("md5");//散列算法:这里使用MD5算法; | |||||
| hashedCredentialsMatcher.setHashIterations(2);//散列的次数,比如散列两次,相当于 md5(md5("")); | |||||
| return hashedCredentialsMatcher; | |||||
| } | |||||
| /** | |||||
| * 开启shiro aop注解支持. | |||||
| * 使用代理方式;所以需要开启代码支持; | |||||
| * | |||||
| * @param securityManager | |||||
| * @return | |||||
| */ | |||||
| @Bean | |||||
| public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) { | |||||
| AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); | |||||
| authorizationAttributeSourceAdvisor.setSecurityManager(securityManager); | |||||
| return authorizationAttributeSourceAdvisor; | |||||
| } | |||||
| /** | |||||
| * 配置shiro redisManager | |||||
| * 使用的是shiro-redis开源插件 | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| public RedisManager redisManager() { | |||||
| RedisManager redisManager = new RedisManager(); | |||||
| redisManager.setHost(host); | |||||
| redisManager.setPort(port); | |||||
| //redisManager.setExpire(expire);// 配置缓存过期时间 | |||||
| redisManager.setTimeout(timeout); | |||||
| redisManager.setPassword(password); | |||||
| return redisManager; | |||||
| } | |||||
| /** | |||||
| * cacheManager 缓存 redis实现 | |||||
| * 使用的是shiro-redis开源插件 | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| public RedisCacheManager cacheManager() { | |||||
| RedisCacheManager redisCacheManager = new RedisCacheManager(); | |||||
| redisCacheManager.setRedisManager(redisManager()); | |||||
| return redisCacheManager; | |||||
| } | |||||
| /** | |||||
| * RedisSessionDAO shiro sessionDao层的实现 通过redis | |||||
| * 使用的是shiro-redis开源插件 | |||||
| */ | |||||
| @Bean | |||||
| public RedisSessionDAO redisSessionDAO() { | |||||
| RedisSessionDAO redisSessionDAO = new RedisSessionDAO(); | |||||
| redisSessionDAO.setRedisManager(redisManager()); | |||||
| return redisSessionDAO; | |||||
| } | |||||
| /** | |||||
| * shiro session的管理 | |||||
| */ | |||||
| @Bean | |||||
| public DefaultWebSessionManager sessionManager() { | |||||
| DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); | |||||
| //设置session过期时间为1小时(单位:毫秒),默认为30分钟 | |||||
| sessionManager.setGlobalSessionTimeout(60 * 60 * 1000); | |||||
| sessionManager.setSessionValidationSchedulerEnabled(true); | |||||
| sessionManager.setSessionIdUrlRewritingEnabled(false); | |||||
| sessionManager.setSessionDAO(redisSessionDAO()); | |||||
| sessionManager.setSessionIdCookie(simpleCookie()); | |||||
| return sessionManager; | |||||
| } | |||||
| @Bean | |||||
| public SimpleCookie simpleCookie() { | |||||
| SimpleCookie simpleCookie = new SimpleCookie("SSIDS"); | |||||
| simpleCookie.setDomain(""); | |||||
| return simpleCookie; | |||||
| } | |||||
| // @Bean | |||||
| // public SimpleCookie rememberMeCookie(){ | |||||
| // //System.out.println("ShiroConfiguration.rememberMeCookie()"); | |||||
| // //这个参数是cookie的名称,对应前端的checkbox的name = rememberMe | |||||
| // SimpleCookie simpleCookie = new SimpleCookie("rememberMe"); | |||||
| // //<!-- 记住我cookie生效时间30天 ,单位秒;--> | |||||
| // simpleCookie.setMaxAge(60*30); | |||||
| // return simpleCookie; | |||||
| // } | |||||
| // @Bean | |||||
| // public CookieRememberMeManager rememberMeManager(){ | |||||
| // //System.out.println("ShiroConfiguration.rememberMeManager()"); | |||||
| // CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager(); | |||||
| // cookieRememberMeManager.setCookie(rememberMeCookie()); | |||||
| // //rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 256 512 位) | |||||
| // cookieRememberMeManager.setCipherKey(Base64.decodeBytes("2AvVhdsgUs0FSA3SDFAdag==")); | |||||
| // return cookieRememberMeManager; | |||||
| // } | |||||
| // @Bean(name = "securityManager") | |||||
| // public DefaultWebSecurityManager defaultWebSecurityManager(MyShiroRealm realm){ | |||||
| // DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); | |||||
| // //设置realm | |||||
| // securityManager.setRealm(realm); | |||||
| // //用户授权/认证信息Cache, 采用EhCache缓存 | |||||
| // securityManager.setCacheManager(cacheManager()); | |||||
| // //注入记住我管理器 | |||||
| // securityManager.setRememberMeManager(rememberMeManager()); | |||||
| // return securityManager; | |||||
| // } | |||||
| } | |||||
| @@ -0,0 +1,31 @@ | |||||
| package com.iformall.config; | |||||
| import javax.servlet.ServletRequest; | |||||
| import javax.servlet.ServletResponse; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import org.apache.shiro.web.filter.authc.FormAuthenticationFilter; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.iformall.common.ResultData; | |||||
| public class ShiroLoginFilter extends FormAuthenticationFilter { | |||||
| @Override | |||||
| protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception { | |||||
| response.setCharacterEncoding("UTF-8"); | |||||
| response.setContentType("application/json"); | |||||
| ResultData resultData = new ResultData(ResultData.UNLOGIN,"用户未登录"); | |||||
| response.getWriter().write(JSON.toJSONString(resultData)); | |||||
| return false; | |||||
| } | |||||
| /** | |||||
| * 判断ajax请求 | |||||
| * @param request | |||||
| * @return | |||||
| */ | |||||
| boolean isAjax(HttpServletRequest request){ | |||||
| return (request.getHeader("X-Requested-With") != null && "XMLHttpRequest".equals( request.getHeader("X-Requested-With").toString()) ) ; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,61 @@ | |||||
| //package com.iformall.config; | |||||
| // | |||||
| //import org.springframework.beans.factory.annotation.Autowired; | |||||
| //import org.springframework.context.annotation.Bean; | |||||
| //import org.springframework.context.annotation.Configuration; | |||||
| //import springfox.documentation.builders.ApiInfoBuilder; | |||||
| //import springfox.documentation.builders.ParameterBuilder; | |||||
| //import springfox.documentation.builders.PathSelectors; | |||||
| //import springfox.documentation.builders.RequestHandlerSelectors; | |||||
| //import springfox.documentation.schema.ModelRef; | |||||
| //import springfox.documentation.service.ApiInfo; | |||||
| //import springfox.documentation.service.Parameter; | |||||
| //import springfox.documentation.spi.DocumentationType; | |||||
| //import springfox.documentation.spring.web.paths.RelativePathProvider; | |||||
| //import springfox.documentation.spring.web.plugins.Docket; | |||||
| //import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| // | |||||
| //import javax.servlet.ServletContext; | |||||
| //import java.util.ArrayList; | |||||
| //import java.util.List; | |||||
| // | |||||
| ////参考:http://blog.csdn.net/catoop/article/details/50668896 | |||||
| //@Configuration | |||||
| //@EnableSwagger2 | |||||
| //public class Swagger2Config { | |||||
| // | |||||
| // @Autowired | |||||
| // private ServletContext servletContext; | |||||
| // | |||||
| // @Bean | |||||
| // public Docket createRestApi() { | |||||
| // ParameterBuilder tokenPar = new ParameterBuilder(); | |||||
| // List<Parameter> pars = new ArrayList<Parameter>(); | |||||
| // //增加一个request的header参数 | |||||
| // tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||||
| // pars.add(tokenPar.build()); | |||||
| // return new Docket(DocumentationType.SWAGGER_2) | |||||
| // .apiInfo(apiInfo()) | |||||
| // .select() | |||||
| // .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||||
| // .paths(PathSelectors.any()) | |||||
| // .build() | |||||
| // .globalOperationParameters(pars) | |||||
| // .pathProvider(new RelativePathProvider(servletContext) { | |||||
| // @Override | |||||
| // public String getApplicationBasePath() { | |||||
| // return "/api"; | |||||
| // } | |||||
| // }); | |||||
| // } | |||||
| // | |||||
| // private ApiInfo apiInfo() { | |||||
| // return new ApiInfoBuilder() | |||||
| // .title("a端 api") | |||||
| // .description("a api") | |||||
| // .termsOfServiceUrl("http://localhost:7000") | |||||
| // .version("2.0") | |||||
| // .build(); | |||||
| // } | |||||
| // | |||||
| //} | |||||
| @@ -0,0 +1,166 @@ | |||||
| package com.iformall.config; | |||||
| import com.fasterxml.jackson.annotation.JsonInclude; | |||||
| import com.fasterxml.jackson.databind.DeserializationConfig; | |||||
| import com.fasterxml.jackson.databind.DeserializationFeature; | |||||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||||
| import com.fasterxml.jackson.databind.module.SimpleModule; | |||||
| import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; | |||||
| import com.iformall.file.aliyun.AliyunOSS; | |||||
| import com.iformall.interceptor.CurrentTenantInterceptor; | |||||
| import com.iformall.interceptor.HttpServletRequestWrapperFilter; | |||||
| import com.iformall.interceptor.RequestInterceptor; | |||||
| import com.iformall.service.MallResourceService; | |||||
| import com.iformall.ueditor.ActionEnter; | |||||
| import com.iformall.ueditor.ConfigManager; | |||||
| import com.iformall.ueditor.UEditorConfig; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |||||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | |||||
| import org.springframework.boot.web.servlet.FilterRegistrationBean; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.http.converter.HttpMessageConverter; | |||||
| import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |||||
| import org.springframework.web.cors.CorsConfiguration; | |||||
| import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | |||||
| import org.springframework.web.filter.CharacterEncodingFilter; | |||||
| import org.springframework.web.filter.CorsFilter; | |||||
| import org.springframework.web.servlet.config.annotation.*; | |||||
| import javax.servlet.Filter; | |||||
| import java.math.BigDecimal; | |||||
| import java.math.BigInteger; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.List; | |||||
| @Configuration | |||||
| @EnableWebMvc | |||||
| @EnableConfigurationProperties({UEditorConfig.class, AwsProperty.class}) | |||||
| public class WebConfig implements WebMvcConfigurer { | |||||
| @Autowired | |||||
| private UEditorConfig uEditorConfig; | |||||
| @Autowired | |||||
| private AwsProperty awsProperty; | |||||
| @Autowired | |||||
| private RequestInterceptor requestInterceptor; | |||||
| @Autowired | |||||
| private CurrentTenantInterceptor tenantInterceptor; | |||||
| @Autowired | |||||
| private MallResourceService mallResourceService; | |||||
| @Autowired | |||||
| private AliyunOSS aliyunOSS; | |||||
| @Bean | |||||
| @ConditionalOnMissingBean(ActionEnter.class) | |||||
| public ActionEnter actionEnter() { | |||||
| ActionEnter actionEnter = new ActionEnter(ConfigManager.getInstance(uEditorConfig, awsProperty, mallResourceService, aliyunOSS)); | |||||
| return actionEnter; | |||||
| } | |||||
| @Bean | |||||
| public CorsFilter corsFilter() { | |||||
| final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); | |||||
| final CorsConfiguration corsConfiguration = new CorsConfiguration(); | |||||
| // 允许cookies跨域 | |||||
| corsConfiguration.setAllowCredentials(true); | |||||
| // 允许向该服务器提交请求的URI, *表示全部允许 | |||||
| corsConfiguration.addAllowedOrigin("*"); | |||||
| // 允许访问的头信息,*表示全部 | |||||
| corsConfiguration.addAllowedHeader("*"); | |||||
| // 允许提交请求的方法, *表示全部允许 | |||||
| corsConfiguration.addAllowedMethod("*"); | |||||
| urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration); | |||||
| return new CorsFilter(urlBasedCorsConfigurationSource); | |||||
| } | |||||
| /** | |||||
| * 用于处理编码问题 | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| @Bean("myCharacterEncodingFilter") | |||||
| public Filter characterEncodingFilter() { | |||||
| CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); | |||||
| characterEncodingFilter.setEncoding("UTF-8"); | |||||
| characterEncodingFilter.setForceEncoding(true); | |||||
| return characterEncodingFilter; | |||||
| } | |||||
| @Override | |||||
| public void addInterceptors(InterceptorRegistry registry) { | |||||
| registry.addInterceptor(requestInterceptor).addPathPatterns("/**"); | |||||
| registry.addInterceptor(tenantInterceptor).addPathPatterns("/**"); | |||||
| } | |||||
| @Override | |||||
| public void addResourceHandlers(ResourceHandlerRegistry registry) { | |||||
| // registry.addResourceHandler("swagger-ui.html") | |||||
| // .addResourceLocations("classpath:/META-INF/resources/"); | |||||
| registry.addResourceHandler("doc.html") | |||||
| .addResourceLocations("classpath:/META-INF/resources/"); | |||||
| registry.addResourceHandler("/webjars/**") | |||||
| .addResourceLocations("classpath:/META-INF/resources/webjars/"); | |||||
| // ueditor | |||||
| registry.addResourceHandler("/upload/**") | |||||
| .addResourceLocations("file:" + uEditorConfig.getUploadPath()); | |||||
| registry.addResourceHandler("/config.json").addResourceLocations("classpath:/config.json"); | |||||
| } | |||||
| @Override | |||||
| public void addCorsMappings(CorsRegistry registry) { | |||||
| registry.addMapping("/**") | |||||
| .allowedOrigins("*") | |||||
| .allowCredentials(true) | |||||
| .allowedMethods("GET", "POST", "DELETE", "PUT") | |||||
| .maxAge(3600); | |||||
| } | |||||
| @Override | |||||
| public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { | |||||
| MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); | |||||
| //ObjectMapper 是Jackson库的主要类。它提供一些功能将转换成Java对象匹配JSON结构,反之亦然 | |||||
| ObjectMapper objectMapper = new ObjectMapper(); | |||||
| SimpleModule simpleModule = new SimpleModule(); | |||||
| //不显示为null的字段 | |||||
| objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | |||||
| DeserializationConfig dc = objectMapper.getDeserializationConfig(); | |||||
| // 设置反序列化日期格式、忽略不存在get、set的属性 | |||||
| objectMapper.setConfig( | |||||
| dc.with(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) | |||||
| .without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | |||||
| ); | |||||
| //序列化将Long转String类型 | |||||
| simpleModule.addSerializer(Long.class, ToStringSerializer.instance); | |||||
| simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); | |||||
| SimpleModule bigIntegerModule = new SimpleModule(); | |||||
| //序列化将BigInteger转String类型 | |||||
| bigIntegerModule.addSerializer(BigInteger.class, ToStringSerializer.instance); | |||||
| SimpleModule bigDecimalModule = new SimpleModule(); | |||||
| //序列化将BigDecimal转String类型 | |||||
| bigDecimalModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); | |||||
| objectMapper.registerModule(simpleModule); | |||||
| objectMapper.registerModule(bigDecimalModule); | |||||
| objectMapper.registerModule(bigIntegerModule); | |||||
| jackson2HttpMessageConverter.setObjectMapper(objectMapper); | |||||
| converters.add(jackson2HttpMessageConverter); | |||||
| } | |||||
| @Bean | |||||
| public FilterRegistrationBean<HttpServletRequestWrapperFilter> Filters() { | |||||
| FilterRegistrationBean<HttpServletRequestWrapperFilter> registrationBean = new FilterRegistrationBean<HttpServletRequestWrapperFilter>(); | |||||
| registrationBean.setFilter(new HttpServletRequestWrapperFilter()); | |||||
| registrationBean.addUrlPatterns("/*"); | |||||
| registrationBean.setName("koalaSignFilter"); | |||||
| return registrationBean; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,32 @@ | |||||
| package com.iformall.config; | |||||
| import me.chanjar.weixin.mp.api.WxMpService; | |||||
| import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; | |||||
| import me.chanjar.weixin.mp.config.WxMpConfigStorage; | |||||
| import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.stereotype.Component; | |||||
| @Component | |||||
| public class WechatMpConfig { | |||||
| @Autowired | |||||
| private WechatWebProperties wechatWebProperties; | |||||
| @Bean | |||||
| public WxMpService wxMpService() { | |||||
| //创建WxMpService实例并设置appid和sectret | |||||
| WxMpService wxMpService = new WxMpServiceImpl(); | |||||
| //这里的设置方式是跟着这个sdk的文档写的 | |||||
| wxMpService.setWxMpConfigStorage(wxConfigProvider()); | |||||
| return wxMpService; | |||||
| } | |||||
| public WxMpConfigStorage wxConfigProvider(){ | |||||
| WxMpDefaultConfigImpl wxConfigProvider = new WxMpDefaultConfigImpl(); | |||||
| wxConfigProvider.setAppId(wechatWebProperties.getAppId()); | |||||
| wxConfigProvider.setSecret(wechatWebProperties.getSecret()); | |||||
| return wxConfigProvider; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,59 @@ | |||||
| package com.iformall.config; | |||||
| import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
| import org.apache.commons.lang3.builder.ToStringStyle; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import org.springframework.stereotype.Component; | |||||
| /** | |||||
| * Stormeye | |||||
| */ | |||||
| @Component | |||||
| @ConfigurationProperties(prefix = "wechat.web") | |||||
| public class WechatWebProperties { | |||||
| /** | |||||
| * 设置微信第三方平台-微信登录的web应用appid | |||||
| */ | |||||
| private String appId; | |||||
| /** | |||||
| * 设置微信第三方平台-微信登录的web应用app secret | |||||
| */ | |||||
| private String secret; | |||||
| /** | |||||
| * 网页URL | |||||
| * @return | |||||
| */ | |||||
| private String url; | |||||
| public String getAppId() { | |||||
| return appId; | |||||
| } | |||||
| public void setAppId(String appId) { | |||||
| this.appId = appId; | |||||
| } | |||||
| public String getSecret() { | |||||
| return secret; | |||||
| } | |||||
| public void setSecret(String secret) { | |||||
| this.secret = secret; | |||||
| } | |||||
| public String getUrl() { | |||||
| return url; | |||||
| } | |||||
| public void setUrl(String url) { | |||||
| this.url = url; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return ToStringBuilder.reflectionToString(this, | |||||
| ToStringStyle.MULTI_LINE_STYLE); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,88 @@ | |||||
| package com.iformall.controller.base; | |||||
| import java.beans.PropertyEditorSupport; | |||||
| import java.text.ParseException; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.Date; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.shiro.UserSession; | |||||
| import com.iformall.utils.Constant; | |||||
| import com.iformall.utils.IPUtil; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.apache.shiro.session.Session; | |||||
| import org.springframework.web.bind.WebDataBinder; | |||||
| import org.springframework.web.bind.annotation.InitBinder; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import org.springframework.web.context.request.RequestContextHolder; | |||||
| import org.springframework.web.context.request.ServletRequestAttributes; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| @RestController | |||||
| public class BaseController { | |||||
| @InitBinder | |||||
| public void InitBinder(WebDataBinder dataBinder) { | |||||
| dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { | |||||
| public void setAsText(String value) { | |||||
| try { | |||||
| setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value)); | |||||
| } catch(ParseException e) { | |||||
| try { | |||||
| setValue(new SimpleDateFormat("yyyy-MM-dd ").parse(value)); | |||||
| } catch (ParseException e1) { | |||||
| setValue(null); | |||||
| } | |||||
| } | |||||
| } | |||||
| public String getAsText() { | |||||
| return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) getValue()); | |||||
| } | |||||
| }); | |||||
| } | |||||
| public MallUserInfo getUser(){ | |||||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||||
| // MallUserInfo user = new MallUserInfo(); | |||||
| // user.setId(2L); | |||||
| // user.setName("localtest"); | |||||
| // user.setIsAdmin(1); | |||||
| return user; | |||||
| } | |||||
| public Long getUserId(){ | |||||
| Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userId); | |||||
| // Long userId = 463627091581734912L; | |||||
| return userId; | |||||
| } | |||||
| // @Deprecated | |||||
| // public String getTenantId(){ | |||||
| // String tenantId = (String)SecurityUtils.getSubject().getSession().getAttribute(UserSession.tenantId); | |||||
| // return tenantId; | |||||
| // } | |||||
| /** | |||||
| * 返回租户信息 | |||||
| * @return | |||||
| */ | |||||
| public TenantEntity getTenantInfo(){ | |||||
| Session session = SecurityUtils.getSubject().getSession(); | |||||
| String tenantId = (String)session.getAttribute(UserSession.tenantId); | |||||
| String parentTenantId = (String)session.getAttribute(UserSession.parentTenantId); | |||||
| TenantEntity tenantEntity = new TenantEntity(); | |||||
| tenantEntity.setTenantId(tenantId); | |||||
| tenantEntity.setParentTenantId(parentTenantId); | |||||
| return tenantEntity; | |||||
| } | |||||
| public String getIpAddr() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| String ipaddress = IPUtil.getIpAddr(request); | |||||
| return ipaddress; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,78 @@ | |||||
| package com.iformall.controller.base; | |||||
| import java.beans.PropertyEditorSupport; | |||||
| import java.text.ParseException; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.po.yqzj.YqzjLunBoTu; | |||||
| import com.iformall.domain.po.yqzj.YqzjNews; | |||||
| import com.iformall.domain.po.yqzj.YqzjPageNews; | |||||
| import com.iformall.domain.po.yqzj.YqzjVideo; | |||||
| import com.iformall.service.YqzjService; | |||||
| import com.iformall.shiro.UserSession; | |||||
| import com.iformall.utils.Constant; | |||||
| import com.iformall.utils.IPUtil; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.apache.shiro.session.Session; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.WebDataBinder; | |||||
| import org.springframework.web.bind.annotation.InitBinder; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import org.springframework.web.context.request.RequestContextHolder; | |||||
| import org.springframework.web.context.request.ServletRequestAttributes; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| @RestController | |||||
| public class YqzjBaseController extends BaseController{ | |||||
| @Autowired | |||||
| public YqzjService yqzjService; | |||||
| public PageInfo<YqzjLunBoTu> lunbotuPageList(YqzjLunBoTu record,int pageType,Integer pageNum, Integer pageSize) { | |||||
| record.setSortColumns("serial_number asc"); | |||||
| record.setType(pageType); | |||||
| return yqzjService.listLunBoTuAsPage(record, pageNum, pageSize); | |||||
| } | |||||
| public void saveOrUpdateLunbotu(YqzjLunBoTu record,int pageType) { | |||||
| record.setType(pageType); | |||||
| yqzjService.saveOrUpdateLunBoTu(record); | |||||
| } | |||||
| public PageInfo<YqzjPageNews> pageNewsList(YqzjPageNews record,int pageType,int newsType,Integer pageNum, Integer pageSize) { | |||||
| record.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||||
| record.setType(pageType); | |||||
| record.setNewsType(newsType); | |||||
| PageInfo<YqzjPageNews> pageinfo = yqzjService.pageNewsAsPage(record, pageNum, pageSize); | |||||
| if (null != pageinfo && null != pageinfo.getList()) { | |||||
| for (int i = 0 ; i < pageinfo.getList().size(); i++) { | |||||
| YqzjPageNews news = pageinfo.getList().get(i); | |||||
| YqzjNews yn = yqzjService.findNewsById(news.getNewsId()); | |||||
| if (null != yn) { | |||||
| news.setNewsTitle(yn.getTitle()); | |||||
| } | |||||
| } | |||||
| } | |||||
| return pageinfo; | |||||
| } | |||||
| public PageInfo<YqzjVideo> videoPageList(YqzjVideo record,int type,Integer pageNum, Integer pageSize) { | |||||
| record.setSortColumns("serial_number asc"); | |||||
| record.setType(type); | |||||
| return yqzjService.listVideoAsPage(record, pageNum, pageSize); | |||||
| } | |||||
| public void saveOrUpdateVideo(YqzjVideo record,int type) { | |||||
| record.setType(type); | |||||
| yqzjService.saveOrUpdateVideo(record); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,56 @@ | |||||
| package com.iformall.controller.basic; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.lang.reflect.Method; | |||||
| import java.util.*; | |||||
| @RestController | |||||
| @RequestMapping("enum") | |||||
| @Api(description="枚举接口") | |||||
| public class EnumController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @SystemControllerLog(description = "会员管理-标签获取") | |||||
| @ApiOperation(value="获取枚举对象", notes="根据获取枚举类名获取枚举对象") | |||||
| @GetMapping("/getEnum/{type}") | |||||
| public ResultData getEnum(@PathVariable("type") String type) { | |||||
| if(StringUtils.isBlank(type)){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| String className = "com.iformall.enums." + type; | |||||
| List<Map<String, String>> list = new ArrayList<Map<String, String>>(); | |||||
| try { | |||||
| // 1.得到枚举类对象 | |||||
| Class<Enum> clz = (Class<Enum>) Class.forName(className); | |||||
| // 2.得到所有枚举常量 | |||||
| Object[] objects = clz.getEnumConstants(); | |||||
| Method getCode = clz.getMethod("getCode"); | |||||
| Method getMessage = clz.getMethod("getMessage"); | |||||
| Map<String, String> map = null; | |||||
| for (Object obj : objects) { | |||||
| map = new HashMap<String, String>(); | |||||
| map.put("code", getCode.invoke(obj).toString()); | |||||
| map.put("message", getMessage.invoke(obj).toString()); | |||||
| list.add(map); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"数据不存在"); | |||||
| } | |||||
| if(list.size() == 0){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"数据不存在"); | |||||
| } | |||||
| return new ResultData(list); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,72 @@ | |||||
| package com.iformall.controller.basic; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.annotation.TenantIgnore; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.service.TtGoodsCategoryService; | |||||
| import com.iformall.utils.DateUtils; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("goodsCategory") | |||||
| public class TtGoodsCategoryController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private TtGoodsCategoryService ttGoodsCategoryService; | |||||
| @TenantIgnore | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("treeList") | |||||
| @ApiImplicitParams({}) | |||||
| @SystemControllerLog(description = "列表") | |||||
| public ResultData treeList() { | |||||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::treeList"); | |||||
| return new ResultData(ttGoodsCategoryService.findTreeList()); | |||||
| } | |||||
| @TenantIgnore | |||||
| @ApiOperation("查询类目") | |||||
| @GetMapping("get") | |||||
| @ApiImplicitParams({}) | |||||
| @SystemControllerLog(description = "列表") | |||||
| public ResultData categoryGet(Integer categoryId) { | |||||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::categoryGet"); | |||||
| if(categoryId == null){ | |||||
| categoryId = 0; | |||||
| } | |||||
| return new ResultData(ttGoodsCategoryService.categoryGet(categoryId)); | |||||
| } | |||||
| @TenantIgnore | |||||
| @ApiOperation("查询抖音类目") | |||||
| @GetMapping("syncGet/{token}") | |||||
| @ApiImplicitParams({}) | |||||
| @SystemControllerLog(description = "列表") | |||||
| public ResultData syncGet(@PathVariable String token) { | |||||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::get"); | |||||
| if(StringUtils.isBlank(token)){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| String systemTime = DateUtils.getSystemTime("MMdd")+"syncgc"; | |||||
| if(!systemTime.equals(token)){ | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| ttGoodsCategoryService.syncGet(); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,165 @@ | |||||
| package com.iformall.controller.basic; | |||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.annotation.UserDataRuleAnnotation; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.WxBillProperty; | |||||
| import com.iformall.domain.po.WxMallBuilding; | |||||
| import com.iformall.domain.po.WxMallFloor; | |||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxPropertyContract; | |||||
| import com.iformall.domain.po.WxRentContract; | |||||
| import com.iformall.domain.po.WxShop; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.po.base.BaseEntity.SortField; | |||||
| import com.iformall.enums.EnumContractOperationType; | |||||
| import com.iformall.enums.EnumContractType; | |||||
| import com.iformall.enums.EnumFlowContractType; | |||||
| import com.iformall.enums.EnumFlowKey; | |||||
| import com.iformall.enums.EnumIsPreview; | |||||
| import com.iformall.enums.EnumRentContractAppStatus; | |||||
| import com.iformall.enums.EnumRentContractStatus; | |||||
| import com.iformall.enums.EnumRentShopType; | |||||
| import com.iformall.enums.EnumRentStartType; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxPropertyContractMapper; | |||||
| import com.iformall.service.WxBillPropertyService; | |||||
| import com.iformall.service.WxMallBuildingService; | |||||
| import com.iformall.service.WxMallFloorService; | |||||
| import com.iformall.service.WxPropertyContractService; | |||||
| import com.iformall.service.WxRentPropertyContractService; | |||||
| import com.iformall.service.WxShopService; | |||||
| import com.iformall.video.VideoFactory; | |||||
| import com.iformall.video.entity.VideUploadResult; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("video") | |||||
| public class VideoController extends BaseController { | |||||
| private Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| VideoFactory videoFactory; | |||||
| @Autowired | |||||
| String videoType; | |||||
| /** | |||||
| * 上传视频 | |||||
| * | |||||
| * @param multiReq | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| @PostMapping(value = "/upload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||||
| @ApiOperation("上传视频") | |||||
| public ResultData upload(@RequestParam("file") MultipartFile multiReq,@RequestParam Map<String, String> param) { | |||||
| try { | |||||
| long size = multiReq.getSize(); | |||||
| String title = param.get("title"); | |||||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||||
| String fileFormat = ""; | |||||
| if (dot >= 0) { | |||||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()).toLowerCase(); | |||||
| if(StringUtils.isBlank(title)){ | |||||
| title = multiReq.getOriginalFilename().substring(0,dot); | |||||
| } | |||||
| } | |||||
| if(!fileFormat.endsWith("mp4") && !fileFormat.endsWith("mp3")){ | |||||
| return new ResultData(ErrorCode.PICTURE_ENDWIDTH_ERROR); | |||||
| } | |||||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoStream(title, multiReq.getInputStream(),fileFormat); | |||||
| result.setSize(size); | |||||
| return new ResultData(result); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 上传视频 | |||||
| * | |||||
| * @param | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| @GetMapping(value = "/uploadProgress") | |||||
| @ApiOperation("上传视频进度") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "videoId", value = "视频编号", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData uploadProgress(String videoId) { | |||||
| try { | |||||
| String result = videoFactory.getExcutor(videoType).getVedioUploadProgress(videoId); | |||||
| return new ResultData(result); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 上传视频 | |||||
| * | |||||
| * @param | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| @GetMapping(value = "/videoContentLength") | |||||
| @ApiOperation("上传视频进度") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "videoId", value = "视频编号", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData videoContentLength(String videoId) { | |||||
| try { | |||||
| String result = videoFactory.getExcutor(videoType).getVedioContentLength(videoId); | |||||
| return new ResultData(result); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||||
| } | |||||
| } | |||||
| @GetMapping(value = "/videoDetial") | |||||
| @ApiOperation("视频详情") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "videoId", value = "视频编号", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData videoDetial(String videoId) { | |||||
| try { | |||||
| VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(videoId,true); | |||||
| return new ResultData(videoDetail); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,128 @@ | |||||
| package com.iformall.controller.basic; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.annotation.TenantIgnore; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.WxBrand; | |||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.enums.EnumDelFlag; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import com.iformall.service.WxBrandService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.collections.CollectionUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("wxBrand") | |||||
| public class WxBrandController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxBrandService wxBrandService; | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "品牌-列表") | |||||
| public ResultData list(@ModelAttribute WxBrand wxBrand,Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxBrandController::list"); | |||||
| if (null == wxBrand) { | |||||
| wxBrand = new WxBrand(); | |||||
| } | |||||
| wxBrand.setTenantId(getTenantInfo().getFinalTenantId()); | |||||
| wxBrand.setSortColumns(BaseEntity.SortField.Id_DESC); | |||||
| final PageInfo<WxBrand> page = wxBrandService.listAsPage(wxBrand, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "品牌-增加") | |||||
| public ResultData add(@RequestBody WxBrand wxBrand) { | |||||
| logger.debug("[" + getIpAddr() + "] WxBrandController::add"); | |||||
| wxBrand.setTenantId(getTenantInfo().getFinalTenantId()); | |||||
| return wxBrandService.save(wxBrand); | |||||
| } | |||||
| @TenantIgnore | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "品牌-更新") | |||||
| public ResultData update(@RequestBody WxBrand wxBrand) { | |||||
| logger.debug("[" + getIpAddr() + "] WxBrandController::update"); | |||||
| if(wxBrand.getId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| if(EnumDelFlag.YES.getCode().equals(wxBrand.getIsDel())){ | |||||
| //判断是否解绑商户 | |||||
| WxMerchant wxMerchant = new WxMerchant(); | |||||
| // wxMerchant.updateTenantInfo(wxBrand); | |||||
| wxMerchant.setIsDel(EnumYesOrNo.NO.getCode()); | |||||
| wxMerchant.setBrand(wxBrand.getId()); | |||||
| } | |||||
| wxBrandService.update(wxBrand); | |||||
| return new ResultData(Result.SUCCESS, "操作成功"); | |||||
| } | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "品牌-删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxBrandController::del"); | |||||
| wxBrandService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "品牌-查找") | |||||
| public ResultData findById(Long id) { | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxBrandService.getById(id)); | |||||
| } | |||||
| @GetMapping("/queryBrand") | |||||
| @SystemControllerLog(description = "品牌-租户-全部") | |||||
| public ResultData queryBrand() { | |||||
| List<Map<String,Object>> brandList = wxBrandService.queryBrand(getTenantInfo()); | |||||
| return new ResultData(brandList); | |||||
| } | |||||
| @ApiOperation("查询品牌名称是否存在") | |||||
| @GetMapping("hasBrand") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "name", value = "name", dataType = "String", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query")}) | |||||
| @SystemControllerLog(description = "品牌-名称是否存在") | |||||
| public ResultData hasBrand(String name, Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxBrandController::hasBrand"); | |||||
| WxBrand wxBrand = new WxBrand(); | |||||
| wxBrand.setId(id); | |||||
| wxBrand.setTenantId(getTenantInfo().getFinalTenantId()); | |||||
| wxBrand.setName(name); | |||||
| return wxBrandService.hasBrand(wxBrand); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,239 @@ | |||||
| package com.iformall.controller.basic; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.WxCustomizeModule; | |||||
| import com.iformall.enums.EnumAppPlat; | |||||
| import com.iformall.enums.EnumThemeType; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import com.iformall.service.WxAppinfoService; | |||||
| import com.iformall.service.WxCustomizeModuleService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @Api(description = "CustomizeModule相关接口") | |||||
| @RequestMapping("wxCustomizeModule") | |||||
| public class WxCustomizeModuleController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxCustomizeModuleService wxCustomizeModuleService; | |||||
| @Autowired | |||||
| WxAppinfoService wxAppinfoService; | |||||
| @ApiOperation("查询CustomizeModule列表") | |||||
| @GetMapping(value = "/getDesc") | |||||
| @SystemControllerLog(description = "查询CustomizeModule列表") | |||||
| public ResultData getDesc(Integer themeType) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getDesc"); | |||||
| try { | |||||
| WxCustomizeModule wxCustomizeModule = new WxCustomizeModule(); | |||||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||||
| if(themeType == null){ | |||||
| wxCustomizeModule.setThemeType(EnumThemeType.C.getCode()); | |||||
| } | |||||
| wxCustomizeModule.setIsUsing(EnumYesOrNo.YES.getCode()); | |||||
| List<WxCustomizeModule> list = wxCustomizeModuleService.findList(wxCustomizeModule); | |||||
| String msg = ""; | |||||
| if(list == null || list.size() == 0){ | |||||
| msg = "注:当前自定义配置无数据,如须使用自定义配置,建议先同步默认配置,再进行修改"; | |||||
| }else if(list.size() < 4 || list.size() > 8){ | |||||
| msg = "注:功能按钮配置达到4个方可生效,最多可添加8个功能按钮"; | |||||
| }else{ | |||||
| msg = "注:配置已生效,请在2分钟后重新登入小程序查看"; | |||||
| } | |||||
| return new ResultData(msg); | |||||
| }catch (Exception e){ | |||||
| logger.error(e.getMessage(),e); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| @ApiOperation("查询CustomizeModule列表") | |||||
| @GetMapping(value = "/list") | |||||
| @SystemControllerLog(description = "查询CustomizeModule列表") | |||||
| public ResultData getList(@ModelAttribute WxCustomizeModule wxCustomizeModule, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getList"); | |||||
| try { | |||||
| if(wxCustomizeModule == null){ | |||||
| wxCustomizeModule = new WxCustomizeModule(); | |||||
| } | |||||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||||
| if(wxCustomizeModule.getThemeType() == null){ | |||||
| wxCustomizeModule.setThemeType(EnumThemeType.C.getCode()); | |||||
| } | |||||
| PageInfo<WxCustomizeModule> page = wxCustomizeModuleService.listAsPage(wxCustomizeModule, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| }catch (Exception e){ | |||||
| logger.error(e.getMessage(),e); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| @ApiOperation("查询CustomizeModule列表") | |||||
| @GetMapping(value = "/findDefault") | |||||
| @SystemControllerLog(description = "查询CustomizeModule列表") | |||||
| public ResultData findDefault(@ModelAttribute WxCustomizeModule wxCustomizeModule) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getList"); | |||||
| try { | |||||
| if(wxCustomizeModule == null){ | |||||
| wxCustomizeModule = new WxCustomizeModule(); | |||||
| } | |||||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||||
| if(wxCustomizeModule.getThemeType() == null){ | |||||
| wxCustomizeModule.setThemeType(EnumThemeType.C.getCode()); | |||||
| } | |||||
| WxAppinfo cAppInfo = null; | |||||
| if(EnumThemeType.C.getCode().equals(wxCustomizeModule.getThemeType())){ | |||||
| cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.WX); | |||||
| if(cAppInfo == null){ | |||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到微信C端小程序"); | |||||
| } | |||||
| }else if(EnumThemeType.TT_C.getCode().equals(wxCustomizeModule.getThemeType())){ | |||||
| cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO); | |||||
| if(cAppInfo == null){ | |||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到抖音C端小程序"); | |||||
| } | |||||
| } | |||||
| if(cAppInfo == null){ | |||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到C端小程序"); | |||||
| } | |||||
| List<WxCustomizeModule> aDefault = wxCustomizeModuleService.findDefault(wxCustomizeModule,cAppInfo); | |||||
| PageInfo<WxCustomizeModule> page = new PageInfo(aDefault); | |||||
| return new ResultData(page); | |||||
| }catch (Exception e){ | |||||
| logger.error(e.getMessage(),e); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| @ApiOperation("恢复主题默认") | |||||
| @PostMapping("/updateDefault") | |||||
| @SystemControllerLog(description = "恢复主题默认") | |||||
| public ResultData updateDefault(@RequestBody WxCustomizeModule wxCustomizeModule) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::updateDefault"); | |||||
| if(wxCustomizeModule == null){ | |||||
| wxCustomizeModule = new WxCustomizeModule(); | |||||
| } | |||||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||||
| if(wxCustomizeModule.getThemeType() == null){ | |||||
| wxCustomizeModule.setThemeType(EnumThemeType.C.getCode()); | |||||
| } | |||||
| WxAppinfo cAppInfo = null; | |||||
| if(EnumThemeType.C.getCode().equals(wxCustomizeModule.getThemeType())){ | |||||
| cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.WX); | |||||
| if(cAppInfo == null){ | |||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到微信C端小程序"); | |||||
| } | |||||
| }else if(EnumThemeType.TT_C.getCode().equals(wxCustomizeModule.getThemeType())){ | |||||
| cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO); | |||||
| if(cAppInfo == null){ | |||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到抖音C端小程序"); | |||||
| } | |||||
| } | |||||
| if(cAppInfo == null){ | |||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到C端小程序"); | |||||
| } | |||||
| return wxCustomizeModuleService.updateDefault(wxCustomizeModule,cAppInfo); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/getById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "-查询") | |||||
| public ResultData getById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getById"); | |||||
| if(id == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| WxCustomizeModule wxCustomizeModule = new WxCustomizeModule(); | |||||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||||
| wxCustomizeModule.setId(id); | |||||
| wxCustomizeModule = wxCustomizeModuleService.getById(wxCustomizeModule); | |||||
| return new ResultData(wxCustomizeModule); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "-删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::delete"); | |||||
| if(id == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| WxCustomizeModule wxCustomizeModule = new WxCustomizeModule(); | |||||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||||
| wxCustomizeModule.setId(id); | |||||
| wxCustomizeModuleService.updateDel(wxCustomizeModule); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @GetMapping("/isNew") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "-置顶") | |||||
| public ResultData isNew(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::delete"); | |||||
| if(id == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| WxCustomizeModule wxCustomizeModule = new WxCustomizeModule(); | |||||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||||
| wxCustomizeModule.setId(id); | |||||
| wxCustomizeModule.setSort(0); | |||||
| wxCustomizeModuleService.saveOrUpdate(wxCustomizeModule); | |||||
| return new ResultData(Result.SUCCESS, "置顶成功", null); | |||||
| } | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "-添加") | |||||
| public ResultData add(@RequestBody WxCustomizeModule wxCustomizeModule) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::add"); | |||||
| if(wxCustomizeModule == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||||
| if(wxCustomizeModule.getThemeType() == null){ | |||||
| wxCustomizeModule.setThemeType(EnumThemeType.C.getCode()); | |||||
| } | |||||
| WxCustomizeModule wxCustomizeModuleQ = new WxCustomizeModule(); | |||||
| wxCustomizeModuleQ.updateTenantInfo(wxCustomizeModule); | |||||
| wxCustomizeModuleQ.setThemeType(wxCustomizeModule.getThemeType()); | |||||
| wxCustomizeModuleQ.setIsUsing(EnumYesOrNo.YES.getCode()); | |||||
| List<WxCustomizeModule> list = wxCustomizeModuleService.findList(wxCustomizeModuleQ); | |||||
| if(list != null && list.size() >= 8){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"当前已超限,最多可添加8条"); | |||||
| } | |||||
| wxCustomizeModuleService.saveOrUpdate(wxCustomizeModule); | |||||
| return new ResultData(); | |||||
| } | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "更新") | |||||
| public ResultData update(@RequestBody WxCustomizeModule wxCustomizeModule) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::update"); | |||||
| if(wxCustomizeModule == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||||
| wxCustomizeModuleService.saveOrUpdate(wxCustomizeModule); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,73 @@ | |||||
| package com.iformall.controller.basic; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxGroup; | |||||
| import com.iformall.service.WxGroupService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxGroup") | |||||
| public class WxGroupController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxGroupService wxGroupService; | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "集团-列表") | |||||
| public ResultData list(@ModelAttribute WxGroup wxGroup, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxGroupController::list"); | |||||
| if (null == wxGroup) wxGroup = new WxGroup(); | |||||
| final PageInfo<WxGroup> page = wxGroupService.listAsPage(wxGroup, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "集团-添加") | |||||
| public ResultData add(@RequestBody WxGroup wxGroup) { | |||||
| logger.debug("[" + getIpAddr() + "] WxGroupController::add"); | |||||
| //Assert.notNull(wxGroup.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxGroupService.saveOrUpdate(wxGroup); | |||||
| return new ResultData(); | |||||
| } | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "集团-更新") | |||||
| public ResultData update(@RequestBody WxGroup wxGroup) { | |||||
| logger.debug("[" + getIpAddr() + "] WxGroupController::update"); | |||||
| wxGroupService.saveOrUpdate(wxGroup); | |||||
| return new ResultData(); | |||||
| } | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "集团-删除") | |||||
| public ResultData delete(String id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxGroupController::delete"); | |||||
| wxGroupService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "集团-查询") | |||||
| public ResultData findById(String id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxGroupController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxGroupService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,88 @@ | |||||
| package com.iformall.controller.basic; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxMallBuilding; | |||||
| import com.iformall.domain.po.WxMallFloor; | |||||
| import com.iformall.service.WxMallBuildingService; | |||||
| import com.iformall.utils.Constant; | |||||
| import com.iformall.utils.RedisCacheUtils; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("wxMallBuilding") | |||||
| public class WxMallBuildingController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMallBuildingService wxMallBuildingService; | |||||
| @Autowired | |||||
| @Qualifier("objectCommonRedisTemplate") | |||||
| RedisTemplate<String, Object> objectCommonRedisTemplate; | |||||
| @ApiOperation("获取楼层楼座数据") | |||||
| @GetMapping("getbuildingfloorlist") | |||||
| @SystemControllerLog(description = "商城-楼座-获取楼层楼座数据") | |||||
| public ResultData getbuildingfloorlist() { | |||||
| logger.debug("[" + getIpAddr() + "] WxMallBuildingController::getbuildingfloorlist"); | |||||
| return wxMallBuildingService.getBuildingFloorList(getTenantInfo()); | |||||
| } | |||||
| @ApiOperation("保存楼层楼座地图") | |||||
| @PostMapping("saveFloorImg") | |||||
| @SystemControllerLog(description = "商城-楼座/楼层-保存地图") | |||||
| public ResultData saveFloorImg(@RequestBody List<WxMallBuilding> record) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMallBuildingController::addBuildingAndFloor"); | |||||
| if(record == null && record.size() > 0) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| for (WxMallBuilding building: record) { | |||||
| List<WxMallFloor> floors = building.getFloors(); | |||||
| if(floors != null && floors.size() > 0){ | |||||
| for (WxMallFloor floor:floors) { | |||||
| if (floor.getId() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| floor.updateTenantInfo(getTenantInfo()); | |||||
| wxMallBuildingService.saveFloorImg(floor); | |||||
| } | |||||
| } | |||||
| } | |||||
| String key = Constant.mallBuildingPrev + getTenantInfo().getTenantId(); | |||||
| RedisCacheUtils.removeCache(objectCommonRedisTemplate, key); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("保存楼层楼座面积") | |||||
| @PostMapping("saveFloorArea") | |||||
| @SystemControllerLog(description = "商城-楼座/楼层-保存面积") | |||||
| public ResultData saveFloorArea(@RequestBody WxMallFloor record) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMallBuildingController::addBuildingAndFloor"); | |||||
| if(record == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| if (record.getId() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| if (record.getTotalArea() == null && record.getOperatingArea() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| record.updateTenantInfo(getTenantInfo()); | |||||
| wxMallBuildingService.saveFloorArea(record); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,100 @@ | |||||
| package com.iformall.controller.basic; | |||||
| import com.google.code.kaptcha.Constants; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxMall; | |||||
| import com.iformall.enums.EnumGroupSupport; | |||||
| import com.iformall.service.WxMallService; | |||||
| import com.iformall.utils.ShiroUtils; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.io.IOUtils; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.imageio.ImageIO; | |||||
| import javax.servlet.ServletException; | |||||
| import javax.servlet.ServletOutputStream; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.awt.image.BufferedImage; | |||||
| import java.io.IOException; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("wxMall") | |||||
| public class WxMallController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMallService wxMallService; | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "商城-更新") | |||||
| public ResultData update(@RequestBody WxMall wxMall) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMallController::update"); | |||||
| wxMallService.update(wxMall); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/mallinfoExt") | |||||
| @SystemControllerLog(description = "商城-查询") | |||||
| public ResultData mallinfoExt() { | |||||
| logger.debug("[" + getIpAddr() + "] WxMallController::mallinfoExt"); | |||||
| return new ResultData(wxMallService.getByTenantInfoExt(getTenantInfo())); | |||||
| } | |||||
| @ApiOperation("查询当前mall的信息") | |||||
| @GetMapping("/mallinfo") | |||||
| @SystemControllerLog(description = "商城-当前查询") | |||||
| public ResultData mallinfo() { | |||||
| logger.debug("[" + getIpAddr() + "] WxMallController::mallinfo"); | |||||
| WxMall mall = wxMallService.getByTenantInfo(getUser()); | |||||
| if(mall == null) { | |||||
| logger.error("未配置相应的mall"); | |||||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||||
| } | |||||
| if (wxMallService.isgroupSupport(mall)) { | |||||
| mall.setSubMalls(wxMallService.getSubByParentTenantId(mall.getTenantId())); | |||||
| } | |||||
| mall.setValidPrompt(wxMallService.mallValid(getUserId(),mall)); | |||||
| return new ResultData(mall); | |||||
| } | |||||
| @ApiOperation("查询当前mall的子广场") | |||||
| @GetMapping("/childMall") | |||||
| @SystemControllerLog(description = "商城-当前查询") | |||||
| public ResultData childMall() { | |||||
| logger.debug("[" + getIpAddr() + "] WxMallController::childMall"); | |||||
| WxMall mall = wxMallService.getByTenantInfo(getUser()); | |||||
| if(mall == null) { | |||||
| logger.error("未配置相应的mall"); | |||||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||||
| } | |||||
| if (wxMallService.isgroupSupport(mall)) { | |||||
| List<WxMall> childMall = wxMallService.getSubByParentTenantId(mall.getTenantId()); | |||||
| return new ResultData(childMall); | |||||
| } | |||||
| return new ResultData(Result.ERROR, "未查询到子广场"); | |||||
| } | |||||
| @ApiOperation("验证码") | |||||
| @GetMapping("/imgUrlH") | |||||
| public ResultData imgUrlH(){ | |||||
| logger.debug("[" + getIpAddr() + "] WxMallController::imgUrlH"); | |||||
| WxMall mall = wxMallService.getByTenantInfo(getUser()); | |||||
| if(mall == null) { | |||||
| logger.error("未配置相应的mall"); | |||||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||||
| } | |||||
| return new ResultData(mall.getImgUrlH()); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,52 @@ | |||||
| package com.iformall.controller.basic; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxMerchantBUser; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.service.WxMerchantBUserService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxMerchantBUser") | |||||
| public class WxMerchantBUserController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMerchantBUserService wxMerchantBUserService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("listVo") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "商户-列表") | |||||
| public ResultData listVo(@ModelAttribute WxMerchantBUser wxMerchantBUser, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::list"); | |||||
| if (null == wxMerchantBUser) wxMerchantBUser = new WxMerchantBUser(); | |||||
| wxMerchantBUser.updateTenantInfo(getTenantInfo()); | |||||
| wxMerchantBUser.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||||
| final PageInfo<WxMerchantBUser> page = wxMerchantBUserService.listAsPage(wxMerchantBUser, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("手机号是否存在") | |||||
| @GetMapping("/hasphone") | |||||
| @ApiImplicitParam(name = "phone", value = "phone", dataType = "String", paramType = "query", required = true) | |||||
| public ResultData hasPhone(String phone) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::hasphone"); | |||||
| boolean has = wxMerchantBUserService.hasPhone(getTenantInfo(), phone); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", has); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,40 @@ | |||||
| package com.iformall.controller.basic; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxMerchantShop; | |||||
| import com.iformall.domain.po.WxShop; | |||||
| import com.iformall.service.WxMerchantShopService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxMerchantShop") | |||||
| public class WxMerchantShopController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMerchantShopService wxMerchantShopService; | |||||
| @ApiOperation("获取关联商铺信息") | |||||
| @GetMapping("queryShopList") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "商户商铺--获取关联商铺信息") | |||||
| public ResultData queryShopList(@ModelAttribute WxMerchantShop wxMerchantShop, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMerchantShopController::queryShopList"); | |||||
| if (null == wxMerchantShop) wxMerchantShop = new WxMerchantShop(); | |||||
| wxMerchantShop.updateTenantInfo(getTenantInfo()); | |||||
| final PageInfo<WxShop> page = wxMerchantShopService.queryShopList(wxMerchantShop, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,168 @@ | |||||
| package com.iformall.controller.basic; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.annotation.TenantIgnore; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.service.*; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @Api(description = "MiniappTheme相关接口") | |||||
| @RequestMapping("wxMiniappTheme") | |||||
| public class WxMiniappThemeController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxMiniappThemeService wxMiniappThemeService; | |||||
| @Autowired | |||||
| WxAppinfoService wxAppinfoService; | |||||
| @ApiOperation("查询MiniappTheme列表") | |||||
| @GetMapping(value = "/list") | |||||
| @SystemControllerLog(description = "查询MiniappTheme列表") | |||||
| @TenantIgnore | |||||
| public ResultData getList(@ModelAttribute WxMiniappTheme wxMiniappTheme, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::getList"); | |||||
| try { | |||||
| if(wxMiniappTheme == null){ | |||||
| wxMiniappTheme = new WxMiniappTheme(); | |||||
| } | |||||
| wxMiniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||||
| if(wxMiniappTheme.getType() == null){ | |||||
| wxMiniappTheme.setType(EnumThemeType.C.getCode()); | |||||
| } | |||||
| if(EnumThemeType.C.getCode().equals(wxMiniappTheme.getType())){ | |||||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.WX); | |||||
| if(cAppInfo == null){ | |||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到微信C端小程序"); | |||||
| } | |||||
| wxMiniappTheme.setMouldType(cAppInfo.getMouldType()); | |||||
| }else if(EnumThemeType.TT_C.getCode().equals(wxMiniappTheme.getType())){ | |||||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO); | |||||
| if(cAppInfo == null){ | |||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到抖音C端小程序"); | |||||
| } | |||||
| wxMiniappTheme.setMouldType(cAppInfo.getMouldType()); | |||||
| } | |||||
| if(wxMiniappTheme.getMouldType() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请先确认模板类型"); | |||||
| } | |||||
| PageInfo<WxMiniappTheme> page = wxMiniappThemeService.listAsPage(wxMiniappTheme, pageNum, pageSize); | |||||
| if(page.getList() != null && page.getList().size() > 0){ | |||||
| WxThemeMall wxThemeMall = new WxThemeMall(); | |||||
| wxThemeMall.setTenantId(getTenantInfo().getTenantId()); | |||||
| wxThemeMall.setThemeType(wxMiniappTheme.getType()); | |||||
| wxThemeMall.setMouldType(wxMiniappTheme.getMouldType()); | |||||
| WxThemeMall themeMall = wxMiniappThemeService.findThemeMall(wxThemeMall); | |||||
| boolean updateStatus = true; | |||||
| if(themeMall != null){ | |||||
| for (WxMiniappTheme theme:page.getList()) { | |||||
| if(theme.getId().equals(themeMall.getThemeId())){ | |||||
| theme.setStatus(0); | |||||
| updateStatus = false; | |||||
| }else{ | |||||
| theme.setStatus(1); | |||||
| } | |||||
| } | |||||
| } | |||||
| if(updateStatus){ | |||||
| page.getList().get(0).setStatus(0); | |||||
| } | |||||
| } | |||||
| return new ResultData(page); | |||||
| }catch (Exception e){ | |||||
| logger.error(e.getMessage(),e); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| @ApiOperation("根据id使之生效") | |||||
| @PostMapping("/updateEffect") | |||||
| @ApiImplicitParam(name = "themeId", value = "themeId", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "根据id使之生效") | |||||
| @TenantIgnore | |||||
| public ResultData updateEffect(@RequestBody WxThemeMall wxThemeMall) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::updateEffect"); | |||||
| if(wxThemeMall == null || wxThemeMall.getThemeId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| WxMiniappTheme miniappTheme = new WxMiniappTheme(); | |||||
| miniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||||
| miniappTheme.setId(wxThemeMall.getThemeId()); | |||||
| WxMiniappTheme theme = wxMiniappThemeService.selectById(miniappTheme); | |||||
| if(theme == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| wxThemeMall.setTenantId(getTenantInfo().getTenantId()); | |||||
| wxThemeMall.setMouldType(theme.getMouldType()); | |||||
| wxThemeMall.setThemeType(theme.getType()); | |||||
| wxMiniappThemeService.updateEffect(wxThemeMall); | |||||
| return new ResultData(Result.SUCCESS); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "-删除") | |||||
| @TenantIgnore | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::delete"); | |||||
| if(id == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| wxMiniappThemeService.updateDel(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "-添加") | |||||
| @TenantIgnore | |||||
| public ResultData add(@RequestBody WxMiniappTheme wxMiniappTheme) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::add"); | |||||
| if(wxMiniappTheme == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| wxMiniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||||
| if(wxMiniappTheme.getType() == null){ | |||||
| wxMiniappTheme.setType(EnumThemeType.C.getCode()); | |||||
| } | |||||
| if(wxMiniappTheme.getMouldType() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"请确认模板类型"); | |||||
| } | |||||
| wxMiniappThemeService.saveOrUpdate(wxMiniappTheme); | |||||
| return new ResultData(); | |||||
| } | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "-更新") | |||||
| public ResultData update(@RequestBody WxMiniappTheme wxMiniappTheme) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::update"); | |||||
| if(wxMiniappTheme == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| wxMiniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||||
| wxMiniappThemeService.saveOrUpdate(wxMiniappTheme); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,209 @@ | |||||
| package com.iformall.controller.basic; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.annotation.TenantIgnore; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.WxShop; | |||||
| import com.iformall.service.WxShopService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("wxShop") | |||||
| public class WxShopController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxShopService wxShopService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "店铺管理-列表") | |||||
| public ResultData list(@ModelAttribute WxShop wxShop, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::list"); | |||||
| if (null == wxShop){ | |||||
| wxShop = new WxShop(); | |||||
| } | |||||
| wxShop.updateTenantInfo(getTenantInfo()); | |||||
| wxShop.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC); | |||||
| final PageInfo<Map<String, Object>> page = wxShopService.listMapAsPage(wxShop, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "店铺管理-新增") | |||||
| public ResultData add(@RequestBody WxShop wxShop) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::add"); | |||||
| wxShop.updateTenantInfo(getTenantInfo()); | |||||
| return wxShopService.saveOrUpdate(wxShop); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "店铺管理-更新") | |||||
| public ResultData update(@RequestBody WxShop wxShop) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::update"); | |||||
| if (null == wxShop){ | |||||
| wxShop = new WxShop(); | |||||
| } | |||||
| wxShop.updateTenantInfo(getTenantInfo()); | |||||
| return wxShopService.saveOrUpdate(wxShop); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @SystemControllerLog(description = "店铺管理-删除") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::delete"); | |||||
| Integer isAdmin = getUser().getIsAdmin(); | |||||
| return wxShopService.deleteById(id, isAdmin); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "店铺管理-id查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxShopService.getById(id)); | |||||
| } | |||||
| @ApiOperation("获取商铺数据") | |||||
| @GetMapping("getShopListByShopNumber") | |||||
| @ApiImplicitParam(name = "shopNumber", value = "shopNumber", dataType = "String", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "店铺管理-获取商铺数据") | |||||
| public ResultData getShoplist(String shopNumber) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::getbshoplist"); | |||||
| return wxShopService.getShopList(getTenantInfo(), shopNumber); | |||||
| } | |||||
| @ApiOperation("获取商户商铺数据") | |||||
| @GetMapping("getMerchantShopByShopId") | |||||
| @ApiImplicitParam(name = "shopId", value = "shopId", dataType = "String", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "店铺管理-获取商户商铺数据") | |||||
| public ResultData getMerchantShopByShopId(String shopId) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::getMerchantShopByShopId"); | |||||
| return wxShopService.getMerchantShopByShopId(getTenantInfo(), shopId); | |||||
| } | |||||
| @ApiOperation("查询商铺号是否存在") | |||||
| @GetMapping("hasShopNumber") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "shopNumber", value = "shopNumber", dataType = "String", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query"), | |||||
| @ApiImplicitParam(name = "type", value = "type", dataType = "Integer", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "店铺管理-查询商铺号是否存在") | |||||
| public ResultData hasShopNumber(String shopNumber, Long id, Integer type) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::hasShopNumber"); | |||||
| WxShop wxShop = new WxShop(); | |||||
| wxShop.setShopNumber(shopNumber); | |||||
| wxShop.setType(type); | |||||
| wxShop.setId(id); | |||||
| wxShop.updateTenantInfo(getTenantInfo()); | |||||
| return wxShopService.hasShopNumber(wxShop); | |||||
| } | |||||
| @ApiOperation("查询商铺地图sid是否存在") | |||||
| @GetMapping("hasShopSid") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "shopNumber", value = "shopNumber", dataType = "String", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query"), | |||||
| @ApiImplicitParam(name = "type", value = "type", dataType = "Integer", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "店铺管理-查询商铺号是否存在") | |||||
| public ResultData hasShopSid(String shopSid, Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::hasShopSid"); | |||||
| WxShop wxShop = new WxShop(); | |||||
| wxShop.setSid(shopSid); | |||||
| wxShop.setId(id); | |||||
| wxShop.updateTenantInfo(getTenantInfo()); | |||||
| return wxShopService.hasShopSid(wxShop); | |||||
| } | |||||
| @ApiOperation("分页列表接品-合同访问") | |||||
| @GetMapping("listShopFromContract") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "店铺管理-合同访问") | |||||
| public ResultData listShopFromContract(@ModelAttribute WxShop wxShop, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::listShopFromContract"); | |||||
| if (null == wxShop){ | |||||
| wxShop = new WxShop(); | |||||
| } | |||||
| wxShop.updateTenantInfo(getTenantInfo()); | |||||
| wxShop.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC); | |||||
| final PageInfo<Map<String, Object>> page = wxShopService.listShopFromContract(wxShop, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("导出店铺") | |||||
| @GetMapping("/exportShop") | |||||
| @SystemControllerLog(description = "店铺管理-导出店铺") | |||||
| public void exportShop(@ModelAttribute WxShop wxShop, HttpServletRequest request, HttpServletResponse response) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::exportShop"); | |||||
| if (null == wxShop){ | |||||
| wxShop = new WxShop(); | |||||
| } | |||||
| wxShop.updateTenantInfo(getTenantInfo()); | |||||
| wxShop.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC); | |||||
| wxShopService.exportShop(wxShop, request, response); | |||||
| } | |||||
| @TenantIgnore | |||||
| @ApiOperation("导出未出租店铺") | |||||
| @GetMapping("/exportNotRentShop") | |||||
| @SystemControllerLog(description = "商铺出租数据-未出租商铺列表-导出") | |||||
| public void exportNotRentShop(@ModelAttribute WxShop wxShop, HttpServletRequest request, HttpServletResponse response) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::exportNotRentShop"); | |||||
| if (null == wxShop){ | |||||
| wxShop = new WxShop(); | |||||
| } | |||||
| wxShop.updateTenantInfo(getTenantInfo()); | |||||
| wxShop.setSortColumns(BaseEntity.SortField.SCreateDate_DESC,BaseEntity.SortField.SId_DESC); | |||||
| wxShopService.exportNotRentShop(wxShop, request, response); | |||||
| } | |||||
| @TenantIgnore | |||||
| @ApiOperation("未出租商铺分页列表接口") | |||||
| @GetMapping("notRentShopList") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "未出租商铺分页列表接口") | |||||
| public ResultData notRentShopList(@ModelAttribute WxShop wxShop, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxShopController::notRentShopList"); | |||||
| if (null == wxShop){ | |||||
| wxShop = new WxShop(); | |||||
| } | |||||
| wxShop.updateTenantInfo(getTenantInfo()); | |||||
| wxShop.setSortColumns(BaseEntity.SortField.SCreateDate_DESC,BaseEntity.SortField.SId_DESC); | |||||
| final PageInfo<Map<String, Object>> page = wxShopService.notRentListMapAsPage(wxShop, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,42 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.PushLimit; | |||||
| import com.iformall.service.PushLimitService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("pushLimit") | |||||
| @Api(description = "疲劳度相关接口") | |||||
| public class PushLimitController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private PushLimitService pushLimitService; | |||||
| @ApiOperation("疲劳度配置") | |||||
| @GetMapping("setting") | |||||
| @SystemControllerLog(description = "疲劳度-配置获取") | |||||
| public ResultData list() { | |||||
| logger.debug("[" + getIpAddr() + "] PushLimitController::list"); | |||||
| PushLimit pushLimit = pushLimitService.getPushLimit(getTenantInfo()); | |||||
| return new ResultData(pushLimit); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "疲劳度-配置更新") | |||||
| public ResultData update(@RequestBody PushLimit pushLimit) { | |||||
| logger.debug("[" + getIpAddr() + "] PushLimitController::update"); | |||||
| pushLimit.updateTenantInfo(getTenantInfo()); | |||||
| pushLimitService.saveOrUpdate(pushLimit); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.iformall.ueditor.ActionEnter; | |||||
| import io.swagger.annotations.Api; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.ResponseBody; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| @RestController | |||||
| @RequestMapping("/ue") | |||||
| @Api(description = "网页bannner图接口") | |||||
| public class UeditorController { | |||||
| @Autowired | |||||
| private ActionEnter actionEnter; | |||||
| @ResponseBody | |||||
| @RequestMapping("/ueditor/exec") | |||||
| public Object exe(HttpServletRequest request){ | |||||
| return actionEnter.exec(request); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,132 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.WxActivity; | |||||
| import com.iformall.enums.EnumActivityStatus; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.WxActivityService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("wxActivity") | |||||
| @Api(description = "活动") | |||||
| public class WxActivityController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxActivityService wxActivityService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "活动-列表") | |||||
| public ResultData list(@ModelAttribute WxActivity wxActivity, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityController::list"); | |||||
| if (null == wxActivity) wxActivity = new WxActivity(); | |||||
| if (wxActivity.getStatus() != null && wxActivity.getStatus() == -1) { | |||||
| wxActivity.setStatus(null); | |||||
| } | |||||
| wxActivity.updateTenantInfo(getTenantInfo()); | |||||
| wxActivity.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||||
| final PageInfo<WxActivity> page = wxActivityService.listAsPage(wxActivity, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "活动-新增") | |||||
| public ResultData add(@RequestBody WxActivity wxActivity) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityController::add"); | |||||
| wxActivity.setStatus(EnumActivityStatus.STATUS_THROW_IN.getCode()); | |||||
| wxActivity.updateTenantInfo(getTenantInfo()); | |||||
| try { | |||||
| return wxActivityService.saveOrUpdate(wxActivity); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "活动-id更新") | |||||
| public ResultData update(@RequestBody WxActivity wxActivity) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityController::update"); | |||||
| try { | |||||
| return wxActivityService.saveOrUpdate(wxActivity); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("updateStatus") | |||||
| @SystemControllerLog(description = "活动-更新状态") | |||||
| public ResultData updateStatus(@RequestBody WxActivity wxActivity) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityController::updateStatus"); | |||||
| try { | |||||
| return wxActivityService.updateStatus(wxActivity); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "活动-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityController::findById"); | |||||
| WxActivity wxActivity = wxActivityService.getById(id); | |||||
| return new ResultData(wxActivity); | |||||
| } | |||||
| @ApiOperation("投放到宣传页") | |||||
| @GetMapping("/sendToCampaign") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "活动-投放到宣传页") | |||||
| public ResultData sendToCampaign(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityController::sendToCampaign"); | |||||
| return wxActivityService.sendToCampaign(id); | |||||
| } | |||||
| @ApiOperation("从宣传页下线") | |||||
| @PostMapping("offLineCampaign") | |||||
| @SystemControllerLog(description = "活动-更新状态") | |||||
| public ResultData offLineCampaign(@RequestBody WxActivity wxActivity) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityController::updateStatus"); | |||||
| return wxActivityService.offLineCampaign(wxActivity); | |||||
| } | |||||
| @ApiOperation("删除") | |||||
| @PostMapping("deleteById") | |||||
| @SystemControllerLog(description = "活动-删除") | |||||
| public ResultData deleteById(@RequestBody WxActivity wxActivity) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityController::deleteById"); | |||||
| if(wxActivity.getId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| return wxActivityService.deleteById(wxActivity.getId(),getTenantInfo().getTenantId()); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,114 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.WxActivityJoin; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.WxActivityJoinService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("wxActivityJoin") | |||||
| @Api(description = "活动参与信息") | |||||
| public class WxActivityJoinController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxActivityJoinService wxActivityJoinService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "活动参与信息-列表") | |||||
| public ResultData list(@ModelAttribute WxActivityJoin wxActivityJoin, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityJoinController::list"); | |||||
| if (null == wxActivityJoin) { | |||||
| wxActivityJoin = new WxActivityJoin(); | |||||
| } | |||||
| wxActivityJoin.updateTenantInfo(getTenantInfo()); | |||||
| wxActivityJoin.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||||
| final PageInfo<WxActivityJoin> page = wxActivityJoinService.listAsPage(wxActivityJoin, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("确认或取消报名") | |||||
| @PostMapping("modifyStatus") | |||||
| @SystemControllerLog(description = "活动参与信息-确认或取消报名") | |||||
| public ResultData modifyStatus(@RequestBody WxActivityJoin wxActivityJoin) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityJoinController::modifyStatus"); | |||||
| if (wxActivityJoin.getId() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id不能为空"); | |||||
| } | |||||
| if (wxActivityJoin.getActivityId() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "activityId不能为空"); | |||||
| } | |||||
| if (wxActivityJoin.getStatus() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "status不能为空"); | |||||
| } | |||||
| try { | |||||
| return wxActivityJoinService.modifyStatus(wxActivityJoin); | |||||
| } catch (MallinkException e) { | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("导出报名表") | |||||
| @RequestMapping("/exportData") | |||||
| @SystemControllerLog(description = "活动参与信息-导出报名表") | |||||
| public void exportData(@ModelAttribute WxActivityJoin wxActivityJoin, HttpServletRequest request, HttpServletResponse response) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityJoinController::exportData"); | |||||
| if (wxActivityJoin.getActivityId() == null) { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "activityId不能为空"); | |||||
| } | |||||
| wxActivityJoin.updateTenantInfo(getTenantInfo()); | |||||
| wxActivityJoinService.exportData(request, response, wxActivityJoin); | |||||
| } | |||||
| @ApiOperation("查询报名总数") | |||||
| @GetMapping("queryJoinInfo") | |||||
| @SystemControllerLog(description = "活动参与信息-查询报名总数") | |||||
| public ResultData queryJoinInfo(@ModelAttribute WxActivityJoin wxActivityJoin) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityJoinController::queryJoinInfo"); | |||||
| if (wxActivityJoin.getActivityId() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "activityId不能为空"); | |||||
| } | |||||
| wxActivityJoin.updateTenantInfo(getTenantInfo()); | |||||
| return wxActivityJoinService.queryJoinInfo(wxActivityJoin); | |||||
| } | |||||
| @ApiOperation("发送短信") | |||||
| @GetMapping("sendMsg") | |||||
| @SystemControllerLog(description = "活动参与信息-发送短信") | |||||
| public ResultData sendMsg(@ModelAttribute WxActivityJoin wxActivityJoin) { | |||||
| logger.debug("[" + getIpAddr() + "] WxActivityJoinController::confirmCompletion"); | |||||
| if (wxActivityJoin.getActivityId() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "activityId不能为空"); | |||||
| } | |||||
| wxActivityJoin.updateTenantInfo(getTenantInfo()); | |||||
| return wxActivityJoinService.sendMsg(wxActivityJoin); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,81 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxCouponActionLog; | |||||
| import com.iformall.service.WxCouponActionLogService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxCouponActionLog") | |||||
| @Api(description = "发券行为记录接口") | |||||
| public class WxCouponActionLogController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxCouponActionLogService wxCouponActionLogService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "注券记录-图表") | |||||
| public ResultData list(@ModelAttribute WxCouponActionLog wxCouponActionLog, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::list"); | |||||
| if (null == wxCouponActionLog) wxCouponActionLog = new WxCouponActionLog(); | |||||
| final PageInfo<WxCouponActionLog> page = wxCouponActionLogService.listAsPage(wxCouponActionLog, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "注券记录-新增") | |||||
| public ResultData add(@RequestBody WxCouponActionLog wxCouponActionLog) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::add"); | |||||
| //Assert.notNull(wxCouponActionLog.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxCouponActionLogService.saveOrUpdate(wxCouponActionLog); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "注券记录-更新") | |||||
| public ResultData update(@RequestBody WxCouponActionLog wxCouponActionLog) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::update"); | |||||
| wxCouponActionLogService.saveOrUpdate(wxCouponActionLog); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "注券记录-删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::delete"); | |||||
| wxCouponActionLogService.deleteById(id,getTenantInfo().getTenantId()); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "注券记录-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxCouponActionLogService.getById(id,getTenantInfo().getTenantId())); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,71 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxCouponCar; | |||||
| import com.iformall.service.WxCouponCarService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxCouponCar") | |||||
| @Api(description = "停车券接口") | |||||
| public class WxCouponCarController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxCouponCarService wxCouponCarService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "停车券-列表") | |||||
| public ResultData list(@ModelAttribute WxCouponCar wxCouponCar, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponCarController::list"); | |||||
| if (null == wxCouponCar) wxCouponCar = new WxCouponCar(); | |||||
| final PageInfo<WxCouponCar> page = wxCouponCarService.listAsPage(wxCouponCar, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "停车券-新增") | |||||
| public ResultData add(@RequestBody WxCouponCar wxCouponCar) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponCarController::add"); | |||||
| //Assert.notNull(wxCouponCar.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxCouponCarService.save(wxCouponCar); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "停车券-更新") | |||||
| public ResultData update(@RequestBody WxCouponCar wxCouponCar) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponCarController::update"); | |||||
| wxCouponCarService.update(wxCouponCar); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "停车券-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponCarController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxCouponCarService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,83 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.WxCouponPassword; | |||||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||||
| import com.iformall.service.WxCouponPasswordService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("couponPassword") | |||||
| @Api(description = "免费卡接口") | |||||
| public class WxCouponPasswordController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxCouponPasswordService wxCouponPasswordService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("/list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "列表") | |||||
| public ResultData list(@ModelAttribute WxCouponPassword wxCouponPassword, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::list"); | |||||
| wxCouponPassword.updateTenantInfo(getTenantInfo()); | |||||
| wxCouponPassword.setSortColumns(BaseEntity.SortField.CreateDate_DESC, BaseEntity.SortField.Id_DESC); | |||||
| final PageInfo<WxCouponPassword> page = wxCouponPasswordService.listAsPage(wxCouponPassword, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("可发送卡数据") | |||||
| @GetMapping("/findCouponList") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "可发送卡数据") | |||||
| public ResultData findCouponList(@ModelAttribute WxCouponPassword wxCouponPassword, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::findCouponList"); | |||||
| wxCouponPassword.updateTenantInfo(getTenantInfo()); | |||||
| final PageInfo<WxCouponPasswordCountInfoVO> page = wxCouponPasswordService.findCouponList(wxCouponPassword, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation(value = "卡密延期", notes = "{\"couponId\":\"string\", \"expireDate\":\"string\"}") | |||||
| @PostMapping("/postpone") | |||||
| @SystemControllerLog(description = "卡密延期") | |||||
| public ResultData postpone(@RequestBody WxCouponPassword wxCouponPassword) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::postpone"); | |||||
| if (wxCouponPassword.getCouponId() == null) { | |||||
| logger.error("couponId不能为空: "); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| WxCouponPassword couponPassword = new WxCouponPassword(); | |||||
| couponPassword.updateTenantInfo(getTenantInfo()); | |||||
| couponPassword.setCouponId(wxCouponPassword.getCouponId()); | |||||
| couponPassword.setExpireDate(wxCouponPassword.getExpireDate()); | |||||
| try { | |||||
| wxCouponPasswordService.postpone(couponPassword); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.COUPON_PASSWORD_POSTPONE_ERR); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,74 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxCouponSendConfig; | |||||
| import com.iformall.enums.EnumCouponSendSendType; | |||||
| import com.iformall.enums.EnumValidStatus; | |||||
| import com.iformall.service.WxCouponSendConfigService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.Date; | |||||
| @RestController | |||||
| @RequestMapping("wxCouponSendConfig") | |||||
| @Api(description = "注劵配置接口") | |||||
| public class WxCouponSendConfigController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxCouponSendConfigService wxCouponSendConfigService; | |||||
| @ApiOperation("获取开关") | |||||
| @GetMapping("get") | |||||
| @SystemControllerLog(description = "发券开关-获取") | |||||
| public ResultData getCouponSendConfig(@ModelAttribute WxCouponSendConfig wxCouponSendConfig) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMallConfigController::getCouponSendConfig"); | |||||
| if (wxCouponSendConfig == null || wxCouponSendConfig.getSendType() == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| wxCouponSendConfig.updateTenantInfo(getTenantInfo()); | |||||
| PageInfo<WxCouponSendConfig> page = wxCouponSendConfigService.listAsPage(wxCouponSendConfig, 1, 1); | |||||
| if (page.getSize() > 0) { | |||||
| return new ResultData(page.getList().get(0)); | |||||
| } else { | |||||
| //配置不存在,添加默认配置(停用) | |||||
| wxCouponSendConfig.setRemark(EnumCouponSendSendType.getEnum(wxCouponSendConfig.getSendType()).getMessage() + "开关"); | |||||
| wxCouponSendConfig.setValue(1); | |||||
| wxCouponSendConfigService.saveOrUpdate(wxCouponSendConfig); | |||||
| return new ResultData(wxCouponSendConfig); | |||||
| } | |||||
| } | |||||
| @PostMapping("update") | |||||
| @ApiOperation("修改开关") | |||||
| @SystemControllerLog(description = "发券开关-修改开关") | |||||
| public ResultData updateCouponSendConfig(@RequestBody WxCouponSendConfig wxCouponSendConfig) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMallConfigController::updateStopCarConpon"); | |||||
| if (wxCouponSendConfig == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| if (wxCouponSendConfig.getId() == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| if (wxCouponSendConfig.getSendType() == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| if (wxCouponSendConfig.getValue() == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| wxCouponSendConfig.updateTenantInfo(getTenantInfo()); | |||||
| wxCouponSendConfig.setUpdateTime(new Date()); | |||||
| wxCouponSendConfigService.update(wxCouponSendConfig); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,92 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.WxFloatingLayer; | |||||
| import com.iformall.domain.vo.WxFloatingLayerVO; | |||||
| import com.iformall.enums.EnumFloatingLayerStatus; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.WxFloatingLayerService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("wxFloatingLayer") | |||||
| @Api(description = "首页浮层展示") | |||||
| public class WxFloatingLayerController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxFloatingLayerService wxFloatingLayerService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("/list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "列表") | |||||
| public ResultData list(@ModelAttribute WxFloatingLayer wxFloatingLayer, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::list"); | |||||
| wxFloatingLayer.updateTenantInfo(getTenantInfo()); | |||||
| wxFloatingLayer.setSortColumns(BaseEntity.SortField.CreateTime_DESC, BaseEntity.SortField.Id_DESC); | |||||
| final PageInfo<WxFloatingLayerVO> page = wxFloatingLayerService.listAsPage(wxFloatingLayer, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("/add") | |||||
| @SystemControllerLog(description = "新增") | |||||
| public ResultData add(@RequestBody WxFloatingLayer wxFloatingLayer) { | |||||
| logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::add"); | |||||
| wxFloatingLayer.updateTenantInfo(getTenantInfo()); | |||||
| wxFloatingLayer.setStatus(EnumFloatingLayerStatus.STATUS_THROW_IN.getCode()); | |||||
| try { | |||||
| return wxFloatingLayerService.saveOrUpdate(wxFloatingLayer); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("/updateStatus") | |||||
| @SystemControllerLog(description = "id更新") | |||||
| public ResultData updateStatus(@RequestBody WxFloatingLayer wxFloatingLayer) { | |||||
| logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::updateStatus"); | |||||
| if (wxFloatingLayer.getId() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id不能为空"); | |||||
| } | |||||
| try { | |||||
| wxFloatingLayer.setStatus(EnumFloatingLayerStatus.STATUS_TAKE_OFFF.getCode()); | |||||
| return wxFloatingLayerService.updateStatus(wxFloatingLayer); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "活动-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::findById"); | |||||
| WxFloatingLayer wxFloatingLayer = wxFloatingLayerService.getById(id); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxFloatingLayer); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,93 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxGameTemplate; | |||||
| import com.iformall.service.WxGameTemplateService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("wxGameTemplate") | |||||
| @Api(description = "游戏模板接口") | |||||
| public class WxGameTemplateController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxGameTemplateService wxGameTemplateService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("listPage") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "游戏模板-分页列表") | |||||
| public ResultData listPage(@ModelAttribute WxGameTemplate wxGameTemplate, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxGameTemplateController::listPage"); | |||||
| if (null == wxGameTemplate) wxGameTemplate = new WxGameTemplate(); | |||||
| final PageInfo<WxGameTemplate> page = wxGameTemplateService.listAsPage(wxGameTemplate, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("列表接口") | |||||
| @GetMapping("list") | |||||
| @SystemControllerLog(description = "游戏模板-列表") | |||||
| public ResultData list(@ModelAttribute WxGameTemplate wxGameTemplate) { | |||||
| logger.debug("[" + getIpAddr() + "] WxGameTemplateController::list"); | |||||
| if (null == wxGameTemplate) wxGameTemplate = new WxGameTemplate(); | |||||
| final List<WxGameTemplate> page = wxGameTemplateService.getList(wxGameTemplate); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "游戏模板-新增") | |||||
| public ResultData add(@RequestBody WxGameTemplate wxGameTemplate) { | |||||
| logger.debug("[" + getIpAddr() + "] WxGameTemplateController::add"); | |||||
| //Assert.notNull(wxGameTemplate.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxGameTemplateService.saveOrUpdate(wxGameTemplate); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "游戏模板-更新") | |||||
| public ResultData update(@RequestBody WxGameTemplate wxGameTemplate) { | |||||
| logger.debug("[" + getIpAddr() + "] WxGameTemplateController::update"); | |||||
| wxGameTemplateService.saveOrUpdate(wxGameTemplate); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "游戏模板-删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxGameTemplateController::delete"); | |||||
| wxGameTemplateService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "游戏模板-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxGameTemplateController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxGameTemplateService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,85 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.WxMerchantPowerBillConfig; | |||||
| import com.iformall.service.WxMerchantPowerBillConfigService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("wxMerchantPowerBillConfig") | |||||
| @Api(description = "商户电费生成配置") | |||||
| public class WxMerchantPowerBillConfigController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMerchantPowerBillConfigService wxMerchantPowerBillConfigService; | |||||
| @ApiOperation("查询数据列表") | |||||
| @GetMapping("/list") | |||||
| @SystemControllerLog(description = "查询数据列表") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData findCouponDataList(@ModelAttribute WxMerchantPowerBillConfig wxMerchantPowerBillConfig, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::list"); | |||||
| wxMerchantPowerBillConfig.updateTenantInfo(getTenantInfo()); | |||||
| wxMerchantPowerBillConfig.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||||
| final PageInfo<WxMerchantPowerBillConfig> page = wxMerchantPowerBillConfigService.listAsPage(wxMerchantPowerBillConfig, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增") | |||||
| @PostMapping("/add") | |||||
| @SystemControllerLog(description = "新增") | |||||
| public ResultData add(@RequestBody WxMerchantPowerBillConfig wxMerchantPowerBillConfig) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::add"); | |||||
| return wxMerchantPowerBillConfigService.saveOrUpdate(wxMerchantPowerBillConfig); | |||||
| } | |||||
| @ApiOperation("更新") | |||||
| @PostMapping("/update") | |||||
| @SystemControllerLog(description = "更新") | |||||
| public ResultData update(@RequestBody WxMerchantPowerBillConfig wxMerchantPowerBillConfig) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::update"); | |||||
| return wxMerchantPowerBillConfigService.saveOrUpdate(wxMerchantPowerBillConfig); | |||||
| } | |||||
| @ApiOperation("删除") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::delete"); | |||||
| wxMerchantPowerBillConfigService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "id查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxMerchantPowerBillConfigService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,152 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.vo.WxMerchantSubsidyVo; | |||||
| import com.iformall.enums.EnumMerchantSubsidyStatus; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.WxMerchantSubsidyService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @RestController | |||||
| @RequestMapping("subsidy") | |||||
| @Api(description = "商户补贴接口") | |||||
| public class WxMerchantSubsidyController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxMerchantSubsidyService wxMerchantSubsidyService; | |||||
| @ApiOperation("补贴记录汇总") | |||||
| @GetMapping("sum") | |||||
| @SystemControllerLog(description = "商户-补贴记录-汇总") | |||||
| public ResultData count(@ModelAttribute WxMerchantSubsidyVo wxMerchantSubsidy) { | |||||
| String ipStr = getIpAddr(); | |||||
| logger.info("subsidy/sum: " + ipStr + " :" + wxMerchantSubsidy.toString()); | |||||
| if (wxMerchantSubsidy == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||||
| } | |||||
| wxMerchantSubsidy.updateTenantInfo(getTenantInfo()); | |||||
| if(StringUtils.isNotBlank(wxMerchantSubsidy.getStatusStr())) { | |||||
| String [] statusAttr = wxMerchantSubsidy.getStatusStr().split(","); | |||||
| List<Integer> tmpList = new ArrayList<Integer>(); | |||||
| for(String status: statusAttr) { | |||||
| tmpList.add(Integer.valueOf(status)); | |||||
| } | |||||
| if(!tmpList.isEmpty()) { | |||||
| wxMerchantSubsidy.setStatusS(tmpList); | |||||
| } | |||||
| } | |||||
| List<Map<String, Object>> retMap = wxMerchantSubsidyService.sumForSubsidy(wxMerchantSubsidy); | |||||
| return new ResultData(retMap); | |||||
| } | |||||
| @ApiOperation("补贴记录") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "商户-补贴记录-列表") | |||||
| public ResultData listMonth(@ModelAttribute WxMerchantSubsidyVo wxMerchantSubsidy, Integer pageNum, Integer pageSize) { | |||||
| String ipStr = getIpAddr(); | |||||
| logger.info("subsidy/list: " + ipStr + " :" + wxMerchantSubsidy.toString()); | |||||
| if (wxMerchantSubsidy == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||||
| } | |||||
| wxMerchantSubsidy.updateTenantInfo(getTenantInfo()); | |||||
| if(StringUtils.isNotBlank(wxMerchantSubsidy.getStatusStr())) { | |||||
| String [] statusAttr = wxMerchantSubsidy.getStatusStr().split(","); | |||||
| List<Integer> tmpList = new ArrayList<Integer>(); | |||||
| for(String status: statusAttr) { | |||||
| tmpList.add(Integer.valueOf(status)); | |||||
| } | |||||
| if(!tmpList.isEmpty()) { | |||||
| wxMerchantSubsidy.setStatusS(tmpList); | |||||
| } | |||||
| } | |||||
| wxMerchantSubsidy.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||||
| final PageInfo<WxMerchantSubsidyVo> page = wxMerchantSubsidyService.listAsPage(wxMerchantSubsidy, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("交易列表") | |||||
| @GetMapping("summary") | |||||
| @SystemControllerLog(description = "结算-总计") | |||||
| public ResultData summary(@ModelAttribute WxMerchantSubsidyVo wxMerchantSubsidy) { | |||||
| logger.debug("[" + getIpAddr() + "] subsidy::summary"); | |||||
| if (null == wxMerchantSubsidy) { | |||||
| wxMerchantSubsidy = new WxMerchantSubsidyVo(); | |||||
| } | |||||
| wxMerchantSubsidy.updateTenantInfo(getTenantInfo()); | |||||
| Map<String, Long> data = wxMerchantSubsidyService.summary(wxMerchantSubsidy); | |||||
| return new ResultData(data); | |||||
| } | |||||
| @ApiOperation("更新补贴记录") | |||||
| @PostMapping("updateSubsidied") | |||||
| @SystemControllerLog(description = "商户-更新补贴记录") | |||||
| public ResultData updateSubsidied(@RequestBody WxMerchantSubsidyVo wxMerchantSubsidy) { | |||||
| String ipStr = getIpAddr(); | |||||
| logger.info("subsidy/update: " + ipStr + " :" + wxMerchantSubsidy.toString()); | |||||
| if (wxMerchantSubsidy == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||||
| } | |||||
| wxMerchantSubsidy.updateTenantInfo(getTenantInfo()); | |||||
| wxMerchantSubsidy.setStatus(EnumMerchantSubsidyStatus.MANUAL_SUBSIDIED.getCode()); | |||||
| wxMerchantSubsidy.setUpdateDate(new Date()); | |||||
| if(StringUtils.isNotBlank(wxMerchantSubsidy.getIdStr())) { | |||||
| String [] idArr = wxMerchantSubsidy.getIdStr().split(","); | |||||
| List<Long> tmpList = new ArrayList<Long>(); | |||||
| for(String id: idArr) { | |||||
| tmpList.add(Long.valueOf(id)); | |||||
| } | |||||
| if(!tmpList.isEmpty()) { | |||||
| wxMerchantSubsidy.setIds(tmpList); | |||||
| } | |||||
| } | |||||
| return wxMerchantSubsidyService.update(wxMerchantSubsidy); | |||||
| } | |||||
| @ApiOperation("补贴记录导出") | |||||
| @GetMapping("/exportData") | |||||
| @SystemControllerLog(description = "商户-补贴记录-导出") | |||||
| public void exportData(@ModelAttribute WxMerchantSubsidyVo wxMerchantSubsidy, HttpServletRequest request, HttpServletResponse response) { | |||||
| logger.info("[" + getIpAddr() + "] subsidy/exportData"); | |||||
| if (wxMerchantSubsidy == null) { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件不能为空"); | |||||
| } | |||||
| wxMerchantSubsidy.updateTenantInfo(getTenantInfo()); | |||||
| if(StringUtils.isNotBlank(wxMerchantSubsidy.getStatusStr())) { | |||||
| String [] statusAttr = wxMerchantSubsidy.getStatusStr().split(","); | |||||
| List<Integer> tmpList = new ArrayList<Integer>(); | |||||
| for(String status: statusAttr) { | |||||
| tmpList.add(Integer.valueOf(status)); | |||||
| } | |||||
| if(!tmpList.isEmpty()) { | |||||
| wxMerchantSubsidy.setStatusS(tmpList); | |||||
| } | |||||
| } | |||||
| wxMerchantSubsidy.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||||
| wxMerchantSubsidyService.exportData(wxMerchantSubsidy, request, response); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,75 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxOpinion; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.WxOpinionService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxOpinion") | |||||
| @Api(description="投诉建议") | |||||
| public class WxOpinionController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxOpinionService wxOpinionService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true) | |||||
| }) | |||||
| @SystemControllerLog(description = "投诉建议-列表") | |||||
| public ResultData list(@ModelAttribute WxOpinion record, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxOpinionController::list"); | |||||
| if (null == record) { | |||||
| record = new WxOpinion(); | |||||
| } | |||||
| record.updateTenantInfo(getTenantInfo()); | |||||
| record.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||||
| final PageInfo<WxOpinion> page = wxOpinionService.listAsPage(record, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/getById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "问券调查--查询") | |||||
| public ResultData getById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxOpinionController::getById"); | |||||
| return new ResultData(wxOpinionService.getById(id)); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "问券调查--更新") | |||||
| public ResultData update(@RequestBody WxOpinion record) { | |||||
| logger.debug("[" + getIpAddr() + "] WxOpinionController::update"); | |||||
| record.updateTenantInfo(getTenantInfo()); | |||||
| try { | |||||
| wxOpinionService.saveOrUpdate(record); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,67 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.WxPowerBillAutoConfig; | |||||
| import com.iformall.service.WxPowerBillAutoConfigService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("wxPowerBillAutoConfig") | |||||
| @Api(description = "电费自动生成配置") | |||||
| public class WxPowerBillAutoConfigController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxPowerBillAutoConfigService wxPowerBillAutoConfigService; | |||||
| @ApiOperation("查询数据列表") | |||||
| @GetMapping("/list") | |||||
| @SystemControllerLog(description = "查询数据列表") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData findCouponDataList(@ModelAttribute WxPowerBillAutoConfig wxPowerBillAutoConfig, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxPowerBillAutoConfigController::list"); | |||||
| wxPowerBillAutoConfig.updateTenantInfo(getTenantInfo()); | |||||
| wxPowerBillAutoConfig.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||||
| final PageInfo<WxPowerBillAutoConfig> page = wxPowerBillAutoConfigService.listAsPage(wxPowerBillAutoConfig, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("修改") | |||||
| @PostMapping("/modify") | |||||
| @SystemControllerLog(description = "修改") | |||||
| public ResultData add(@RequestBody WxPowerBillAutoConfig wxPowerBillAutoConfig) { | |||||
| logger.debug("[" + getIpAddr() + "] WxPowerBillAutoConfigController::modify"); | |||||
| return wxPowerBillAutoConfigService.modify(wxPowerBillAutoConfig); | |||||
| } | |||||
| @ApiOperation("得到配置信息") | |||||
| @GetMapping("/getConfig") | |||||
| @SystemControllerLog(description = "id查询") | |||||
| public ResultData getConfig() { | |||||
| logger.debug("[" + getIpAddr() + "] WxPowerBillAutoConfigController::getConfig"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxPowerBillAutoConfigService.getConfig(getTenantInfo())); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,91 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxPrepayment; | |||||
| import com.iformall.domain.po.WxPrepaymentHistory; | |||||
| import com.iformall.enums.EnumUserType; | |||||
| import com.iformall.service.WxPrepaymentService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("prepayment") | |||||
| @Api(description = "预付费") | |||||
| public class WxPrepaymentController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxPrepaymentService wxPrepaymentService; | |||||
| @ApiOperation("列表查询") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "预付费-列表查询") | |||||
| public ResultData list(@ModelAttribute WxPrepayment wxPrepayment, Integer pageNum, Integer pageSize) { | |||||
| String ipStr = getIpAddr(); | |||||
| logger.info("prepayment/list: " + ipStr); | |||||
| if (wxPrepayment == null) { | |||||
| wxPrepayment = new WxPrepayment(); | |||||
| } | |||||
| final PageInfo<WxPrepayment> page = wxPrepaymentService.listAsPage(wxPrepayment, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("列表查询历史") | |||||
| @GetMapping("listHistory") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "预付费-列表查询历史") | |||||
| public ResultData listHistory(@ModelAttribute WxPrepaymentHistory wxPrepaymentHistory, Integer pageNum, Integer pageSize) { | |||||
| String ipStr = getIpAddr(); | |||||
| logger.info("prepayment/listHistory: " + ipStr); | |||||
| if (wxPrepaymentHistory == null) { | |||||
| wxPrepaymentHistory = new WxPrepaymentHistory(); | |||||
| } | |||||
| final PageInfo<WxPrepaymentHistory> page = wxPrepaymentService.listHistoryAsPage(wxPrepaymentHistory, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("首次充值") | |||||
| @PostMapping("payFirst") | |||||
| @SystemControllerLog(description = "预付费-交费") | |||||
| public ResultData payFirst(@RequestBody WxPrepayment wxPrepayment) { | |||||
| logger.debug("[" + getIpAddr() + "] prepayment::add"); | |||||
| wxPrepayment.updateTenantInfo(getTenantInfo()); | |||||
| wxPrepayment.setOperationType(EnumUserType.MALLUSER.getCode()); | |||||
| wxPrepayment.setOperator(getUserId()); | |||||
| wxPrepaymentService.payFirst(wxPrepayment); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("再次充值") | |||||
| @PostMapping("payAgain") | |||||
| @SystemControllerLog(description = "预付费-交费或扣费") | |||||
| public ResultData payAgain(@RequestBody WxPrepayment wxPrepayment) { | |||||
| logger.debug("[" + getIpAddr() + "] prepayment::update"); | |||||
| wxPrepayment.updateTenantInfo(getTenantInfo()); | |||||
| wxPrepayment.setOperationType(EnumUserType.MALLUSER.getCode()); | |||||
| wxPrepayment.setOperator(getUserId()); | |||||
| wxPrepaymentService.payAgain(wxPrepayment); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,87 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxQuestion; | |||||
| import com.iformall.domain.po.WxQuestionConfig; | |||||
| import com.iformall.enums.EnumQuestionConfigStatus; | |||||
| import com.iformall.service.*; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("wxQuestion") | |||||
| @Api(description="问券调查") | |||||
| public class WxQuestionController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxQuestionService wxQuestionService; | |||||
| @ApiOperation("查寻问券配置") | |||||
| @GetMapping("getConfig") | |||||
| @SystemControllerLog(description = "营销-问券调查-配置获取") | |||||
| public Result getQuestionConfig() { | |||||
| logger.debug("[" + getIpAddr() + "] WxQuestionController::getQuestionConfig"); | |||||
| WxQuestionConfig wxQuestionConfig = new WxQuestionConfig(); | |||||
| wxQuestionConfig.updateTenantInfo(getTenantInfo()); | |||||
| WxQuestion wxQuestion = new WxQuestion(); | |||||
| wxQuestion.updateTenantInfo(wxQuestionConfig); | |||||
| List<WxQuestionConfig> list = wxQuestionService.findConfigList(wxQuestionConfig); | |||||
| if (list.size() > 0) { | |||||
| list.get(0).setQuestions(wxQuestionService.findList(wxQuestion)); | |||||
| return new ResultData(list.get(0)); | |||||
| } | |||||
| wxQuestionConfig.setQuestions(wxQuestionService.findList(wxQuestion)); | |||||
| wxQuestionConfig.setQuestionList(""); | |||||
| wxQuestionConfig.setCouponTypeList(""); | |||||
| wxQuestionConfig.setStatus(EnumQuestionConfigStatus.OFF.getCode()); | |||||
| return new ResultData(wxQuestionConfig); | |||||
| } | |||||
| @ApiOperation("设置问券配置") | |||||
| @PostMapping("setConfig") | |||||
| @SystemControllerLog(description = "营销-问券调查-设置") | |||||
| public Result setQuestionConfig(@RequestBody WxQuestionConfig wxQuestionConfig) { | |||||
| logger.debug("[" + getIpAddr() + "] WxQuestionController::setQuestionConfig"); | |||||
| if (wxQuestionConfig == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| if (wxQuestionConfig.getQuestionList() == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| if (wxQuestionConfig.getCouponTypeList() == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| String[] arys1 = wxQuestionConfig.getQuestionList().split(","); | |||||
| List<Long> qs = new ArrayList<>(); | |||||
| for (int i = 0; i < arys1.length; i++) { | |||||
| if (!arys1[i].isEmpty()) | |||||
| qs.add(Long.parseLong(arys1[i])); | |||||
| } | |||||
| String[] arys2 = wxQuestionConfig.getCouponTypeList().split(","); | |||||
| List<Long> ct = new ArrayList<>(); | |||||
| for (int i = 0; i < arys2.length; i++) { | |||||
| if (!arys2[i].isEmpty()) | |||||
| ct.add(Long.parseLong(arys2[i])); | |||||
| } | |||||
| wxQuestionConfig.setQuestionList(JSONObject.toJSONString(qs)); | |||||
| wxQuestionConfig.setCouponTypeList(JSONObject.toJSONString(ct)); | |||||
| wxQuestionConfig.updateTenantInfo(getTenantInfo()); | |||||
| wxQuestionService.saveOrUpdateConfig(wxQuestionConfig); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,176 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxQuestionOneself; | |||||
| import com.iformall.domain.po.WxQuestionOneselfUser; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.enums.EnumQuestionOneselfStatus; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.WxQuestionOneselfService; | |||||
| import com.iformall.service.WxQuestionOneselfUserService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| @RestController | |||||
| @RequestMapping("wxQuestionOneself") | |||||
| @Api(description="问券调查") | |||||
| public class WxQuestionOneselfController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxQuestionOneselfService wxQuestionOneselfService; | |||||
| @Autowired | |||||
| private WxQuestionOneselfUserService wxQuestionOneselfUserService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true) | |||||
| }) | |||||
| @SystemControllerLog(description = "问券调查-列表") | |||||
| public ResultData list(@ModelAttribute WxQuestionOneself record, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::list"); | |||||
| if (null == record) { | |||||
| record = new WxQuestionOneself(); | |||||
| } | |||||
| if (record.getStatus() != null && record.getStatus() == -1) { | |||||
| record.setStatus(null); | |||||
| } | |||||
| record.updateTenantInfo(getTenantInfo()); | |||||
| record.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Sort_DESC); | |||||
| final PageInfo<WxQuestionOneself> page = wxQuestionOneselfService.listAsPage(record, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "问券调查-新增") | |||||
| public ResultData add(@RequestBody WxQuestionOneself record) { | |||||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::add"); | |||||
| record.updateTenantInfo(getTenantInfo()); | |||||
| try { | |||||
| wxQuestionOneselfService.saveOrUpdate(record); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "问券调查--更新") | |||||
| public ResultData update(@RequestBody WxQuestionOneself record) { | |||||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::update"); | |||||
| record.updateTenantInfo(getTenantInfo()); | |||||
| try { | |||||
| wxQuestionOneselfService.saveOrUpdate(record); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("updateStatus") | |||||
| @SystemControllerLog(description = "问券调查--更新状态") | |||||
| public ResultData updateStatus(@RequestBody WxQuestionOneself record) { | |||||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::updateStatus"); | |||||
| if(record == null || record.getStatus() == null || record.getId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| if(!record.getStatus().equals(EnumQuestionOneselfStatus.STATUS_TAKE_OFFF.getCode()) | |||||
| && !record.getStatus().equals(EnumQuestionOneselfStatus.INJECT_ONLINE.getCode())) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| return wxQuestionOneselfService.updateStatus(record); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/detailsById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "问券调查--查询") | |||||
| public ResultData detailsById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::detailsById"); | |||||
| return new ResultData(wxQuestionOneselfService.detailsById(id)); | |||||
| } | |||||
| @ApiOperation("投放到宣传页") | |||||
| @GetMapping("/sendToCampaign") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "问券调查--投放到宣传页") | |||||
| public ResultData sendToCampaign(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::sendToCampaign"); | |||||
| return wxQuestionOneselfService.sendToCampaign(id); | |||||
| } | |||||
| @ApiOperation("从宣传页下线") | |||||
| @GetMapping("offLineCampaign") | |||||
| @SystemControllerLog(description = "问券调查--从宣传页下线") | |||||
| public ResultData offLineCampaign(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::offLineCampaign"); | |||||
| return wxQuestionOneselfService.offLineCampaign(id); | |||||
| } | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("userList") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true) | |||||
| }) | |||||
| @SystemControllerLog(description = "userList-列表") | |||||
| public ResultData userList(@ModelAttribute WxQuestionOneselfUser record, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::userList"); | |||||
| if (null == record) { | |||||
| record = new WxQuestionOneselfUser(); | |||||
| } | |||||
| record.updateTenantInfo(getTenantInfo()); | |||||
| record.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||||
| final PageInfo<WxQuestionOneselfUser> page = wxQuestionOneselfUserService.listAsPage(record, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/userDetails") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "问券调查--查询") | |||||
| public ResultData userDetails(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::userDetails"); | |||||
| return new ResultData(wxQuestionOneselfUserService.userDetailsById(id)); | |||||
| } | |||||
| @ApiOperation("导出") | |||||
| @GetMapping("/exportData") | |||||
| @SystemControllerLog(description = "导出") | |||||
| public void exportData(@ModelAttribute WxQuestionOneselfUser record, HttpServletRequest request, HttpServletResponse response) { | |||||
| logger.info("[" + getIpAddr() + "] WxQuestionOneselfController/exportData"); | |||||
| if (null == record || record.getQuestionId() == null) { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| record.updateTenantInfo(getTenantInfo()); | |||||
| record.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||||
| wxQuestionOneselfUserService.exportData(record, request, response); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,61 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.utils.PayUtil; | |||||
| import io.swagger.annotations.Api; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxSubsidy; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import javax.imageio.ImageIO; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.awt.image.BufferedImage; | |||||
| import java.util.Map; | |||||
| @RestController | |||||
| @RequestMapping("wxSubsidy") | |||||
| @Api(description = "商城补贴支付接口") | |||||
| public class WxSubsidyController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| // @ApiOperation("补贴扫码支付发起") | |||||
| // @GetMapping("prePay") | |||||
| // @ApiImplicitParams({ | |||||
| // @ApiImplicitParam(name = "amount", value = "金额", dataType = "String", paramType = "query", required = true)}) | |||||
| // @SystemControllerLog(description = "商城补贴-补贴扫码支付发起") | |||||
| // public void subsidyPrepay(String amount, HttpServletResponse response) throws Exception { | |||||
| // String ipStr = getIpAddr(); | |||||
| // logger.info("subsidyPrepay: " + ipStr + "-" + amount); | |||||
| // MallUserInfo userInfo = getUser(); | |||||
| // ResultData resultData = wxSubsidyService.createSubsidy(userInfo, ipStr, amount); | |||||
| // if (resultData.code == 200) { | |||||
| // String codeUrl = ((Map<String, String>) resultData.data).get("code_url"); | |||||
| // BufferedImage image = PayUtil.getQRCodeImge(codeUrl); | |||||
| // | |||||
| // response.setContentType("image/jpeg"); | |||||
| // response.setHeader("Pragma", "no-cache"); | |||||
| // response.setHeader("Cache-Control", "no-cache"); | |||||
| // response.setIntHeader("Expires", -1); | |||||
| // ImageIO.write(image, "JPEG", response.getOutputStream()); | |||||
| // } else { | |||||
| // throw new MallinkException(resultData.code, resultData.message); | |||||
| // } | |||||
| // } | |||||
| } | |||||
| @@ -0,0 +1,107 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.EnumWxTopicStatus; | |||||
| import com.iformall.enums.EnumWxTopicType; | |||||
| import com.iformall.service.*; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.Date; | |||||
| @RestController | |||||
| @RequestMapping("topic") | |||||
| @Api(description = "专题相关接口") | |||||
| public class WxTopicController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxTopicService wxTopicService; | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "专题-列表") | |||||
| public ResultData list(WxTopic wxTopic, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxTopicController::list"); | |||||
| wxTopic.updateTenantInfo(getTenantInfo()); | |||||
| wxTopic.setTopicType(EnumWxTopicType.SPECIAL_TOPIC.getCode()); | |||||
| PageInfo<WxTopic> page = wxTopicService.listAsPage(wxTopic, pageNum, pageSize); | |||||
| //可投放、已上线,时间区间查的是活动开始时间 | |||||
| //已下线、已作为,时间区间查的是活动结束时间 | |||||
| //设置正在上架的专题 | |||||
| Date now = new Date(); | |||||
| page.getList().stream().forEach(cc->{ | |||||
| if (cc.getStatus().equals(EnumWxTopicStatus.VAILD.getCode()) && | |||||
| cc.getEndTime()!=null && cc.getBeginTime()!=null && | |||||
| now.getTime() >= cc.getBeginTime().getTime() && | |||||
| now.getTime() <= cc.getEndTime().getTime()) { | |||||
| cc.setIsOnline(1); | |||||
| } | |||||
| }); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @GetMapping("findById") | |||||
| @SystemControllerLog(description = "专题-获取详情") | |||||
| public ResultData findById(WxTopic wxTopic) { | |||||
| logger.debug("[" + getIpAddr() + "] WxTopicController::findById"); | |||||
| wxTopic.updateTenantInfo(getTenantInfo()); | |||||
| WxTopic queryTopic = wxTopicService.findById(wxTopic); | |||||
| return new ResultData(queryTopic); | |||||
| } | |||||
| @PostMapping("saveOrUpdate") | |||||
| @SystemControllerLog(description = "专题-保存更新") | |||||
| public ResultData saveOrUpdate(@RequestBody WxTopic wxTopic) { | |||||
| logger.debug("[" + getIpAddr() + "] WxTopicController::saveOrUpdate"); | |||||
| wxTopic.updateTenantInfo(getTenantInfo()); | |||||
| if(wxTopic.getTopicType() == null){ | |||||
| wxTopic.setTopicType(EnumWxTopicType.SPECIAL_TOPIC.getCode()); | |||||
| } | |||||
| return wxTopicService.saveOrUpdate(wxTopic); | |||||
| } | |||||
| @GetMapping("findByType") | |||||
| @SystemControllerLog(description = "专题-获取详情") | |||||
| public ResultData findByType(Integer topicType) { | |||||
| logger.debug("[" + getIpAddr() + "] WxTopicController::findByType"); | |||||
| if(topicType == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| WxTopic wxTopic = new WxTopic(); | |||||
| wxTopic.updateTenantInfo(getTenantInfo()); | |||||
| wxTopic.setTopicType(topicType); | |||||
| WxTopic queryTopic = wxTopicService.findByType(wxTopic); | |||||
| return new ResultData(queryTopic); | |||||
| } | |||||
| @PostMapping("updateByType") | |||||
| @SystemControllerLog(description = "专题-保存更新") | |||||
| public ResultData updateByType(@RequestBody WxTopic wxTopic) { | |||||
| logger.debug("[" + getIpAddr() + "] WxTopicController::updateByType"); | |||||
| wxTopic.updateTenantInfo(getTenantInfo()); | |||||
| if(wxTopic.getTopicType() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| wxTopic.setName(EnumWxTopicType.getEnum(wxTopic.getTopicType()).getMessage()); | |||||
| if(StringUtils.isBlank(wxTopic.getName())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| return wxTopicService.saveOrUpdate(wxTopic); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,48 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.dto.WxUserCouponDto; | |||||
| import com.iformall.service.WxUserCouponService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestBody; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| /** | |||||
| * Created by syf on 2018/8/10. | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("wxUserCoupon") | |||||
| @Api(description = "会员卡券查询接口") | |||||
| public class WxUserCouponController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxUserCouponService wxUserCouponService; | |||||
| @ApiOperation("查询用户卡券接口") | |||||
| @PostMapping("findByStatus") | |||||
| @SystemControllerLog(description = "会员管理-查询用户卡券接口") | |||||
| public ResultData findByStatus(@RequestBody WxUserCouponDto wxUserCoupon) { | |||||
| logger.debug("[" + getIpAddr() + "] WxUserCouponController::findByStatus"); | |||||
| //根据用户id,用户卡券状态查找 | |||||
| if(wxUserCoupon==null||wxUserCoupon.getCUserId()==null||wxUserCoupon.getCouponStatus()==null){ | |||||
| return new ResultData(Result.ERROR,"查询失败"); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS,"查询成功",wxUserCouponService.findList(getTenantInfo(),wxUserCoupon.getCUserId(),wxUserCoupon.getCouponStatus())); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,173 @@ | |||||
| package com.iformall.controller.mem; | |||||
| import cn.afterturn.easypoi.excel.ExcelImportUtil; | |||||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||||
| import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; | |||||
| import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; | |||||
| import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.WxTags; | |||||
| import com.iformall.domain.vo.CUserBaseInfoT; | |||||
| import com.iformall.domain.vo.MerchantPoiT; | |||||
| import com.iformall.service.WxTagsService; | |||||
| import org.apache.shiro.session.UnknownSessionException; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||||
| import org.springframework.scheduling.annotation.Async; | |||||
| import org.springframework.stereotype.Component; | |||||
| import java.io.File; | |||||
| import java.util.List; | |||||
| import java.util.concurrent.TimeUnit; | |||||
| @Component | |||||
| public class AsyncTask { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxTagsService wxTagsService; | |||||
| @Autowired | |||||
| StringRedisTemplate stringRedisTemplate; | |||||
| private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> { | |||||
| @Override | |||||
| public Object importHandler(CUserBaseInfoT obj, String name, Object value) { | |||||
| if (value == null) { | |||||
| value = ""; | |||||
| } | |||||
| System.out.println(name + " + " + value.toString()); | |||||
| return super.importHandler(obj, name, value); | |||||
| } | |||||
| } | |||||
| private class PoiExcelHandler extends ExcelDataHandlerDefaultImpl<MerchantPoiT> { | |||||
| @Override | |||||
| public Object importHandler(MerchantPoiT obj, String name, Object value) { | |||||
| if (value == null) { | |||||
| value = ""; | |||||
| } | |||||
| System.out.println(name + " + " + value.toString()); | |||||
| return super.importHandler(obj, name, value); | |||||
| } | |||||
| } | |||||
| private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||||
| if(fail) { | |||||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||||
| } | |||||
| } | |||||
| @Async | |||||
| public void importExcelData(File file, MallUserInfo user, String importKey) { | |||||
| ImportParams params = new ImportParams(); | |||||
| // 需要验证 | |||||
| params.setImportFields(new String[]{"姓名", "性别", "手机号*", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "成长值", "积分"}); | |||||
| IExcelDataHandler<CUserBaseInfoT> handler = new AsyncTask.UserExcelHandler(); | |||||
| handler.setNeedHandlerFields(new String[]{"手机号*"}); | |||||
| params.setNeedVerify(true); | |||||
| ExcelImportResult<CUserBaseInfoT> datalist = null; | |||||
| try { | |||||
| datalist = ExcelImportUtil.importExcelMore(file, CUserBaseInfoT.class, params); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| logger.error(e.getMessage()); | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| return; | |||||
| } | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| if(datalist == null) { | |||||
| logger.error("导入模板失败: 模板数据解析失败"); | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| return; | |||||
| } | |||||
| List<CUserBaseInfoT> successList = datalist.getList(); | |||||
| List<CUserBaseInfoT> failList = datalist.getFailList(); | |||||
| logger.info("验证通过的数量: " + successList.size()); | |||||
| logger.info("验证未通过的数量: " + failList.size()); | |||||
| int total = successList.size() + failList.size(); | |||||
| int all_success = successList.size(); | |||||
| int all_fail = failList.size(); | |||||
| //添加到redis里 | |||||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||||
| if(successList.size() > 0) { | |||||
| WxTags wxTagsQ = new WxTags(); | |||||
| List<WxTags> tagList = wxTagsService.findList(wxTagsQ); | |||||
| } | |||||
| } | |||||
| @Async | |||||
| public void importExcelPoiData(File file, MallUserInfo user, String importKey) { | |||||
| ImportParams params = new ImportParams(); | |||||
| // 需要验证 | |||||
| params.setImportFields(new String[]{"服务商POI_ID", "POI名称", "省份", "城市", "地址", "经度", "纬度", "高德ID(非必填)", | |||||
| "已匹配POI_ID", "已匹配POI名称", "已匹配POI省份", "已匹配POI城市", "已匹配POI地址", "未匹配原因", "其他信息"}); | |||||
| IExcelDataHandler<MerchantPoiT> handler = new AsyncTask.PoiExcelHandler(); | |||||
| handler.setNeedHandlerFields(new String[]{"服务商POI_ID","已匹配POI_ID"}); | |||||
| params.setNeedVerify(true); | |||||
| ExcelImportResult<MerchantPoiT> datalist = null; | |||||
| try { | |||||
| datalist = ExcelImportUtil.importExcelMore(file, MerchantPoiT.class, params); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| logger.error(e.getMessage()); | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| return; | |||||
| } | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| if(datalist == null) { | |||||
| logger.error("导入模板失败: 模板数据解析失败"); | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| return; | |||||
| } | |||||
| List<MerchantPoiT> successList = datalist.getList(); | |||||
| List<MerchantPoiT> failList = datalist.getFailList(); | |||||
| logger.info("验证通过的数量: " + successList.size()); | |||||
| logger.info("验证未通过的数量: " + failList.size()); | |||||
| int total = successList.size() + failList.size(); | |||||
| int all_success = successList.size(); | |||||
| int all_fail = failList.size(); | |||||
| //添加到redis里 | |||||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||||
| if(successList.size() > 0) { | |||||
| try { | |||||
| successList.parallelStream().forEach(poiBase -> { | |||||
| }); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| e.printStackTrace(); | |||||
| logger.error("导入模板失败:"+e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,169 @@ | |||||
| package com.iformall.controller.mem; | |||||
| import cn.afterturn.easypoi.excel.ExcelImportUtil; | |||||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||||
| import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; | |||||
| import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; | |||||
| import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.WxShop; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.vo.WxBillDailyVo; | |||||
| import com.iformall.enums.EnumDelStatus; | |||||
| import com.iformall.enums.EnumShopStatus; | |||||
| import com.iformall.mapper.WxShopMapper; | |||||
| import com.iformall.service.WxBillDailyService; | |||||
| import org.apache.shiro.session.UnknownSessionException; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||||
| import org.springframework.scheduling.annotation.Async; | |||||
| import org.springframework.stereotype.Component; | |||||
| import java.io.File; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.concurrent.TimeUnit; | |||||
| @Component | |||||
| public class BillDailyAsyncTask { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxBillDailyService wxBillDailyService; | |||||
| @Autowired | |||||
| StringRedisTemplate stringRedisTemplate; | |||||
| @Autowired | |||||
| WxShopMapper wxShopMapper; | |||||
| private class BillDailyExcelHandler extends ExcelDataHandlerDefaultImpl<WxBillDailyVo> { | |||||
| @Override | |||||
| public Object importHandler(WxBillDailyVo obj, String name, Object value) { | |||||
| if (value == null) { | |||||
| value = ""; | |||||
| } | |||||
| System.out.println(name + " + " + value.toString()); | |||||
| return super.importHandler(obj, name, value); | |||||
| } | |||||
| } | |||||
| private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||||
| if (fail) { | |||||
| stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||||
| } | |||||
| } | |||||
| @Async | |||||
| public void importExcelData(File file, MallUserInfo user, String importKey) { | |||||
| ImportParams params = new ImportParams(); | |||||
| // 需要验证 | |||||
| params.setImportFields(new String[]{"商铺号*", "费用类型*", "实际应收金额(元)*", "实收金额(元)*", "缴款截止日期*", "租赁商铺类型*"}); | |||||
| IExcelDataHandler<WxBillDailyVo> handler = new BillDailyAsyncTask.BillDailyExcelHandler(); | |||||
| handler.setNeedHandlerFields(new String[]{"商铺号*", "费用类型*", "实际应收金额(元)*", "实收金额(元)*", "缴款截止日期*", "租赁商铺类型*"}); | |||||
| params.setNeedVerify(true); | |||||
| ExcelImportResult<WxBillDailyVo> datalist = null; | |||||
| try { | |||||
| datalist = ExcelImportUtil.importExcelMore(file, WxBillDailyVo.class, params); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| logger.error(e.getMessage()); | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| return; | |||||
| } | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| if (datalist == null) { | |||||
| logger.error("导入模板失败: 模板数据解析失败"); | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| return; | |||||
| } | |||||
| List<WxBillDailyVo> successList = datalist.getList(); | |||||
| List<WxBillDailyVo> failList = datalist.getFailList(); | |||||
| List<WxBillDailyVo> processList = new ArrayList<>(); | |||||
| int fail = 0; | |||||
| for (WxBillDailyVo vo : successList) { | |||||
| //店铺 | |||||
| WxShop shop = new WxShop(); | |||||
| shop.setShopNumber(vo.getShopNumber()); | |||||
| shop.updateTenantInfo(user); | |||||
| shop.setType(vo.getRentShopType()); | |||||
| shop.setStatus(EnumShopStatus.RENT.getCode()); | |||||
| shop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||||
| WxShop wxShop = wxShopMapper.selectOne(new QueryWrapper(shop)); | |||||
| if (wxShop == null) { | |||||
| logger.error("店铺不存在", vo.toString()); | |||||
| fail++; | |||||
| continue; | |||||
| } | |||||
| String receivePayStr = vo.getReceivePayStr(); | |||||
| long receivePay = new BigDecimal(receivePayStr).multiply(new BigDecimal(100)).longValue(); | |||||
| if (receivePay <= 0) { | |||||
| logger.error("实际应收金额小于等于0", vo.toString()); | |||||
| fail++; | |||||
| continue; | |||||
| } | |||||
| String payStr = vo.getPayStr(); | |||||
| long pay = new BigDecimal(payStr).multiply(new BigDecimal(100)).longValue(); | |||||
| if (pay < 0) { | |||||
| logger.error("实收金额小于0", vo.toString()); | |||||
| fail++; | |||||
| continue; | |||||
| } | |||||
| if (receivePay < pay) { | |||||
| logger.error("实际应收金额小于实收金额", vo.toString()); | |||||
| fail++; | |||||
| continue; | |||||
| } | |||||
| vo.setReceivePay(receivePay); | |||||
| vo.setPay(pay); | |||||
| vo.updateTenantInfo(user); | |||||
| vo.setShopId(wxShop.getId()); | |||||
| vo.setRentShopType(wxShop.getType()); | |||||
| processList.add(vo); | |||||
| } | |||||
| logger.info("验证通过的数量: " + processList.size()); | |||||
| logger.info("验证未通过的数量: " + failList.size()); | |||||
| int all_success = processList.size(); | |||||
| int all_fail = failList.size() + fail; | |||||
| int total = processList.size() + all_fail; | |||||
| //添加到redis里 | |||||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||||
| if (processList.size() > 0) { | |||||
| try { | |||||
| processList.parallelStream().forEach(billDaily -> { | |||||
| try { | |||||
| //插入数据 | |||||
| wxBillDailyService.insertData(billDaily, importKey, user); | |||||
| } catch (UnknownSessionException ue) { | |||||
| logger.error("session :" + ue.getMessage()); | |||||
| } | |||||
| }); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| e.printStackTrace(); | |||||
| logger.error("导入模板失败:" + e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,333 @@ | |||||
| package com.iformall.controller.mem; | |||||
| import cn.afterturn.easypoi.excel.ExcelImportUtil; | |||||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||||
| import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; | |||||
| import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; | |||||
| import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxTags; | |||||
| import com.iformall.domain.vo.CUserBaseInfoT; | |||||
| import com.iformall.domain.vo.WxBillExcelTemplate; | |||||
| import com.iformall.domain.vo.WxBillExcelTemplateOther; | |||||
| import com.iformall.enums.EnumMerchantStatus; | |||||
| import com.iformall.mapper.WxMerchantMapper; | |||||
| import com.iformall.service.WxBillAllService; | |||||
| import com.iformall.service.WxTagsService; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.apache.shiro.session.UnknownSessionException; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||||
| import org.springframework.scheduling.annotation.Async; | |||||
| import org.springframework.stereotype.Component; | |||||
| import java.io.File; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.*; | |||||
| import java.util.concurrent.TimeUnit; | |||||
| import java.util.stream.Collectors; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Component | |||||
| public class ImportTemplateTask { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxTagsService wxTagsService; | |||||
| @Autowired | |||||
| StringRedisTemplate stringRedisTemplate; | |||||
| @Autowired | |||||
| private WxBillAllService wxBillAllService; | |||||
| @Autowired | |||||
| private WxMerchantMapper wxMerchantMapper; | |||||
| @Async | |||||
| public void importBillData(File file, MallUserInfo user, String importKey) { | |||||
| ImportParams params = new ImportParams(); | |||||
| // 需要验证 | |||||
| params.setImportFields(new String[]{"商户名*", "费用类型*", "费用属性*", "费用所属期-开始时间*", "费用所属期-结束时间*", "收款金额(元)*", "收款日期*", "截止缴款日*", "收款方式"}); | |||||
| params.setNeedVerify(true); | |||||
| ExcelImportResult<WxBillExcelTemplate> datalist = null; | |||||
| try { | |||||
| datalist = ExcelImportUtil.importExcelMore(file, WxBillExcelTemplate.class, params); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| logger.error(e.getMessage()); | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| return; | |||||
| } | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| if (datalist == null) { | |||||
| logger.error("导入模板失败: 模板数据解析失败"); | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| return; | |||||
| } | |||||
| List<WxBillExcelTemplate> successList = datalist.getList(); | |||||
| List<WxBillExcelTemplate> failList = datalist.getFailList(); | |||||
| //此处判断商户是否存在 | |||||
| //1 过滤重复商户名 | |||||
| Set<String> merchantSet = successList.parallelStream().filter(s -> StringUtils.isNotEmpty(s.getMerchantName())) | |||||
| .map(s -> StringUtils.trim(s.getMerchantName())) | |||||
| .collect(Collectors.toSet()); | |||||
| //2 查询商户名是否存在 | |||||
| Map<String, WxMerchant> merchantMap = new HashMap<>(); | |||||
| merchantSet.parallelStream().forEach(merchantName -> { | |||||
| WxMerchant wxMerchantQuery = new WxMerchant(); | |||||
| wxMerchantQuery.updateTenantInfo(user); | |||||
| wxMerchantQuery.setName(merchantName); | |||||
| wxMerchantQuery.setStatus(EnumMerchantStatus.VALID.getCode()); | |||||
| WxMerchant wxMerchant = wxMerchantMapper.selectOne(new QueryWrapper(wxMerchantQuery)); | |||||
| if (wxMerchant != null) { | |||||
| merchantMap.put(merchantName, wxMerchant); | |||||
| } | |||||
| }); | |||||
| //3 计失败条数 | |||||
| List<WxBillExcelTemplate> billSuccessList = new ArrayList<>(); | |||||
| successList.parallelStream().forEach(s -> { | |||||
| if (StringUtils.isNotEmpty(s.getMerchantName()) && null != s.getBillType() | |||||
| && StringUtils.isNotEmpty(s.getBillAttr()) && null != s.getStarttime() | |||||
| && null != s.getEndtime() && StringUtils.isNotEmpty(s.getPayStr()) | |||||
| && null != s.getPayDate() && null != s.getReceiveDate()) { | |||||
| WxMerchant wxMerchant = merchantMap.get(s.getMerchantName()); | |||||
| if (wxMerchant != null) { | |||||
| Long merchantId = wxMerchant.getId(); | |||||
| if (merchantId != null) { | |||||
| s.setMerchantId(merchantId); | |||||
| Integer type = wxMerchant.getType(); | |||||
| s.setMerchantType(type); | |||||
| billSuccessList.add(s); | |||||
| } | |||||
| } | |||||
| } | |||||
| }); | |||||
| int billSuccessSize = billSuccessList.size(); | |||||
| int successSize = successList.size(); | |||||
| int failSize = failList.size(); | |||||
| int total = successSize + failSize; | |||||
| int failCount = successSize - billSuccessSize; | |||||
| int all_success = billSuccessSize; | |||||
| int all_fail = failSize + failCount; | |||||
| logger.info("验证通过的数量: " + billSuccessSize); | |||||
| logger.info("验证未通过的数量: " + failSize); | |||||
| //添加到redis里 | |||||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||||
| if (billSuccessSize > 0) { | |||||
| try { | |||||
| billSuccessList.stream().forEach(bill -> { | |||||
| try { | |||||
| wxBillAllService.importBill(importKey, bill, user); | |||||
| } catch (UnknownSessionException ue) { | |||||
| logger.error("session :" + ue.getMessage()); | |||||
| } | |||||
| }); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| e.printStackTrace(); | |||||
| logger.error("导入模板失败:" + e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| public void importBillDataOther(File file, MallUserInfo user, String importKey) { | |||||
| ImportParams params = new ImportParams(); | |||||
| // 需要验证 | |||||
| params.setImportFields(new String[]{"商户名*", "费用类型*", "费用名称*", "费用所属期-开始时间*", "费用所属期-结束时间*", "实际应收金额(元)*", "收款金额(元)*", "收款日期", "截止缴款日*", "收款方式"}); | |||||
| params.setNeedVerify(true); | |||||
| ExcelImportResult<WxBillExcelTemplateOther> datalist = null; | |||||
| try { | |||||
| datalist = ExcelImportUtil.importExcelMore(file, WxBillExcelTemplateOther.class, params); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| logger.error(e.getMessage()); | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| return; | |||||
| } | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| if (datalist == null) { | |||||
| logger.error("导入模板失败: 模板数据解析失败"); | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| return; | |||||
| } | |||||
| List<WxBillExcelTemplateOther> successList = datalist.getList(); | |||||
| List<WxBillExcelTemplateOther> failList = datalist.getFailList(); | |||||
| //此处判断商户是否存在 | |||||
| //1 过滤重复商户名 | |||||
| Set<String> merchantSet = successList.parallelStream().filter(s -> StringUtils.isNotEmpty(s.getMerchantName())) | |||||
| .map(s -> StringUtils.trim(s.getMerchantName())) | |||||
| .collect(Collectors.toSet()); | |||||
| //2 查询商户名是否存在 | |||||
| Map<String, WxMerchant> merchantMap = new HashMap<>(); | |||||
| merchantSet.parallelStream().forEach(merchantName -> { | |||||
| WxMerchant wxMerchantQuery = new WxMerchant(); | |||||
| wxMerchantQuery.updateTenantInfo(user); | |||||
| wxMerchantQuery.setName(merchantName); | |||||
| wxMerchantQuery.setStatus(EnumMerchantStatus.VALID.getCode()); | |||||
| WxMerchant wxMerchant = wxMerchantMapper.selectOne(new QueryWrapper(wxMerchantQuery)); | |||||
| if (wxMerchant != null) { | |||||
| merchantMap.put(merchantName, wxMerchant); | |||||
| } | |||||
| }); | |||||
| //3 计失败条数 | |||||
| List<WxBillExcelTemplateOther> billSuccessList = new ArrayList<>(); | |||||
| successList.parallelStream().forEach(s -> { | |||||
| boolean flag = StringUtils.isNotEmpty(s.getMerchantName()) && null != s.getBillType() | |||||
| && StringUtils.isNotEmpty(s.getBillAttr()) && null != s.getStarttime() | |||||
| && null != s.getEndtime() && StringUtils.isNotEmpty(s.getPayStr()) | |||||
| && null != s.getReceiveDate() && StringUtils.isNotEmpty(s.getReceivePayStr()); | |||||
| if (flag) { | |||||
| double pay = new BigDecimal(s.getPayStr()).doubleValue(); | |||||
| //付款大于0且付款日期不为空说明是更新账单 或者 付款为0且付款日期为空是新增账单 满足其一即可继续 | |||||
| flag = (pay > 0 && null != s.getPayDate()) || (pay == 0 && null == s.getPayDate()); | |||||
| if (flag) { | |||||
| WxMerchant wxMerchant = merchantMap.get(s.getMerchantName()); | |||||
| if (wxMerchant != null) { | |||||
| Long merchantId = wxMerchant.getId(); | |||||
| if (merchantId != null) { | |||||
| s.setMerchantId(merchantId); | |||||
| Integer type = wxMerchant.getType(); | |||||
| s.setMerchantType(type); | |||||
| billSuccessList.add(s); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| }); | |||||
| int billSuccessSize = billSuccessList.size(); | |||||
| int successSize = successList.size(); | |||||
| int failSize = failList.size(); | |||||
| int total = successSize + failSize; | |||||
| int failCount = successSize - billSuccessSize; | |||||
| int all_success = billSuccessSize; | |||||
| int all_fail = failSize + failCount; | |||||
| logger.info("验证通过的数量: " + billSuccessSize); | |||||
| logger.info("验证未通过的数量: " + failSize); | |||||
| //添加到redis里 | |||||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||||
| if (billSuccessSize > 0) { | |||||
| try { | |||||
| billSuccessList.stream().forEach(bill -> { | |||||
| try { | |||||
| wxBillAllService.importBillOther(importKey, bill, user); | |||||
| } catch (UnknownSessionException ue) { | |||||
| logger.error("session :" + ue.getMessage()); | |||||
| } | |||||
| }); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| e.printStackTrace(); | |||||
| logger.error("导入模板失败:" + e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> { | |||||
| @Override | |||||
| public Object importHandler(CUserBaseInfoT obj, String name, Object value) { | |||||
| if (value == null) { | |||||
| value = ""; | |||||
| } | |||||
| System.out.println(name + " + " + value.toString()); | |||||
| return super.importHandler(obj, name, value); | |||||
| } | |||||
| } | |||||
| private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||||
| if (fail) { | |||||
| stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||||
| } | |||||
| } | |||||
| @Async | |||||
| public void importMemberData(File file, MallUserInfo user, String importKey) { | |||||
| ImportParams params = new ImportParams(); | |||||
| // 需要验证 | |||||
| params.setImportFields(new String[]{"姓名", "性别", "手机号*", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值", "积分"}); | |||||
| IExcelDataHandler<CUserBaseInfoT> handler = new ImportTemplateTask.UserExcelHandler(); | |||||
| handler.setNeedHandlerFields(new String[]{"手机号*"}); | |||||
| params.setNeedVerify(true); | |||||
| ExcelImportResult<CUserBaseInfoT> datalist = null; | |||||
| try { | |||||
| datalist = ExcelImportUtil.importExcelMore(file, CUserBaseInfoT.class, params); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| logger.error(e.getMessage()); | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| return; | |||||
| } | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| if (datalist == null) { | |||||
| logger.error("导入模板失败: 模板数据解析失败"); | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| return; | |||||
| } | |||||
| List<CUserBaseInfoT> successList = datalist.getList(); | |||||
| List<CUserBaseInfoT> failList = datalist.getFailList(); | |||||
| logger.info("验证通过的数量: " + successList.size()); | |||||
| logger.info("验证未通过的数量: " + failList.size()); | |||||
| int total = successList.size() + failList.size(); | |||||
| int all_success = successList.size(); | |||||
| int all_fail = failList.size(); | |||||
| //添加到redis里 | |||||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||||
| if (successList.size() > 0) { | |||||
| WxTags wxTagsQ = new WxTags(); | |||||
| List<WxTags> tagList = wxTagsService.findList(wxTagsQ); | |||||
| try { | |||||
| successList.parallelStream().forEach(uBase -> { | |||||
| }); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| e.printStackTrace(); | |||||
| logger.error("导入模板失败:" + e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,111 @@ | |||||
| package com.iformall.controller.mem; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.service.*; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("userBasicInfoAddress") | |||||
| @Api(description = "会员地址相关接口") | |||||
| public class UserBasicInfoAddressController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private UserBasicInfoAddressService userBasicInfoAddressService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "会员地址-列表") | |||||
| public ResultData list(@ModelAttribute UserBasicInfoAddress userBasicInfoAddress, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] UserBasicInfoAddressController::list"); | |||||
| if (null == userBasicInfoAddress) { | |||||
| userBasicInfoAddress = new UserBasicInfoAddress(); | |||||
| } | |||||
| if(userBasicInfoAddress.getUserId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "用户ID为空"); | |||||
| } | |||||
| userBasicInfoAddress.undateFinalTenantId(getTenantInfo()); | |||||
| PageInfo<UserBasicInfoAddress> page = userBasicInfoAddressService.listAsPage(userBasicInfoAddress, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @PostMapping("saveOrUpdate") | |||||
| @SystemControllerLog(description = "会员地址-保存更新") | |||||
| public ResultData saveOrUpdate(@RequestBody UserBasicInfoAddress userBasicInfoAddress) { | |||||
| logger.debug("[" + getIpAddr() + "] userBasicInfoAddress::saveOrUpdate"); | |||||
| if(userBasicInfoAddress == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| if(userBasicInfoAddress.getUserId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| userBasicInfoAddress.undateFinalTenantId(getTenantInfo()); | |||||
| userBasicInfoAddressService.saveOrUpdate(userBasicInfoAddress); | |||||
| return new ResultData(); | |||||
| } | |||||
| @PostMapping("setUpDefault") | |||||
| @SystemControllerLog(description = "会员地址-默认") | |||||
| public ResultData setUpDefault(@RequestBody UserBasicInfoAddress userBasicInfoAddress) { | |||||
| logger.debug("[" + getIpAddr() + "] userBasicInfoAddress::setUpDefault"); | |||||
| if(userBasicInfoAddress == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| if(userBasicInfoAddress.getId() == null || userBasicInfoAddress.getUserId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "用户ID或者Id为空"); | |||||
| } | |||||
| userBasicInfoAddress.undateFinalTenantId(getTenantInfo()); | |||||
| userBasicInfoAddressService.updateDefault(userBasicInfoAddress); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("消息模板-删除") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "消息验证模板-删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] userBasicInfoAddress::delete"); | |||||
| if(id == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "Id为空"); | |||||
| } | |||||
| UserBasicInfoAddress userBasicInfoAddress = new UserBasicInfoAddress(); | |||||
| userBasicInfoAddress.setId(id); | |||||
| userBasicInfoAddress.undateFinalTenantId(getTenantInfo()); | |||||
| userBasicInfoAddressService.deleteById(userBasicInfoAddress); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("消息模板-查询") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "消息验证模板-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] userBasicInfoAddress::findById"); | |||||
| if(id == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "Id为空"); | |||||
| } | |||||
| UserBasicInfoAddress userBasicInfoAddress = new UserBasicInfoAddress(); | |||||
| userBasicInfoAddress.setId(id); | |||||
| userBasicInfoAddress.undateFinalTenantId(getTenantInfo()); | |||||
| userBasicInfoAddressService.findById(userBasicInfoAddress); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", null); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,82 @@ | |||||
| package com.iformall.controller.mem; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.annotation.TenantIgnore; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxCUserCar; | |||||
| import com.iformall.service.WxCUserCarService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxCUserCar") | |||||
| public class WxCUserCarController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxCUserCarService wxCUserCarService; | |||||
| @TenantIgnore | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "停车-列表") | |||||
| public ResultData list(@ModelAttribute WxCUserCar wxCUserCar, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::list"); | |||||
| if (null == wxCUserCar) wxCUserCar = new WxCUserCar(); | |||||
| wxCUserCar.updateTenantInfo(getTenantInfo()); | |||||
| final PageInfo<WxCUserCar> page = wxCUserCarService.listAsPage(wxCUserCar, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "停车-新增") | |||||
| public ResultData add(@RequestBody WxCUserCar wxCUserCar) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::add"); | |||||
| //Assert.notNull(wxCUserCar.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxCUserCarService.saveOrUpdate(wxCUserCar); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "停车-更新") | |||||
| public ResultData update(@RequestBody WxCUserCar wxCUserCar) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::update"); | |||||
| wxCUserCarService.saveOrUpdate(wxCUserCar); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "停车-删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::delete"); | |||||
| wxCUserCarService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "停车-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxCUserCarService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,79 @@ | |||||
| package com.iformall.controller.mem; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxCUserFrom; | |||||
| import com.iformall.domain.vo.WxCUserFromVo; | |||||
| import com.iformall.enums.EnumCUserFrom; | |||||
| import com.iformall.service.WxCUserFromService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| @RestController | |||||
| @RequestMapping("wxCUserFrom") | |||||
| public class WxCUserFromController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxCUserFromService wxCUserFromService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "分享-列表") | |||||
| public ResultData list(@ModelAttribute WxCUserFrom wxCUserFrom, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::list"); | |||||
| if (null == wxCUserFrom) wxCUserFrom = new WxCUserFrom(); | |||||
| wxCUserFrom.updateTenantInfo(getTenantInfo()); | |||||
| final PageInfo<WxCUserFrom> page = wxCUserFromService.listAsPage(wxCUserFrom, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/visits") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "分享-列表") | |||||
| public ResultData visits(@ModelAttribute WxCUserFromVo wxCUserFromVo,Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::findById"); | |||||
| if (null == wxCUserFromVo) wxCUserFromVo = new WxCUserFromVo(); | |||||
| if(wxCUserFromVo.getFromType() == null){ | |||||
| wxCUserFromVo.setFromType(EnumCUserFrom.FROM_C_USER_BASIC_INFO.getCode()); | |||||
| } | |||||
| wxCUserFromVo.updateTenantInfo(getTenantInfo()); | |||||
| final PageInfo<WxCUserFromVo> page = wxCUserFromService.listAsVisitsPage(wxCUserFromVo, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @GetMapping("/exportData") | |||||
| @SystemControllerLog(description = "导出数据") | |||||
| public void exportData(@ModelAttribute WxCUserFrom wxCUserFrom, HttpServletRequest request, HttpServletResponse response) { | |||||
| if (null == wxCUserFrom) wxCUserFrom = new WxCUserFrom(); | |||||
| wxCUserFrom.updateTenantInfo(getTenantInfo()); | |||||
| wxCUserFromService.exportData(request, response, wxCUserFrom); | |||||
| } | |||||
| @GetMapping("/exportDataVisits") | |||||
| @SystemControllerLog(description = "导出数据") | |||||
| public void exportDataVisits(@ModelAttribute WxCUserFromVo wxCUserFromVo, HttpServletRequest request, HttpServletResponse response) { | |||||
| if (null == wxCUserFromVo) wxCUserFromVo = new WxCUserFromVo(); | |||||
| wxCUserFromVo.updateTenantInfo(getTenantInfo()); | |||||
| if(wxCUserFromVo.getFromType() == null){ | |||||
| wxCUserFromVo.setFromType(EnumCUserFrom.FROM_C_USER_BASIC_INFO.getCode()); | |||||
| } | |||||
| wxCUserFromService.exportDataVisits(request, response, wxCUserFromVo); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,114 @@ | |||||
| package com.iformall.controller.mem; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestBody; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxLevelConfig; | |||||
| import com.iformall.service.WxLevelConfigService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("wxLevelConfig") | |||||
| @Api(description = "等级权益相关接口") | |||||
| public class WxLevelConfigController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxLevelConfigService wxLevelConfigService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "会员等级权益-列表") | |||||
| public ResultData list(@ModelAttribute WxLevelConfig wxLevelConfig, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxLevelConfigController::list"); | |||||
| if (null == wxLevelConfig) wxLevelConfig = new WxLevelConfig(); | |||||
| wxLevelConfig.updateTenantInfo(getTenantInfo()); | |||||
| wxLevelConfig.setSortColumns(BaseEntity.SortField.Points_ASC); | |||||
| final PageInfo<WxLevelConfig> page = wxLevelConfigService.listAsPage(wxLevelConfig, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "会员等级权益-新增") | |||||
| public ResultData add(@RequestBody List<WxLevelConfig> levelConfigs) { | |||||
| logger.debug("[" + getIpAddr() + "] WxLevelConfigController::add"); | |||||
| try { | |||||
| if (StringUtils.isNotBlank(getTenantInfo().getParentTenantId())) { | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "子广场用户无此权限"); | |||||
| } | |||||
| wxLevelConfigService.batchSave(getTenantInfo(), levelConfigs); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.DB_FAIL); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("更改会员权益") | |||||
| @PostMapping("updateCapabilities") | |||||
| @SystemControllerLog(description = "会员等级权益-更改会员权益") | |||||
| public ResultData updateCapabilities(@RequestBody List<WxLevelConfig> levelConfigs) { | |||||
| logger.debug("[" + getIpAddr() + "] WxLevelConfigController::add"); | |||||
| try { | |||||
| if (StringUtils.isNotBlank(getTenantInfo().getParentTenantId())) { | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "子广场用户无此权限"); | |||||
| } | |||||
| wxLevelConfigService.batchUpdateCapabilities(getTenantInfo(), levelConfigs); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.DB_FAIL); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @PostMapping("/del") | |||||
| @SystemControllerLog(description = "会员等级权益-删除") | |||||
| public ResultData delete(@RequestBody WxLevelConfig wxLevelConfig) { | |||||
| logger.debug("[" + getIpAddr() + "] WxLevelConfigController::delete"); | |||||
| if(wxLevelConfig.getId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| if (StringUtils.isNotBlank(getTenantInfo().getParentTenantId())) { | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "子广场用户无此权限"); | |||||
| } | |||||
| wxLevelConfigService.deleteById(wxLevelConfig.getId()); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "会员等级权益-获取") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxLevelConfigController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxLevelConfigService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,100 @@ | |||||
| package com.iformall.controller.mem; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||||
| import com.iformall.domain.po.WxScoreHistory; | |||||
| import com.iformall.enums.EnumCUserBasicInfoStatus; | |||||
| import com.iformall.service.WxScoreHistoryService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxScoreHistory") | |||||
| public class WxScoreHistoryController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxScoreHistoryService wxScoreHistoryService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "成长值-历史") | |||||
| public ResultData list(@ModelAttribute WxScoreHistory wxScoreHistory, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxScoreHistoryController::list"); | |||||
| if (null == wxScoreHistory) wxScoreHistory = new WxScoreHistory(); | |||||
| wxScoreHistory.setTenantId(getTenantInfo().getFinalTenantId()); | |||||
| wxScoreHistory.setFinalTenantId(getTenantInfo().getFinalTenantId()); | |||||
| final PageInfo<WxScoreHistory> page = wxScoreHistoryService.listAsPage(wxScoreHistory, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "成长值-新增") | |||||
| public ResultData add(@RequestBody WxScoreHistory wxScoreHistory) { | |||||
| logger.debug("[" + getIpAddr() + "] WxScoreHistoryController::add"); | |||||
| //Assert.notNull(wxScoreHistory.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| if (checkMemberStatus(wxScoreHistory.getCUserId())) { | |||||
| return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | |||||
| } | |||||
| wxScoreHistory.setTenantId(getTenantInfo().getFinalTenantId()); | |||||
| wxScoreHistory.setFinalTenantId(getTenantInfo().getFinalTenantId()); | |||||
| wxScoreHistoryService.saveOrUpdate(wxScoreHistory); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "成长值-更新") | |||||
| public ResultData update(@RequestBody WxScoreHistory wxScoreHistory) { | |||||
| logger.debug("[" + getIpAddr() + "] WxScoreHistoryController::update"); | |||||
| if (checkMemberStatus(wxScoreHistory.getCUserId())) { | |||||
| return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | |||||
| } | |||||
| wxScoreHistory.setTenantId(getTenantInfo().getFinalTenantId()); | |||||
| wxScoreHistory.setFinalTenantId(getTenantInfo().getFinalTenantId()); | |||||
| wxScoreHistoryService.saveOrUpdate(wxScoreHistory); | |||||
| return new ResultData(); | |||||
| } | |||||
| public boolean checkMemberStatus(Long userId) { | |||||
| return false; | |||||
| } | |||||
| // @ApiOperation("根据id删除接口") | |||||
| // @GetMapping("/del") | |||||
| // @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| // @SystemControllerLog(description = "成长值-删除") | |||||
| // public ResultData delete(Long id) { | |||||
| // logger.debug("[" + getIpAddr() + "] WxScoreHistoryController::delete"); | |||||
| // wxScoreHistoryService.deleteById(id); | |||||
| // return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| // } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "成长值-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxScoreHistoryController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxScoreHistoryService.getById(id,getTenantInfo().getFinalTenantId())); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,120 @@ | |||||
| package com.iformall.controller.mem; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxMall; | |||||
| import com.iformall.domain.po.WxScoreRules; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumCreditLockedStatus; | |||||
| import com.iformall.enums.EnumGroupSupport; | |||||
| import com.iformall.enums.EnumScoreRules; | |||||
| import com.iformall.service.WxMallService; | |||||
| import com.iformall.service.WxScoreRulesService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxScoreRules") | |||||
| @Api(description = "成长值积分规则相关接口") | |||||
| public class WxScoreRulesController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxScoreRulesService wxScoreRulesService; | |||||
| @Autowired | |||||
| private WxMallService wxMallService; | |||||
| @ApiOperation("成长值配置") | |||||
| @GetMapping("setting") | |||||
| @SystemControllerLog(description = "成长值-配置") | |||||
| public ResultData list() { | |||||
| logger.debug("[" + getIpAddr() + "] WxScoreRulesController::list"); | |||||
| WxScoreRules scoreRules = wxScoreRulesService.getScoreRules(getTenantInfo()); | |||||
| if (scoreRules.getCreditLocked() == null) { | |||||
| scoreRules.setCreditLocked(EnumCreditLockedStatus.OPEN.getCode()); | |||||
| } | |||||
| return new ResultData(scoreRules); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "成长值-积分-配置-新增") | |||||
| public ResultData add(@RequestBody WxScoreRules wxScoreRules) { | |||||
| logger.debug("[" + getIpAddr() + "] WxScoreRulesController::add"); | |||||
| if(wxScoreRules.getType() != null){ | |||||
| if(wxScoreRules.getType().equals(EnumScoreRules.SCORE.getCode()) || wxScoreRules.getType().equals(EnumScoreRules.CREDIT.getCode())){ | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "子广场用户无此权限"); | |||||
| } | |||||
| wxScoreRules.updateTenantInfo(tenantEntity); | |||||
| }else if(wxScoreRules.getType().equals(EnumScoreRules.CREDIT_DOUBLE.getCode())){ | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| if(wxMallService.isgroupSupport(tenantEntity)){ | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "集团用户无此权限"); | |||||
| } | |||||
| wxScoreRules.updateTenantInfo(tenantEntity); | |||||
| }else{ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"type"); | |||||
| } | |||||
| }else{ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"type"); | |||||
| } | |||||
| wxScoreRulesService.saveOrUpdate(wxScoreRules); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("积分配置") | |||||
| @GetMapping("/credit_rules") | |||||
| @SystemControllerLog(description = "积分-配置") | |||||
| public ResultData creditRulesList() { | |||||
| logger.debug("[" + getIpAddr() + "] creditRulesList::list"); | |||||
| WxScoreRules scoreRules = wxScoreRulesService.getCreditRules(getTenantInfo().getFinalTenantId()); | |||||
| return new ResultData(scoreRules); | |||||
| } | |||||
| @ApiOperation("积分倍率") | |||||
| @GetMapping("/credit_double") | |||||
| @SystemControllerLog(description = "积分-配置") | |||||
| public ResultData creditDoubleRulesList() { | |||||
| logger.debug("[" + getIpAddr() + "] creditDoubleRulesList::list"); | |||||
| if(wxMallService.isgroupSupport(getUser())){ | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "集团用户无此权限"); | |||||
| } | |||||
| WxScoreRules scoreRules = wxScoreRulesService.getCreditDoubleRules(getTenantInfo().getTenantId()); | |||||
| return new ResultData(scoreRules); | |||||
| } | |||||
| @ApiOperation("更新积分开关状态") | |||||
| @PostMapping("updateCreditLocked") | |||||
| @SystemControllerLog(description = "更新积分开关状态") | |||||
| public ResultData updateCreditLocked(@RequestBody WxScoreRules wxScoreRules) { | |||||
| logger.debug("[" + getIpAddr() + "] WxScoreRulesController::updateCreditLocked"); | |||||
| if (null == wxScoreRules.getId()) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id不能为空"); | |||||
| } | |||||
| if (null == wxScoreRules.getCreditLocked()) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "creditLocked不能为空"); | |||||
| } | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "子广场用户无此权限"); | |||||
| } | |||||
| wxScoreRules.updateTenantInfo(tenantEntity); | |||||
| try { | |||||
| wxScoreRulesService.updateCreditLocked(wxScoreRules); | |||||
| } catch (Exception e) { | |||||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "更新积分开关状态失败"); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,74 @@ | |||||
| package com.iformall.controller.mem; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxUserChannel; | |||||
| import com.iformall.service.WxUserChannelService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxUserChannel") | |||||
| public class WxUserChannelController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxUserChannelService wxUserChannelService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "会员等级权益-更改会员权益") | |||||
| public ResultData list(@ModelAttribute WxUserChannel wxUserChannel, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxUserChannelController::list"); | |||||
| if (null == wxUserChannel) wxUserChannel = new WxUserChannel(); | |||||
| final PageInfo<WxUserChannel> page = wxUserChannelService.listAsPage(wxUserChannel, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| public ResultData add(@RequestBody WxUserChannel wxUserChannel) { | |||||
| logger.debug("[" + getIpAddr() + "] WxUserChannelController::add"); | |||||
| //Assert.notNull(wxUserChannel.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxUserChannelService.saveOrUpdate(wxUserChannel); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| public ResultData update(@RequestBody WxUserChannel wxUserChannel) { | |||||
| logger.debug("[" + getIpAddr() + "] WxUserChannelController::update"); | |||||
| wxUserChannelService.saveOrUpdate(wxUserChannel); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxUserChannelController::delete"); | |||||
| wxUserChannelService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxUserChannelController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxUserChannelService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,81 @@ | |||||
| package com.iformall.controller.msg; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.WxMsgCallback; | |||||
| import com.iformall.service.WxMsgCallbackService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("msgCallback") | |||||
| public class WxMsgCallbackController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMsgCallbackService wxMsgCallbackService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "短信回调结果-列表") | |||||
| public ResultData list(@ModelAttribute WxMsgCallback wxMsgCallback, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgCallbackController::list"); | |||||
| if (null == wxMsgCallback) wxMsgCallback = new WxMsgCallback(); | |||||
| wxMsgCallback.updateTenantInfo(getTenantInfo()); | |||||
| wxMsgCallback.setSortColumns(BaseEntity.SortField.Createtime_DESC); | |||||
| final PageInfo<WxMsgCallback> page = wxMsgCallbackService.listAsPage(wxMsgCallback, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "短信回调结果-新增") | |||||
| public ResultData add(@RequestBody WxMsgCallback wxMsgCallback) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgCallbackController::add"); | |||||
| //Assert.notNull(wxMsgCallback.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxMsgCallback.updateTenantInfo(getTenantInfo()); | |||||
| wxMsgCallbackService.saveOrUpdate(wxMsgCallback); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "短信回调结果-更新") | |||||
| public ResultData update(@RequestBody WxMsgCallback wxMsgCallback) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgCallbackController::update"); | |||||
| wxMsgCallbackService.saveOrUpdate(wxMsgCallback); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "短信回调结果-删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgCallbackController::delete"); | |||||
| wxMsgCallbackService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "短信回调结果-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgCallbackController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxMsgCallbackService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,81 @@ | |||||
| package com.iformall.controller.msg; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxMsgConfig; | |||||
| import com.iformall.service.WxMsgConfigService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxMsgConfig") | |||||
| public class WxMsgConfigController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMsgConfigService wxMsgConfigService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "短信-配置-列表") | |||||
| public ResultData list(@ModelAttribute WxMsgConfig wxMsgConfig, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgConfigController::list"); | |||||
| if (null == wxMsgConfig) wxMsgConfig = new WxMsgConfig(); | |||||
| final PageInfo<WxMsgConfig> page = wxMsgConfigService.listAsPage(wxMsgConfig, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "短信-配置-新增") | |||||
| public ResultData add(@RequestBody WxMsgConfig wxMsgConfig) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgConfigController::add"); | |||||
| //Assert.notNull(wxMsgConfig.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxMsgConfig.updateTenantInfo(getTenantInfo()); | |||||
| wxMsgConfigService.saveOrUpdate(wxMsgConfig); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "短信-配置-更新") | |||||
| public ResultData update(@RequestBody WxMsgConfig wxMsgConfig) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgConfigController::update"); | |||||
| wxMsgConfig.updateTenantInfo(getTenantInfo()); | |||||
| wxMsgConfigService.saveOrUpdate(wxMsgConfig); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "短信-配置-删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgConfigController::delete"); | |||||
| wxMsgConfigService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "短信-配置-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgConfigController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxMsgConfigService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,94 @@ | |||||
| package com.iformall.controller.msg; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.WxMsgModel; | |||||
| import com.iformall.enums.EnumMsgModelType; | |||||
| import com.iformall.service.WxMsgModelService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxMsgModel") | |||||
| public class WxMsgModelController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMsgModelService wxMsgModelService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "短信模板-列表") | |||||
| public ResultData list(@ModelAttribute WxMsgModel wxMsgModel, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgModelController::list"); | |||||
| if (null == wxMsgModel) wxMsgModel = new WxMsgModel(); | |||||
| wxMsgModel.updateTenantInfo(getTenantInfo()); | |||||
| wxMsgModel.setSortColumns(BaseEntity.SortField.Createtime_DESC); | |||||
| final PageInfo<WxMsgModel> page = wxMsgModelService.listAsPage(wxMsgModel, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "短信模板-新增") | |||||
| public ResultData add(@RequestBody WxMsgModel wxMsgModel) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgModelController::add"); | |||||
| //Assert.notNull(wxMsgModel.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxMsgModel.updateTenantInfo(getTenantInfo()); | |||||
| if(wxMsgModel.getTemplateType() == null){ | |||||
| wxMsgModel.setTemplateType(EnumMsgModelType.TZ.getCode()); | |||||
| } | |||||
| return wxMsgModelService.saveOrUpdate(wxMsgModel); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "短信模板-更新") | |||||
| public ResultData update(@RequestBody WxMsgModel wxMsgModel) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgModelController::update"); | |||||
| return wxMsgModelService.saveOrUpdate(wxMsgModel); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "短信模板-删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgModelController::delete"); | |||||
| wxMsgModelService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "短信模板-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgModelController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxMsgModelService.getById(id)); | |||||
| } | |||||
| @ApiOperation("获取所有数据") | |||||
| @GetMapping("getmodellist") | |||||
| @SystemControllerLog(description = "短信模板-获取所有数据") | |||||
| public ResultData getModelList() { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgModelController::getmodellist"); | |||||
| return wxMsgModelService.getModelList(getTenantInfo()); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,92 @@ | |||||
| package com.iformall.controller.msg; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.WxMsgSignature; | |||||
| import com.iformall.service.WxMsgSignatureService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxMsgSignature") | |||||
| public class WxMsgSignatureController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMsgSignatureService wxMsgSignatureService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "消息签名-列表") | |||||
| public ResultData list(@ModelAttribute WxMsgSignature wxMsgSignature, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgSignatureController::list"); | |||||
| if (null == wxMsgSignature) wxMsgSignature = new WxMsgSignature(); | |||||
| wxMsgSignature.updateTenantInfo(getTenantInfo()); | |||||
| wxMsgSignature.setSortColumns(BaseEntity.SortField.Createtime_DESC); | |||||
| final PageInfo<WxMsgSignature> page = wxMsgSignatureService.listAsPage(wxMsgSignature, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "消息签名-新增") | |||||
| public ResultData add(@RequestBody WxMsgSignature wxMsgSignature) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgSignatureController::add"); | |||||
| //Assert.notNull(wxMsgSignature.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxMsgSignature.updateTenantInfo(getTenantInfo()); | |||||
| wxMsgSignatureService.saveOrUpdate(wxMsgSignature); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "消息签名-更新") | |||||
| public ResultData update(@RequestBody WxMsgSignature wxMsgSignature) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgSignatureController::update"); | |||||
| wxMsgSignature.updateTenantInfo(getTenantInfo()); | |||||
| wxMsgSignatureService.saveOrUpdate(wxMsgSignature); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "消息签名-删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgSignatureController::delete"); | |||||
| wxMsgSignatureService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "消息签名-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgSignatureController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxMsgSignatureService.getById(id)); | |||||
| } | |||||
| @ApiOperation("获取所有数据") | |||||
| @GetMapping("getsignaturelist") | |||||
| @SystemControllerLog(description = "消息签名-获取所有") | |||||
| public ResultData getsignaturelist() { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgSignatureController::getsignaturelist"); | |||||
| return wxMsgSignatureService.getSignatureList(getTenantInfo()); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,114 @@ | |||||
| package com.iformall.controller.msg; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxMsgValidationcode; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumProject; | |||||
| import com.iformall.service.WxMsgValidationcodeService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxMsgValidationcode") | |||||
| public class WxMsgValidationcodeController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMsgValidationcodeService wxMsgValidationcodeService; | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "消息验证码-列表") | |||||
| public ResultData list(@ModelAttribute WxMsgValidationcode wxMsgValidationcode, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeController::list"); | |||||
| if (null == wxMsgValidationcode) wxMsgValidationcode = new WxMsgValidationcode(); | |||||
| final PageInfo<WxMsgValidationcode> page = wxMsgValidationcodeService.listAsPage(wxMsgValidationcode, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "消息验证码-添加") | |||||
| public ResultData add(@RequestBody WxMsgValidationcode wxMsgValidationcode) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeController::add"); | |||||
| //Assert.notNull(wxMsgValidationcode.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxMsgValidationcode.updateTenantInfo(getTenantInfo()); | |||||
| wxMsgValidationcodeService.saveOrUpdate(wxMsgValidationcode); | |||||
| return new ResultData(); | |||||
| } | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "消息验证码-更新") | |||||
| public ResultData update(@RequestBody WxMsgValidationcode wxMsgValidationcode) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeController::update"); | |||||
| wxMsgValidationcode.updateTenantInfo(getTenantInfo()); | |||||
| wxMsgValidationcodeService.saveOrUpdate(wxMsgValidationcode); | |||||
| return new ResultData(); | |||||
| } | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "消息验证码-删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeController::update"); | |||||
| wxMsgValidationcodeService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "消息验证码-查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxMsgValidationcodeService.getById(id)); | |||||
| } | |||||
| @GetMapping("sendvalidationcode") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "tenantId", value = "租户ID", dataType = "String", paramType = "query"), | |||||
| @ApiImplicitParam(name = "parentTenantId", value = "父租户ID", dataType = "String", paramType = "query"), | |||||
| @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "type", value = "场景", dataType = "Integer", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "appid", value = "appid", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData sendvalidationcode(String tenantId, String parentTenantId, String phone, Integer type, String appid) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeController::sendvalidationcode"); | |||||
| WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||||
| wxMsgValidationcode.setTenantId(tenantId); | |||||
| wxMsgValidationcode.setParentTenantId(parentTenantId); | |||||
| wxMsgValidationcode.setPhone(phone); | |||||
| wxMsgValidationcode.setType(type); | |||||
| return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode,EnumProject.PROJECT_2.getCode()); | |||||
| } | |||||
| @GetMapping("hasvalidationcode") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "tenantId", value = "租户ID", dataType = "String", paramType = "query"), | |||||
| @ApiImplicitParam(name = "parentTenantId", value = "父租户ID", dataType = "String", paramType = "query"), | |||||
| @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "type", value = "场景", dataType = "Integer", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "code", value = "验证码", dataType = "String", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "appid", value = "appid", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData hasvalidationcode(String tenantId, String parentTenantId, String phone, Integer type, String code, String appid) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeController::hasvalidationcode"); | |||||
| WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||||
| wxMsgValidationcode.setTenantId(tenantId); | |||||
| wxMsgValidationcode.setParentTenantId(parentTenantId); | |||||
| wxMsgValidationcode.setPhone(phone); | |||||
| wxMsgValidationcode.setType(type); | |||||
| wxMsgValidationcode.setCode(code); | |||||
| return wxMsgValidationcodeService.hasvalidationcode(wxMsgValidationcode); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,95 @@ | |||||
| package com.iformall.controller.msg; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxMsgValidationcodeModel; | |||||
| import com.iformall.enums.EnumMsgModelReplace; | |||||
| import com.iformall.service.WxMsgValidationcodeModelService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxMsgValidationcodeModel") | |||||
| public class WxMsgValidationcodeModelController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMsgValidationcodeModelService wxMsgValidationcodeModelService; | |||||
| @ApiOperation("消息模板-列表") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "消息验证模板-列表") | |||||
| public ResultData list(@ModelAttribute WxMsgValidationcodeModel wxMsgValidationcodeModel, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeModelController::list"); | |||||
| if (null == wxMsgValidationcodeModel) wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | |||||
| wxMsgValidationcodeModel.updateTenantInfo(getTenantInfo()); | |||||
| PageInfo<WxMsgValidationcodeModel> page = wxMsgValidationcodeModelService.listAsPage(wxMsgValidationcodeModel, pageNum, pageSize); | |||||
| page.getList().forEach(m -> { | |||||
| for (EnumMsgModelReplace e : EnumMsgModelReplace.values()) { | |||||
| m.setContent(m.getContent().replace(e.getCode(),e.getMessage())); | |||||
| } | |||||
| }); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("消息模板-添加") | |||||
| @PostMapping("add") | |||||
| @SystemControllerLog(description = "消息验证模板-添加") | |||||
| public ResultData add(@RequestBody WxMsgValidationcodeModel wxMsgValidationcodeModel) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeModelController::add"); | |||||
| //Assert.notNull(wxMsgValidationcodeModel.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxMsgValidationcodeModel.updateTenantInfo(getTenantInfo()); | |||||
| return wxMsgValidationcodeModelService.saveOrUpdate(wxMsgValidationcodeModel); | |||||
| } | |||||
| @ApiOperation("消息模板-更新") | |||||
| @PostMapping("update") | |||||
| @SystemControllerLog(description = "消息验证模板-更新") | |||||
| public ResultData update(@RequestBody WxMsgValidationcodeModel wxMsgValidationcodeModel) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeModelController::update"); | |||||
| wxMsgValidationcodeModelService.saveOrUpdate(wxMsgValidationcodeModel); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("消息模板-打开/关闭发送") | |||||
| @PostMapping("updateOpen") | |||||
| @SystemControllerLog(description = "消息验证模板-打开/关闭发送") | |||||
| public ResultData updateOpen(@RequestBody WxMsgValidationcodeModel wxMsgValidationcodeModel) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeModelController::updateOpen"); | |||||
| wxMsgValidationcodeModelService.update(wxMsgValidationcodeModel); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("消息模板-删除") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "消息验证模板-删除") | |||||
| public ResultData delete(String id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeModelController::delete"); | |||||
| wxMsgValidationcodeModelService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("消息模板-查询") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "消息验证模板-查询") | |||||
| public ResultData findById(String id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeModelController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxMsgValidationcodeModelService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,133 @@ | |||||
| package com.iformall.controller.sys; | |||||
| import com.google.code.kaptcha.Constants; | |||||
| import com.google.code.kaptcha.Producer; | |||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.controller.sys.mallUserInfo.MallUserInfoBaseController; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.vo.MallUserInfoVo; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.service.*; | |||||
| import com.iformall.shiro.UserSession; | |||||
| import com.iformall.shiro.UseriFormallToken; | |||||
| import com.iformall.utils.Constant; | |||||
| import com.iformall.utils.RedisCacheUtils; | |||||
| import com.iformall.utils.ShiroUtils; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.io.IOUtils; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.apache.shiro.authc.DisabledAccountException; | |||||
| import org.apache.shiro.authc.UnknownAccountException; | |||||
| import org.apache.shiro.authc.UsernamePasswordToken; | |||||
| import org.apache.shiro.session.Session; | |||||
| import org.apache.shiro.subject.Subject; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.imageio.ImageIO; | |||||
| import javax.servlet.ServletException; | |||||
| import javax.servlet.ServletOutputStream; | |||||
| import javax.servlet.http.Cookie; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.awt.image.BufferedImage; | |||||
| import java.io.IOException; | |||||
| import java.net.URLEncoder; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @RestController | |||||
| @Api(description = "登录相关接口") | |||||
| public class HomeController extends MallUserInfoBaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Value("${version}") | |||||
| private String version; | |||||
| @Autowired | |||||
| private Producer producer; | |||||
| @Autowired | |||||
| @Qualifier("objectCommonRedisTemplate") | |||||
| RedisTemplate<String, Object> redisTemplate; | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("验证码") | |||||
| @GetMapping("/captcha.jpg") | |||||
| public void captcha(HttpServletResponse response)throws ServletException, IOException { | |||||
| logger.debug("[" + getIpAddr() + "] HomeController::captcha"); | |||||
| response.setHeader("Cache-Control", "no-store, no-cache"); | |||||
| response.setContentType("image/jpeg"); | |||||
| //生成文字验证码 | |||||
| String text = producer.createText(); | |||||
| //生成图片验证码 | |||||
| BufferedImage image = producer.createImage(text); | |||||
| //保存到shiro session | |||||
| // ShiroUtils.setSessionAttribute(Constants.KAPTCHA_SESSION_KEY, text); | |||||
| String key = Constant.captchaPrev + ":" + getIpAddr(); | |||||
| RedisCacheUtils.cache(redisTemplate, key, text, 60); | |||||
| logger.info("验证码接口-生成的验证码:{}", text); | |||||
| ServletOutputStream out = response.getOutputStream(); | |||||
| ImageIO.write(image, "jpg", out); | |||||
| IOUtils.closeQuietly(out); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("慧影登录") | |||||
| @PostMapping("/doLogin") | |||||
| public ResultData login(@RequestBody MallUserInfo user, HttpServletResponse response) { | |||||
| return doLogin(user, response, EnumProject.PROJECT_2); | |||||
| } | |||||
| @ApiOperation("慧影发送手机验证码") | |||||
| @GetMapping("sendLoginPhoneCode") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData sendLoginPhoneCode(String phone) { | |||||
| return doSendLoginPhoneCode(phone, EnumProject.PROJECT_2); | |||||
| } | |||||
| @ApiOperation(value = "慧影手机验证码登录", notes = "{\"phone\",\"string\",\"code\",\"string\"}") | |||||
| @PostMapping("/doLoginByPhone") | |||||
| public ResultData doLoginByPhone(@RequestBody Map<String, String> params, HttpServletResponse response) { | |||||
| return doLoginByPhone(params, response, EnumProject.PROJECT_2); | |||||
| } | |||||
| @ApiOperation("登出") | |||||
| @GetMapping("/logout") | |||||
| @SystemControllerLog(description = "用户登出") | |||||
| public ResultData logout() { | |||||
| logger.debug("[" + getIpAddr() + "] HomeController::logout"); | |||||
| ResultData data = new ResultData(); | |||||
| SecurityUtils.getSubject().logout(); | |||||
| return data; | |||||
| } | |||||
| @ApiOperation("获取后端版本号") | |||||
| @GetMapping("/version") | |||||
| public ResultData version() { | |||||
| logger.debug("[" + getIpAddr() + "] HomeController::version"); | |||||
| logger.info(">>>>>>>>>>>>>"+version); | |||||
| return new ResultData(version); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,164 @@ | |||||
| package com.iformall.controller.sys; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumUserAdmin; | |||||
| import com.iformall.service.MallRolePermissionService; | |||||
| import com.iformall.service.MallRoleService; | |||||
| import com.iformall.service.MallUserRoleService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("role") | |||||
| @Api(description = "角色相关接口") | |||||
| public class MallRoleController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private MallRoleService sysRoleService; | |||||
| @Autowired | |||||
| private MallRolePermissionService sysRolePermissionService; | |||||
| @Autowired | |||||
| private MallUserRoleService mallUserRoleService; | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("角色列表") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData list(MallRole sysRole, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] MallRoleController::list"); | |||||
| sysRole.updateTenantInfo(getTenantInfo()); | |||||
| sysRole.setSortColumns(BaseEntity.SortField.Id_DESC); | |||||
| final PageInfo<MallRole> page = sysRoleService.listAsPage(sysRole, pageNum, pageSize); | |||||
| for (MallRole r : page.getList()) { | |||||
| MallRolePermission p = new MallRolePermission(); | |||||
| p.setRoleId(r.getId()); | |||||
| p.updateTenantInfo(sysRole); | |||||
| List<MallRolePermission> pers = sysRolePermissionService.getList(p); | |||||
| String menus = ""; | |||||
| for (MallRolePermission rp : pers) { | |||||
| menus += rp.getPermissionId() + ","; | |||||
| } | |||||
| if (menus.length() > 1) { | |||||
| menus = menus.substring(0, menus.length() - 1); | |||||
| } | |||||
| r.setMenus(menus); | |||||
| } | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("角色详情") | |||||
| @GetMapping("findById") | |||||
| //@RequiresPermissions("sys:role:get") | |||||
| @SystemControllerLog(description = "用户管理-role信息") | |||||
| public ResultData findById(MallRole sysRole) { | |||||
| logger.debug("[" + getIpAddr() + "] MallRoleController::list"); | |||||
| if (sysRole.getId() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| MallRole role = sysRoleService.getById(sysRole.getId()); | |||||
| MallRolePermission p = new MallRolePermission(); | |||||
| p.setRoleId(role.getId()); | |||||
| p.updateTenantInfo(getTenantInfo()); | |||||
| List<MallRolePermission> pers = sysRolePermissionService.getList(p); | |||||
| String menus = ""; | |||||
| for (MallRolePermission rp : pers) { | |||||
| menus += rp.getPermissionId() + ","; | |||||
| } | |||||
| if (menus.length() > 1) { | |||||
| menus = menus.substring(0, menus.length() - 1); | |||||
| } | |||||
| role.setMenus(menus); | |||||
| return new ResultData(role); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("角色保存") | |||||
| @PostMapping("saveOrUpdate") | |||||
| //@RequiresPermissions("sys:role:save") | |||||
| @SystemControllerLog(description = "用户管理-rule保存") | |||||
| public ResultData saveOrUpdate(@RequestBody MallRole sysRole) { | |||||
| logger.debug("[" + getIpAddr() + "] MallRoleController::saveOrUpdate"); | |||||
| MallUserInfo currentUser = getUser(); | |||||
| if(!getTenantInfo().getTenantId().equals(currentUser.getTenantId())){ | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
| } | |||||
| if (currentUser.getIsAdmin().equals(EnumUserAdmin.Normal.getCode())) { | |||||
| return new ResultData(ErrorCode.USER_NOT_ADMIN.getCode(), "只有系统管理员才能保存角色"); | |||||
| } | |||||
| int count = checkUnique(sysRole.getName(), currentUser); | |||||
| if (sysRole.getId() == null && count > 0) { | |||||
| return new ResultData(ResultData.ERROR, "角色名已存在"); | |||||
| } | |||||
| sysRole.updateTenantInfo(currentUser); | |||||
| sysRoleService.saveOrUpdate(sysRole); | |||||
| if (StringUtils.isNoneBlank(sysRole.getMenus())) { | |||||
| String[] menuIds = sysRole.getMenus().split(","); | |||||
| List<Long> mIds = new ArrayList<>(); | |||||
| for (String mId : menuIds) { | |||||
| mIds.add(Long.valueOf(mId)); | |||||
| } | |||||
| sysRolePermissionService.savePermissions(currentUser, sysRole.getId(), mIds.toArray(new Long[]{})); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("角色删除") | |||||
| @PostMapping("/del") | |||||
| //@RequiresPermissions("sys:role:del") | |||||
| @SystemControllerLog(description = "用户管理-rule删除") | |||||
| public ResultData delete(@RequestBody MallRole sysRole) { | |||||
| logger.debug("[" + getIpAddr() + "] MallRoleController::delete"); | |||||
| MallUserInfo currentUser = getUser(); | |||||
| if (currentUser.getIsAdmin().equals(EnumUserAdmin.Normal.getCode())) { | |||||
| return new ResultData(ErrorCode.USER_NOT_ADMIN.getCode(), "只有系统管理员才能删除角色"); | |||||
| } | |||||
| if(!getTenantInfo().getTenantId().equals(currentUser.getTenantId())){ | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
| } | |||||
| MallUserRole record = new MallUserRole(); | |||||
| record.setRoleId(sysRole.getId()); | |||||
| int count = mallUserRoleService.cntUserList(record); | |||||
| if (count > 0) { | |||||
| return new ResultData(ErrorCode.USER_USE_ROLE.getCode(), "有用户使用此角色,请先删除相应的用户!!"); | |||||
| } | |||||
| sysRoleService.deleteById(sysRole.getId()); | |||||
| sysRolePermissionService.deleteByRoleId(sysRole.getId()); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| private int checkUnique(String name, TenantEntity tenantEntity) { | |||||
| MallRole role = new MallRole(); | |||||
| role.setName(name); | |||||
| role.updateTenantInfo(tenantEntity); | |||||
| return sysRoleService.countList(role); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,43 @@ | |||||
| package com.iformall.controller.sys; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.vo.MallUserActionVo; | |||||
| import com.iformall.service.MallUserActionService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("mallUserAction") | |||||
| public class MallUserActionController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private MallUserActionService mallUserActionService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData list(@ModelAttribute MallUserActionVo userAction, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] MallUserActionController::list"); | |||||
| if (null == userAction) { | |||||
| userAction = new MallUserActionVo(); | |||||
| } else { | |||||
| if(StringUtils.isBlank(userAction.getName())) { | |||||
| userAction.setName(null); | |||||
| } | |||||
| } | |||||
| final PageInfo<MallUserActionVo> page = mallUserActionService.listAsPage(userAction, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,211 @@ | |||||
| package com.iformall.controller.sys; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.controller.sys.mallUserInfo.MallUserInfoBaseController; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.enums.EnumMallUserStatus; | |||||
| import com.iformall.enums.EnumProject; | |||||
| import com.iformall.enums.EnumUserAdmin; | |||||
| import com.iformall.service.*; | |||||
| import com.iformall.shiro.PasswordHelper; | |||||
| import com.iformall.shiro.UserSession; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.util.Assert; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * @author chenkx | |||||
| * @date 2018-01-05. | |||||
| */ | |||||
| @Api(value = "API - UserInfoController", description = "用户接口") | |||||
| @RestController | |||||
| @RequestMapping("user") | |||||
| public class MallUserInfoController extends MallUserInfoBaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| MallUserRoleService mallUserRoleService; | |||||
| @Autowired | |||||
| MallPermissionService mallPermissionService; | |||||
| @Autowired | |||||
| MallRolePermissionService mallRolePermissionService; | |||||
| @Autowired | |||||
| WxMsgValidationcodeService wxMsgValidationcodeService; | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation(value = "慧影-用户分页接口", response = String.class) | |||||
| @GetMapping("lists") | |||||
| //@RequiresPermissions("sys:user:list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "用户管理-列表") | |||||
| public ResultData listAsPage(MallUserInfo userInfo, Integer pageNum, Integer pageSize) { | |||||
| return listAsPage(userInfo, pageNum, pageSize, EnumProject.PROJECT_2); | |||||
| } | |||||
| @ApiOperation(value = "用户详情接口", response = String.class) | |||||
| @GetMapping("detail") | |||||
| //@RequiresPermissions("sys:user:info") | |||||
| @SystemControllerLog(description = "用户管理-用户详情") | |||||
| public ResultData detail(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::detail"); | |||||
| final MallUserInfo user = userInfoService.getById(id); | |||||
| user.setPassword(null); | |||||
| user.setBopenId(null); | |||||
| if(StringUtils.isNotBlank(user.getWebOpenId())) { | |||||
| user.setWebOpenId("保密"); | |||||
| } | |||||
| return new ResultData(user); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation(value = "慧影-创建用户接口", response = String.class) | |||||
| @PostMapping("add") | |||||
| //@RequiresPermissions("sys:user:add") | |||||
| @SystemControllerLog(description = "用户管理-创建用户") | |||||
| public ResultData createUser(@RequestBody MallUserInfo userInfo) { | |||||
| return doCreateUser(userInfo, EnumProject.PROJECT_2); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation(value = "慧影-修改用户接口", response = String.class) | |||||
| @PostMapping("update") | |||||
| //@RequiresPermissions("sys:user:update") | |||||
| @SystemControllerLog(description = "用户管理-修改用户") | |||||
| public ResultData updateUser(@RequestBody MallUserInfo userInfo) { | |||||
| return doUpdateUser(userInfo,EnumProject.PROJECT_2); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation(value = "删除用户接口", response = String.class) | |||||
| @PostMapping("/del") | |||||
| //@RequiresPermissions("sys:user:del") | |||||
| @SystemControllerLog(description = "用户管理-删除用户") | |||||
| public ResultData deleteUser(@RequestBody MallUserInfo userInfo) { | |||||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::deleteUser"); | |||||
| MallUserInfo currentUser = getUser(); | |||||
| if (currentUser.getIsAdmin().equals(EnumUserAdmin.Normal.getCode())) { | |||||
| return new ResultData(ErrorCode.USER_NOT_ADMIN.getCode(), "只有系统管理员才能删除用户"); | |||||
| } | |||||
| // if(!getTenantInfo().getTenantId().equals(currentUser.getTenantId())){ | |||||
| // return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
| // } | |||||
| if (currentUser.getId().equals(userInfo.getId())) { | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "用户不能删除自己"); | |||||
| } | |||||
| userInfoService.deleteById(userInfo.getId()); | |||||
| userRoleService.deleteByUserId(userInfo.getId()); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation(value = "起停用户接口") | |||||
| @PostMapping("updateStatus") | |||||
| //@RequiresPermissions("sys:user:update") | |||||
| @SystemControllerLog(description = "用户管理-起停用户") | |||||
| public ResultData modifyStatus(@RequestBody MallUserInfo userInfo) { | |||||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::modifyStatus"); | |||||
| MallUserInfo currentUser = getUser(); | |||||
| if (currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode())) { | |||||
| // if(!getTenantInfo().getTenantId().equals(currentUser.getTenantId())){ | |||||
| // return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
| // } | |||||
| MallUserInfo userInfo1 = userInfoService.getById(userInfo.getId()); | |||||
| if(userInfo1 == null) { | |||||
| logger.error(ErrorCode.USER_IS_EMPTY.getMessage()); | |||||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| MallUserInfo updateUserInfo = new MallUserInfo(); | |||||
| updateUserInfo.setId(userInfo.getId()); | |||||
| updateUserInfo.updateTenantInfo(currentUser); | |||||
| updateUserInfo.setStatus(userInfo.getStatus()); | |||||
| userInfoService.saveOrUpdate(userInfo); | |||||
| return new ResultData(); | |||||
| } else { | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
| } | |||||
| } | |||||
| @ApiOperation(value = "用户权限检查") | |||||
| @GetMapping("hasButtonPermission") | |||||
| @SystemControllerLog(description = "用户管理-用户权限检查") | |||||
| public ResultData hasButtonPermission(String permissions) { | |||||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::hasButtonPermission"); | |||||
| MallUserInfo info = getUser(); | |||||
| info.setPassword("保密"); | |||||
| Map<String, Boolean> map = new HashMap<>(); | |||||
| for (String name : permissions.split(",")) { | |||||
| Long userId = (Long)SecurityUtils.getSubject().getSession().getAttribute(UserSession.userId); | |||||
| boolean has = userInfoService.hasButtonPermission(userId, name); | |||||
| map.put(name, has); | |||||
| } | |||||
| return new ResultData(map); | |||||
| } | |||||
| @ApiOperation(value = "用户权限检查") | |||||
| @GetMapping("getUser") | |||||
| //@RequiresPermissions("sys:user:info") | |||||
| @SystemControllerLog(description = "用户管理-获取用户信息") | |||||
| public ResultData getUserInfo() { | |||||
| ///logger.debug("[" + getIpAddr() + "] MallUserInfoController::getUserInfo"); | |||||
| MallUserInfo info = getUser(); | |||||
| info.protectInfos(); | |||||
| return new ResultData(info); | |||||
| } | |||||
| @ApiOperation(value = "获取菜单") | |||||
| @GetMapping("/getMenu") | |||||
| @SystemControllerLog(description = "用户管理-获取菜单") | |||||
| public ResultData getMenu() { | |||||
| MallUserInfo info = getUser(); | |||||
| String menu = userRoleService.getPermissionsByUser(info); | |||||
| return new ResultData(menu); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation(value = "慧影-用户密码发送验证码") | |||||
| @GetMapping("sendvalidationcode") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "userName", value = "手机号", dataType = "String", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "type", value = "场景(1:登录)", dataType = "Integer", paramType = "query", required = true)}) | |||||
| public ResultData sendvalidationcode(String userName, Integer type) { | |||||
| return doSendvalidationcode(userName,type,EnumProject.PROJECT_2); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation(value = "慧影-修改密码", notes = "{\"userName\",\"string\",\"pwd\",\"string\"}") | |||||
| @PostMapping("/updatepwd") | |||||
| @SystemControllerLog(description = "用户管理-修改密码") | |||||
| public ResultData updatepwd(@RequestBody Map<String, String> params) { | |||||
| return doUpdatepwd(params, EnumProject.PROJECT_2); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,62 @@ | |||||
| package com.iformall.controller.sys; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.MallRole; | |||||
| import com.iformall.domain.po.MallRolePermission; | |||||
| import com.iformall.domain.po.SysConfig; | |||||
| import com.iformall.domain.po.SysConfigValue; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.service.SysConfigService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("sysConfig") | |||||
| public class SysConfigController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private SysConfigService sysConfigService; | |||||
| @ApiOperation("角色列表") | |||||
| @GetMapping("list") | |||||
| //@RequiresPermissions("sys:role:list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData list(MallRole sysRole, Integer pageNum, Integer pageSize) { | |||||
| SysConfig config = new SysConfig(); | |||||
| config.setStatus(0); | |||||
| PageInfo<SysConfig> page = sysConfigService.listAsPage(config, pageNum, pageSize, getTenantInfo()); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("详情接口") | |||||
| @GetMapping("detail") | |||||
| @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id", dataType = "long", paramType = "query", required = true)}) | |||||
| public ResultData detail(Long id) { | |||||
| SysConfig config = sysConfigService.getById(id, getTenantInfo()); | |||||
| return new ResultData(config); | |||||
| } | |||||
| @ApiOperation("更新值接口") | |||||
| @PostMapping("saveValue") | |||||
| public ResultData saveValue(@RequestBody SysConfigValue configValue) { | |||||
| sysConfigService.saveConfigValue(configValue.getConfigItemId(), getTenantInfo(), configValue.getConfigItemValue()); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,122 @@ | |||||
| package com.iformall.controller.sys; | |||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.MallPermission; | |||||
| import com.iformall.domain.po.MallRole; | |||||
| import com.iformall.domain.po.MallRolePermission; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumMenuType; | |||||
| import com.iformall.enums.EnumPermissionType; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.MallPermissionService; | |||||
| import com.iformall.service.MallRolePermissionService; | |||||
| import com.iformall.service.MallRoleService; | |||||
| import com.iformall.service.MallUserInfoService; | |||||
| import com.iformall.utils.Constant; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.apache.shiro.authz.annotation.RequiresPermissions; | |||||
| import org.apache.shiro.util.Assert; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import org.springframework.web.method.HandlerMethod; | |||||
| import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; | |||||
| import org.springframework.web.servlet.mvc.method.RequestMappingInfo; | |||||
| import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; | |||||
| import java.util.*; | |||||
| /** | |||||
| * @author Stormeye Wu | |||||
| * @date 2019-04-20. | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("menu") | |||||
| public class SysMenuController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private MallPermissionService mallPermissionService; | |||||
| @Autowired | |||||
| private MallUserInfoService mallUserInfoService; | |||||
| @ApiOperation("导航菜单") | |||||
| @GetMapping("/nav") | |||||
| @SystemControllerLog(description = "菜单-导航菜单") | |||||
| public ResultData nav(){ | |||||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::nav"); | |||||
| MallUserInfo user = getUser(); | |||||
| List<MallPermission> menuList = mallPermissionService.getUserMenuList(user, 0L, true); | |||||
| Set<String> permissions = mallUserInfoService.getUserPermissions(user, true); | |||||
| Map map = new HashMap<>(); | |||||
| map.put("menuList", menuList); | |||||
| map.put("permissions", permissions); | |||||
| return new ResultData(map); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("所有菜单列表") | |||||
| @GetMapping("list") | |||||
| //@RequiresPermissions("sys:menu:list") | |||||
| @SystemControllerLog(description = "菜单-所有菜单列表") | |||||
| public ResultData getList() { | |||||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::list"); | |||||
| MallUserInfo user = getUser(); | |||||
| if (user.checkGroupAdmin()) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| user.setTenantId(tenantEntity.getTenantId()); | |||||
| if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { | |||||
| user.setParentTenantId(tenantEntity.getParentTenantId()); | |||||
| } | |||||
| } | |||||
| List<MallPermission> menuList = mallPermissionService.getUserMenuList(user, 0L, false); | |||||
| Set<String> permissions = mallUserInfoService.getUserPermissions(user, false); | |||||
| Map map = new HashMap<>(); | |||||
| map.put("menuList", menuList); | |||||
| map.put("permissions", permissions); | |||||
| return new ResultData(map); | |||||
| } | |||||
| @ApiOperation("菜单信息") | |||||
| @GetMapping("/findById") | |||||
| //@RequiresPermissions("sys:menu:info") | |||||
| @SystemControllerLog(description = "菜单-权限查找") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::findById"); | |||||
| return new ResultData(Result.SUCCESS, "成功", mallPermissionService.getById(id)); | |||||
| } | |||||
| @ApiOperation("获取父子菜单ID信息") | |||||
| @GetMapping("/getMenuIdsById") | |||||
| //@RequiresPermissions("sys:menu:info") | |||||
| @SystemControllerLog(description = "菜单-父子菜单查找") | |||||
| public ResultData getMenuIdsById(Long parentId) { | |||||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::getMenusById"); | |||||
| MallUserInfo user = getUser(); | |||||
| return new ResultData(Result.SUCCESS, "成功", mallPermissionService.queryUserMenuIds(user, parentId, false)); | |||||
| } | |||||
| @ApiOperation("获取父子菜单信息") | |||||
| @GetMapping("/getMenusById") | |||||
| //@RequiresPermissions("sys:menu:info") | |||||
| @SystemControllerLog(description = "菜单-父子菜单查找") | |||||
| public ResultData getMenusById(Long parentId) { | |||||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::getMenusById"); | |||||
| MallUserInfo user = getUser(); | |||||
| return new ResultData(Result.SUCCESS, "成功", mallPermissionService.getUserMenuList(user, parentId, false)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,37 @@ | |||||
| package com.iformall.controller.sys; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.SysNotice; | |||||
| import com.iformall.service.SysNoticeService; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("sysnotice") | |||||
| public class SysNoticeController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private SysNoticeService sysNoticeService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("sysNotice") | |||||
| public ResultData sysNotice() { | |||||
| SysNotice notice = new SysNotice(); | |||||
| notice.setStatus(1); | |||||
| notice.setType(1); | |||||
| List<SysNotice> noticelist = sysNoticeService.selectList(notice); | |||||
| if (null != noticelist && noticelist.size() > 0 ) { | |||||
| return new ResultData(noticelist.get(0)); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,206 @@ | |||||
| package com.iformall.controller.sys; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.file.aliyun.AliyunOSS; | |||||
| import com.iformall.utils.ImgUtil; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import javax.imageio.ImageIO; | |||||
| import java.awt.image.BufferedImage; | |||||
| import java.util.*; | |||||
| @RestController | |||||
| @RequestMapping(value = "upload") | |||||
| @Api(description = "文件上传接口") | |||||
| public class UploadController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private AliyunOSS aliyunOSS; | |||||
| /** | |||||
| * 上传文件 | |||||
| * | |||||
| * @param multiReq | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| @PostMapping(value = "/awsFileUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||||
| @ApiOperation("上传文件") | |||||
| @SystemControllerLog(description = "文件上传") | |||||
| public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq) { | |||||
| logger.info("[" + getIpAddr() + "] UploadController::awsfileUpload"); | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| try { | |||||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||||
| String fileFormat = ""; | |||||
| if (dot >= 0) { | |||||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||||
| } | |||||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||||
| return data; | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 图片上传 | |||||
| * | |||||
| * @param multiReq | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| @PostMapping(value = "/awsImgUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||||
| @ApiOperation("上传图片") | |||||
| @SystemControllerLog(description = "上传图片") | |||||
| public ResultData awsImgUpload(@RequestParam("file") MultipartFile multiReq | |||||
| ,@RequestParam Map<String, String> param) { | |||||
| logger.info("[" + getIpAddr() + "] UploadController::awsImgUpload"); | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| long size = multiReq.getSize(); | |||||
| final long length = 2097152; | |||||
| if (size > length) { | |||||
| return new ResultData(ErrorCode.PICTURE_SIZE_EXCEED); | |||||
| } | |||||
| String fileFormat = ""; | |||||
| try { | |||||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||||
| if (dot >= 0) { | |||||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||||
| } | |||||
| String imgFormat = ImgUtil.getImgFormat(fileFormat); | |||||
| if(StringUtils.isNotBlank(imgFormat)) { | |||||
| long maxSize = 0l; | |||||
| try { | |||||
| maxSize = Long.parseLong(param.get("size")); | |||||
| } catch (NumberFormatException e) {} | |||||
| if(maxSize > 0l && size > maxSize*1024){ | |||||
| return new ResultData(ErrorCode.PICTURE_SIZE_CUSTOMIZE); | |||||
| } | |||||
| BufferedImage bufferedImage = ImageIO.read(multiReq.getInputStream()); | |||||
| if(bufferedImage != null){ | |||||
| int width = 0;int hight = 0; | |||||
| try { | |||||
| width = Integer.parseInt(param.get("width")); | |||||
| hight = Integer.parseInt(param.get("hight")); | |||||
| } catch (NumberFormatException e) {} | |||||
| Integer relWidth = bufferedImage.getWidth(); | |||||
| Integer relHeight = bufferedImage.getHeight(); | |||||
| if((width > 0 && width != relWidth.intValue()) | |||||
| || (hight > 0 && hight != relHeight.intValue())){ | |||||
| return new ResultData(ErrorCode.PICTURE_W_H_CUSTOMIZE); | |||||
| } | |||||
| } | |||||
| } | |||||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||||
| return data; | |||||
| } catch (Exception e) { | |||||
| logger.error("解析图片",e); | |||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 多文件上传 | |||||
| * | |||||
| * @param files | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| @PostMapping(value = "/awsFilesUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||||
| @ApiOperation("多文件上传") | |||||
| @SystemControllerLog(description = "多文件上传") | |||||
| public ResultData awsFilesUpload(@RequestParam("files") MultipartFile[] files) { | |||||
| logger.info("[" + getIpAddr() + "] UploadController::awsFilesUpload"); | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| try { | |||||
| if(files.length > 0){ | |||||
| ResultData data = new ResultData(); | |||||
| List<Map<String,String>> dataList = new ArrayList<Map<String,String>>(); | |||||
| for(MultipartFile multipartFile: files) { | |||||
| Map<String, String> map = new HashMap<>(); | |||||
| map.put("key", multipartFile.getOriginalFilename()); | |||||
| int dot = multipartFile.getOriginalFilename().lastIndexOf('.'); | |||||
| String fileFormat = ""; | |||||
| if (dot >= 0) { | |||||
| fileFormat = multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length());; | |||||
| } | |||||
| ResultData data1 = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multipartFile.getInputStream()); | |||||
| if(data1.code == ResultData.SUCCESS) { | |||||
| Map _data = (Map)data1.data; | |||||
| map.put("url", (String) _data.get("url")); | |||||
| dataList.add(map); | |||||
| } else { | |||||
| // 部分成功 | |||||
| data.code = ResultData.SUCCESS; | |||||
| data.data = dataList; | |||||
| return data; | |||||
| } | |||||
| } | |||||
| data.code = ResultData.SUCCESS; | |||||
| data.data = dataList; | |||||
| return data; | |||||
| }else{ | |||||
| return new ResultData(); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 内部接口-A端上传图片文件 | |||||
| * | |||||
| * @param multiReq | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| @PostMapping(value = "/cimgUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||||
| @ApiOperation("内部接口-A端上传图片文件") | |||||
| public ResultData cimgUpload(@RequestParam("file") MultipartFile multiReq) { | |||||
| logger.info("[" + getIpAddr() + "] UploadController::cimgUpload"); | |||||
| try { | |||||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||||
| String fileFormat = ""; | |||||
| if (dot >= 0) { | |||||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||||
| } | |||||
| ResultData data = aliyunOSS.uploadFile("builtin", fileFormat, multiReq.getInputStream()); | |||||
| return data; | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||||
| } | |||||
| } | |||||
| } | |||||