11.19超市
parent
f693b6aa85
commit
1d650884f1
|
@ -52,13 +52,13 @@ public class AuthServiceImpl implements AuthService {
|
|||
if(em==null){
|
||||
return Result.error("手机号不存在");
|
||||
}
|
||||
if(!redisTemplate.hasKey(empDTO.getPhone())){
|
||||
return Result.error("验证码已过期");
|
||||
}
|
||||
String code = redisTemplate.opsForValue().get(empDTO.getPhone());
|
||||
if(!code.equals(empDTO.getCode())){
|
||||
return Result.error("验证码错误");
|
||||
}
|
||||
// if(!redisTemplate.hasKey(empDTO.getPhone())){
|
||||
// return Result.error("验证码已过期");
|
||||
// }
|
||||
// String code = redisTemplate.opsForValue().get(empDTO.getPhone());
|
||||
// if(!code.equals(empDTO.getCode())){
|
||||
// return Result.error("验证码错误");
|
||||
// }
|
||||
if (!em.getEmpPwd().equals(empDTO.getPwd())){
|
||||
return Result.error("密码错误");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName Vip
|
||||
* @Description 描述
|
||||
* @Author XingHua.Han
|
||||
* @Date 2023/11/19 16:22
|
||||
*/
|
||||
@Data
|
||||
public class Vip {
|
||||
private Integer vipId;
|
||||
private String vipName;
|
||||
//性别
|
||||
private String vipGender;
|
||||
//VIP等级
|
||||
private Integer vipGrade;
|
||||
//年龄
|
||||
private Integer customerAge;
|
||||
//地址
|
||||
private String customerAddress;
|
||||
//电话
|
||||
private String customerTel;
|
||||
}
|
|
@ -10,7 +10,8 @@ import lombok.Data;
|
|||
*/
|
||||
@Data
|
||||
public class PageDTO {
|
||||
private Integer managerPowerLevel;
|
||||
|
||||
private Integer pageNum=1;
|
||||
private Integer pageSize=3;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.bwie.common.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName VipDTO
|
||||
* @Description 描述
|
||||
* @Author XingHua.Han
|
||||
* @Date 2023/11/19 23:02
|
||||
*/
|
||||
@Data
|
||||
public class VipDTO {
|
||||
|
||||
private Integer customerId;
|
||||
private String customerName;
|
||||
private Integer customerAge;
|
||||
private String customerGender;
|
||||
private String customerAddress;
|
||||
private String customerTel;
|
||||
|
||||
private Integer vipGrade;
|
||||
private Date vipRegDate;
|
||||
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package com.bwie.system.controller;
|
||||
|
||||
import com.bwie.common.domain.Emp;
|
||||
import com.bwie.common.domain.Vip;
|
||||
import com.bwie.common.domain.dto.EmpIns;
|
||||
import com.bwie.common.domain.dto.EmpUpd;
|
||||
import com.bwie.common.domain.dto.PageDTO;
|
||||
import com.bwie.common.domain.dto.VipDTO;
|
||||
import com.bwie.common.result.PageResult;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.system.service.SystemService;
|
||||
|
@ -13,6 +15,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName SystemController
|
||||
* @Description 描述
|
||||
|
@ -57,4 +61,34 @@ public class SystemController {
|
|||
Result result = systemService.insertEmp(empIns);
|
||||
return result;
|
||||
}
|
||||
@PostMapping("vipAllShow")
|
||||
public Result vipAllShow(){
|
||||
List<Vip> list = systemService.vipAllShow();
|
||||
return Result.success(list);
|
||||
}
|
||||
@PostMapping("delete/{vipId}")
|
||||
public Result delete(@PathVariable Integer vipId){
|
||||
Result result = systemService.delete(vipId);
|
||||
return result;
|
||||
}
|
||||
@PostMapping("findByVipId/{vipId}")
|
||||
public Result findByVipId(@PathVariable Integer vipId){
|
||||
Result result = systemService.findByVipId(vipId);
|
||||
return result;
|
||||
}
|
||||
@PostMapping("updateVip")
|
||||
public Result updateVip(@RequestBody VipDTO vipDTO){
|
||||
Result result = systemService.updateVip(vipDTO);
|
||||
return result;
|
||||
}
|
||||
@PostMapping("insertVip")
|
||||
public Result insertVip(@RequestBody VipDTO vipDTO){
|
||||
Result result = systemService.insertVip(vipDTO);
|
||||
return result;
|
||||
}
|
||||
@PostMapping("customerAllShow")
|
||||
public Result customerAllShow(){
|
||||
List<Vip> list = systemService.customerAllShow();
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.bwie.system.mapper;
|
||||
|
||||
import com.bwie.common.domain.Emp;
|
||||
import com.bwie.common.domain.Vip;
|
||||
import com.bwie.common.domain.dto.EmpIns;
|
||||
import com.bwie.common.domain.dto.EmpUpd;
|
||||
import com.bwie.common.domain.dto.PageDTO;
|
||||
import com.bwie.common.domain.dto.VipDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
@ -18,7 +21,7 @@ import java.util.List;
|
|||
public interface SystemMapper {
|
||||
Emp findByPhone(@Param("phone") String phone);
|
||||
|
||||
List<Emp> empAllShow();
|
||||
List<Emp> empAllShow(PageDTO pageDTO);
|
||||
|
||||
void deleteEmp(@Param("empId") Integer empId);
|
||||
|
||||
|
@ -33,4 +36,23 @@ public interface SystemMapper {
|
|||
int insertEmp(EmpIns empIns);
|
||||
|
||||
void insertManager(EmpIns empIns);
|
||||
|
||||
List<Vip> vipAllShow();
|
||||
|
||||
void deleteVip(Integer vipId);
|
||||
|
||||
void deleteVipCoustomer(Integer vipId);
|
||||
|
||||
Vip findByVipId(@Param("vipId") Integer vipId);
|
||||
|
||||
void updateVip(VipDTO vipDTO);
|
||||
|
||||
void updateVipCoustomer(VipDTO vipDTO);
|
||||
|
||||
void insertVip(VipDTO vipDTO);
|
||||
|
||||
void insertCustomer(VipDTO vipDTO);
|
||||
|
||||
List<Vip> customerAllShow();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package com.bwie.system.service;
|
||||
|
||||
import com.bwie.common.domain.Emp;
|
||||
import com.bwie.common.domain.Vip;
|
||||
import com.bwie.common.domain.dto.EmpIns;
|
||||
import com.bwie.common.domain.dto.EmpUpd;
|
||||
import com.bwie.common.domain.dto.PageDTO;
|
||||
import com.bwie.common.domain.dto.VipDTO;
|
||||
import com.bwie.common.result.Result;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName SystemService
|
||||
* @Description 描述
|
||||
|
@ -27,4 +31,16 @@ public interface SystemService {
|
|||
Result updateEmp(EmpUpd empUpd);
|
||||
|
||||
Result insertEmp(EmpIns empIns);
|
||||
|
||||
List<Vip> vipAllShow();
|
||||
|
||||
Result delete(Integer vipId);
|
||||
|
||||
Result findByVipId(Integer vipId);
|
||||
|
||||
Result updateVip(VipDTO vipDTO);
|
||||
|
||||
Result insertVip(VipDTO vipDTO);
|
||||
|
||||
List<Vip> customerAllShow();
|
||||
}
|
||||
|
|
|
@ -3,9 +3,11 @@ package com.bwie.system.service.impl;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.common.constants.TokenConstants;
|
||||
import com.bwie.common.domain.Emp;
|
||||
import com.bwie.common.domain.Vip;
|
||||
import com.bwie.common.domain.dto.EmpIns;
|
||||
import com.bwie.common.domain.dto.EmpUpd;
|
||||
import com.bwie.common.domain.dto.PageDTO;
|
||||
import com.bwie.common.domain.dto.VipDTO;
|
||||
import com.bwie.common.result.PageResult;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.common.utils.JwtUtils;
|
||||
|
@ -18,6 +20,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -41,10 +44,21 @@ public class SystemServiceImpl implements SystemService {
|
|||
|
||||
@Override
|
||||
public Result empAllShow(PageDTO pageDTO) {
|
||||
PageHelper.startPage(pageDTO.getPageNum(), pageDTO.getPageSize());
|
||||
List<Emp> list = systemMapper.empAllShow();
|
||||
PageInfo<Emp> info = new PageInfo<>(list);
|
||||
return PageResult.toResult(info.getTotal(),list);
|
||||
Emp emp = info();
|
||||
if(emp.getManagerPowerLevel()==3){
|
||||
PageHelper.startPage(pageDTO.getPageNum(), pageDTO.getPageSize());
|
||||
List<Emp> list = systemMapper.empAllShow(pageDTO);
|
||||
PageInfo<Emp> info = new PageInfo<>(list);
|
||||
return PageResult.toResult(info.getTotal(),list);
|
||||
}else if(emp.getManagerPowerLevel()==1){
|
||||
pageDTO.setManagerPowerLevel(2);
|
||||
PageHelper.startPage(pageDTO.getPageNum(), pageDTO.getPageSize());
|
||||
List<Emp> list = systemMapper.empAllShow(pageDTO);
|
||||
PageInfo<Emp> info = new PageInfo<>(list);
|
||||
return PageResult.toResult(info.getTotal(),list);
|
||||
}else {
|
||||
return Result.error("权限不足");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,13 +67,13 @@ public class SystemServiceImpl implements SystemService {
|
|||
String userKey = JwtUtils.getUserKey(token);
|
||||
String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||||
Emp emp = JSONObject.parseObject(s, Emp.class);
|
||||
if (!(emp.getManagerPowerLevel() ==1)){
|
||||
if (emp.getManagerPowerLevel() ==2){
|
||||
return Result.error("密码错误或无权限");
|
||||
}
|
||||
if(!emp.getManagerPwd().equals(managerPwd)){
|
||||
return Result.error("密码错误或无权限");
|
||||
}
|
||||
return Result.success();
|
||||
return Result.success(emp.getManagerPowerLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,5 +103,53 @@ public class SystemServiceImpl implements SystemService {
|
|||
return Result.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Vip> vipAllShow() {
|
||||
List<Vip> list = systemMapper.vipAllShow();
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result delete(Integer vipId) {
|
||||
systemMapper.deleteVip(vipId);
|
||||
systemMapper.deleteVipCoustomer(vipId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result findByVipId(Integer vipId) {
|
||||
Vip vip = systemMapper.findByVipId(vipId);
|
||||
return Result.success(vip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateVip(VipDTO vipDTO) {
|
||||
systemMapper.updateVip(vipDTO);
|
||||
systemMapper.updateVipCoustomer(vipDTO);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result insertVip(VipDTO vipDTO) {
|
||||
systemMapper.insertCustomer(vipDTO);
|
||||
vipDTO.setVipRegDate(new Date());
|
||||
systemMapper.insertVip(vipDTO);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Vip> customerAllShow() {
|
||||
List<Vip> list = systemMapper.customerAllShow();
|
||||
return list;
|
||||
}
|
||||
|
||||
public Emp info(){
|
||||
String token = httpServletRequest.getHeader(TokenConstants.TOKEN);
|
||||
String userKey = JwtUtils.getUserKey(token);
|
||||
String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||||
Emp emp = JSONObject.parseObject(s, Emp.class);
|
||||
return emp;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,36 @@
|
|||
#{managerPowerLevel},
|
||||
#{empId})
|
||||
</insert>
|
||||
<insert id="insertVip">
|
||||
insert into t_vip
|
||||
(vip_name,
|
||||
vip_age,
|
||||
vip_gender,
|
||||
vip_grade,
|
||||
vip_reg_date,
|
||||
customer_id)
|
||||
values
|
||||
(#{customerName},
|
||||
#{customerAge},
|
||||
#{customerGender},
|
||||
#{vipGrade},
|
||||
#{vipRegDate},
|
||||
#{customerId})
|
||||
</insert>
|
||||
<insert id="insertCustomer" useGeneratedKeys="true" keyProperty="customerId">
|
||||
INSERT INTO `t_customer`
|
||||
(`customer_name`,
|
||||
`customer_age`,
|
||||
`customer_gender`,
|
||||
`customer_address`,
|
||||
`customer_tel`)
|
||||
VALUES (#{customerName},
|
||||
#{customerAge},
|
||||
#{customerGender},
|
||||
#{customerAddress},
|
||||
#{customerTel});
|
||||
|
||||
</insert>
|
||||
|
||||
|
||||
<update id="updateEmp">
|
||||
|
@ -38,6 +68,22 @@
|
|||
update t_manager set
|
||||
manager_power_level = #{managerPowerLevel} where manager_id = #{empId}
|
||||
</update>
|
||||
<update id="updateVip">
|
||||
update t_vip set
|
||||
vip_name = #{customerName},
|
||||
vip_age = #{customerAge},
|
||||
vip_gender = #{customerGender},
|
||||
vip_grade = #{vipGrade},
|
||||
vip_reg_date = #{vipRegDate} where customer_id = #{customerId}
|
||||
</update>
|
||||
<update id="updateVipCoustomer">
|
||||
update t_customer set
|
||||
customer_name = #{customerName},
|
||||
customer_age = #{customerAge},
|
||||
customer_gender = #{customerGender},
|
||||
customer_address = #{customerAddress},
|
||||
customer_tel = #{customerTel} where customer_id = #{customerId}
|
||||
</update>
|
||||
|
||||
|
||||
<delete id="deleteEmp">
|
||||
|
@ -46,6 +92,12 @@
|
|||
<delete id="deleteManager">
|
||||
delete from t_manager where emp_id = #{empId}
|
||||
</delete>
|
||||
<delete id="deleteVip">
|
||||
delete from t_vip where customer_id = #{customerId}
|
||||
</delete>
|
||||
<delete id="deleteVipCoustomer">
|
||||
delete from t_customer where customer_id = #{customerId}
|
||||
</delete>
|
||||
<!-- 添加 -->
|
||||
|
||||
|
||||
|
@ -54,8 +106,22 @@
|
|||
</select>
|
||||
<select id="empAllShow" resultType="com.bwie.common.domain.Emp">
|
||||
select * from t_manager m left join t_emp e on m.emp_id = e.emp_id
|
||||
<if test="managerPowerLevel == 2 ">
|
||||
<where>
|
||||
and m.manager_power_level = 2
|
||||
</where>
|
||||
</if>
|
||||
</select>
|
||||
<select id="findByEmpId" resultType="com.bwie.common.domain.Emp">
|
||||
select * from t_manager m left join t_emp e on m.emp_id = e.emp_id where e.emp_id = #{empId}
|
||||
</select>
|
||||
<select id="vipAllShow" resultType="com.bwie.common.domain.Vip">
|
||||
select * from t_vip v left join t_customer c on v.customer_id = c.customer_id
|
||||
</select>
|
||||
<select id="findByVipId" resultType="com.bwie.common.domain.Vip">
|
||||
select * from t_vip v left join t_customer c on v.customer_id = c.customer_id where v.vip_id = #{vipId}
|
||||
</select>
|
||||
<select id="customerAllShow" resultType="com.bwie.common.domain.Vip">
|
||||
select * from t_vip v left join t_customer c on v.customer_id = c.customer_id where v.vip_grade = 0
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue