yml配置
server:
port: 8080
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/db_userorder?serverTimezone=UTC
username: root
password: 123
mybatis:
type-aliases-package: com.fs.pojo
mapper-locations: classpath*:mapper/*Mapper.xml
实体类
Ordering
/**
* @author hua
* @version 1.0
* @title Ordering
* @description 订单信息
* @create 2024/3/15 16:05
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Ordering {
private Integer opId;
private String opName;
private String proName;
private String proStyle;
private String prodes;
private String proText;
private String userId;
}
UserInfo
/**
* @author hua
* @version 1.0
* @title Userinfo
* @description 用户信息
* @create 2024/3/15 16:03
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserInfo {
private Integer userId;
private String loginName;
private String loginPass;
private String realyName;
}
dao层
OrderingMapper
/**
* @author hua
* @version 1.0
* @title OrderingMapper
* @description 订单信息dao层
* @create 2024/3/6 17:09
*/
@Mapper
public interface OrderingMapper {
/**
* 查询所有订单信息
* @return
*/
List<Ordering> queryAll();
/**
* 删除指定订单信息
* @return
*/
void deleteById(int opId);
}
UserInfoMapper
/**
* @author hua
* @version 1.0
* @title UserInfoMapper
* @description 用户信息dao
* @create 2024/2/22 15:16
*/
@Mapper
public interface UserInfoMapper {
/**
* 检查客户登录名
* @param loginName
* @return
*/
UserInfo queryByLoginName(String loginName);
}
控制器
/**
* @author hua
* @version 1.0
* @title LogisticsServlet
* @description 物流系统服务器
* @create 2024/3/4 16:17
*/
@Controller
public class LogisticsServlet {
@Resource
private OrderingService orderingService;
@Resource
private UserInfoService userInfoService;
@RequestMapping("/login.action")
@ResponseBody
public JsonVO login(String loginName, String loginPass, HttpSession session) throws Exception {
JsonVO jsonVO=new JsonVO();
UserInfo userInfo = userInfoService.queryByLoginName(loginName);
if(userInfo==null){
jsonVO.setMessage("卡号错误");
jsonVO.setCode(400);
}else {
if(!userInfo.getLoginPass().equals(loginPass)){
jsonVO.setMessage("密码错误");
jsonVO.setCode(401);
}else {
jsonVO.setMessage("登录成功");
jsonVO.setCode(200);
session.setAttribute("customer",userInfo);
}
}
return jsonVO;
}
@RequestMapping("/getAll.action")
@ResponseBody
public JsonVO getAll() throws Exception {
JsonVO jsonVO=new JsonVO();
List<Ordering> orderings = orderingService.queryAll();
jsonVO.setCode(200);
jsonVO.setMessage("查询成功");
jsonVO.setDates(orderings);
return jsonVO;
}
@RequestMapping("/removeOne.action")
@ResponseBody
public JsonVO removeOne(int opId) throws Exception {
JsonVO jsonVO=new JsonVO();
orderingService.deleteById(opId);
jsonVO.setCode(200);
jsonVO.setMessage("删除成功");
return jsonVO;
}
}