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