当前项目的品牌列表的查询

service

public interface BrandService {
    public List<TbBrand> findAll();
}

serviceimp

@Service
public class BrandServiceImpl implements BrandService {

    @Autowired
    private TbBrandMapper brandMapper;

    @Override
    public List<TbBrand> findAll() {
        return brandMapper.findAll();
    }
}

BrandController

@RestController
@RequestMapping("/brand")
public class BrandController {
	@Reference
	private BrandService brandService;
	/**
	 * 返回全部列表
	 * @return
	 */
	@RequestMapping("/findAll")
	public List<TbBrand> findAll(){			
		return brandService.findAll();
	}
}

总结:利用反向工程generatorSqlmapCustom实现实体类与数据访问层代码的自动生成

pinyougou-pojo工程中创建po层,把生成的po层代码拷贝到po层中;pingyougou-dao工程中创建dao层,把生成的dao层代码拷贝到dao层中;pinyougou-sellergoods-interface工程中创建service层,在其中新建BrandService接口;pinyougou-sellergoods-service工程中创建serviceimp层,在其中新建BrandServiceImpl来实现BrandService接口,写入查询所有品牌的代码;pingyougou-manager-web工程中创建controller层,在其中新建BrandController类,写入实现查询的代码。最后运行sercice和web工程,进行测试。

猜你喜欢

转载自blog.csdn.net/Liaoyuh/article/details/81322144