家居建材商城|基于Springboot+Vue实现家居建材商城(一)https://developer.aliyun.com/article/1423364
查询入库记录
订单管理
退换货处理
后台管理员登陆
商铺管理
商品管理
订单管理
营销管理-轮播图管理
营销管理-分类推荐
用户-角色-权限管理
四,核心代码展示
package com.qiu.controller; import com.qiu.entity.Role; import com.qiu.service.RoleService; import com.qiu.util.general.CommonResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * 用户授权等相关业务 */ @CrossOrigin @RestController public class RoleController { @Autowired private RoleService roleService; /** * 根据id查询角色信息 * * @param roleId 角色编号 */ @RequestMapping(value = "/role/findById") public CommonResult findById(Integer roleId) { Role role = roleService.selectById(roleId); if (role != null) { return CommonResult.success("查询成功", role); } return CommonResult.error("查询失败"); } /** * 根据角色名称查询角色 * * @param roleName 角色名称 */ @RequestMapping(value = "/role/findByKey") public CommonResult findByKey(String roleName) { Role role = roleService.selectByKey(roleName); if (role != null) { return CommonResult.success("查询成功", role); } return CommonResult.error("查询失败"); } /** * 判断角色是否存在 * * @param roleId 角色编号 * @param roleName 角色名称 */ @RequestMapping(value = "/role/existRoleName") public CommonResult existRoleName(Integer roleId, String roleName) { boolean exist = roleService.existsRoleName(roleId, roleName); return CommonResult.success("查询成功", exist); } /** * 查询所有角色信息 */ @RequestMapping(value = "/role/findAll") public CommonResult findAll() { List<Role> roles = roleService.selectAll(); if (roles != null) { return CommonResult.success("查询成功", roles); } return CommonResult.error("查询失败"); } /** * 查询所有可用的角色信息 */ @RequestMapping(value = "/role/findAllUsable") public CommonResult findAllUsable() { List<Role> roles = roleService.selectAllUsable(); if (roles != null) { return CommonResult.success("查询成功", roles); } return CommonResult.error("查询失败"); } /** * 查询角色数量 */ @RequestMapping(value = "/role/count") public CommonResult findCount() { int count = roleService.selectCount(); return CommonResult.success("查询成功", count); } /** * 新增角色信息 * * @param role 角色信息 */ @RequestMapping(value = "/role/add") public CommonResult add(Role role) { if (role != null) { if (roleService.insertData(role)) { return CommonResult.success("添加成功", role); } return CommonResult.error("添加失败"); } return CommonResult.error("角色信息不存在"); } /** * 更新角色信息 * * @param role 角色信息 */ @RequestMapping(value = "/role/update") public CommonResult update(Role role) { if (roleService.updateById(role)) { return CommonResult.success("更新成功", role); } return CommonResult.error("更新失败"); } /** * 删除角色信息 * * @param roleId 角色编号 */ @RequestMapping(value = "/role/delete") public CommonResult delete(Integer roleId) { if (roleService.deleteById(roleId)) { return CommonResult.success("删除成功", roleId); } return CommonResult.error("删除失败"); } }
package com.qiu.controller; import com.qiu.entity.ShoppingCart; import com.qiu.service.ShoppingCartService; import com.qiu.util.general.CommonResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Map; /** * 购物车业务类 */ @RestController @CrossOrigin public class ShoppingCartController { @Autowired private ShoppingCartService shoppingCartService; /** * 新增商品到购物车 * * @param shoppingCart 购物车商品信息 */ @RequestMapping(value = "/shoppingCart/add") public CommonResult addShoppingCart(ShoppingCart shoppingCart) { if (shoppingCartService.insertData(shoppingCart)) { return CommonResult.success("购物车添加成功", shoppingCart); } return CommonResult.error("购物车添加失败"); } /** * 更新购物车商品 * * @param shoppingCart 购物车商品信息 */ @RequestMapping(value = "/shoppingCart/update") public CommonResult updateShoppingCart(ShoppingCart shoppingCart) { if (shoppingCartService.updateById(shoppingCart)) { return CommonResult.success("购物车修改成功", shoppingCart); } return CommonResult.error("购物车修改失败"); } /** * 购物车移除商品 * * @param cartId 购物车商品编号 */ @RequestMapping(value = "/shoppingCart/deleteById") public CommonResult deleteShoppingCart(Integer cartId) { if (shoppingCartService.deleteById(cartId)) { return CommonResult.success("购物车删除成功", "cartId: " + cartId); } return CommonResult.error("购物车删除失败"); } /** * 根据用户移除购物车 * * @param account 用户账户 */ @RequestMapping(value = "/shoppingCart/deleteByUser") public CommonResult deleteByUser(String account) { if (shoppingCartService.deleteByUser(account)) { return CommonResult.success("购物车删除成功", account); } return CommonResult.error("购物车删除失败"); } /** * 查询用户账号下的购物车信息 * * @param account 用户账户 */ @RequestMapping(value = "/shoppingCart/findAll") public CommonResult findAllShoppingCart(String account) { List<Map<String, Object>> shoppingInfo = shoppingCartService.selectAll(account); if (shoppingInfo != null) { return CommonResult.success("购物车查询成功", shoppingInfo); } return CommonResult.error("购物车查询失败"); } /** * 根据购物车商品编号查询购物车商品信息 * * @param cartId 购物车商品编号 */ @RequestMapping(value = "/shoppingCart/findById") public CommonResult findById(Integer cartId) { ShoppingCart shoppingCart = shoppingCartService.selectById(cartId); if (shoppingCart != null) { return CommonResult.success("购物车查询成功", shoppingCart); } return CommonResult.error("购物车查询失败"); } }
家居建材商城|基于Springboot+Vue实现家居建材商城(三)https://developer.aliyun.com/article/1423366