发表于: 2020-07-10 21:02:36
1 1460
写service层
package com.jnshu.service;
import com.jnshu.pojo.Account;
import java.util.List;
public interface AccountService {
int deleteByPrimaryKey(Long id);
int insert(Account record);
/* int insertSelective(Account record);*/
List<Account> selectAccount(Account record);
/*int updateByPrimaryKeySelective(Account record);*/
int updateByPrimaryKey(Account record);
}
@Service
public class AccountServiceImpl implements AccountService {
@Autowired
private AccountMapper accountMapper;
public int deleteByPrimaryKey(Long id){
accountMapper.deleteByPrimaryKey(id);
return 1;
}
public int insert(Account record){
accountMapper.insert(record);
return 1;
}
public List<Account> selectAccount(Account record){
return accountMapper.selectAccount(record);
}
public int updateByPrimaryKey(Account record){
accountMapper.updateByPrimaryKey(record);
return 1;
}/
}
@Controller
public class AccountController {
@Autowired
private AccountService accountService;
@GetMapping("/Account")
@ResponseBody
public JSONArray selectAccount(@Param("username")String username){
Account account = new Account();
account.setUsername(username);
List<Account> list = accountService.selectAccount(account);
JSONArray jsonArray =JSONArray.fromObject(list);
return jsonArray;
}
@PostMapping("/Account")
public String insertAccount(@Param("username")String username,@Param("password")String password){
Account account = new Account();
account.setId(0L);
account.setUsername(username);
account.setPassword(password);
account.setRole("aaa");
account.setCreateby("管理员");
account.setCreateat(20200710L);
account.setUpdateby("管理员");
account.setUpdateat(20200710L);
accountService.insert(account);
return "success";
}
没写完
今日问题暂无
明日计划 task3
评论