Goods表設(shè)計(jì)的有問題啊
10年積累的成都網(wǎng)站制作、成都做網(wǎng)站經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有懷化免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
goods(贊數(shù))應(yīng)該在新聞表里
goods表只要存id
news_id(新聞id)
user_id(用戶id)
發(fā)sql查是否已點(diǎn)贊的時(shí)候where條件判斷news_id
和
user_id
select
count(1)
from
Goods
where
news_id=?
and
user_id=?
值大于0就代表已點(diǎn)贊
只等于0就插入點(diǎn)贊的數(shù)據(jù)
你要實(shí)現(xiàn)點(diǎn)贊哪種效果?
點(diǎn)贊標(biāo)簽初始化的時(shí)候使用空心紅邊的心做背景;
點(diǎn)贊之后把點(diǎn)贊標(biāo)簽的圖片換成紅色實(shí)心的心做背景;
在點(diǎn)贊操作的事件里面保存點(diǎn)贊數(shù)據(jù)到你的數(shù)據(jù)庫(kù)!
第一個(gè)類Customer
public class Customer{
private String firstName;
private String lastName;
private Account account;
public Customer(String f,String l){
this.firstName=f;
this.lastName=l;
}
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public Account getAccount(){return account;}
public void setAccount(Account acct){
this.account=acct;
}
}
第二個(gè)類Bank
public class Bank{
private int numberOfCustomers;
private List
customerList;
public Bank(){
customerList=new ArrayList
();
numberOfCustomers=customerList.size();
}
public int getNumberOfCustomers(){
return numberOfCustomers;
}
public void addCustomer(String f,String l){
customerList.add(new Customer(f,l))
}
public Customer getCustomer(int index){
return customerList.get(index);
}
}
第三個(gè)類Account
public class Account{
private Double balance;
public Account(Double init_balance){
this.balance=init_balance
}
public Double getBalance(){
return balance;
}
public Double deposit(Double amount){
return balance+amount;
}
public Boolean withDraw(Double amount){
if(balance-amount=0){
return true;
}else{
return false;
}
}
自己親手?jǐn)]出來(lái)的,求點(diǎn)贊,代碼如下:
public class Employee {
private static int EmNum=1;
public static int getNextNum(){
EmNum++;
return EmNum;
}
}
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
int first=Employee.getNextNum();//調(diào)用第一次
System.out.println(first);
int second=Employee.getNextNum();//調(diào)用第二次
System.out.println(second);
}
}
就是個(gè)ajax調(diào)用后臺(tái)對(duì)這個(gè)數(shù)量加1,做這個(gè)操作時(shí),注意后臺(tái)這個(gè)加1方法要同步;提示這么多了,自己完成更有成就感,拿來(lái)主義是得不到成長(zhǎng)的
用INCREMENT常量代替原有的增量值1?這是幾個(gè)意思,我理解為直接替換了,你自己改改,還是親手?jǐn)]的,求點(diǎn)贊:
public class Employee {
public final static int INCREMENT=100;
public static int getNextNum(){
return INCREMENT;
}
}
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
int first=Employee.getNextNum()+1;//調(diào)用第一次
System.out.println(first);
int second=Employee.getNextNum()+1;//調(diào)用第二次
System.out.println(second);
}
}