界面展示:
增
删
改
查
----------------------------------------------------------------------------------------------
利用 laiuimini 模板对相应模块进行修改:
provider
package com.hz.controller;
import com.hz.pojo.Provider;
import com.hz.service.ProviderService;
import com.hz.utils.ResultAJAX;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/pro")
public class ProviderController {
@Autowired
private ProviderService providerService;
@RequestMapping("/findProviderList")
@ResponseBody
public ResultAJAX findProviderList(
@RequestParam(value = "page",defaultValue = "1") Integer page,
@RequestParam(value = "limit",defaultValue = "10") Integer limit,
String proName,
String proDesc){
return providerService.findProviderList(page,limit,proName,proDesc);
}
@RequestMapping("/findProviderById/{id}")
@ResponseBody
public ResultAJAX findProviderById(@PathVariable("id") Long id){
return providerService.findProviderById(id);
}
@RequestMapping("/updateProvider")
@ResponseBody
public ResultAJAX updateProvider(Provider provider){
return providerService.updateProvider(provider);
}
@RequestMapping("/insertProvider")
@ResponseBody
public ResultAJAX insertProvider(Provider provider){
return providerService.insertProvider(provider);
}
@RequestMapping("/deleteProvider/{id}")
@ResponseBody
public ResultAJAX deleteProvider(@PathVariable("id") Integer id){
return providerService.deleteProvider(id);
};
}
user
package com.hz.controller;
import com.hz.service.UserService;
import com.hz.utils.ResultAJAX;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping("/userLogin")
@ResponseBody
public ResultAJAX userLogin(
String userCode,
String userPassword){
return userService.userLogin(userCode,userPassword);
}
}
provider
package com.hz.mapper;
import com.hz.pojo.Provider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface ProviderMapper {
/**
* 条件查询供应商信息
*/
public abstract List findProviderList(
@Param("pyl") Integer pyl,
@Param("limit") Integer limit,
@Param("proName") String proName,
@Param("proDesc") String proDesc
);
/**
* 获得总记录数
* @return
*/
public abstract int findProviderListCount(
@Param("proName")String proName,
@Param("proDesc")String proDesc);
/**
* 根据供应商ID 获得单个对象
*/
public abstract Provider findProviderById(Long id);
/**
* 保存
*/
public abstract int updateProvider(Provider provider);
/**
*根据id删除用户
*/
public abstract int deleteProvider(Integer id);
/**
* 新增
*/
public abstract int insertProvider(Provider provider);
}
user
package com.hz.mapper;
import com.hz.pojo.User;
import org.apache.ibatis.annotations.Param;
/**
* 用户登录
*/
public interface UserMapper {
/**
* 用户登录
*/
public abstract User userLogin(
@Param("userCode") String userCode,
@Param("userPassword") String userPassword);
}
实体类略过
provider
package com.hz.service;
import com.hz.pojo.Provider;
import com.hz.utils.ResultAJAX;
import java.util.List;
public interface ProviderService {
/**
* 条件查询
*/
public abstract ResultAJAX findProviderList(Integer page,Integer limit,String proName,String proDesc);
/**
* 查
*/
public abstract ResultAJAX findProviderById(Long id);
/**
* 保存
*/
public abstract ResultAJAX updateProvider(Provider provider);
/**
* 新增
*/
public abstract ResultAJAX insertProvider(Provider provider);
/**
* 删除
*/
public abstract ResultAJAX deleteProvider(Integer id);
}
package com.hz.service.impl;
import com.hz.mapper.ProviderMapper;
import com.hz.pojo.Provider;
import com.hz.service.ProviderService;
import com.hz.utils.ResultAJAX;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ProviderServiceImpl implements ProviderService {
@Autowired
private ProviderMapper providerMapper;
@Override
public ResultAJAX findProviderList(Integer page,Integer limit,String proName,String proDesc) {
//偏移量 = (当前页-1)*每页记录数
int pyl = (page-1)*limit;
List providerList = providerMapper.findProviderList(pyl,limit,proName,proDesc);
//总记录数
int count = providerMapper.findProviderListCount(proName,proDesc);
return ResultAJAX.successLayui(count ,providerList);
}
@Override
public ResultAJAX findProviderById(Long id) {
return ResultAJAX.success(providerMapper.findProviderById(id));
}
//更新
@Override
public ResultAJAX updateProvider(Provider provider) {
if (providerMapper.updateProvider(provider)>=1){
return ResultAJAX.success();
}else {
return ResultAJAX.error();
}
}
//新增
@Override
public ResultAJAX insertProvider(Provider provider) {
return ResultAJAX.success(providerMapper.insertProvider(provider));
}
//删除
@Override
public ResultAJAX deleteProvider(Integer id) {
return ResultAJAX.success(providerMapper.deleteProvider(id));
}
}
----------------------------------------------------------------------------
user
package com.hz.service;
import com.hz.utils.ResultAJAX;
public interface UserService {
public abstract ResultAJAX userLogin(String userCode,String userPassword);
}
package com.hz.service.impl;
import com.hz.mapper.UserMapper;
import com.hz.service.UserService;
import com.hz.utils.ResultAJAX;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserMapper userMapper;
@Override
public ResultAJAX userLogin(String userCode, String userPassword) {
if (userMapper.userLogin(userCode,userPassword)!=null){
return ResultAJAX.success(userMapper.userLogin(userCode,userPassword));
}else{
return ResultAJAX.error();
}
}
}
package com.hz.utils;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class ResultAJAX {
private Integer code;
private String msg;
private Integer count;
private Object data;
public ResultAJAX(Integer code, String msg, Object data) {
this.code = code;
this.msg = msg;
this.data = data;
}
public static ResultAJAX successLayui(Integer count,Object data){
return new ResultAJAX(0,"操作成功",count,data);
}
public static ResultAJAX success(){
return new ResultAJAX(0,"操作成功",null);
}
public static ResultAJAX success(Object data){
return new ResultAJAX(0,"操作成功",data);
}
public static ResultAJAX error(){
return new ResultAJAX(1,"操作失败",null);
}
}
js部分