package com.suntak.demo.service.impl;
import com.suntak.demo.dao.UserDao;
import com.suntak.demo.entity.User;
import com.suntak.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserDao userDao;
@Override
public List<User> getUserList() {
return userDao.queryUser();
}
@Override
public User getUserById(int userid) {
return userDao.getUserById(userid);
}
@Override
public User checkUser(String username, String password) {
return userDao.checkUser(username,password);
}
@Transactional
@Override
public boolean addUser(User user) {
if(user.getUserid() != null && !"".equals(user.getUserid())){
user.setRegisterDate(new Date());
try{
int effectedNum = userDao.insertUser(user);
if(effectedNum > 0){
return true;
}else{
throw new RuntimeException("插入用户信息失败! ");
}
}catch (Exception e){
throw new RuntimeException("插入用户信息失败! " + e.getMessage());
}
}else{
throw new RuntimeException("用户信息不能为空! ");
}
}
@Override
public boolean modifyUser(User user) {
if(user.getUserid() != null && !"".equals(user.getUserid())){
user.setRegisterDate(new Date());
try{
int effectedNum = userDao.updateUser(user);
if(effectedNum > 0){
return true;
}else{
throw new RuntimeException("更新用户信息失败! ");
}
}catch (Exception e){
throw new RuntimeException("更新用户信息失败! " + e.getMessage());
}
}else{
throw new RuntimeException("用户信息不能为空! ");
}
}
@Override
public boolean deleteUser(int userid) {
try{
int effectedNum = userDao.deletUser(userid);
if(effectedNum > 0){
return true;
}else{
throw new RuntimeException("删除用户信息失败! ");
}
}catch (Exception e){
throw new RuntimeException("删除用户信息失败! " + e.getMessage());
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于微信小程序和springBoot的一个投票系统.zip (23个子文件)
Graduation Design
mvnw.cmd 6KB
pom.xml 2KB
src
test
java
com
suntak
demo
DemoApplicationTests.java 340B
dao
UserDaoTest.java 2KB
main
resources
mapper
UserMapping.xml 2KB
application.properties 468B
mybatis-config.xml 657B
java
com
suntak
demo
DemoApplication.java 317B
handler
GlobalExceptionHandler.java 663B
controller
UserController.java 3KB
dao
UserDao.java 868B
hello.java 434B
service
UserService.java 888B
impl
UserServiceImpl.java 3KB
entity
Msg.java 1KB
User.java 1KB
config
dao
DataSourceConfiguration.java 1KB
SessionFactoryConfiguration.java 2KB
service
TransactionManagementConfiguration.java 847B
.mvn
wrapper
maven-wrapper.properties 116B
maven-wrapper.jar 47KB
mvnw 9KB
.gitignore 268B
共 23 条
- 1
资源评论
学术菜鸟小晨
- 粉丝: 1w+
- 资源: 4928
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功