Giter VIP home page Giter VIP logo

atfu-service's Introduction

atfu SpringBoot后台项目

配套前端项目

本项目主要演示:

  1. SpringBoot项目入门

  2. SpringBoot发送邮件

  3. SpringBoot集成mybatis-plus


准备数据库,执行以下MySQL脚本

mysql -uroot -p < ./sql/atfu.sql

修改application-dev.properties中你的MySQL密码

# 你的MySQL密码
spring.datasource.password=

设置application.properties中的你的QQ邮箱和授权码

# 你的邮箱
spring.mail.username[email protected]
# 你的QQ邮箱授权码,获取方式 https://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256
spring.mail.password=

获取QQ邮箱授权码方式

从idea导入项目,依赖下载完成后运行

下载前端项目并运行

前端项目链接

两个接口

产品数据接口,展示mybatis-plus的使用 mybatis-plus官网

    /**
     * 产品分页接口
     * 
     * @param page
     * @return com.yuan.atfu.domain.vo.BaseResponse
     * @author David Hong
     */
    @GetMapping("/{page}")
    public BaseResponse products(@PathVariable Integer page) {
        IPage<Product> iPage = productService.pageOrderByGmtCreateDesc(page, 10);
        Map<String, Object> ret = new HashMap<>(1);
        ret.put("list", iPage.getRecords());
        ret.put("total", iPage.getTotal());
        ret.put("currentPage", page);
        return BaseResponse.ok(ret);
    }

    /**
     * 产品搜索分页接口
     * 
     * @param content
     * @param page
     * @return com.yuan.atfu.domain.vo.BaseResponse
     * @author David Hong
     */
    @GetMapping("/search/{content}/{page}")
    public BaseResponse search(@PathVariable("content")String content, @PathVariable("page")Integer page) {
        log.info("search={}, page={}", content, page);
        IPage<Product> iPage = productService.search(content, page, 10);
        Map<String, Object> ret = new HashMap<>(1);
        ret.put("list", iPage.getRecords());
        ret.put("total", iPage.getTotal());
        ret.put("currentPage", page);
        return BaseResponse.ok(ret);
    }

mybatis-plus lambda方式拼接MySQL

    /**
     * 使用mybatis-plus提供的lambda的方式
     *
     * @param pageNum
     * @param pageSize
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.yuan.atfu.domain.entity.Product>
     * @author David Hong
     */
    @Override
    public IPage<Product> pageOrderByGmtCreateDesc(Integer pageNum, Integer pageSize) {
        return lambdaQuery()
                .orderByDesc(Product::getGmtCreate)
                .page(new Page<>(pageNum, pageSize));
    }

mybatis-plus mapper注解方式使用MySQL

    /**
     * MySQL like 查询
     *
     * @param page
     * @param content
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.yuan.atfu.domain.entity.Product>
     * @author David Hong
     */
    @Select("select * from product where no like #{content} or type like #{content} or brand like #{content} or package_type like #{content} order by gmt_create desc")
    IPage<Product> search(IPage<Product> page, String content);

产品展示页面

询问下单接口,发送邮件,展示SpringBootMail的使用

/**
 * @author David Hong
 * @version 1.0
 * @description 询问下单controller
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/intention")
public class IntentionController {

    @Autowired
    private IntentionService intentionService;

    @PostMapping
    public BaseResponse post(@RequestBody IntentionForm reqIntention) {
        log.info(reqIntention.toString());
        Intention intention = new Intention();
        BeanUtils.copyProperties(reqIntention, intention);
        // 插入 咨询意向 记录
        intention.insert();
        // 发送邮件
        intentionService.sendEmail(intention);
        return BaseResponse.ok("我们已收到询价下单请求,我们会尽快联系您!");
    }

}

询问下单发送邮件页面

atfu-service's People

Contributors

davidhong1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.