Commit 7c6d61b0 authored by zhangc's avatar zhangc

Merge branch 'dm_dev' of gitlab.ioubuy.cn:yaobenzhang/dm_project into dm_dev

parents a9ebb74d 85e41fe9
......@@ -15,7 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
*/
@EnableTransactionManagement
@Configuration
@MapperScan("com.jz.manage.moduls.mapper")
@MapperScan("com.jz.dm.mall.moduls.mapper")
public class MybatisPlusConfig {
@Bean
......
package com.jz.dm.mall.moduls.controller.customer;
import com.jz.common.utils.Result;
import com.jz.common.utils.StatusCode;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import com.jz.dm.mall.moduls.service.MallCustomerService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @ClassName:
* @Author: Carl
* @Date: 2020/12/2
* @Version:
*/
@RestController
@RequestMapping("/customer")
@Api(tags = "商城登陆api")
public class LoginController {
/**
* 服务对象
*/
@Autowired
private MallCustomerService mallCustomerService;
@Autowired
private RedisTemplate redisTemplate;
/**
* 登录功能
* @param username 账号
* @param password 密码
* @return
*/
@GetMapping(value = "/login")
public Result<MallCustomer> login(String username, String password) {
// 手机
String ph = "^[1][34578]\\d{9}$";
// 如果是手机验证
if (username.matches(username)) {
MallCustomer mallCustomer = mallCustomerService.selectByPhone(username);
if (mallCustomer != null) {
if (mallCustomer.getCustomerPhone().equals(username) && mallCustomer.getPassword().equals(password)){
return new Result<>(true, "登录成功!", StatusCode.OK);
}
return new Result<>(false, "用户名或密码错误!", StatusCode.ERROR);
}
}
MallCustomer mallCustomer = mallCustomerService.selectByAccount(username);
if (mallCustomer != null) {
if (mallCustomer.getCustomerAccount().equals(username) && mallCustomer.getPassword().equals(password)){
return new Result<>(true, "登录成功!", StatusCode.OK);
}
}
return new Result<>(false, "用户名或密码错误!", StatusCode.ERROR);
}
}
......@@ -2,8 +2,7 @@ package com.jz.dm.mall.moduls.controller.customer;
import com.jz.common.base.BaseController;
import com.jz.common.constant.RedisMessageConstant;
import com.jz.common.entity.MallCustomer;
import com.jz.common.entity.SysUser;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import com.jz.common.utils.Result;
import com.jz.common.utils.StatusCode;
import com.jz.dm.mall.moduls.service.MallCustomerService;
......@@ -32,25 +31,13 @@ public class MallCustomerController extends BaseController {
@Autowired
private RedisTemplate redisTemplate;
/**
* 登录功能
* @param customerAccount 账号
* @param password 密码
* @return
*/
@GetMapping(value = "/login")
public Result<SysUser> login(String customerAccount, String password) {
// 获取用户的信息
MallCustomer mallCustomer = mallCustomerService.selectByUsername(customerAccount);
if (mallCustomer == null) {
return new Result<>(false, "用户不存在!", StatusCode.LOGINERROR);
}
if (mallCustomer.getCustomerAccount().equals(customerAccount) && mallCustomer.getPassword().equals(password)) {
return new Result<>(true, "登录成功!", StatusCode.OK);
}
return new Result<>(false, "用户名或密码错误!", StatusCode.ERROR);
@PostMapping(value = "/saveCustomer")
public Result saveCustomer(Map<String, String> paramMap) {
return null;
}
/**
* 手机号码校验
* @param paramMap
......
package com.jz.dm.mall.moduls.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
......@@ -19,6 +21,7 @@ public class MallCustomer implements Serializable {
/**
* 用户id
*/
@TableId(value = "customer_id",type = IdType.AUTO)
private Long customerId;
/**
* 企业id
......
package com.jz.dm.mall.moduls.mapper;
import com.jz.common.base.BaseMapper;
import com.jz.common.entity.MallCustomer;
import com.jz.dm.mall.moduls.entity.MallCustomer;
/**
* 商城用户(TMallCustomer)表数据库访问层
......@@ -11,5 +11,7 @@ import com.jz.common.entity.MallCustomer;
*/
public interface MallCustomerDao extends BaseMapper<MallCustomer> {
MallCustomer selectByAccount(String username);
MallCustomer selectByPhone(String username);
}
\ No newline at end of file
package com.jz.dm.mall.moduls.service;
import com.jz.common.entity.MallCustomer;
import com.jz.dm.mall.moduls.entity.MallCustomer;
/**
* 商城用户(TMallCustomer)表服务接口
......@@ -12,8 +12,16 @@ public interface MallCustomerService {
/**
* 通过用户账号进行查询
* @param customerAccount
* @param username
* @return
*/
MallCustomer selectByUsername(String customerAccount);
MallCustomer selectByAccount(String username);
/**
* 通过手机号进行查询
* @param username
* @return
*/
MallCustomer selectByPhone(String username);
}
\ No newline at end of file
package com.jz.dm.mall.moduls.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jz.common.entity.MallCustomer;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import com.jz.dm.mall.moduls.mapper.MallCustomerDao;
import com.jz.dm.mall.moduls.service.MallCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -21,13 +21,23 @@ public class MallCustomerServiceImpl implements MallCustomerService {
/**
* 通过用户账号进行查询
*
* @param customerAccount
* @param username
* @return
*/
@Override
public MallCustomer selectByUsername(String customerAccount) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("customer_account", customerAccount);
return tMallCustomerDao.selectOne(queryWrapper);
public MallCustomer selectByAccount(String username) {
return tMallCustomerDao.selectByAccount(username);
}
/**
* 通过手机号进行查询
*
* @param username
* @return
*/
@Override
public MallCustomer selectByPhone(String username) {
return tMallCustomerDao.selectByPhone(username);
}
}
\ No newline at end of file
......@@ -165,4 +165,17 @@
delete from t_mall_customer where customer_id = #{customerId}
</delete>
<select id="selectByAccount" resultMap="TMallCustomerMap">
select
customer_id, department_id, password, customer_account, customer_name, customer_phone, customer_email, customer_address, customer_point, register_time, customer_level, identity_card, cre_time, upt_time, del_flag
from t_mall_customer
where customer_account = #{username};
</select>
<select id="selectByPhone" resultMap="TMallCustomerMap">
select
customer_id, department_id, password, customer_account, customer_name, customer_phone, customer_email, customer_address, customer_point, register_time, customer_level, identity_card, cre_time, upt_time, del_flag
from t_mall_customer
where customer_phone = #{username};
</select>
</mapper>
\ No newline at end of file
......@@ -28,23 +28,36 @@ public class LoginController extends BaseController {
private RedisTemplate redisTemplate;
/**
* 登录功能
* @param account 账号
* @param username 账号
* @param password 密码
* @return
*/
@GetMapping(value = "login")
public Result<SysUser> login(String account, String password) {
// 获取用户的信息
SysUser sysUser = sysUserService.selectByUsername(account);
if (sysUser == null) {
return new Result<>(false, "用户不存在!", StatusCode.LOGINERROR);
public Result login(String username, String password) {
// 手机
String ph = "^[1][34578]\\d{9}$";
// 如果是手机验证
if (username.matches(username)) {
SysUser sysUser = sysUserService.selectByPhone(username);
if (sysUser != null) {
if (sysUser.getTelephone().equals(username) && sysUser.getPassword().equals(password)){
return new Result<>(true, "登录成功!", StatusCode.OK);
}
return new Result<>(false, "用户名或密码错误!", StatusCode.ERROR);
}
}
if (sysUser.getAccount().equals(account) && sysUser.getPassword().equals(password)) {
return new Result<>(true, "登录成功!", StatusCode.OK);
SysUser sysUser = sysUserService.selectByUsername(username);
if (sysUser != null) {
if (sysUser.getAccount().equals(username) && sysUser.getPassword().equals(password)){
return new Result<>(true, "登录成功!", StatusCode.OK);
}
}
return new Result<>(false, "用户名或密码错误!", StatusCode.ERROR);
}
/**
* 手机号码校验
* @param paramMap
......
......@@ -7,7 +7,6 @@ import com.jz.manage.moduls.service.SysUserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -26,11 +25,4 @@ public class SysUserController extends BaseController {
*/
@Autowired
private SysUserService sysUserService;
// @PostMapping("/register")
// public Result saveSysUser(@RequestBody SysUser sysUser) throws Exception{
// if (sysUser == null) {
// return new Result(false, "注册信息失败!");
// }
// }
}
\ No newline at end of file
......@@ -17,6 +17,4 @@ public interface SysUserDao extends BaseMapper<SysUser> {
List<Map> getUserRoleByAccount(@Param("account") String account);
// void saveSysUser(SysUser)
}
\ No newline at end of file
......@@ -16,7 +16,9 @@ public interface SysUserService {
/*
* 通过用户帐号进行查询
* */
SysUser selectByUsername(String account);
SysUser selectByUsername(String username);
SysUser selectByPhone(String telephone);
Map<String,Object> getUserRoleByAccount(String account);
}
\ No newline at end of file
......@@ -31,6 +31,13 @@ public class SysUserServiceImpl implements SysUserService {
return sysUserDao.selectOne(queryWrapper);
}
@Override
public SysUser selectByPhone(String username) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("telephone", username);
return sysUserDao.selectOne(queryWrapper);
}
@Override
public Map<String, Object> getUserRoleByAccount(String account) {
Set<String> roleSet = new HashSet<>();
......
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