1.6总结

发布时间 2024-01-06 16:06:38作者: 奉禾

程序整理

private static DataSource ds ;

static {

    try {
        //1.加载配置文件
        Properties pro = new Properties();
        //使用ClassLoader加载配置文件,获取字节输入流
        InputStream is = JDBCUtils.class.getClassLoader().getResourceAsStream("druid.properties");
        pro.load(is);
        //2.初始化连接池对象
        ds = DruidDataSourceFactory.createDataSource(pro);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

/**
 * 获取连接池对象
 */
public static DataSource getDataSource(){
    return ds;
}


/**
 * 获取连接Connection对象
 */
public static Connection getConnection() throws SQLException {
    return  ds.getConnection();
}

}
这样的话使用起来也简单

corsconfig是一个基于Spring框架的配置类,

Loggerinterceptor拦截器,用于记录用户的访问信息。主要功能是在请求处理的不同阶段记录用户的访问信息,以便后续的监控。

SessionConfiguration则是配置拦截器
SessionInterceptor处理http请求,为了实现一个免登录效果,不用运行及登录,主要内容在preHandle()和afterCompletion()方法来处理请求。

BudgetController预算控制类,点击增加add就会跳转预算添加界面,grtlist根据分页和预算对象查找对象
public ResultBean add(String projectName,String content,double money,double cost,String remark,String completeTime) {
SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String date=dateFormat.format(new Date());
Budget budget=new Budget();
budget.setProjectName(projectName);
budget.setContent(content);
budget.setMoney(money);
budget.setCost(cost);
budget.setDateTime(date);
budget.setRemark(remark);
budget.setCompleteTime(completeTime);
budgetService.add(budget);
return ResultBean.success();
}
以及update delete更新删除操作。

Callpay为催缴款项,add跳转到支付添加界面,然后可以根据电话号码跳转到cuijiao(Model model, Integer id)界面callType为催缴支付情况。

public ResultBean callType(Integer callpayId,Integer callType) {
SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String date=dateFormat.format(new Date());
Customer customer=callpayMapper.selectById(callpayId);
if (callType==0){
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("");
message.setTo(customer.getEmail());
message.setSubject("催缴信息");
message.setText("尊敬的"+customer.getcName()+",你有一笔缴费信息需要缴纳!");
javaMailSender.send(message);
}
return ResultBean.success();
}

BillController是账单的管理类
findByWhereNoPage统计图的查询方法

顾客增删改查控制类实现CustomerController

public class CustomerController {

@Autowired
CustomerService customerService;

// 跳转到客户添加页面
@GetMapping
public String add() {
    return "customer/customer-add";
}

// 获取客户列表
@GetMapping("/list")
@ResponseBody
public PageResultBean<Customer> getList(@RequestParam(value = "page", defaultValue = "1") int page,
                                      @RequestParam(value = "limit", defaultValue = "10") int limit,
                                      Customer customer) {
    List<Customer> sites = customerService.selectAll(page, limit, customer);
    PageInfo<Customer> userPageInfo = new PageInfo<>(sites);
    return new PageResultBean<>(userPageInfo.getTotal(), userPageInfo.getList());
}

// 添加客户
@PostMapping
@ResponseBody
public ResultBean add(String cName,String cNo,String password,String phone,String company,String address,String email) {

    SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    String date=dateFormat.format(new Date());
    Customer customer=new Customer(cName,phone,company,address,email,date);
    customer.setPassword(password);
    customer.setcNo(cNo);
    customerService.add(customer);
    return ResultBean.success();
}

@GetMapping("/{id}")
public String update(@PathVariable("id") Integer id, Model model) {
    model.addAttribute("customerInfo", customerService.selectOne(id));
    return "customer/customer-add";