Commit 9149956a by 唐功亮

【新增】 用户登录-(未完成)

parent 89d3dbf2
package io.office.modules.manage.controller;
import java.util.Arrays;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.office.modules.manage.entity.LogLoginEntity;
import io.office.modules.manage.service.LogLoginService;
import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 17:47:13
*/
@RestController
@RequestMapping("/loglogin")
public class LogLoginController {
@Autowired
private LogLoginService logLoginService;
/**
* 用户登录
*/
@RequestMapping("/api/login")
// @RequiresPermissions("manage:member:list")
public R login(@RequestBody Map<String, Object> params, HttpServletRequest request, HttpServletResponse response){
logLoginService.login(params,request,response);
return R.ok();
}
/**
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("manage:loglogin:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = logLoginService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
// @RequiresPermissions("manage:loglogin:info")
public R info(@PathVariable("id") Integer id){
LogLoginEntity logLogin = logLoginService.getById(id);
return R.ok().put("logLogin", logLogin);
}
/**
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("manage:loglogin:save")
public R save(@RequestBody LogLoginEntity logLogin){
logLoginService.save(logLogin);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("manage:loglogin:update")
public R update(@RequestBody LogLoginEntity logLogin){
logLoginService.updateById(logLogin);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("manage:loglogin:delete")
public R delete(@RequestBody Integer[] ids){
logLoginService.removeByIds(Arrays.asList(ids));
return R.ok();
}
}
package io.office.modules.manage.dao;
import io.office.modules.manage.entity.LogLoginEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 17:47:13
*/
@Mapper
public interface LogLoginDao extends BaseMapper<LogLoginEntity> {
}
package io.office.modules.manage.dao;
import io.office.modules.manage.entity.LogLoginEntity;
import io.office.modules.manage.entity.MemberEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;
/**
* ${comments}
......@@ -14,4 +17,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MemberDao extends BaseMapper<MemberEntity> {
@Select("select * from member where username=#{userName}")
MemberEntity selectByName(@Param("userName") String userName);
}
package io.office.modules.manage.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 17:47:13
*/
@Data
@TableName("log_login")
public class LogLoginEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* $column.comments
*/
@TableId
private Integer id;
/**
* $column.comments
*/
private String username;
/**
* $column.comments
*/
private String search;
/**
* $column.comments
*/
private String carno;
/**
* $column.comments
*/
private String userphone;
/**
* $column.comments
*/
private Date loginTime;
/**
* $column.comments
*/
private String loginIp;
/**
* $column.comments
*/
private String loginUrl;
public LogLoginEntity(Integer id, String username, String search, String carno, String userphone, Date loginTime, String loginIp, String loginUrl) {
this.id = id;
this.username = username;
this.search = search;
this.carno = carno;
this.userphone = userphone;
this.loginTime = loginTime;
this.loginIp = loginIp;
this.loginUrl = loginUrl;
}
}
package io.office.modules.manage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import io.office.common.utils.PageUtils;
import io.office.modules.manage.entity.LogLoginEntity;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 17:47:13
*/
public interface LogLoginService extends IService<LogLoginEntity> {
PageUtils queryPage(Map<String, Object> params);
void login(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response);
}
package io.office.modules.manage.service.impl;
import io.office.common.exception.RRException;
import io.office.modules.manage.dao.MemberDao;
import io.office.modules.manage.entity.MemberEntity;
import io.office.modules.manage.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.office.common.utils.PageUtils;
import io.office.common.utils.Query;
import io.office.modules.manage.dao.LogLoginDao;
import io.office.modules.manage.entity.LogLoginEntity;
import io.office.modules.manage.service.LogLoginService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Service("logLoginService")
public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity> implements LogLoginService {
@Autowired
private LogLoginDao logLoginDao;
@Autowired
private MemberDao memberDao;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<LogLoginEntity> page = this.page(
new Query<LogLoginEntity>().getPage(params),
new QueryWrapper<LogLoginEntity>()
);
return new PageUtils(page);
}
@Override
public void login(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) {
String userName = String.valueOf(params.get("userName")==null?"":params.get("userName"));
String passWord = String.valueOf(params.get("passWord")==null?"":params.get("passWord"));
String verification = String.valueOf(params.get("verification")==null?"":params.get("verification"));//验证码
//session中获取验证码
//判断 验证码是否正确
MemberEntity user=memberDao.selectByName(userName);
String phone = user.getPhone();
String password = user.getPassword();
String passwordMD5 = MD5Util.md5Encrypt32Upper(passWord);
//判断密码是否正确
if (!passwordMD5.equals(password)){
throw new RRException("密码不正确!");
}
//添加登录日志 log_login
logLoginDao.insert(new LogLoginEntity(1,userName,"用户来源","条码卡号",phone,new Date(),"IP","url"));
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment