当前位置:   article > 正文

Java项目:超市进销存管理系统(java+SpringBoot+Html+Layui+echarts+mysql)_java mysql超市库存数量用数据类型

java mysql超市库存数量用数据类型

源码获取:博客首页 "资源" 里下载!

项目介绍

超市进销存管理系统,分为管理员与普通员工两种角色;

管理员主要功能包括:

员工管理:员工的添加、编辑、删除;

普通员工主要功能包括:

供应商管理:供应商的添加、删除、修改;

商品管理:商品种类管理、商品信息管理;

库存管理;

订单管理;

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7版本;
7.lombok 注:一定要安装,否则会有问题;

技术栈

1. 后端:SpringBoot+Mybatis

2. 前端:Html+jQuery+Layui+echarts

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;

3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;

4. 管理员访问地址:http://localhost:8085/admin

5. 员工访问地址:http://localhost:8085

 

 

 

 

 

 

前端控制器用户控制层: 

  1. /**
  2. * <p>
  3. * 前端控制器
  4. * </p>
  5. *
  6. */
  7. @RestController
  8. @RequestMapping("/user")
  9. public class UserController {
  10. @Autowired
  11. private UserService userService;
  12. @Autowired
  13. private RoleService roleService;
  14. /**
  15. * 登录
  16. *
  17. * @param username 用户名
  18. * @param password 密码
  19. * @param request
  20. * @return
  21. */
  22. @SysLog("登陆操作")
  23. @PostMapping("/login")
  24. public Result login(String username, String password, HttpServletRequest request) {
  25. try {
  26. //获取当前登录主体对象
  27. Subject subject = SecurityUtils.getSubject();
  28. UsernamePasswordToken token = new UsernamePasswordToken(username, password);
  29. subject.login(token);
  30. LoginUserVO userDTO = (LoginUserVO) subject.getPrincipal();
  31. request.getSession().setAttribute("username", userDTO.getUser());
  32. return Result.success(true, "200", "登录成功");
  33. } catch (UnknownAccountException e) {
  34. e.printStackTrace();
  35. return Result.error(false, "400", "登录失败,用户名不存在");
  36. }catch (IncorrectCredentialsException e) {
  37. e.printStackTrace();
  38. return Result.error(false, "400", "登录失败,密码错误");
  39. }catch (AuthenticationException e) {
  40. e.printStackTrace();
  41. return Result.error(false, "400", "登录失败,账户禁用");
  42. }
  43. }
  44. /**
  45. * 得到登陆验证码
  46. * @param response
  47. * @param session
  48. * @throws IOException
  49. */
  50. @RequestMapping("/getCode")
  51. public void getCode(HttpServletResponse response, HttpSession session) throws IOException {
  52. //定义图形验证码的长和宽
  53. LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(116, 36,4,5);
  54. session.setAttribute("code",lineCaptcha.getCode());
  55. try {
  56. ServletOutputStream outputStream = response.getOutputStream();
  57. lineCaptcha.write(outputStream);
  58. outputStream.close();
  59. } catch (IOException e) {
  60. e.printStackTrace();
  61. }
  62. }
  63. /**
  64. * 查询所有用户信息
  65. *
  66. * @param userVO
  67. * @return
  68. */
  69. @SysLog("用户查询操作")
  70. @RequestMapping("/userList")
  71. public DataGridViewResult userList(UserVO userVO) {
  72. //分页构造函数
  73. IPage<User> page = new Page<>(userVO.getPage(), userVO.getLimit());
  74. QueryWrapper<User> queryWrapper = new QueryWrapper<>();
  75. queryWrapper.like(!StringUtils.isEmpty(userVO.getUsername()), "username", userVO.getUsername());
  76. queryWrapper.like(!StringUtils.isEmpty(userVO.getUname()), "uname", userVO.getUname());
  77. /**
  78. * 翻页查询
  79. * @param page 翻页对象
  80. * @param queryWrapper 实体对象封装操作类
  81. */
  82. IPage<User> userIPage = userService.page(page, queryWrapper);
  83. return new DataGridViewResult(userIPage.getTotal(), userIPage.getRecords());
  84. }
  85. /**
  86. * 添加用户信息
  87. *
  88. * @param user
  89. * @return
  90. */
  91. @SysLog("用户添加操作")
  92. @PostMapping("/adduser")
  93. public Result addRole(User user) {
  94. user.setUcreatetime(new Date());
  95. String salt = UUIDUtil.randomUUID();
  96. user.setPassword(PasswordUtil.md5("000000", salt, 2));
  97. user.setSalt(salt);
  98. user.setType(1);
  99. boolean bool = userService.save(user);
  100. try {
  101. if (bool) {
  102. return Result.success(true, "200", "添加成功!");
  103. }
  104. } catch (Exception e) {
  105. e.printStackTrace();
  106. }
  107. return Result.error(false, null, "添加失败!");
  108. }
  109. /**
  110. * 校验用户名是否存在
  111. *
  112. * @param username
  113. * @return
  114. */
  115. @RequestMapping("/checkUserName")
  116. public String checkUserName(String username) {
  117. Map<String, Object> map = new HashMap<>();
  118. try {
  119. QueryWrapper<User> queryWrapper = new QueryWrapper<>();
  120. queryWrapper.eq("username", username);
  121. User user = userService.getOne(queryWrapper);
  122. if (user != null) {
  123. map.put("exist", true);
  124. map.put("message", "用户名已存在");
  125. } else {
  126. map.put("exist", false);
  127. map.put("message", "用户名可以使用");
  128. }
  129. } catch (Exception e) {
  130. e.printStackTrace();
  131. }
  132. return JSON.toJSONString(map);
  133. }
  134. /**
  135. * 修改用户信息
  136. *
  137. * @param user
  138. * @return
  139. */
  140. @SysLog("用户修改操作")
  141. @PostMapping("/updateuser")
  142. public Result updateUser(User user) {
  143. boolean bool = userService.updateById(user);
  144. try {
  145. if (bool) {
  146. return Result.success(true, "200", "修改成功!");
  147. }
  148. } catch (Exception e) {
  149. e.printStackTrace();
  150. }
  151. return Result.error(false, null, "修改失败!");
  152. }
  153. /**
  154. * 删除单条数据
  155. *
  156. * @param id
  157. * @return
  158. */
  159. @SysLog("用户删除操作")
  160. @RequestMapping("/deleteOne")
  161. public Result deleteOne(int id) {
  162. boolean bool = userService.removeById(id);
  163. try {
  164. if (bool) {
  165. return Result.success(true, "200", "删除成功!");
  166. }
  167. } catch (Exception e) {
  168. e.printStackTrace();
  169. }
  170. return Result.error(false, null, "删除失败!");
  171. }
  172. /**
  173. * 重置密码
  174. *
  175. * @param id
  176. * @return
  177. */
  178. @SysLog("用户修改操作")
  179. @PostMapping("/resetPwd")
  180. public Result resetPwd(int id) {
  181. User user = new User();
  182. String salt = UUIDUtil.randomUUID();
  183. user.setUid(id);
  184. user.setPassword(PasswordUtil.md5("000000", salt, 2));
  185. user.setSalt(salt);
  186. boolean bool = userService.updateById(user);
  187. try {
  188. if (bool) {
  189. return Result.success(true, "200", "重置成功!");
  190. }
  191. } catch (Exception e) {
  192. e.printStackTrace();
  193. }
  194. return Result.error(false, null, "重置失败!");
  195. }
  196. /**
  197. * 根据id查询当前用户拥有的角色
  198. *
  199. * @param id
  200. * @return
  201. */
  202. @RequestMapping("/initRoleByUserId")
  203. public DataGridViewResult initRoleByUserId(int id) {
  204. List<Map<String, Object>> mapList = null;
  205. try {
  206. //查询所有角色列表
  207. mapList = roleService.listMaps();
  208. //根据用户id查询用户拥有的角色
  209. Set<Integer> roleIdList = userService.findRoleByUserId(id);
  210. for (Map<String, Object> map : mapList) {
  211. //定义标记 默认不选中
  212. boolean flag = false;
  213. int roleId = (int) map.get("roleid");
  214. for (Integer rid : roleIdList) {
  215. if (rid == roleId) {
  216. flag = true;
  217. break;
  218. }
  219. }
  220. map.put("LAY_CHECKED", flag);
  221. }
  222. } catch (Exception e) {
  223. e.printStackTrace();
  224. }
  225. return new DataGridViewResult(Long.valueOf(mapList.size()), mapList);
  226. }
  227. /**
  228. * 为用户分配角色
  229. *
  230. * @param roleids
  231. * @param userid
  232. * @return
  233. */
  234. @SysLog("用户添加操作")
  235. @RequestMapping("/saveUserRole")
  236. public Result saveUserRole(String roleids, int userid) {
  237. try {
  238. if (userService.saveUserRole(userid, roleids)) {
  239. return Result.success(true, null, "分配成功");
  240. }
  241. } catch (Exception e) {
  242. e.printStackTrace();
  243. }
  244. return Result.error(false, null, "分配失败");
  245. }
  246. /**
  247. * 修改密码
  248. *
  249. * @param newPassWord1
  250. * @param newPassWord2
  251. * @return
  252. */
  253. @RequestMapping("/updateUserPassWord")
  254. public Result updateUserPassWord(String newPassWord1, String newPassWord2,HttpSession session) {
  255. User sessionUser = (User) session.getAttribute("username");
  256. if (newPassWord1.equals(newPassWord2)){
  257. User user = new User();
  258. String salt = UUIDUtil.randomUUID();
  259. user.setUid(sessionUser.getUid());
  260. user.setPassword(PasswordUtil.md5(newPassWord1, salt, 2));
  261. user.setSalt(salt);
  262. boolean bool = userService.updateById(user);
  263. if (bool){
  264. return Result.success(true,null,"修改成功");
  265. }else {
  266. return Result.error(false,null,"修改失败!");
  267. }
  268. }else {
  269. return Result.error(false,null,"修改失败,两次密码不一致!");
  270. }
  271. }
  272. }

