Skip to content

Commit

Permalink
11/4
Browse files Browse the repository at this point in the history
  • Loading branch information
sususama committed Nov 11, 2019
1 parent 9a3df6e commit 8041cf4
Show file tree
Hide file tree
Showing 5 changed files with 331 additions and 0 deletions.
165 changes: 165 additions & 0 deletions APO1/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

95 changes: 95 additions & 0 deletions APO1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>edu.xatu</groupId>
<artifactId>APO1</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.1.9.RELEASE</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.48</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.20</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13-beta-3</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>

</dependencies>
</project>
21 changes: 21 additions & 0 deletions APO1/src/main/java/edu/xatu/dao/ChannelDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package edu.xatu.dao;

import edu.xatu.entity.Accout;
import edu.xatu.entity.Channel;

public interface ChannelDao {
public void addChannel(Channel channel);

/**
* 根据帐号名查询帐号
* @param accountName
* @return
*/
public Accout findByAccountName(String accountName);

/**
* 修改帐号
* @param account
*/
public void updateAccount(Accout account);
}
41 changes: 41 additions & 0 deletions APO1/src/main/java/edu/xatu/dao/ChannelDaoImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package edu.xatu.dao;

import edu.xatu.entity.Accout;
import edu.xatu.entity.Channel;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.sql.ResultSet;
import java.sql.SQLException;

@Repository
public class ChannelDaoImpl implements ChannelDao {
@Resource
private JdbcTemplate jdbcTemplate;
public void addChannel(Channel channel) {
String sql="insert into t_channel values(?,?,?)";
jdbcTemplate.update(sql,channel.getCid(),
channel.getCname(),
channel.getDescription());
}

public Accout findByAccountName(String accountName) {
String sql = "select * from t_account where accountName = ?";

return jdbcTemplate.queryForObject(sql, new RowMapper<Accout>() {
public Accout mapRow(ResultSet resultSet, int i) throws SQLException {
Accout a = new Accout();
a.setAccountName(resultSet.getString("accountName"));
a.setMoney(resultSet.getInt("money"));
return a;
}
},accountName);
}

public void updateAccount(Accout account) {
String sql = "update t_account set money = ? where accountName = ?";
jdbcTemplate.update(sql,account.getMoney(),account.getAccountName());
}
}
9 changes: 9 additions & 0 deletions APO1/src/main/java/edu/xatu/entity/Accout.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package edu.xatu.entity;

import lombok.Data;

@Data
public class Accout {
private String accountName;
private int money;
}

0 comments on commit 8041cf4

Please sign in to comment.