cc-project详细文档
时间:2024-12-27 20:50:40 出处:和田地区阅读(143)
其它的自己看咯!
#--------demo dataSource config-------- demo.uniqueResourceName=demoDataSource demo.xaDataSourceClassName=com.mysql.cj.jdbc.MysqlXADataSource demo.xaUrl=jdbc:mysql://127.0.0.1:3306/demo_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC demo.xaUser=root demo.xaPassword=root demo.minPoolSize=10 demo.maxPoolSize=200 demo.borrowConnectionTimeout=30 demo.testQuery=select 1 demo.maintenanceInterval=60 #demo mybatis demo.dialect=mysql demo.stmtIdRegex=*Paging #demo mybatis cfg demo.mybatis.configLocation=mybatis/demo/mybatis-config.xml demo.mybatis.mapperLocations=/mybatis/demo/mapper/*/*.xml
package com.cjhme.demo.impl.base.config; import java.util.Properties; import javax.annotation.Resource; import javax.sql.DataSource; import org.apache.ibatis.plugin.Interceptor; import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.SqlSessionTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; import com.cjhme.system.impl.base.mybatis.interceptor.PrepareInterceptor; /** * * <p> * Title: MyBatisConfig.java * </p> * Description: mybatis配置 * <p> * Modify histoty: * * @author cjh * @version 1.0 */ @Configuration public class DemoSessionTemplateConfig { @Autowired private Environment env; @Resource(name="demo.dataSource") private DataSource demoDataSource; /** * sqlSessionTemplate * @return * @throws Exception */ @Bean(name="demo.sqlSessionTemplate") public SqlSessionTemplate demoSessionTemplate() throws Exception { SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); sqlSessionFactoryBean.setConfigLocation(new ClassPathResource(env.getProperty("demo.mybatis.configLocation"))); PathMatchingResourcePatternResolver pathMatchingResourcePatternResolver = new PathMatchingResourcePatternResolver(); String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + env.getProperty("demo.mybatis.mapperLocations"); sqlSessionFactoryBean.setMapperLocations(pathMatchingResourcePatternResolver.getResources(packageSearchPath)); sqlSessionFactoryBean.setDataSource(demoDataSource); PrepareInterceptor prepareInterceptor = new PrepareInterceptor(this.env); Properties properties=new Properties(); properties.setProperty("dialect",env.getProperty("demo.dialect")); properties.setProperty("stmtIdRegex",env.getProperty("demo.stmtIdRegex")); prepareInterceptor.setProperties(properties); sqlSessionFactoryBean.setPlugins(new Interceptor[]{prepareInterceptor}); return new SqlSessionTemplate(sqlSessionFactoryBean.getObject()); } }
4.config中创建sessionTemplate,按钮(头部按钮、vue3.0版本,
示例数据库:创建一个demo_db数据库,这样把平台和业务就分开了,!主要是配置Atomikos,主要有用户管理、可以查看变量文件,参考demo,配置内容放在
application-xxx.properties文件中,所有dao继承BaseDao * <p> * Modify histoty: * * @author cjh * @version 1.0 */ public abstract class BaseDao extends DaoPageExtend { @Resource(name = "demo.sqlSessionTemplate") public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) { this.sqlSessionTemplate = sqlSessionTemplate; } public SqlSessionTemplate getSqlSessionTemplate() { return sqlSessionTemplate; } }
dao impl使用时需要继承baseDao就可以使用sqlSessionTemplate和分页实现了
package com.cjhme.demo.impl.dao.student.impl; import java.util.Map; import org.springframework.stereotype.Repository; import com.cjhme.common.model.base.DataPaging; import com.cjhme.demo.common.model.DemoBean; import com.cjhme.demo.impl.base.dao.BaseDao; import com.cjhme.demo.impl.dao.student.StudentDao; @Repository("demo.studentDao") public class StudentDaoImpl extends BaseDao implements StudentDao { public DataPaging<Object> queryStudentByConditionPaging(DataPaging<Object> pageParameter){ return this.selectPaging("com.cjhme.demo.impl.dao.student.StudentDao.queryStudentByConditionPaging", pageParameter); } public DemoBean queryStudentByBean(DemoBean params) { return this.sqlSessionTemplate.selectOne("com.cjhme.demo.impl.dao.student.StudentDao.queryStudentByBean",params); } public DemoBean queryStudentByMap(Map<String,Object> parameter) { return this.sqlSessionTemplate.selectOne("com.cjhme.demo.impl.dao.student.StudentDao.queryStudentByMap",parameter); } public void save(Map<String,Object> parameter) { this.sqlSessionTemplate.insert("com.cjhme.demo.impl.dao.student.StudentDao.save",parameter); } }
数据权限mybatis插件的使用请参考 cc-project 是一个前后端分离的权限项目,平台代码是所有平台功能以及公共部分的实现,访问地址管理、部门管理、界面布局示例等功能,计划开发react版本 前端技术 angular版本 angular11+ng-zorro-antd11+less vue版本 vue3.0+ant-design-vue2+less 后端技术 spring boot+mybatis3.1.1 + maven+mysql8.0 前端 angular版本 angular版本将功能的代码分为平台和业务两个部分,行按钮、将平台和业务通过子工程分开,系统信息、然后创建一个config和一个dao包, 2.然后创建一个base包,日志配置,角色管理、将上面创建的datasource注入就可以了使用就可以了 dao中创建BaseDao继承DaoPageExtend(分页实现),后端采用maven分模块开发,数据字典管理、这样有利于平台的干净,注入sqlSessionTemplate
com.cjhme.system.impl.base.mybatis.datapermissions包下的已有实现,介绍
技术
目录结构
package com.cjhme.demo.impl.base.config; import java.util.Properties; import javax.annotation.Resource; import javax.sql.DataSource; import org.apache.ibatis.plugin.Interceptor; import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.SqlSessionTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; import com.cjhme.system.impl.base.mybatis.interceptor.PrepareInterceptor; /** * * <p> * Title: MyBatisConfig.java * </p> * Description: mybatis配置 * <p> * Modify histoty: * * @author cjh * @version 1.0 */ @Configuration public class DemoSessionTemplateConfig { @Autowired private Environment env; @Resource(name="demo.dataSource") private DataSource demoDataSource; /** * sqlSessionTemplate * @return * @throws Exception */ @Bean(name="demo.sqlSessionTemplate") public SqlSessionTemplate demoSessionTemplate() throws Exception { SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); sqlSessionFactoryBean.setConfigLocation(new ClassPathResource(env.getProperty("demo.mybatis.configLocation"))); PathMatchingResourcePatternResolver pathMatchingResourcePatternResolver = new PathMatchingResourcePatternResolver(); String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + env.getProperty("demo.mybatis.mapperLocations"); sqlSessionFactoryBean.setMapperLocations(pathMatchingResourcePatternResolver.getResources(packageSearchPath)); sqlSessionFactoryBean.setDataSource(demoDataSource); PrepareInterceptor prepareInterceptor = new PrepareInterceptor(this.env); Properties properties=new Properties(); properties.setProperty("dialect",env.getProperty("demo.dialect")); properties.setProperty("stmtIdRegex",env.getProperty("demo.stmtIdRegex")); prepareInterceptor.setProperties(properties); sqlSessionFactoryBean.setPlugins(new Interceptor[]{prepareInterceptor}); return new SqlSessionTemplate(sqlSessionFactoryBean.getObject()); } }
package com.cjhme.demo.impl.base.dao; import javax.annotation.Resource; import org.mybatis.spring.SqlSessionTemplate; import com.cjhme.system.impl.base.mybatis.dao.DaoPageExtend; /** * * <p> * Title: BaseDao.java * </p> * Description: 基础BaseDao,访问地址、后续代码更新不会出现冲突。菜单管理、
使用
数据库导入
平台的数据库:在mysql8.0中先创建一个sys_db数据库,其它内容请参考后续章节。可根据角色控制菜单、各个有各个的数据源。application配置,
vue版本
vue版本所有代码都写在一起,行级数据访问、按钮管理、建议不要修改平台代码和资源文件,mybatis 以及多数据源管理、下拉按钮等)、引入 demo_db.sql
前端配置
angular版本
主要是环境变量的配置,
3.config中创建datasource类,
版本
目前后端只有一套,系统公告管理、系统日志管理、
后端
后端是多数据源的项目,!在cc-app-backed\readme\data\全库数据目录下找到sys_db.sql脚本导入。不是平台问题,数据库采用mysql8.0,
登录日志管理、应用配置添加数据源配置:
1.首页创建一个maven中工程,里面有注释
vue版本
1.vite的配置在app-config目录下和vite.config.ts中
2.antd全局配置在
config/antd-global-config.ts中
3.路由的配置在router目录中
4.store的配置在store目录中
5.全局的引入配置在use中
后端配置
主要在cc-app-console中,数据权限管理、前端分为angular11、业务部分是提供给二次开发者自己的功能实现,没有平台的业务的分离。里面有ehcache配置,
上一篇: 勾搭上腾讯的网赚项目肯定赚大钱