前端控制器角色控制层:

  1. /**
  2. * <p>
  3. * 前端控制器
  4. * </p>
  5. *
  6. */
  7. @RestController
  8. @RequestMapping("/role")
  9. public class RoleController {
  10. @Autowired
  11. private RoleService roleService;
  12. @Autowired
  13. private PermissionService permissionService;
  14. /**
  15. * 查询所有角色信息
  16. * @param roleVO
  17. * @return
  18. */
  19. @SysLog("角色查询操作")
  20. @RequestMapping("/roleList")
  21. public DataGridViewResult roleList(RoleVO roleVO) {
  22. //分页构造函数
  23. IPage<Role> page = new Page<>(roleVO.getPage(), roleVO.getLimit());
  24. QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
  25. queryWrapper.like(!StringUtils.isEmpty(roleVO.getRolename()), "rolename", roleVO.getRolename());
  26. /**
  27. * 翻页查询
  28. *
  29. * @param page 翻页对象
  30. * @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
  31. */
  32. IPage<Role> roleIPage = roleService.page(page, queryWrapper);
  33. return new DataGridViewResult(roleIPage.getTotal(), roleIPage.getRecords());
  34. }
  35. /**
  36. * 添加角色信息
  37. *
  38. * @param role
  39. * @return
  40. */
  41. @SysLog("角色添加操作")
  42. @PostMapping("/addrole")
  43. public Result addRole(Role role) {
  44. boolean bool = roleService.save(role);
  45. try {
  46. if (bool) {
  47. return Result.success(true, "200", "添加成功!");
  48. }
  49. } catch (Exception e) {
  50. e.printStackTrace();
  51. }
  52. return Result.error(false, null, "添加失败!");
  53. }
  54. /**
  55. * 修改角色信息
  56. *
  57. * @param role
  58. * @return
  59. */
  60. @SysLog("角色修改操作")
  61. @PostMapping("/updaterole")
  62. public Result updateRole(Role role) {
  63. boolean bool = roleService.updateById(role);
  64. try {
  65. if (bool) {
  66. return Result.success(true, "200", "修改成功!");
  67. }
  68. } catch (Exception e) {
  69. e.printStackTrace();
  70. }
  71. return Result.error(false, null, "修改失败!");
  72. }
  73. /**
  74. * 删除单条数据
  75. *
  76. * @param id
  77. * @return
  78. */
  79. @SysLog("角色删除操作")
  80. @RequestMapping("/deleteOne")
  81. public Result deleteOne(int id) {
  82. boolean bool = roleService.removeById(id);
  83. try {
  84. if (bool) {
  85. return Result.success(true, "200", "删除成功!");
  86. }
  87. } catch (Exception e) {
  88. e.printStackTrace();
  89. }
  90. return Result.error(false, null, "删除失败!");
  91. }
  92. /**
  93. * 初始化权限菜单树
  94. *
  95. * @param roleId
  96. * @return
  97. */
  98. @RequestMapping("/initPermissionByRoleId")
  99. public DataGridViewResult initPermissionByRoleId(int roleId) {
  100. //创建条件构造器对象
  101. QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
  102. List<Permission> permissionList = permissionService.list();
  103. List<Integer> currentPermissionIds = permissionService.findRolePermissionIdByRoleId(roleId);
  104. //保存角色拥有的菜单
  105. List<Permission> currentPermissions = new ArrayList<>();
  106. if (currentPermissionIds != null && currentPermissionIds.size() > 0) {
  107. queryWrapper.in("id", currentPermissionIds);
  108. currentPermissions = permissionService.list(queryWrapper);
  109. }
  110. List<TreeNode> treeNodes = new ArrayList<>();
  111. for (Permission p1 : permissionList) {
  112. //定义变量标记是否选中
  113. String checkArr = "0";
  114. for (Permission p2 : currentPermissions) {
  115. if (p1.getId().equals(p2.getId())) {
  116. checkArr = "1";
  117. break;
  118. }
  119. }
  120. Boolean spread = p1.getSpread() == 1 ? true : false;
  121. treeNodes.add(new TreeNode(p1.getId(), p1.getPid(), p1.getTitle(), spread, checkArr));
  122. }
  123. return new DataGridViewResult(treeNodes);
  124. }
  125. /**
  126. * 保存分配权限关系方法
  127. *
  128. * @param roleid
  129. * @param ids
  130. * @return
  131. */
  132. @SysLog("角色添加操作")
  133. @RequestMapping("/saveRolePermission")
  134. public Result saveRolePermission(int roleid, String ids) {
  135. try {
  136. if (roleService.saveRolePermission(roleid, ids)) {
  137. return Result.success(true, null, "分配成功");
  138. }
  139. } catch (Exception e) {
  140. e.printStackTrace();
  141. }
  142. return Result.error(false, null, "分配失败");
  143. }
  144. }

前端控制器客户管理: 

  1. /**
  2. * <p>
  3. * 前端控制器
  4. * </p>
  5. *
  6. */
  7. @RestController
  8. @RequestMapping("/customer")
  9. public class CustomerController {
  10. @Autowired
  11. private CustomerService customerService;
  12. /**
  13. * 客户模糊查询
  14. * @param
  15. * @return
  16. */
  17. @SysLog("客户查询操作")
  18. @RequestMapping("/customerList")
  19. public DataGridViewResult customerList(CustomerVO customerVO) {
  20. //创建分页信息 参数1 当前页 参数2 每页显示条数
  21. IPage<Customer> page = new Page<>(customerVO.getPage(), customerVO.getLimit());
  22. QueryWrapper<Customer> queryWrapper = new QueryWrapper<>();
  23. queryWrapper.like(!StringUtils.isEmpty(customerVO.getCustvip()),"custvip", customerVO.getCustvip());
  24. IPage<Customer> customerIPage = customerService.page(page, queryWrapper);
  25. /**
  26. * logsIPage.getTotal() 总条数
  27. * logsIPage.getRecords() 分页记录列表
  28. */
  29. return new DataGridViewResult(customerIPage.getTotal(),customerIPage.getRecords());
  30. }
  31. /**
  32. * 客户批量删除
  33. * @param ids
  34. * @return
  35. */
  36. @SysLog("客户删除操作")
  37. @RequestMapping("/deleteList")
  38. public Result deleteList(String ids) {
  39. //将字符串拆分成数组
  40. String[] idsStr = ids.split(",");
  41. List<String> list = Arrays.asList(idsStr);
  42. boolean bool = customerService.removeByIds(list);
  43. if(bool){
  44. return Result.success(true,"200","删除成功!");
  45. }
  46. return Result.error(false,null,"删除失败!");
  47. }
  48. /**
  49. * 添加客户信息
  50. * @param customer
  51. * @return
  52. */
  53. @SysLog("客户添加操作")
  54. @PostMapping("/addcustomer")
  55. public Result addCustomer(Customer customer){
  56. String id = RandomStringUtils.randomAlphanumeric(10);
  57. customer.setCustvip(id);
  58. boolean bool = customerService.save(customer);
  59. if(bool){
  60. return Result.success(true,"200","添加成功!");
  61. }
  62. return Result.error(false,null,"添加失败!");
  63. }
  64. /**
  65. * 修改客户信息
  66. * @param customer
  67. * @return
  68. */
  69. @SysLog("客户修改操作")
  70. @PostMapping("/updatecustomer")
  71. public Result updateCustomer(Customer customer){
  72. boolean bool = customerService.updateById(customer);
  73. if(bool){
  74. return Result.success(true,"200","修改成功!");
  75. }
  76. return Result.error(false,null,"修改失败!");
  77. }
  78. /**
  79. * 删除单条数据
  80. * @param id
  81. * @return
  82. */
  83. @SysLog("客户删除操作")
  84. @RequestMapping("/deleteOne")
  85. public Result deleteOne(int id) {
  86. boolean bool = customerService.removeById(id);
  87. if(bool){
  88. return Result.success(true,"200","删除成功!");
  89. }
  90. return Result.error(false,null,"删除失败!");
  91. }
  92. /**
  93. *
  94. * 加载下拉框
  95. * @return
  96. */
  97. @RequestMapping("/loadAllCustomer")
  98. public DataGridViewResult loadAllCustomer(){
  99. QueryWrapper<Customer> queryWrapper = new QueryWrapper<>();
  100. List<Customer> list = customerService.list(queryWrapper);
  101. return new DataGridViewResult(list);
  102. }
  103. }

