//整体目录
springmvc_day02_02_fileupload
springmvc_day02_03_exception
springmvc_day02_04_intercepor
ssm
src
main
java
cn
itcast
controller
AccountController
ClothesController
UserController
dao
AccountDao
ClothesExWarehousingMapper
ClothesMapper
ClothesSizeMapper
ClothesTypeMapper
ClothesWarehousingMapper
SysUserMapper
domain
entity
Clothes
ClothesExWarehousing
ClothesSize
ClothesType
ClothesVo
ClothesWarehousing
SysUser
service
impl
AccountServiceImpl
ClothesServiceImpl
UserServiceImpl
ClothesService
IAccountService
UserService
test
util
resources
cn
itcast
dao
ClothesExWarehousingMapper.xml
ClothesMapper.xml
ClothesSizeMapper.xml
ClothesTypeMapper.xml
ClothesWarehousingMapper.xml
SysUserMapper.xml
applicationCongtext.xml
springmvc.xml
SqlMap.xml
webapp
target
pom.xml
/登录cn.itcast.controller.UserController
package cn.itcast.controller;
import cn.itcast.entity.SysUser;
import cn.itcast.service.UserService;
import cn.itcast.util.ClothesCons;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
-
登录
-
@autor songxingsongxing
-
@date 20200305
*/
@RestController
@RequestMapping(“user”)
public class UserController {@Autowired
UserService userService;/**
- 获取用户信息
- @autor songxingsongxing
- @date 20200305
- @param userName
- @param password
- @return
*/
@RequestMapping(value = “/login” , method = RequestMethod.GET)
public Map<String, Object> login(@RequestParam(“userName”)String userName, @RequestParam(“password”)String password) {
Map<String, Object> map = new HashMap<>();
map.put(“STATUS”, 1);
map.put(“MSG”, ClothesCons.QUERY_SUCCESS);
SysUser sysUser = null;
try {
sysUser= userService.get(userName,password);
} catch (Exception e) {
e.printStackTrace();
map.put(“STATUS”, 0);
map.put(“MSG”, ClothesCons.QUERY_FAIL);
return map;
}
if(sysUser ==null){
map.put(“STATUS”, 0);
map.put(“MSG”, ClothesCons.ACCOUNT_PASSWORD_FAIL);
}
return map;
}
}
//cn.itcast.service.UserService
package cn.itcast.service;
import cn.itcast.entity.SysUser;
public interface UserService {
public SysUser get(String userName, String password) throws Exception;
}
//cn.itcast.service.impl.UserServiceImpl
package cn.itcast.service.impl;
import cn.itcast.dao.SysUserMapper;
import cn.itcast.entity.SysUser;
import cn.itcast.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
-
登录
-
@autor songxingsongxing
-
@date 20200305
*/
@Service
public class UserServiceImpl implements UserService {@Autowired
SysUserMapper sysUserMapper;@Override
public SysUser get(String userName, String password) throws Exception {
/* String passwordOfMd5 = null;
return sysUserMapper.selectByPrimaryKey(userName, passwordOfMd5);*/
return null;
}
}
//cn.itcast.dao.SysUserMapper
package cn.itcast.dao;
import cn.itcast.entity.SysUser;
public interface SysUserMapper {
int deleteByPrimaryKey(Integer userId);
int insert(SysUser record);
int insertSelective(SysUser record);
SysUser selectByPrimaryKey(Integer userId, String password);
int updateByPrimaryKeySelective(SysUser record);
int updateByPrimaryKey(SysUser record);
}
//cn/itcast/dao/SysUserMapper.xml
//cn.itcast.controller.ClothesController
package cn.itcast.controller;
import cn.itcast.entity.ClothesVo;
import cn.itcast.entity.SysUser;
import cn.itcast.service.ClothesService;
import cn.itcast.service.UserService;
import cn.itcast.util.ClothesCons;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
-
登录
-
@autor songxingsongxing
-
@date 20200305
*/
@Controller
@RequestMapping("/Clothes")
public class ClothesController {@Autowired
ClothesService clothesService;/**
- 获取用户信息
- @autor songxingsongxing
- @date 20200305
- @param clothesName
- @param clothesColor
- @return
*/
@ResponseBody
@RequestMapping(value = “/getClothes” , method = RequestMethod.GET)
public JSONObject getClothes(@RequestParam(value = “clothesName”, required = false)String clothesName,
@RequestParam(value = “clothesColor”, required = false)String clothesColor) {
Map<String, Object> map = new HashMap<>();
map.put(“STATUS”, 1);
map.put(“MSG”, ClothesCons.QUERY_SUCCESS);
SysUser sysUser = null;
try {
List list= clothesService.getClothes(clothesName,clothesColor);
map.put(“datas”, list);
} catch (Exception e) {
e.printStackTrace();
map.put(“STATUS”, 0);
map.put(“MSG”, ClothesCons.QUERY_FAIL);
// return map;
}
return new JSONObject();
}
}
/cn.itcast.service.ClothesService
package cn.itcast.service;
import cn.itcast.entity.ClothesVo;
import java.util.List;
public interface ClothesService {
public List getClothes(String clothesName, String clothesColor) throws Exception;
}
/cn.itcast.service.impl.ClothesServiceImpl
package cn.itcast.service.impl;
import cn.itcast.dao.ClothesMapper;
import cn.itcast.entity.ClothesVo;
import cn.itcast.service.ClothesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*
*/
@Service
public class ClothesServiceImpl implements ClothesService {
@Autowired
ClothesMapper clothesMapper;
/**
*
* @param clothesName
* @param clothesColor
* @return
* @throws Exception
*/
@Override
public List<ClothesVo> getClothes(String clothesName, String clothesColor) throws Exception {
return clothesMapper.selectByNameAndColor(clothesName, clothesColor);
}
}
//cn.itcast.dao.ClothesMapper
package cn.itcast.dao;
import cn.itcast.entity.Clothes;
import cn.itcast.entity.ClothesVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ClothesMapper {
int deleteByPrimaryKey(Integer clothesId);
int insert(Clothes record);
int insertSelective(Clothes record);
Clothes selectByPrimaryKey(Integer clothesId);
int updateByPrimaryKeySelective(Clothes record);
int updateByPrimaryKey(Clothes record);
List<ClothesVo> selectByNameAndColor(@Param("clothesName") String clothesName, @Param("clothesColor")String clothesColor);
}
//cn/itcast/dao/ClothesTypeMapper.xml