提交 534c71ca 编写于 作者: U u014427391

重整项目结构

上级 a5d696b5
......@@ -27,7 +27,7 @@ public class BaseConfig {
/**
* repository 所在包
*/
public static final String REPOSITORY_PACKAGES = "com.muses.taoshop.repository";
public static final String REPOSITORY_PACKAGES = "com.muses.taoshop.**.repository";
/**
* mapper 所在包
......@@ -37,37 +37,17 @@ public class BaseConfig {
/**
* 实体类 所在包
*/
public static final String ENTITY_PACKAGES = "com.muses.taoshop.dto";
/**
* JPA 实体管理器
*/
public static final String ENTITY_MANAGER = "shopEntityManager";
/**
* JPA 实体管理器工厂
*/
public static final String ENTITY_MANAGER_FACTORY = "shopEntityManagerFactory";
/**
* JPA 事务管理器
*/
public static final String JPA_TRANSACTION_MANAGER = "shopJpaTransactionManager";
/**
* JPA 持久化单元
*/
public static final String PERSISTENCE_UNIT = "shopPersistenceUnit";
public static final String ENTITY_PACKAGES = "com.muses.taoshop.**.dto";
/**
* Mybatis session 工厂
*/
public static final String SQL_SESSION_FACTORY = "shopSqlSessionFactory";
public static final String SQL_SESSION_FACTORY = "sqlSessionFactory";
/**
* Mybatis 事务管理器
*/
public static final String MYBATIS_TRANSACTION_MANAGER = "shopMybatisTransactionManager";
public static final String MYBATIS_TRANSACTION_MANAGER = "mybatisTransactionManager";
/**
* Jedis连接池
......
......@@ -7,7 +7,8 @@ import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
import static com.muses.taoshop.common.core.database.config.BaseConfig.*;
import static com.muses.taoshop.common.core.database.config.BaseConfig.DATA_SOURCE_NAME;
import static com.muses.taoshop.common.core.database.config.BaseConfig.DATA_SOURCE_PROPERTIES;
/**
......
......@@ -4,19 +4,17 @@ import com.muses.taoshop.common.core.database.annotation.MybatisRepository;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.resource.PathResourceResolver;
import javax.sql.DataSource;
......@@ -59,7 +57,9 @@ public class MybatisConfig {
//factoryBean.setConfigLocation(new ClassPathResource("mybatis-config.xml"));
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
try{
factoryBean.setMapperLocations(resolver.getResources("classpath*:/mybatis/mapper/*Mapper.xml"));
factoryBean.setTypeAliasesPackage("com.muses.taoshop.**.dto");
factoryBean.setVfs(SpringBootVFS.class);
factoryBean.setMapperLocations(resolver.getResources("classpath*:/mybatis/*Mapper.xml"));
return factoryBean.getObject();
}catch (Exception e){
e.printStackTrace();
......
package com.muses.taoshop.portal.config;
package com.muses.taoshop.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;
......
package com.muses.taoshop.portal.web.controller;
package com.muses.taoshop.web.controller;
import com.alibaba.fastjson.JSON;
import com.muses.taoshop.item.dto.ItemBrand;
import com.muses.taoshop.item.service.IItemBrankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <pre>
......@@ -23,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestParam;
@RequestMapping("/portal")
public class IndexController {
@Autowired
IItemBrankService iItemBrankService;
//@RequestMapping(value = "/toIndex" ,method = RequestMethod.GET)
@GetMapping(value = "/toIndex.do")
public String toIndex(){
......@@ -34,4 +40,12 @@ public class IndexController {
return "";
}
@GetMapping(value = "/doTest")
@ResponseBody
public String doTest(){
List<ItemBrand> itemBrands = iItemBrankService.listItemBrand();
String str = JSON.toJSON(itemBrands).toString();
return str;
}
}
package com.muses.taoshop.item.service;
import com.muses.taoshop.item.dto.ItemBrand;
import java.util.List;
/**
* <pre>
* TODO 类说明
......@@ -13,4 +17,5 @@ package com.muses.taoshop.item.service;
* </pre>
*/
public interface IItemBrankService {
List<ItemBrand> listItemBrand();
}
......@@ -4,8 +4,10 @@ import com.muses.taoshop.common.core.database.annotation.MybatisRepository;
import com.muses.taoshop.item.dto.ItemBrand;
import java.util.List;
@MybatisRepository
public interface ItemBrandRepository {
public interface ItemBrandMapper {
int deleteByPrimaryKey(Long id);
......@@ -22,4 +24,6 @@ public interface ItemBrandRepository {
int updateByPrimaryKeySelective(ItemBrand record);
int updateByPrimaryKey(ItemBrand record);
List<ItemBrand> listItemBrand();
}
\ No newline at end of file
......@@ -4,7 +4,7 @@ import com.muses.taoshop.common.core.database.annotation.MybatisRepository;
import com.muses.taoshop.item.dto.ItemCategory;
@MybatisRepository
public interface ItemCategoryRepository {
public interface ItemCategoryMapper {
int deleteByPrimaryKey(Long id);
......
package com.muses.taoshop.item.service;
import com.muses.taoshop.item.dto.ItemBrand;
import com.muses.taoshop.item.mapper.ItemBrandMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <pre>
* TODO 类说明
......@@ -17,6 +22,14 @@ import org.springframework.stereotype.Service;
@Service
public class ItemBrankServiceImpl implements IItemBrankService{
@Autowired
ItemBrandMapper itemBrandMapper;
@Override
public List<ItemBrand> listItemBrand() {
return itemBrandMapper.listItemBrand();
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.muses.taoshop.item.mapper.ItemBrandMapper" >
<resultMap id="ItemBrand" type="com.muses.taoshop.item.dto.ItemBrand" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="brand_name" property="brandName" jdbcType="VARCHAR" />
<result column="last_modify_time" property="lastModifyTime" jdbcType="TIMESTAMP" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
</resultMap>
<select id="listItemBrand" resultMap="ItemBrand">
<![CDATA[
SELECT * from item_brand
]]>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册