商品管理控制层:

  1. /**
  2. * <p>
  3. * 前端控制器
  4. * </p>
  5. *
  6. */
  7. @RestController
  8. @RequestMapping("/goods")
  9. public class GoodsController {
  10. @Autowired
  11. private GoodsService goodsService;
  12. @Autowired
  13. private ProviderService providerService;
  14. @Autowired
  15. private CategoryService categoryService;
  16. /**
  17. * 商品模糊查询
  18. *
  19. * @param
  20. * @return
  21. */
  22. @SysLog("商品查询操作")
  23. @RequestMapping("/goodsList")
  24. public DataGridViewResult goodsList(GoodsVO goodsVO) {
  25. //创建分页信息 参数1 当前页 参数2 每页显示条数
  26. IPage<Goods> page = new Page<>(goodsVO.getPage(), goodsVO.getLimit());
  27. QueryWrapper<Goods> queryWrapper = new QueryWrapper<>();
  28. queryWrapper.eq(goodsVO.getProviderid() != null && goodsVO.getProviderid() != 0, "providerid", goodsVO.getProviderid());
  29. queryWrapper.like(!StringUtils.isEmpty(goodsVO.getGname()), "gname", goodsVO.getGname());
  30. IPage<Goods> goodsIPage = goodsService.page(page, queryWrapper);
  31. List<Goods> records = goodsIPage.getRecords();
  32. for (Goods goods : records) {
  33. Provider provider = providerService.getById(goods.getProviderid());
  34. if (null != provider) {
  35. goods.setProvidername(provider.getProvidername());
  36. }
  37. }
  38. return new DataGridViewResult(goodsIPage.getTotal(), records);
  39. }
  40. /**
  41. * 添加商品信息
  42. *
  43. * @param goods
  44. * @return
  45. */
  46. @SysLog("商品添加操作")
  47. @PostMapping("/addgoods")
  48. public Result addGoods(Goods goods) {
  49. String id = RandomStringUtils.randomAlphanumeric(8);
  50. if (goods.getGoodsimg()!=null&&goods.getGoodsimg().endsWith("_temp")){
  51. String newName = AppFileUtils.renameFile(goods.getGoodsimg());
  52. goods.setGoodsimg(newName);
  53. }
  54. goods.setGnumbering(id);
  55. boolean bool = goodsService.save(goods);
  56. if (bool) {
  57. return Result.success(true, "200", "添加成功!");
  58. }
  59. return Result.error(false, null, "添加失败!");
  60. }
  61. /**
  62. * 修改商品信息
  63. *
  64. * @param goods
  65. * @return
  66. */
  67. @SysLog("商品修改操作")
  68. @PostMapping("/updategoods")
  69. public Result updateGoods(Goods goods) {
  70. //商品图片不是默认图片
  71. if (!(goods.getGoodsimg()!=null&&goods.getGoodsimg().equals(Constast.DEFAULT_IMG))){
  72. if (goods.getGoodsimg().endsWith("_temp")){
  73. String newName = AppFileUtils.renameFile(goods.getGoodsimg());
  74. goods.setGoodsimg(newName);
  75. //删除原先的图片
  76. String oldPath = goodsService.getById(goods.getGid()).getGoodsimg();
  77. AppFileUtils.removeFileByPath(oldPath);
  78. }
  79. }
  80. boolean bool = goodsService.updateById(goods);
  81. if (bool) {
  82. return Result.success(true, "200", "修改成功!");
  83. }
  84. return Result.error(false, null, "修改失败!");
  85. }
  86. /**
  87. * 删除单条数据
  88. *
  89. * @param id
  90. * @return
  91. */
  92. @SysLog("商品删除操作")
  93. @RequestMapping("/deleteOne")
  94. public Result deleteOne(int id) {
  95. boolean bool = goodsService.removeById(id);
  96. if (bool) {
  97. return Result.success(true, "200", "删除成功!");
  98. }
  99. return Result.error(false, null, "删除失败!");
  100. }
  101. /**
  102. * 根据id查询当前商品拥有的类别
  103. *
  104. * @param id
  105. * @return
  106. */
  107. @RequestMapping("/initGoodsByCategoryId")
  108. public DataGridViewResult initGoodsByCategoryId(int id) {
  109. List<Map<String, Object>> mapList = null;
  110. try {
  111. //查询所有类别列表
  112. mapList = categoryService.listMaps();
  113. //根据商品id查询商品拥有的类别
  114. Set<Integer> cateIdList = categoryService.findGoodsByCategoryId(id);
  115. for (Map<String, Object> map : mapList) {
  116. //定义标记 默认不选中
  117. boolean flag = false;
  118. int cateId = (int) map.get("cateid");
  119. for (Integer cid : cateIdList) {
  120. if (cid == cateId) {
  121. flag = true;
  122. break;
  123. }
  124. }
  125. map.put("LAY_CHECKED", flag);
  126. }
  127. } catch (Exception e) {
  128. e.printStackTrace();
  129. }
  130. return new DataGridViewResult(Long.valueOf(mapList.size()), mapList);
  131. }
  132. /**
  133. * 根据商品id加载商品信息
  134. * @param goodsid
  135. * @return
  136. */
  137. @GetMapping("/loadGoodsById")
  138. public DataGridViewResult loadGoodsById(int goodsid) {
  139. QueryWrapper<Goods> goodsQueryWrapper = new QueryWrapper<>();
  140. goodsQueryWrapper.eq(goodsid != 0, "gid", goodsid);
  141. Goods goods = goodsService.getById(goodsid);
  142. return new DataGridViewResult(goods);
  143. }
  144. /**
  145. * 为商品分配类别
  146. *
  147. * @param categoryids
  148. * @param goodsid
  149. * @return
  150. */
  151. @SysLog("类别添加操作")
  152. @RequestMapping("/saveGoodsCategory")
  153. public Result saveGoodsCategory(String categoryids, int goodsid) {
  154. try {
  155. if (goodsService.saveGoodsCategory(goodsid, categoryids)) {
  156. return Result.success(true, null, "分配成功");
  157. }
  158. } catch (Exception e) {
  159. e.printStackTrace();
  160. }
  161. return Result.error(false, null, "分配失败");
  162. }
  163. /**
  164. * 加载下拉框
  165. *
  166. * @return
  167. */
  168. @RequestMapping("/loadAllGoods")
  169. public DataGridViewResult loadAllGoods() {
  170. QueryWrapper<Goods> queryWrapper = new QueryWrapper<>();
  171. List<Goods> list = goodsService.list(queryWrapper);
  172. return new DataGridViewResult(list);
  173. }
  174. /**
  175. * 根据供应商查商品下拉框
  176. *
  177. * @param providerid
  178. * @return
  179. */
  180. @RequestMapping("/loadGoodsByProvidreId")
  181. public DataGridViewResult loadGoodsByProvidreId(Integer providerid) {
  182. QueryWrapper<Goods> goodsQueryWrapper = new QueryWrapper<>();
  183. goodsQueryWrapper.eq(providerid != null, "providerid", providerid);
  184. List<Goods> list = goodsService.list(goodsQueryWrapper);
  185. for (Goods goods : list) {
  186. Provider provider = providerService.getById(goods.getProviderid());
  187. if (null != provider) {
  188. goods.setProvidername(provider.getProvidername());
  189. }
  190. }
  191. return new DataGridViewResult(list);
  192. }
  193. }

源码获取:博客首页 "资源" 里下载! 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/316899
推荐阅读
相关标签
  

闽ICP备14008679号