From 258740edb2029ed2b8fc0065b7210bd91613184e Mon Sep 17 00:00:00 2001 From: pqyt64hnf <2543568107@qq.com> Date: Sun, 30 Apr 2023 01:13:47 +0800 Subject: [PATCH] Delete 'src/main/java/com/service' --- src/main/java/com/service | 78 --------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 src/main/java/com/service diff --git a/src/main/java/com/service b/src/main/java/com/service deleted file mode 100644 index 633822f..0000000 --- a/src/main/java/com/service +++ /dev/null @@ -1,78 +0,0 @@ -package com.example.service; - -import com.example.dao.AdminInfoDao; -import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; -import com.example.entity.AdminInfo; -import com.example.exception.CustomException; -import com.example.common.ResultCode; -import com.example.vo.AdminInfoVo; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import cn.hutool.crypto.SecureUtil; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.util.Date; -import java.util.List; - -@Service -public class AdminInfoService { - - @Resource - private AdminInfoDao adminInfoDao; - - public AdminInfo add(AdminInfo adminInfo) { - // 唯一校验 - int count = adminInfoDao.checkRepeat("name", adminInfo.getName(), null); - if (count > 0) { - throw new CustomException("1001", "用户名\"" + adminInfo.getName() + "\"已存在"); - } - if (StringUtils.isEmpty(adminInfo.getPassword())) { - // 默认密码123456 - adminInfo.setPassword(SecureUtil.md5("123456")); - } else { - adminInfo.setPassword(SecureUtil.md5(adminInfo.getPassword())); - } - adminInfoDao.insertSelective(adminInfo); - return adminInfo; - } - - public void delete(Long id) { - adminInfoDao.deleteByPrimaryKey(id); - } - - public void update(AdminInfo adminInfo) { - adminInfoDao.updateByPrimaryKeySelective(adminInfo); - } - - public AdminInfo findById(Long id) { - return adminInfoDao.selectByPrimaryKey(id); - } - - public List findAll() { - return adminInfoDao.findByName("all"); - } - - public PageInfo findPage(String name, Integer pageNum, Integer pageSize, HttpServletRequest request) { - PageHelper.startPage(pageNum, pageSize); - List all = adminInfoDao.findByName(name); - return PageInfo.of(all); - } - - public AdminInfoVo findByUserName(String name) { - return adminInfoDao.findByUsername(name); - } - - public AdminInfo login(String username, String password) { - AdminInfo adminInfo = adminInfoDao.findByUsername(username); - if (adminInfo == null) { - throw new CustomException(ResultCode.USER_ACCOUNT_ERROR); - } - if (!SecureUtil.md5(password).equalsIgnoreCase(adminInfo.getPassword())) { - throw new CustomException(ResultCode.USER_ACCOUNT_ERROR); - } - return adminInfo; - } - -}