├── .idea ├── .name ├── logistics.iml ├── encodings.xml ├── misc.xml └── compiler.xml ├── src └── main │ ├── resources │ ├── file.properties │ ├── log4j.properties │ ├── mapper │ │ ├── sys │ │ │ ├── DeptMapper.xml │ │ │ ├── UserMapper.xml │ │ │ ├── NoticeMapper.xml │ │ │ ├── LoginfoMapper.xml │ │ │ ├── PermissionMapper.xml │ │ │ └── RoleMapper.xml │ │ └── bus │ │ │ ├── GoodsMapper.xml │ │ │ ├── InportMapper.xml │ │ │ ├── CustomerMapper.xml │ │ │ └── ProviderMapper.xml │ └── application.yml │ └── java │ └── com │ └── dev │ └── warehouse │ ├── sys │ ├── common │ │ ├── Constants.java │ │ ├── ActiverUser.java │ │ ├── DataGridView.java │ │ ├── CacheBean.java │ │ ├── TreeNodeBuilder.java │ │ ├── SpringUtil.java │ │ ├── Constast.java │ │ ├── WebUtils.java │ │ ├── ResultObj.java │ │ ├── PinyinUtils.java │ │ ├── TreeNode.java │ │ └── AppFileUtils.java │ ├── service │ │ ├── IDeptService.java │ │ ├── INoticeService.java │ │ ├── ILoginfoService.java │ │ ├── IPermissionService.java │ │ ├── IUserService.java │ │ ├── impl │ │ │ ├── LoginfoServiceImpl.java │ │ │ ├── NoticeServiceImpl.java │ │ │ ├── PermissionServiceImpl.java │ │ │ ├── DeptServiceImpl.java │ │ │ ├── UserServiceImpl.java │ │ │ └── RoleServiceImpl.java │ │ └── IRoleService.java │ ├── mapper │ │ ├── DeptMapper.java │ │ ├── UserMapper.java │ │ ├── LoginfoMapper.java │ │ ├── NoticeMapper.java │ │ ├── PermissionMapper.java │ │ └── RoleMapper.java │ ├── vo │ │ ├── DeptVo.java │ │ ├── PermissionVo.java │ │ ├── UserVo.java │ │ ├── RoleVo.java │ │ ├── LoginfoVo.java │ │ └── NoticeVo.java │ ├── config │ │ ├── MybatisPlusConfig.java │ │ ├── ResourcesConfig.java │ │ └── ShiroAutoConfiguration.java │ ├── entity │ │ ├── Loginfo.java │ │ ├── Notice.java │ │ ├── Role.java │ │ ├── Dept.java │ │ ├── Permission.java │ │ └── User.java │ ├── controller │ │ ├── PhotoController.java │ │ ├── CacheController.java │ │ ├── FileController.java │ │ ├── LoginfoController.java │ │ ├── LoginController.java │ │ ├── SystemController.java │ │ ├── DeptController.java │ │ ├── RoleController.java │ │ ├── PermissionController.java │ │ ├── NoticeController.java │ │ └── MenuController.java │ ├── cache │ │ ├── CachePool.java │ │ └── CacheAspect.java │ └── realm │ │ └── UserRealm.java │ ├── bus │ ├── mapper │ │ ├── xml │ │ │ ├── SalesMapper.xml │ │ │ ├── OutportMapper.xml │ │ │ └── SalesbackMapper.xml │ │ ├── GoodsMapper.java │ │ ├── SalesMapper.java │ │ ├── InportMapper.java │ │ ├── OutportMapper.java │ │ ├── CustomerMapper.java │ │ ├── ProviderMapper.java │ │ └── SalesbackMapper.java │ ├── service │ │ ├── IGoodsService.java │ │ ├── ISalesService.java │ │ ├── IInportService.java │ │ ├── ICustomerService.java │ │ ├── IProviderService.java │ │ ├── IOutportService.java │ │ ├── ISalesbackService.java │ │ └── impl │ │ │ ├── GoodsServiceImpl.java │ │ │ ├── CustomerServiceImpl.java │ │ │ ├── ProviderServiceImpl.java │ │ │ ├── SalesServiceImpl.java │ │ │ ├── OutportServiceImpl.java │ │ │ ├── SalesbackServiceImpl.java │ │ │ └── InportServiceImpl.java │ ├── vo │ │ ├── GoodsVo.java │ │ ├── ProviderVo.java │ │ ├── CustomerVo.java │ │ ├── InportVo.java │ │ ├── SalesVo.java │ │ ├── OutportVo.java │ │ └── SalesbackVo.java │ ├── entity │ │ ├── Provider.java │ │ ├── Customer.java │ │ ├── Goods.java │ │ ├── Sales.java │ │ ├── Outport.java │ │ ├── Inport.java │ │ └── Salesback.java │ ├── controller │ │ ├── BusinessController.java │ │ ├── OutportController.java │ │ ├── SalesbackController.java │ │ ├── SalesController.java │ │ ├── CustomerController.java │ │ ├── ProviderController.java │ │ ├── InportController.java │ │ └── GoodsController.java │ └── cache │ │ └── BusinessCacheAspect.java │ └── WarehouseApplication.java ├── image ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.jpg ├── 5.jpg ├── 6.jpg ├── 7.jpg ├── 8.jpg ├── 9.jpg └── 10.jpg ├── README.md └── pom.xml /.idea/.name: -------------------------------------------------------------------------------- 1 | warehouseSys -------------------------------------------------------------------------------- /src/main/resources/file.properties: -------------------------------------------------------------------------------- 1 | filepath=E:/upload/ -------------------------------------------------------------------------------- /.idea/logistics.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /image/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No239Implement-a-simple-inventory-management-backend-system/HEAD/image/1.jpg -------------------------------------------------------------------------------- /image/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No239Implement-a-simple-inventory-management-backend-system/HEAD/image/2.jpg -------------------------------------------------------------------------------- /image/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No239Implement-a-simple-inventory-management-backend-system/HEAD/image/3.jpg -------------------------------------------------------------------------------- /image/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No239Implement-a-simple-inventory-management-backend-system/HEAD/image/4.jpg -------------------------------------------------------------------------------- /image/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No239Implement-a-simple-inventory-management-backend-system/HEAD/image/5.jpg -------------------------------------------------------------------------------- /image/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No239Implement-a-simple-inventory-management-backend-system/HEAD/image/6.jpg -------------------------------------------------------------------------------- /image/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No239Implement-a-simple-inventory-management-backend-system/HEAD/image/7.jpg -------------------------------------------------------------------------------- /image/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No239Implement-a-simple-inventory-management-backend-system/HEAD/image/8.jpg -------------------------------------------------------------------------------- /image/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No239Implement-a-simple-inventory-management-backend-system/HEAD/image/9.jpg -------------------------------------------------------------------------------- /image/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No239Implement-a-simple-inventory-management-backend-system/HEAD/image/10.jpg -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/common/Constants.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.common; 2 | 3 | public class Constants { 4 | /** 5 | * 资源映射路径 前缀 6 | */ 7 | public static final String RESOURCE_PREFIX = "/profile"; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=DEBUG, stdout 2 | # Console output... 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n -------------------------------------------------------------------------------- /src/main/resources/mapper/sys/DeptMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/mapper/sys/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/resources/mapper/bus/GoodsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/mapper/bus/InportMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/mapper/sys/NoticeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/mapper/bus/CustomerMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/mapper/bus/ProviderMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/mapper/sys/LoginfoMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/service/IDeptService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.sys.entity.Dept; 5 | 6 | public interface IDeptService extends IService { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/mapper/xml/SalesMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/mapper/DeptMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.sys.entity.Dept; 5 | 6 | 7 | public interface DeptMapper extends BaseMapper { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.sys.entity.User; 5 | 6 | public interface UserMapper extends BaseMapper { 7 | 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/service/INoticeService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.sys.entity.Notice; 5 | 6 | public interface INoticeService extends IService { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/mapper/GoodsMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.bus.entity.Goods; 5 | 6 | 7 | public interface GoodsMapper extends BaseMapper { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/mapper/SalesMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.bus.entity.Sales; 5 | 6 | 7 | public interface SalesMapper extends BaseMapper { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/mapper/xml/OutportMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/mapper/InportMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.bus.entity.Inport; 5 | 6 | 7 | public interface InportMapper extends BaseMapper { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/mapper/OutportMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.bus.entity.Outport; 5 | 6 | 7 | public interface OutportMapper extends BaseMapper { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/mapper/xml/SalesbackMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/IGoodsService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.bus.entity.Goods; 5 | 6 | 7 | public interface IGoodsService extends IService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/ISalesService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.bus.entity.Sales; 5 | 6 | 7 | public interface ISalesService extends IService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/mapper/LoginfoMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.sys.entity.Loginfo; 5 | 6 | 7 | public interface LoginfoMapper extends BaseMapper { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/mapper/NoticeMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.sys.entity.Notice; 5 | 6 | 7 | public interface NoticeMapper extends BaseMapper { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/mapper/CustomerMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.bus.entity.Customer; 5 | 6 | 7 | public interface CustomerMapper extends BaseMapper { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/mapper/ProviderMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.bus.entity.Provider; 5 | 6 | 7 | public interface ProviderMapper extends BaseMapper { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/IInportService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.bus.entity.Inport; 5 | 6 | 7 | public interface IInportService extends IService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/mapper/SalesbackMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.bus.entity.Salesback; 5 | 6 | 7 | public interface SalesbackMapper extends BaseMapper { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/service/ILoginfoService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.sys.entity.Loginfo; 5 | 6 | 7 | public interface ILoginfoService extends IService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/ICustomerService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.bus.entity.Customer; 5 | 6 | 7 | public interface ICustomerService extends IService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/IProviderService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.bus.entity.Provider; 5 | 6 | 7 | public interface IProviderService extends IService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/service/IPermissionService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.sys.entity.Permission; 5 | 6 | 7 | public interface IPermissionService extends IService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/vo/DeptVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.vo; 2 | import com.dev.warehouse.sys.entity.Dept; 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | @Data 7 | @EqualsAndHashCode(callSuper = false) 8 | public class DeptVo extends Dept { 9 | 10 | private Integer page=1; 11 | private Integer limit=10; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/vo/GoodsVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.vo; 2 | 3 | 4 | import com.dev.warehouse.bus.entity.Goods; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | 9 | @Data 10 | @EqualsAndHashCode(callSuper = false) 11 | public class GoodsVo extends Goods { 12 | 13 | private Integer page=1; 14 | private Integer limit=10; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/vo/PermissionVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.vo; 2 | 3 | import com.dev.warehouse.sys.entity.Permission; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | 8 | @Data 9 | @EqualsAndHashCode(callSuper = false) 10 | public class PermissionVo extends Permission { 11 | 12 | private Integer page=1; 13 | private Integer limit=10; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/vo/UserVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.vo; 2 | 3 | import com.dev.warehouse.sys.entity.User; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | 8 | @Data 9 | @EqualsAndHashCode(callSuper = false) 10 | public class UserVo extends User { 11 | 12 | private Integer page=1; 13 | private Integer limit=10; 14 | 15 | /** 16 | * 验证码 17 | */ 18 | private String code; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/service/IUserService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.sys.entity.User; 5 | 6 | 7 | public interface IUserService extends IService { 8 | 9 | /** 10 | * 保存用户和角色的关系 11 | * @param uid 用户的ID 12 | * @param ids 用户拥有的角色的ID的数组 13 | */ 14 | void saveUserRole(Integer uid, Integer[] ids); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/mapper/sys/PermissionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | delete from sys_role_permission where pid = ${id} 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/IOutportService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.bus.entity.Outport; 5 | 6 | 7 | public interface IOutportService extends IService { 8 | 9 | /** 10 | * 对商品进货进行退货处理 11 | * @param id 进货单ID 12 | * @param number 退货数量 13 | * @param remark 备注 14 | */ 15 | void addOutport(Integer id, Integer number, String remark); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/common/ActiverUser.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.common; 2 | 3 | 4 | import com.dev.warehouse.sys.entity.User; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import java.util.List; 10 | 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class ActiverUser { 15 | 16 | private User user; 17 | 18 | private List roles; 19 | 20 | private List permission; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/ISalesbackService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.bus.entity.Salesback; 5 | 6 | 7 | public interface ISalesbackService extends IService { 8 | 9 | /** 10 | * 对商品销售进行退货处理 11 | * @param id 销售单ID 12 | * @param number 退货数量 13 | * @param remark 备注 14 | */ 15 | void addSalesback(Integer id, Integer number, String remark); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/vo/ProviderVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.vo; 2 | 3 | import com.dev.warehouse.bus.entity.Provider; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | 8 | @Data 9 | @EqualsAndHashCode(callSuper = false) 10 | public class ProviderVo extends Provider { 11 | 12 | /** 13 | * 分页参数,当前是第一页,每页10条数据 14 | */ 15 | private Integer page=1; 16 | private Integer limit=10; 17 | 18 | /** 19 | * 批量删除供应商,存放供应商ID的数组 20 | */ 21 | private Integer[] ids; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/vo/CustomerVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.vo; 2 | 3 | 4 | import com.dev.warehouse.bus.entity.Customer; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | 9 | @Data 10 | @EqualsAndHashCode(callSuper = false) 11 | public class CustomerVo extends Customer { 12 | 13 | /** 14 | * 分页参数,当前是第一页,每页10条数据 15 | */ 16 | private Integer page=1; 17 | private Integer limit=10; 18 | 19 | /** 20 | * 批量删除客户,存放客户ID的数组 21 | */ 22 | private Integer[] ids; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/mapper/PermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.sys.entity.Permission; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.io.Serializable; 8 | 9 | public interface PermissionMapper extends BaseMapper { 10 | 11 | /** 12 | * 根据权限ID或菜单ID删除sys_role_permission表里面的数据 13 | * @param id 14 | */ 15 | void deleteRolePermissionByPid(@Param("id") Serializable id); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/service/impl/LoginfoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.dev.warehouse.sys.entity.Loginfo; 5 | import com.dev.warehouse.sys.mapper.LoginfoMapper; 6 | import com.dev.warehouse.sys.service.ILoginfoService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | @Service 11 | @Transactional 12 | public class LoginfoServiceImpl extends ServiceImpl implements ILoginfoService { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/service/impl/NoticeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.dev.warehouse.sys.entity.Notice; 5 | import com.dev.warehouse.sys.mapper.NoticeMapper; 6 | import com.dev.warehouse.sys.service.INoticeService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | 11 | @Service 12 | @Transactional 13 | public class NoticeServiceImpl extends ServiceImpl implements INoticeService { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.config; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | @ConditionalOnClass(value= {PaginationInterceptor.class}) 10 | public class MybatisPlusConfig { 11 | @Bean 12 | public PaginationInterceptor paginationInterceptor() { 13 | return new PaginationInterceptor(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/vo/InportVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.vo; 2 | 3 | 4 | import com.dev.warehouse.bus.entity.Inport; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import java.util.Date; 10 | 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class InportVo extends Inport { 14 | 15 | private Integer page = 1; 16 | 17 | private Integer limit = 10; 18 | 19 | @DateTimeFormat(pattern = "yyyy-MM-dd") 20 | private Date startTime; 21 | 22 | @DateTimeFormat(pattern = "yyyy-MM-dd") 23 | private Date endTime; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/vo/SalesVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.vo; 2 | 3 | 4 | import com.dev.warehouse.bus.entity.Sales; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import java.util.Date; 10 | 11 | 12 | @Data 13 | @EqualsAndHashCode(callSuper = false) 14 | public class SalesVo extends Sales { 15 | 16 | private Integer page = 1; 17 | 18 | private Integer limit = 10; 19 | 20 | @DateTimeFormat(pattern = "yyyy-MM-dd") 21 | private Date startTime; 22 | 23 | @DateTimeFormat(pattern = "yyyy-MM-dd") 24 | private Date endTime; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/vo/RoleVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.vo; 2 | 3 | import com.dev.warehouse.sys.entity.Role; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | import org.springframework.format.annotation.DateTimeFormat; 7 | 8 | import java.util.Date; 9 | 10 | 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class RoleVo extends Role { 14 | 15 | private Integer page=1; 16 | private Integer limit=10; 17 | 18 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 19 | private Date startTime; 20 | 21 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 22 | private Date endTime; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/vo/OutportVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.vo; 2 | 3 | 4 | import com.dev.warehouse.bus.entity.Outport; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import java.util.Date; 10 | 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class OutportVo extends Outport { 14 | 15 | private Integer page = 1; 16 | 17 | private Integer limit = 10; 18 | 19 | @DateTimeFormat(pattern = "yyyy-MM-dd") 20 | private Date startTime; 21 | 22 | @DateTimeFormat(pattern = "yyyy-MM-dd") 23 | private Date endTime; 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/vo/SalesbackVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.vo; 2 | 3 | 4 | import com.dev.warehouse.bus.entity.Salesback; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import java.util.Date; 10 | 11 | 12 | @Data 13 | @EqualsAndHashCode(callSuper = false) 14 | public class SalesbackVo extends Salesback { 15 | 16 | private Integer page = 1; 17 | 18 | private Integer limit = 10; 19 | 20 | @DateTimeFormat(pattern = "yyyy-MM-dd") 21 | private Date startTime; 22 | 23 | @DateTimeFormat(pattern = "yyyy-MM-dd") 24 | private Date endTime; 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/common/DataGridView.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.common; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class DataGridView { 11 | 12 | private Integer code=0; 13 | private String msg=""; 14 | //返回的记录总条数 15 | private Long count=0L; 16 | //返回的记录 17 | private Object data; 18 | 19 | public DataGridView(Long count, Object data) { 20 | this.count = count; 21 | this.data = data; 22 | } 23 | 24 | public DataGridView(Object data) { 25 | this.data = data; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/vo/LoginfoVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.vo; 2 | 3 | import com.dev.warehouse.sys.entity.Loginfo; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | import org.springframework.format.annotation.DateTimeFormat; 7 | 8 | import java.util.Date; 9 | 10 | @Data 11 | @EqualsAndHashCode(callSuper = false) 12 | public class LoginfoVo extends Loginfo { 13 | 14 | private Integer page=1; 15 | private Integer limit=10; 16 | 17 | //接收多个id 18 | private Integer[] ids; 19 | 20 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 21 | private Date startTime; 22 | 23 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 24 | private Date endTime; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/vo/NoticeVo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.vo; 2 | 3 | import com.dev.warehouse.sys.entity.Notice; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | import org.springframework.format.annotation.DateTimeFormat; 7 | 8 | import java.util.Date; 9 | 10 | 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class NoticeVo extends Notice { 14 | 15 | private Integer page=1; 16 | private Integer limit=10; 17 | 18 | //接受多个ID 19 | private Integer[] ids; 20 | 21 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 22 | private Date startTime; 23 | 24 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 25 | private Date endTime; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/common/CacheBean.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.common; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | 5 | public class CacheBean { 6 | 7 | private String key; 8 | 9 | private Object value; 10 | 11 | public CacheBean() { 12 | } 13 | 14 | public CacheBean(String key, Object value) { 15 | this.key = key; 16 | this.value = value; 17 | } 18 | 19 | public String getKey() { 20 | return key; 21 | } 22 | 23 | public void setKey(String key) { 24 | this.key = key; 25 | } 26 | 27 | public Object getValue() { 28 | return JSON.toJSON(value).toString(); 29 | } 30 | 31 | public void setValue(Object value) { 32 | this.value = value; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/common/TreeNodeBuilder.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.common; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * 把没有层级关系的集合变成有层级关系的集合 8 | */ 9 | public class TreeNodeBuilder { 10 | public static List build(List treeNodes, Integer topPid) { 11 | List nodes = new ArrayList(); 12 | for (TreeNode n1 : treeNodes) { 13 | if (n1.getPid()==topPid){ 14 | nodes.add(n1); 15 | } 16 | for (TreeNode n2 : treeNodes) { 17 | if (n1.getId()==n2.getPid()){ 18 | n1.getChildren().add(n2); 19 | } 20 | } 21 | } 22 | return nodes; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/service/IRoleService.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.dev.warehouse.sys.entity.Role; 5 | 6 | import java.util.List; 7 | 8 | 9 | public interface IRoleService extends IService { 10 | 11 | /** 12 | * 根据角色ID查询当前角色拥有的菜单ID和权限ID 13 | * @param roleId 14 | * @return 15 | */ 16 | List queryRolePermissionIdsByRid(Integer roleId); 17 | 18 | /** 19 | * 保存角色和菜单权限之间的关系 20 | * @param rid 21 | * @param ids 22 | */ 23 | void saveRolePermission(Integer rid, Integer[] ids); 24 | 25 | /** 26 | * 查询当前用户拥有的角色ID集合 27 | * @param id 28 | * @return 29 | */ 30 | List queryUserRoleIdsByUid(Integer id); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/config/ResourcesConfig.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.config; 2 | 3 | import com.dev.warehouse.sys.common.Constants; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 8 | 9 | @Configuration 10 | public class ResourcesConfig implements WebMvcConfigurer { 11 | 12 | @Value("${yuanlrc.photoFilePath}") 13 | private String filePath; 14 | 15 | @Override 16 | public void addResourceHandlers(ResourceHandlerRegistry registry) 17 | { 18 | /** 本地文件上传路径 */ 19 | registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + filePath ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/common/SpringUtil.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.common; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class SpringUtil implements ApplicationContextAware { 10 | 11 | private static ApplicationContext applicationContext; 12 | 13 | @Override 14 | public void setApplicationContext(ApplicationContext act) throws BeansException { 15 | applicationContext = act; 16 | } 17 | 18 | public static ApplicationContext getApplicationContext(){ 19 | return applicationContext; 20 | } 21 | 22 | public static T getBean(Class cls){ 23 | return applicationContext.getBean(cls); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/entity/Loginfo.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | import lombok.experimental.Accessors; 9 | 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | 14 | @Data 15 | @EqualsAndHashCode(callSuper = false) 16 | @Accessors(chain = true) 17 | @TableName("sys_loginfo") 18 | public class Loginfo implements Serializable { 19 | 20 | private static final long serialVersionUID=1L; 21 | 22 | @TableId(value = "id", type = IdType.AUTO) 23 | private Integer id; 24 | 25 | private String loginname; 26 | 27 | private String loginip; 28 | 29 | private Date logintime; 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/entity/Notice.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | import lombok.experimental.Accessors; 9 | 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | 14 | @Data 15 | @EqualsAndHashCode(callSuper = false) 16 | @Accessors(chain = true) 17 | @TableName("sys_notice") 18 | public class Notice implements Serializable { 19 | 20 | private static final long serialVersionUID=1L; 21 | 22 | @TableId(value = "id", type = IdType.AUTO) 23 | private Integer id; 24 | 25 | private String title; 26 | 27 | private String content; 28 | 29 | private Date createtime; 30 | 31 | private String opername; 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/entity/Role.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | import lombok.experimental.Accessors; 9 | 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | 14 | @Data 15 | @EqualsAndHashCode(callSuper = false) 16 | @Accessors(chain = true) 17 | @TableName("sys_role") 18 | public class Role implements Serializable { 19 | 20 | private static final long serialVersionUID=1L; 21 | 22 | @TableId(value = "id", type = IdType.AUTO) 23 | private Integer id; 24 | 25 | private String name; 26 | 27 | private String remark; 28 | 29 | /** 30 | * 0不可用,1可用 31 | */ 32 | private Integer available; 33 | 34 | private Date createtime; 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/service/impl/PermissionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.dev.warehouse.sys.entity.Permission; 5 | import com.dev.warehouse.sys.mapper.PermissionMapper; 6 | import com.dev.warehouse.sys.service.IPermissionService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import java.io.Serializable; 11 | 12 | 13 | @Service 14 | @Transactional 15 | public class PermissionServiceImpl extends ServiceImpl implements IPermissionService { 16 | 17 | @Override 18 | public boolean removeById(Serializable id) { 19 | 20 | //根据权限ID或菜单ID删除sys_role_permission表中的数据 21 | PermissionMapper permissionMapper = this.getBaseMapper(); 22 | permissionMapper.deleteRolePermissionByPid(id); 23 | //删除权限表中的数据 24 | return super.removeById(id); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/impl/GoodsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | 5 | import com.dev.warehouse.bus.entity.Goods; 6 | import com.dev.warehouse.bus.mapper.GoodsMapper; 7 | import com.dev.warehouse.bus.service.IGoodsService; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import java.io.Serializable; 12 | 13 | 14 | @Service 15 | @Transactional 16 | public class GoodsServiceImpl extends ServiceImpl implements IGoodsService { 17 | 18 | @Override 19 | public boolean save(Goods entity) { 20 | return super.save(entity); 21 | } 22 | 23 | @Override 24 | public boolean updateById(Goods entity) { 25 | return super.updateById(entity); 26 | } 27 | 28 | @Override 29 | public boolean removeById(Serializable id) { 30 | return super.removeById(id); 31 | } 32 | 33 | @Override 34 | public Goods getById(Serializable id) { 35 | return super.getById(id); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/entity/Provider.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | import lombok.ToString; 9 | import lombok.experimental.Accessors; 10 | 11 | import java.io.Serializable; 12 | 13 | @Data 14 | @EqualsAndHashCode(callSuper = false) 15 | @Accessors(chain = true) 16 | @TableName("bus_provider") 17 | @ToString 18 | public class Provider implements Serializable { 19 | 20 | private static final long serialVersionUID=1L; 21 | 22 | @TableId(value = "id", type = IdType.AUTO) 23 | private Integer id; 24 | 25 | private String providername; 26 | 27 | private String zip; 28 | 29 | private String address; 30 | 31 | private String telephone; 32 | 33 | private String connectionperson; 34 | 35 | private String phone; 36 | 37 | private String bank; 38 | 39 | private String account; 40 | 41 | private String email; 42 | 43 | private String fax; 44 | 45 | private Integer available; 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/entity/Customer.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | import lombok.ToString; 9 | import lombok.experimental.Accessors; 10 | 11 | import java.io.Serializable; 12 | 13 | 14 | @Data 15 | @EqualsAndHashCode(callSuper = false) 16 | @Accessors(chain = true) 17 | @TableName("bus_customer") 18 | @ToString 19 | public class Customer implements Serializable { 20 | 21 | private static final long serialVersionUID=1L; 22 | 23 | @TableId(value = "id", type = IdType.AUTO) 24 | private Integer id; 25 | 26 | private String customername; 27 | 28 | private String zip; 29 | 30 | private String address; 31 | 32 | private String telephone; 33 | 34 | private String connectionpersion; 35 | 36 | private String phone; 37 | 38 | private String bank; 39 | 40 | private String account; 41 | 42 | private String email; 43 | 44 | private String fax; 45 | 46 | private Integer available; 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/common/Constast.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.common; 2 | 3 | 4 | public class Constast { 5 | 6 | /** 7 | * 状态码 正常 200 错误 -1 8 | */ 9 | public static final Integer OK=200; 10 | public static final Integer ERROR=-1; 11 | 12 | /** 13 | * 用户默认密码 14 | */ 15 | public static final String USER_DEFAULT_PWD="123456"; 16 | 17 | /** 18 | * 菜单可用状态 0不可用 1可用 19 | */ 20 | public static final Object AVAILABLE_TRUE = 1; 21 | public static final Object AVAILABLE_FALSE = 0; 22 | 23 | /** 24 | * 菜单和权限类型 menu 菜单 permission 权限 25 | */ 26 | public static final String TYPE_MENU = "menu"; 27 | public static final String TYPE_PERMISSION = "permission"; 28 | 29 | /** 30 | * 用户类型 0 超级管理员 1 系统用户 31 | */ 32 | public static final Integer USER_TYPE_SUPER = 0; 33 | public static final Integer USER_TYPE_NORMAL = 1; 34 | 35 | /** 36 | * 菜单是否展开 0不展开 1展开 37 | */ 38 | public static final Integer OPEN_TRUE = 1; 39 | public static final Integer OPEN_FALSE = 0; 40 | 41 | /** 42 | * 商品默认图片 43 | */ 44 | public static final String DEFAULT_IMG= "/images/noDefaultImage.jpg"; 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/entity/Dept.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | import lombok.ToString; 9 | import lombok.experimental.Accessors; 10 | 11 | import java.io.Serializable; 12 | import java.util.Date; 13 | 14 | 15 | @Data 16 | @EqualsAndHashCode(callSuper = false) 17 | @Accessors(chain = true) 18 | @TableName("sys_dept") 19 | @ToString 20 | public class Dept implements Serializable { 21 | 22 | private static final long serialVersionUID=1L; 23 | 24 | @TableId(value = "id", type = IdType.AUTO) 25 | private Integer id; 26 | 27 | private Integer pid; 28 | 29 | private String name; 30 | 31 | /** 32 | * 是否展开,0不展开,1展开 33 | */ 34 | private Integer open; 35 | 36 | private String remark; 37 | 38 | private String address; 39 | 40 | /** 41 | * 是否可用,0不可用,1可用 42 | */ 43 | private Integer available; 44 | 45 | /** 46 | * 排序码 47 | */ 48 | private Integer ordernum; 49 | 50 | private Date createtime; 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/entity/Permission.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | import lombok.experimental.Accessors; 9 | 10 | import java.io.Serializable; 11 | 12 | 13 | @Data 14 | @EqualsAndHashCode(callSuper = false) 15 | @Accessors(chain = true) 16 | @TableName("sys_permission") 17 | public class Permission implements Serializable { 18 | 19 | private static final long serialVersionUID=1L; 20 | 21 | @TableId(value = "id", type = IdType.AUTO) 22 | private Integer id; 23 | 24 | private Integer pid; 25 | 26 | private String type; 27 | 28 | private String title; 29 | 30 | /** 31 | * 权限编码[只有type=permission才有 user:view] 32 | */ 33 | private String percode; 34 | 35 | private String icon; 36 | 37 | private String href; 38 | 39 | private String target; 40 | 41 | private Integer open; 42 | 43 | private Integer ordernum; 44 | 45 | /** 46 | * 是否可用[0不可用,1可用] 47 | */ 48 | private Integer available; 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/WarehouseApplication.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.web.servlet.MultipartConfigFactory; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.util.unit.DataSize; 10 | 11 | import javax.servlet.MultipartConfigElement; 12 | 13 | @Configuration 14 | @SpringBootApplication 15 | @MapperScan(basePackages = {"com.dev.warehouse.*.mapper"}) 16 | public class WarehouseApplication { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(WarehouseApplication.class, args); 20 | } 21 | 22 | @Bean 23 | public MultipartConfigElement multipartConfigElement() { 24 | MultipartConfigFactory factory = new MultipartConfigFactory(); 25 | /** 26 | * 单个数据大小 27 | */ 28 | factory.setMaxFileSize(DataSize.parse("102400KB")); 29 | /** 30 | * 总上传数据大小 31 | */ 32 | factory.setMaxRequestSize(DataSize.parse("102400KB")); 33 | return factory.createMultipartConfig(); 34 | } 35 | 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/service/impl/DeptServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.Wrapper; 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 5 | import com.dev.warehouse.sys.entity.Dept; 6 | import com.dev.warehouse.sys.mapper.DeptMapper; 7 | import com.dev.warehouse.sys.service.IDeptService; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import java.io.Serializable; 12 | 13 | 14 | @Service 15 | @Transactional 16 | public class DeptServiceImpl extends ServiceImpl implements IDeptService { 17 | 18 | @Override 19 | public Dept getById(Serializable id) { 20 | return super.getById(id); 21 | } 22 | 23 | @Override 24 | public boolean update(Dept entity, Wrapper updateWrapper){ 25 | return super.update(entity,updateWrapper); 26 | } 27 | 28 | @Override 29 | public boolean updateById(Dept entity){ 30 | return super.updateById(entity); 31 | } 32 | 33 | @Override 34 | public boolean removeById(Serializable id){ 35 | return super.removeById(id); 36 | } 37 | 38 | @Override 39 | public boolean save(Dept entity) { 40 | return super.save(entity); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/impl/CustomerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.dev.warehouse.bus.entity.Customer; 5 | import com.dev.warehouse.bus.mapper.CustomerMapper; 6 | import com.dev.warehouse.bus.service.ICustomerService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import java.io.Serializable; 11 | import java.util.Collection; 12 | 13 | 14 | @Service 15 | @Transactional 16 | public class CustomerServiceImpl extends ServiceImpl implements ICustomerService { 17 | 18 | @Override 19 | public boolean save(Customer entity) { 20 | return super.save(entity); 21 | } 22 | 23 | @Override 24 | public boolean updateById(Customer entity) { 25 | return super.updateById(entity); 26 | } 27 | 28 | @Override 29 | public boolean removeById(Serializable id) { 30 | return super.removeById(id); 31 | } 32 | 33 | @Override 34 | public Customer getById(Serializable id) { 35 | return super.getById(id); 36 | } 37 | 38 | @Override 39 | public boolean removeByIds(Collection idList) { 40 | return super.removeByIds(idList); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/impl/ProviderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | 5 | import com.dev.warehouse.bus.entity.Provider; 6 | import com.dev.warehouse.bus.mapper.ProviderMapper; 7 | import com.dev.warehouse.bus.service.IProviderService; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import java.io.Serializable; 12 | import java.util.Collection; 13 | 14 | 15 | @Service 16 | @Transactional 17 | public class ProviderServiceImpl extends ServiceImpl implements IProviderService { 18 | 19 | @Override 20 | public boolean save(Provider entity) { 21 | return super.save(entity); 22 | } 23 | 24 | @Override 25 | public boolean updateById(Provider entity) { 26 | return super.updateById(entity); 27 | } 28 | 29 | @Override 30 | public boolean removeById(Serializable id) { 31 | return super.removeById(id); 32 | } 33 | @Override 34 | public Provider getById(Serializable id) { 35 | return super.getById(id); 36 | } 37 | 38 | @Override 39 | public boolean removeByIds(Collection idList) { 40 | return super.removeByIds(idList); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/entity/Goods.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | import lombok.ToString; 10 | import lombok.experimental.Accessors; 11 | 12 | import java.io.Serializable; 13 | 14 | 15 | @Data 16 | @EqualsAndHashCode(callSuper = false) 17 | @Accessors(chain = true) 18 | @TableName("bus_goods") 19 | @ToString 20 | public class Goods implements Serializable { 21 | 22 | private static final long serialVersionUID=1L; 23 | 24 | @TableId(value = "id", type = IdType.AUTO) 25 | private Integer id; 26 | 27 | private String goodsname; 28 | 29 | private String produceplace; 30 | 31 | private String size; 32 | 33 | private String goodspackage; 34 | 35 | private String productcode; 36 | 37 | private String promitcode; 38 | 39 | private String description; 40 | 41 | private Double price; 42 | 43 | private Integer number; 44 | 45 | private Integer dangernum; 46 | 47 | private String goodsimg; 48 | 49 | private Integer available; 50 | 51 | private Integer providerid; 52 | 53 | @TableField(exist = false) 54 | private String providername; 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/controller/PhotoController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.core.io.Resource; 6 | import org.springframework.core.io.ResourceLoader; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.ResponseBody; 12 | 13 | @RequestMapping("/photo") 14 | @Controller 15 | public class PhotoController { 16 | @Autowired 17 | private ResourceLoader resourceLoader; 18 | 19 | @Value("${yuanlrc.photoFilePath}") 20 | private String uploadPhotoPath;//文件保存位置 21 | 22 | /** 23 | * 系统统一的图片查看方法 24 | * @param filename 25 | * @return 26 | */ 27 | @RequestMapping(value="/view") 28 | @ResponseBody 29 | public ResponseEntity viewPhoto(@RequestParam(name="filename",required=true)String filename){ 30 | Resource resource = resourceLoader.getResource("file:" + uploadPhotoPath + filename); 31 | try { 32 | return ResponseEntity.ok(resource); 33 | } catch (Exception e) { 34 | return ResponseEntity.notFound().build(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/entity/Sales.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | import lombok.experimental.Accessors; 10 | 11 | import java.io.Serializable; 12 | import java.util.Date; 13 | 14 | 15 | @Data 16 | @EqualsAndHashCode(callSuper = false) 17 | @Accessors(chain = true) 18 | @TableName("bus_sales") 19 | public class Sales implements Serializable { 20 | 21 | private static final long serialVersionUID=1L; 22 | 23 | @TableId(value = "id", type = IdType.AUTO) 24 | private Integer id; 25 | 26 | private Integer customerid; 27 | 28 | private String paytype; 29 | 30 | private Date salestime; 31 | 32 | private String operateperson; 33 | 34 | private Integer number; 35 | 36 | private String remark; 37 | 38 | private Double saleprice; 39 | 40 | private Integer goodsid; 41 | 42 | /** 43 | * 客户名称 44 | */ 45 | @TableField(exist = false) 46 | private String customername; 47 | 48 | /** 49 | * 商品名称 50 | */ 51 | @TableField(exist = false) 52 | private String goodsname; 53 | 54 | /** 55 | * 商品规格 56 | */ 57 | @TableField(exist = false) 58 | private String size; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/entity/Outport.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | import lombok.experimental.Accessors; 10 | 11 | import java.io.Serializable; 12 | import java.util.Date; 13 | 14 | @Data 15 | @EqualsAndHashCode(callSuper = false) 16 | @Accessors(chain = true) 17 | @TableName("bus_outport") 18 | public class Outport implements Serializable { 19 | 20 | private static final long serialVersionUID=1L; 21 | 22 | @TableId(value = "id", type = IdType.AUTO) 23 | private Integer id; 24 | 25 | private Integer providerid; 26 | 27 | private String paytype; 28 | 29 | private Date outputtime; 30 | 31 | private String operateperson; 32 | 33 | private Double outportprice; 34 | 35 | private Integer number; 36 | 37 | private String remark; 38 | 39 | private Integer goodsid; 40 | 41 | /** 42 | * 供应商姓名 43 | */ 44 | @TableField(exist = false) 45 | private String providername; 46 | 47 | /** 48 | * 商品名称 49 | */ 50 | @TableField(exist = false) 51 | private String goodsname; 52 | 53 | /** 54 | * 商品规格 55 | */ 56 | @TableField(exist = false) 57 | private String size; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/entity/Inport.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | import lombok.experimental.Accessors; 10 | 11 | import java.io.Serializable; 12 | import java.util.Date; 13 | 14 | 15 | @Data 16 | @EqualsAndHashCode(callSuper = false) 17 | @Accessors(chain = true) 18 | @TableName("bus_inport") 19 | public class Inport implements Serializable { 20 | 21 | private static final long serialVersionUID=1L; 22 | 23 | @TableId(value = "id", type = IdType.AUTO) 24 | private Integer id; 25 | 26 | private String paytype; 27 | 28 | private Date inporttime; 29 | 30 | private String operateperson; 31 | 32 | private Integer number; 33 | 34 | private String remark; 35 | 36 | private Double inportprice; 37 | 38 | private Integer providerid; 39 | 40 | private Integer goodsid; 41 | 42 | /** 43 | * 供应商姓名 44 | */ 45 | @TableField(exist = false) 46 | private String providername; 47 | 48 | /** 49 | * 商品名称 50 | */ 51 | @TableField(exist = false) 52 | private String goodsname; 53 | 54 | /** 55 | * 商品规格 56 | */ 57 | @TableField(exist = false) 58 | private String size; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/resources/mapper/sys/RoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | delete from sys_role_permission where rid = #{pid} 7 | 8 | 9 | 10 | delete from sys_user_role where rid = #{pid} 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | insert into sys_role_permission(rid,pid) values (#{rid},#{pid}) 21 | 22 | 23 | 24 | 25 | delete from sys_user_role where uid = #{id} 26 | 27 | 28 | 29 | 32 | 33 | 34 | 35 | insert into sys_user_role(uid,rid) values (#{uid},#{rid}) 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/entity/Salesback.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | import lombok.experimental.Accessors; 10 | 11 | import java.io.Serializable; 12 | import java.util.Date; 13 | 14 | 15 | @Data 16 | @EqualsAndHashCode(callSuper = false) 17 | @Accessors(chain = true) 18 | @TableName("bus_salesback") 19 | public class Salesback implements Serializable { 20 | 21 | private static final long serialVersionUID=1L; 22 | 23 | @TableId(value = "id", type = IdType.AUTO) 24 | private Integer id; 25 | 26 | private Integer customerid; 27 | 28 | private String paytype; 29 | 30 | private Date salesbacktime; 31 | 32 | private Double salebackprice; 33 | 34 | private String operateperson; 35 | 36 | private Integer number; 37 | 38 | private String remark; 39 | 40 | private Integer goodsid; 41 | 42 | /** 43 | * 客户姓名 44 | */ 45 | @TableField(exist = false) 46 | private String customername; 47 | 48 | /** 49 | * 商品名称 50 | */ 51 | @TableField(exist = false) 52 | private String goodsname; 53 | 54 | /** 55 | * 商品规格 56 | */ 57 | @TableField(exist = false) 58 | private String size; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/common/WebUtils.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.common; 2 | 3 | import org.springframework.web.context.request.RequestContextHolder; 4 | import org.springframework.web.context.request.ServletRequestAttributes; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpSession; 8 | 9 | public class WebUtils { 10 | 11 | /** 12 | * 得到request 13 | * @return 14 | */ 15 | public static HttpServletRequest getRequest(){ 16 | ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); 17 | HttpServletRequest request = requestAttributes.getRequest(); 18 | return request; 19 | } 20 | 21 | /** 22 | * 得到session 23 | * @return 24 | */ 25 | public static HttpSession getSession(){ 26 | return getRequest().getSession(); 27 | } 28 | 29 | public static ServletRequestAttributes getServletRequestAttributes() { 30 | return (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); 31 | } 32 | 33 | /** 34 | * 得到当前线程的请求对象 35 | * @return 36 | */ 37 | public static HttpServletRequest getHttpServletRequest() { 38 | return getServletRequestAttributes().getRequest(); 39 | } 40 | 41 | /** 42 | * 得到session对象 43 | */ 44 | public static HttpSession getHttpSession() { 45 | return getHttpServletRequest().getSession(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | #配置数据源 2 | spring: 3 | datasource: 4 | druid: 5 | driver-class-name: com.mysql.jdbc.Driver 6 | url: jdbc:mysql://127.0.0.1:3306/warehouse?useUnicode=true&characterEncoding=utf8 7 | username: root 8 | password: root 9 | max-active: 20 10 | max-wait: 5000 11 | initial-size: 1 12 | filters: stat,log4j,wall 13 | validation-query: SELECT 'X' #验证连接 14 | enable: true 15 | #监控配置 16 | stat-view-servlet: 17 | enabled: true 18 | login-username: root 19 | login-password: 123456 20 | url-pattern: /druid/* 21 | 22 | servlet: 23 | multipart: 24 | max-file-size: 1MB 25 | max-request-size: 10MB 26 | 27 | #thymeleaf的配置 28 | thymeleaf: 29 | cache: false 30 | enabled: true 31 | 32 | jackson: 33 | date-format: yyyy-MM-dd HH:mm:ss 34 | time-zone: GMT+8 35 | 36 | #配置mybatisplus 37 | mybatis-plus: 38 | mapper-locations: classpath*:mapper/**/*Mapper.xml 39 | global-config: 40 | db-config: 41 | id-type: auto 42 | configuration: 43 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 44 | 45 | #shiro的配置 46 | shiro: 47 | hash-algorithm-name: md5 48 | hash-iterations: 2 49 | anon-urls: 50 | - /index.html* 51 | - /sys/toLogin* 52 | - /login/login* 53 | - /login/getCode 54 | - /resources/** 55 | login-url: /index.html 56 | log-out-url: /login/logout* 57 | authc-ulrs: 58 | - /** 59 | 60 | #修改端口号为8088 61 | server: 62 | port: 8089 63 | 64 | #图片上传路径 65 | yuanlrc: 66 | photoFilePath: E:/upload/ 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/mapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.dev.warehouse.sys.entity.Role; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.io.Serializable; 9 | import java.util.List; 10 | 11 | 12 | @Mapper 13 | public interface RoleMapper extends BaseMapper { 14 | 15 | /** 16 | * 根据角色ID删除sys_role_permission表中的数据 17 | * @param id 角色的id 18 | */ 19 | void deleteRolePermissionByRid(@Param("pid") Serializable id); 20 | 21 | /** 22 | * 根据角色ID删除sys_user_role表中的数据 23 | * @param id 角色的id 24 | */ 25 | void deleteUserRoleByRid(@Param("pid") Serializable id); 26 | 27 | /** 28 | * 根据角色ID查询当前角色拥有的菜单ID和权限ID 29 | * @param roleId 30 | * @return 31 | */ 32 | List queryRolePermissionIdsByRid(@Param("roleId") Integer roleId); 33 | 34 | /** 35 | * 保存角色和菜单权限之间的关系 36 | * @param rid 37 | * @param pid 38 | */ 39 | void saveRolePermission(@Param("rid") Integer rid, @Param("pid") Integer pid); 40 | 41 | /** 42 | * 根据用户id删除用户角色中间表的数据 43 | * @param id 44 | */ 45 | void deleteRoleUserByUid(@Param("id") Serializable id); 46 | 47 | /** 48 | * 查询当前用户拥有的角色ID集合 49 | * @param id 50 | * @return 51 | */ 52 | List queryUserRoleIdsByUid(@Param("id") Integer id); 53 | 54 | /** 55 | * 保存用户和角色的关系 56 | * @param uid 用户的ID 57 | * @param rid 用户拥有的角色的ID的数组 58 | */ 59 | void insertUserRole(@Param("uid") Integer uid, @Param("rid") Integer rid); 60 | } 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 基于Springboot的进销存后台系统 2 | = 3 | ### 完整代码获取地址:从戎源码网 ([https://armycodes.com/](https://armycodes.com/)) 4 | ### 作者微信:19941326836 QQ:952045282 5 | ### 承接计算机毕业设计、Java毕业设计、Python毕业设计、深度学习、机器学习 6 | ### 选题+开题报告+任务书+程序定制+安装调试+论文+答辩ppt 一条龙服务 7 | ### 所有选题地址https://github.com/nature924/allProject 8 | 9 | 一、项目介绍 10 | --- 11 | 基于Springboot框架实现的进销存后台系统包含一种角色:管理员、主要功能如下。 12 | 13 | ### 1. 后台首页:管理员可以查看系统的概览信息和统计数据。 14 | ### 2. 基础管理: 15 | - 客户管理:管理员可以管理客户信息,包括添加、编辑和删除客户。 16 | - 供应商管理:管理员可以管理供应商信息,包括添加、编辑和删除供应商。 17 | - 商品管理:管理员可以管理商品信息,包括添加、编辑和删除商品。 18 | ### 3. 进货管理: 19 | - 商品进货:管理员可以录入商品进货信息,包括选择供应商、商品数量和价格等。 20 | - 商品退货查询:管理员可以查询和处理商品退货信息。 21 | ### 4. 销售管理: 22 | - 商品销售:管理员可以录入商品销售信息,包括选择客户、商品数量和价格等。 23 | - 销售退货查询:管理员可以查询和处理销售退货信息。 24 | ### 5. 系统管理: 25 | - 部门管理:管理员可以管理系统的部门信息,包括添加、编辑和删除部门。 26 | - 菜单管理:管理员可以管理系统的菜单信息,包括添加、编辑和删除菜单。 27 | - 权限管理:管理员可以管理系统的权限信息,包括给用户分配权限和设置权限级别。 28 | - 角色管理:管理员可以管理系统的角色信息,包括添加、编辑和删除角色。 29 | - 用户管理:管理员可以管理系统的用户信息,包括添加、编辑和删除用户。 30 | ### 6. 其它管理: 31 | - 登陆日志:管理员可以查看用户的登录日志,包括登录时间和IP地址等信息。 32 | - 系统公告:管理员可以发布系统公告,包括公告标题和内容。 33 | - 图标管理:管理员可以上传和管理系统的图标文件。 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 二、项目技术 42 | --- 43 | - 编程语言:Java 44 | - 数据库:MySQL 45 | - 项目管理工具:Maven 46 | - 前端技术:VUE、HTML、Jquery、Bootstrap 47 | - 后端技术:Spring、SpringMVC、MyBatis 48 | 49 | 三、运行环境 50 | --- 51 | - 操作系统:Windows、macOS都可以 52 | - JDK版本:JDK1.8以上都可以 53 | - 开发工具:IDEA、Ecplise、Myecplise都可以 54 | - 数据库: MySQL5.7以上都可以 55 | - Tomcat:任意版本都可以 56 | - Maven:任意版本都可以 57 | 58 | 四、运行截图 59 | --- 60 | 61 | ### 程序截图: 62 | ![image/1.png](image/1.jpg) 63 | ![image/1.png](image/2.jpg) 64 | ![image/1.png](image/3.jpg) 65 | ![image/1.png](image/4.jpg) 66 | ![image/1.png](image/5.jpg) 67 | ![image/1.png](image/6.jpg) 68 | ![image/1.png](image/7.jpg) 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/common/ResultObj.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.common; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class ResultObj { 11 | 12 | public static final ResultObj LOGIN_SUCCESS=new ResultObj(Constast.OK,"登陆成功"); 13 | public static final ResultObj LOGIN_ERROR_PASS=new ResultObj(Constast.ERROR,"用户名或密码错误"); 14 | public static final ResultObj LOGIN_ERROR_CODE=new ResultObj(Constast.ERROR,"验证码错误"); 15 | 16 | public static final ResultObj ADD_SUCCESS = new ResultObj(Constast.OK,"添加成功"); 17 | public static final ResultObj ADD_ERROR = new ResultObj(Constast.ERROR,"添加失败"); 18 | 19 | public static final ResultObj DELETE_SUCCESS = new ResultObj(Constast.OK,"删除成功"); 20 | public static final ResultObj DELETE_ERROR = new ResultObj(Constast.ERROR,"删除失败"); 21 | 22 | public static final ResultObj UPDATE_SUCCESS = new ResultObj(Constast.OK,"修改成功"); 23 | public static final ResultObj UPDATE_ERROR = new ResultObj(Constast.ERROR,"修改失败"); 24 | 25 | public static final ResultObj RESET_SUCCESS = new ResultObj(Constast.OK,"重置成功"); 26 | public static final ResultObj RESET_ERROR = new ResultObj(Constast.ERROR,"重置失败"); 27 | 28 | public static final ResultObj DISPATCH_SUCCESS = new ResultObj(Constast.OK,"分配成功"); 29 | public static final ResultObj DISPATCH_ERROR = new ResultObj(Constast.ERROR,"分配失败"); 30 | 31 | public static final ResultObj BACKINPORT_SUCCESS = new ResultObj(Constast.OK,"退货成功"); 32 | public static final ResultObj BACKINPORT_ERROR = new ResultObj(Constast.ERROR,"退货失败"); 33 | public static final ResultObj SYNCCACHE_SUCCESS = new ResultObj(Constast.OK,"同步缓存成功"); 34 | 35 | private Integer code; 36 | private String msg; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/controller/BusinessController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | 7 | @Controller 8 | @RequestMapping("bus") 9 | public class BusinessController { 10 | 11 | /** 12 | * 跳转到客户管理页面 13 | * @return 14 | */ 15 | @RequestMapping("toCustomerManager") 16 | public String toCustomerManager(){ 17 | return "business/customer/customerManager"; 18 | } 19 | 20 | /** 21 | * 跳转到供应商管理页面 22 | * @return 23 | */ 24 | @RequestMapping("toProviderManager") 25 | public String toProviderManager(){ 26 | return "business/provider/providerManager"; 27 | } 28 | 29 | /** 30 | * 跳转到商品管理页面 31 | * @return 32 | */ 33 | @RequestMapping("toGoodsManager") 34 | public String toGoodsManager(){ 35 | return "business/goods/goodsManager"; 36 | } 37 | 38 | /** 39 | * 跳转到进货管理页面 40 | * @return 41 | */ 42 | @RequestMapping("toInportManager") 43 | public String toInportManager(){ 44 | return "business/inport/inportManager"; 45 | } 46 | 47 | /** 48 | * 跳转到退货管理页面 49 | * @return 50 | */ 51 | @RequestMapping("toOutportManager") 52 | public String toOutportManager(){ 53 | return "business/outport/outportManager"; 54 | } 55 | 56 | /** 57 | * 跳转到商品销售管理页面 58 | * @return 59 | */ 60 | @RequestMapping("toSalesManager") 61 | public String toSalesManager(){ 62 | return "business/sales/salesManager"; 63 | } 64 | 65 | /** 66 | * 跳转到商品销售管理页面 67 | * @return 68 | */ 69 | @RequestMapping("toSalesbackManager") 70 | public String toSalesbackManager(){ 71 | return "business/salesback/salesbackManager"; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.dev.warehouse.sys.entity.User; 5 | import com.dev.warehouse.sys.mapper.RoleMapper; 6 | import com.dev.warehouse.sys.mapper.UserMapper; 7 | import com.dev.warehouse.sys.service.IUserService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import java.io.Serializable; 13 | 14 | @Service 15 | @Transactional 16 | public class UserServiceImpl extends ServiceImpl implements IUserService { 17 | 18 | @Autowired 19 | private RoleMapper roleMapper; 20 | 21 | @Override 22 | public boolean save(User entity) { 23 | return super.save(entity); 24 | } 25 | 26 | @Override 27 | public boolean updateById(User entity) { 28 | return super.updateById(entity); 29 | } 30 | 31 | @Override 32 | public User getById(Serializable id) { 33 | return super.getById(id); 34 | } 35 | 36 | @Override 37 | public boolean removeById(Serializable id) { 38 | //根据用户id删除用户角色中间表的数据 39 | roleMapper.deleteRoleUserByUid(id); 40 | //删除用户头像[如果是默认头像不删除,否则删除] 41 | 42 | return super.removeById(id); 43 | } 44 | 45 | /** 46 | * 保存用户和角色的关系 47 | * @param uid 用户的ID 48 | * @param ids 用户拥有的角色的ID的数组 49 | */ 50 | @Override 51 | public void saveUserRole(Integer uid, Integer[] ids) { 52 | //1.根据用户ID删除sys_user_role里面的数据 53 | roleMapper.deleteRoleUserByUid(uid); 54 | if (null!=ids&&ids.length>0){ 55 | for (Integer rid : ids) { 56 | roleMapper.insertUserRole(uid,rid); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/common/PinyinUtils.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.common; 2 | 3 | import net.sourceforge.pinyin4j.PinyinHelper; 4 | import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; 5 | import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; 6 | import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; 7 | import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; 8 | import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; 9 | 10 | public class PinyinUtils { 11 | 12 | /** 13 | * 返回一个拼音字符串,并且首字母大写 14 | */ 15 | public static String getPingYin(String inputString) { 16 | HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat(); 17 | format.setCaseType(HanyuPinyinCaseType.LOWERCASE); 18 | format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); 19 | format.setVCharType(HanyuPinyinVCharType.WITH_V); 20 | String output = ""; 21 | if (inputString != null && inputString.length() > 0 && !"null".equals(inputString)) { 22 | char[] input = inputString.trim().toCharArray(); 23 | try { 24 | for (int i = 0; i < input.length; i++) { 25 | if (Character.toString(input[i]).matches("[\\u4E00-\\u9FA5]+")) { 26 | String[] temp = PinyinHelper.toHanyuPinyinStringArray(input[i], format); 27 | output += temp[0]; 28 | } else { 29 | output += Character.toString(input[i]); 30 | } 31 | } 32 | } catch (BadHanyuPinyinOutputFormatCombination e) { 33 | e.printStackTrace(); 34 | } 35 | } else { 36 | return "*"; 37 | } 38 | return output; 39 | } 40 | 41 | /* public static void main(String[] args) { 42 | String s = getPingYin("落亦"); 43 | System.out.println(s); 44 | }*/ 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | import lombok.ToString; 10 | import lombok.experimental.Accessors; 11 | import org.springframework.format.annotation.DateTimeFormat; 12 | 13 | import java.io.Serializable; 14 | import java.util.Date; 15 | 16 | @Data 17 | @EqualsAndHashCode(callSuper = false) 18 | @Accessors(chain = true) 19 | @TableName("sys_user") 20 | @ToString 21 | public class User implements Serializable { 22 | 23 | private static final long serialVersionUID=1L; 24 | 25 | @TableId(value = "id", type = IdType.AUTO) 26 | private Integer id; 27 | 28 | private String name; 29 | 30 | private String loginname; 31 | 32 | private String pwd; 33 | 34 | private String address; 35 | 36 | private Integer sex; 37 | 38 | private String remark; 39 | 40 | private Integer deptid; 41 | 42 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 43 | private Date hiredate; 44 | 45 | /** 46 | * 上级领导id 47 | */ 48 | private Integer mgr; 49 | 50 | /** 51 | * 是否可用,0不可用,1可用 52 | */ 53 | private Integer available; 54 | 55 | /** 56 | * 排序码 57 | */ 58 | private Integer ordernum; 59 | 60 | /** 61 | * 用户类型[0超级管理员,1管理员,2普通用户] 62 | */ 63 | private Integer type; 64 | 65 | /** 66 | * 用户头像地址 67 | */ 68 | private String imgpath; 69 | 70 | /** 71 | * 盐 72 | */ 73 | private String salt; 74 | 75 | /** 76 | * 领导名称 77 | */ 78 | @TableField(exist = false) 79 | private String leadername; 80 | 81 | /** 82 | * 部门名称 83 | */ 84 | @TableField(exist = false) 85 | private String deptname; 86 | 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/controller/CacheController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.controller; 2 | 3 | 4 | import com.dev.warehouse.sys.cache.CachePool; 5 | import com.dev.warehouse.sys.common.CacheBean; 6 | import com.dev.warehouse.sys.common.DataGridView; 7 | import com.dev.warehouse.sys.common.ResultObj; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import java.util.Map; 14 | import java.util.Set; 15 | 16 | @RestController 17 | @RequestMapping("cache") 18 | public class CacheController { 19 | 20 | private static volatile Map CACHE_CONTAINER= CachePool.CACHE_CONTAINER; 21 | 22 | /** 23 | * 查询所有缓存 24 | * @return 25 | */ 26 | @RequestMapping("loadAllCache") 27 | public DataGridView loadAllCache(){ 28 | List list = new ArrayList<>(); 29 | 30 | Set> entrySet = CACHE_CONTAINER.entrySet(); 31 | for (Map.Entry entry : entrySet) { 32 | list.add(new CacheBean(entry.getKey(),entry.getValue())); 33 | } 34 | return new DataGridView(list); 35 | } 36 | 37 | /** 38 | * 删除缓存 39 | * @param key 40 | * @return 41 | */ 42 | @RequestMapping("deleteCache") 43 | public ResultObj deleteCache(String key){ 44 | CachePool.removeCacheByKey(key); 45 | return ResultObj.DELETE_SUCCESS; 46 | } 47 | 48 | /** 49 | * 清空所有缓存 50 | * @return 51 | */ 52 | @RequestMapping("removeAllCache") 53 | public ResultObj removeAllCache(){ 54 | CachePool.removeAll(); 55 | return ResultObj.DELETE_SUCCESS; 56 | } 57 | 58 | /** 59 | * 同步缓存 60 | * @return 61 | */ 62 | @RequestMapping("syncCache") 63 | public ResultObj syncCache(){ 64 | CachePool.syncData(); 65 | return ResultObj.SYNCCACHE_SUCCESS; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/controller/FileController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.controller; 2 | 3 | import cn.hutool.core.date.DateUtil; 4 | import com.dev.warehouse.sys.common.AppFileUtils; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | import org.springframework.web.multipart.MultipartFile; 9 | 10 | import java.io.File; 11 | import java.io.IOException; 12 | import java.util.Date; 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | 16 | @RestController 17 | @RequestMapping("file") 18 | public class FileController { 19 | 20 | /** 21 | * 文件上传 22 | * @param mf 23 | * @return 24 | */ 25 | @RequestMapping("uploadFile") 26 | public Map uploadFile(MultipartFile mf) { 27 | //1.得到文件名 28 | String oldName = mf.getOriginalFilename(); 29 | //2.根据旧的文件名生成新的文件名 30 | String newName= AppFileUtils.createNewFileName(oldName); 31 | //3.得到当前日期的字符串 32 | String dirName= DateUtil.format(new Date(), "yyyy-MM-dd"); 33 | //4.构造文件夹 34 | File dirFile=new File(AppFileUtils.UPLOAD_PATH,dirName); 35 | //5.判断当前文件夹是否存在 36 | if(!dirFile.exists()) { 37 | //如果不存在则创建新文件夹 38 | dirFile.mkdirs(); 39 | } 40 | //6.构造文件对象 41 | File file=new File(dirFile, newName+"_temp"); 42 | //7.把mf里面的图片信息写入file 43 | try { 44 | mf.transferTo(file); 45 | } catch (IllegalStateException | IOException e) { 46 | e.printStackTrace(); 47 | } 48 | Map map=new HashMap(); 49 | map.put("path",dirName+"/"+newName+"_temp"); 50 | return map; 51 | } 52 | 53 | /** 54 | * 图片下载 55 | */ 56 | @RequestMapping("showImageByPath") 57 | public ResponseEntity showImageByPath(String path){ 58 | return AppFileUtils.createResponseEntity(path); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.dev.warehouse.sys.entity.Role; 5 | import com.dev.warehouse.sys.mapper.RoleMapper; 6 | import com.dev.warehouse.sys.service.IRoleService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import java.io.Serializable; 11 | import java.util.List; 12 | 13 | 14 | @Service 15 | @Transactional 16 | public class RoleServiceImpl extends ServiceImpl implements IRoleService { 17 | 18 | @Override 19 | public boolean removeById(Serializable id) { 20 | //根据角色ID删除sys_role_permission表中的数据 21 | this.getBaseMapper().deleteRolePermissionByRid(id); 22 | //根据角色ID删除sys_user_role表中的数据 23 | this.getBaseMapper().deleteUserRoleByRid(id); 24 | return super.removeById(id); 25 | } 26 | 27 | /** 28 | * 根据角色ID查询当前角色拥有的菜单ID和权限ID 29 | * @param roleId 30 | * @return 31 | */ 32 | @Override 33 | public List queryRolePermissionIdsByRid(Integer roleId) { 34 | return this.getBaseMapper().queryRolePermissionIdsByRid(roleId); 35 | } 36 | 37 | /** 38 | * 保存角色和菜单权限之间的关系 39 | * @param rid 40 | * @param ids 41 | */ 42 | @Override 43 | public void saveRolePermission(Integer rid, Integer[] ids) { 44 | RoleMapper roleMapper = this.getBaseMapper(); 45 | //根据rid删除sys_role_permission 46 | roleMapper.deleteRolePermissionByRid(rid); 47 | if (ids!=null&&ids.length>0){ 48 | for (Integer pid : ids){ 49 | roleMapper.saveRolePermission(rid,pid); 50 | } 51 | } 52 | } 53 | 54 | /** 55 | * 查询当前用户拥有的角色ID集合 56 | * @param id 57 | * @return 58 | */ 59 | @Override 60 | public List queryUserRoleIdsByUid(Integer id) { 61 | return getBaseMapper().queryUserRoleIdsByUid(id); 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/common/TreeNode.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.common; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class TreeNode { 16 | 17 | private Integer id; 18 | @JsonProperty("parentId") 19 | private Integer pid; 20 | private String title; 21 | private String icon; 22 | private String href; 23 | private Boolean spread; 24 | private List children = new ArrayList(); 25 | 26 | /** 27 | * 0为不选中 1为选中 28 | */ 29 | private String checkArr="0"; 30 | 31 | /** 32 | * 首页左边导航菜单的构造器 33 | * @param id 34 | * @param pid 35 | * @param title 36 | * @param icon 37 | * @param href 38 | * @param spread 39 | */ 40 | public TreeNode(Integer id, Integer pid, String title, String icon, String href, Boolean spread) { 41 | this.id = id; 42 | this.pid = pid; 43 | this.title = title; 44 | this.icon = icon; 45 | this.href = href; 46 | this.spread = spread; 47 | } 48 | 49 | /** 50 | * 部门 dtree的构造器 51 | * @param id 52 | * @param pid 53 | * @param title 54 | * @param spread 55 | */ 56 | public TreeNode(Integer id, Integer pid, String title, Boolean spread) { 57 | this.id = id; 58 | this.pid = pid; 59 | this.title = title; 60 | this.spread = spread; 61 | } 62 | 63 | /** 64 | * 给角色分配权限的构造器 65 | * @param id 66 | * @param pid 67 | * @param title 68 | * @param spread 69 | * @param checkArr 70 | */ 71 | public TreeNode(Integer id, Integer pid, String title, Boolean spread, String checkArr) { 72 | this.id = id; 73 | this.pid = pid; 74 | this.title = title; 75 | this.spread = spread; 76 | this.checkArr = checkArr; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/impl/SalesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | 5 | import com.dev.warehouse.bus.entity.Goods; 6 | import com.dev.warehouse.bus.entity.Sales; 7 | import com.dev.warehouse.bus.mapper.GoodsMapper; 8 | import com.dev.warehouse.bus.mapper.SalesMapper; 9 | import com.dev.warehouse.bus.service.ISalesService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.io.Serializable; 14 | 15 | 16 | @Service 17 | public class SalesServiceImpl extends ServiceImpl implements ISalesService { 18 | 19 | @Autowired 20 | private GoodsMapper goodsMapper; 21 | 22 | /** 23 | * 添加商品销售 24 | * @param entity 商品销售实体类 25 | * @return 26 | */ 27 | @Override 28 | public boolean save(Sales entity) { 29 | Goods goods = goodsMapper.selectById(entity.getGoodsid()); 30 | goods.setNumber(goods.getNumber()-entity.getNumber()); 31 | //更新商品的库存信息 32 | goodsMapper.updateById(goods); 33 | return super.save(entity); 34 | } 35 | 36 | /** 37 | * 更新商品销售 38 | * @param entity 商品销售实体类 39 | * @return 40 | */ 41 | @Override 42 | public boolean updateById(Sales entity) { 43 | //根据销售单ID查询销售单信息 44 | Sales sales = baseMapper.selectById(entity.getId()); 45 | Goods goods = goodsMapper.selectById(entity.getGoodsid()); 46 | //仓库商品数量=原库存-销售单修改之前的数量+修改之后的数量 47 | // 80 +40 - 50 30 48 | goods.setNumber(goods.getNumber()+sales.getNumber()-entity.getNumber()); 49 | //更新商品 50 | goodsMapper.updateById(goods); 51 | return super.updateById(entity); 52 | } 53 | 54 | /** 55 | * 删除商品销售信息 56 | * @param id 商品销售单ID 57 | * @return 58 | */ 59 | @Override 60 | public boolean removeById(Serializable id) { 61 | //根据商品销售单ID查询出销售单数据 62 | Sales sales = baseMapper.selectById(id); 63 | Goods goods = goodsMapper.selectById(sales.getGoodsid()); 64 | //仓库商品数量=原库存+删除商品销售单的数量 65 | goods.setNumber(goods.getNumber()+sales.getNumber()); 66 | goodsMapper.updateById(goods); 67 | return super.removeById(id); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/impl/OutportServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | 5 | import com.dev.warehouse.bus.entity.Goods; 6 | import com.dev.warehouse.bus.entity.Inport; 7 | import com.dev.warehouse.bus.entity.Outport; 8 | import com.dev.warehouse.bus.mapper.GoodsMapper; 9 | import com.dev.warehouse.bus.mapper.InportMapper; 10 | import com.dev.warehouse.bus.mapper.OutportMapper; 11 | import com.dev.warehouse.bus.service.IOutportService; 12 | import com.dev.warehouse.sys.common.WebUtils; 13 | import com.dev.warehouse.sys.entity.User; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Service; 16 | 17 | import java.util.Date; 18 | 19 | 20 | @Service 21 | public class OutportServiceImpl extends ServiceImpl implements IOutportService { 22 | 23 | @Autowired 24 | private InportMapper inportMapper; 25 | 26 | @Autowired 27 | private GoodsMapper goodsMapper; 28 | 29 | /** 30 | * @param id 进货单ID 31 | * @param number 退货数量 32 | * @param remark 备注 33 | */ 34 | @Override 35 | public void addOutport(Integer id, Integer number, String remark) { 36 | //1.通过进货单ID查询出进货单信息 37 | Inport inport = inportMapper.selectById(id); 38 | //2.根据商品ID查询商品信息 39 | Goods goods = goodsMapper.selectById(inport.getGoodsid()); 40 | //3.修改商品的数量 商品的数量-退货的数量 41 | goods.setNumber(goods.getNumber()-number); 42 | 43 | //修改进货的数量 44 | inport.setNumber(inport.getNumber()-number); 45 | inportMapper.updateById(inport); 46 | 47 | //4.进行修改 48 | goodsMapper.updateById(goods); 49 | 50 | //5.添加退货单信息 51 | Outport outport = new Outport(); 52 | outport.setGoodsid(inport.getGoodsid()); 53 | outport.setNumber(number); 54 | User user = (User) WebUtils.getSession().getAttribute("user"); 55 | outport.setOperateperson(user.getName()); 56 | 57 | outport.setOutportprice(inport.getInportprice()); 58 | 59 | outport.setPaytype(inport.getPaytype()); 60 | outport.setOutputtime(new Date()); 61 | outport.setRemark(remark); 62 | outport.setProviderid(inport.getProviderid()); 63 | getBaseMapper().insert(outport); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/impl/SalesbackServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | 5 | import com.dev.warehouse.bus.entity.Goods; 6 | import com.dev.warehouse.bus.entity.Sales; 7 | import com.dev.warehouse.bus.entity.Salesback; 8 | import com.dev.warehouse.bus.mapper.GoodsMapper; 9 | import com.dev.warehouse.bus.mapper.SalesMapper; 10 | import com.dev.warehouse.bus.mapper.SalesbackMapper; 11 | import com.dev.warehouse.bus.service.ISalesbackService; 12 | import com.dev.warehouse.sys.common.WebUtils; 13 | import com.dev.warehouse.sys.entity.User; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Service; 16 | 17 | import java.util.Date; 18 | 19 | 20 | @Service 21 | public class SalesbackServiceImpl extends ServiceImpl implements ISalesbackService { 22 | 23 | @Autowired 24 | private SalesMapper salesMapper; 25 | 26 | @Autowired 27 | private GoodsMapper goodsMapper; 28 | 29 | /** 30 | * @param id 销售单ID 31 | * @param number 退货数量 32 | * @param remark 备注 33 | */ 34 | @Override 35 | public void addSalesback(Integer id, Integer number, String remark) { 36 | //1.通过销售单ID查询出销售单信息 37 | Sales sales = salesMapper.selectById(id); 38 | //2.根据商品ID查询商品信息 39 | Goods goods = goodsMapper.selectById(sales.getGoodsid()); 40 | //3.修改商品的数量 商品的数量-退货的数量 41 | goods.setNumber(goods.getNumber()+number); 42 | 43 | //修改进货的数量 44 | sales.setNumber(sales.getNumber()-number); 45 | salesMapper.updateById(sales); 46 | 47 | //4.进行修改 48 | goodsMapper.updateById(goods); 49 | 50 | //5.添加退货单信息 51 | Salesback salesback = new Salesback(); 52 | salesback.setGoodsid(sales.getGoodsid()); 53 | 54 | salesback.setNumber(number); 55 | User user = (User) WebUtils.getSession().getAttribute("user"); 56 | salesback.setOperateperson(user.getName()); 57 | 58 | 59 | salesback.setSalebackprice(sales.getSaleprice()); 60 | salesback.setPaytype(sales.getPaytype()); 61 | 62 | salesback.setSalesbacktime(new Date()); 63 | salesback.setRemark(remark); 64 | 65 | 66 | salesback.setCustomerid(sales.getCustomerid()); 67 | 68 | 69 | getBaseMapper().insert(salesback); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/service/impl/InportServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | 5 | import com.dev.warehouse.bus.entity.Goods; 6 | import com.dev.warehouse.bus.entity.Inport; 7 | import com.dev.warehouse.bus.mapper.GoodsMapper; 8 | import com.dev.warehouse.bus.mapper.InportMapper; 9 | import com.dev.warehouse.bus.service.IInportService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | import org.springframework.transaction.annotation.Transactional; 13 | 14 | import java.io.Serializable; 15 | 16 | @Service 17 | @Transactional 18 | public class InportServiceImpl extends ServiceImpl implements IInportService { 19 | 20 | @Autowired 21 | private GoodsMapper goodsMapper; 22 | 23 | /** 24 | * 保存商品进货 25 | * @param entity 26 | * @return 27 | */ 28 | @Override 29 | public boolean save(Inport entity) { 30 | //根据商品ID查询商品 31 | Goods goods = goodsMapper.selectById(entity.getGoodsid()); 32 | goods.setNumber(goods.getNumber()+entity.getNumber()); 33 | goodsMapper.updateById(goods); 34 | //保存进货信息 35 | return super.save(entity); 36 | } 37 | 38 | /** 39 | * 更新商品进货 40 | * @param entity 41 | * @return 42 | */ 43 | @Override 44 | public boolean updateById(Inport entity) { 45 | //根据进货ID查询进货信息 46 | Inport inport = baseMapper.selectById(entity.getId()); 47 | //根据商品ID查询商品信息 48 | Goods goods = goodsMapper.selectById(entity.getGoodsid()); 49 | //库存算法 当前库存-进货单修改之前的数量+修改之后的数量 50 | goods.setNumber(goods.getNumber()-inport.getNumber()+entity.getNumber()); 51 | goodsMapper.updateById(goods); 52 | //更新进货单 53 | return super.updateById(entity); 54 | } 55 | 56 | /** 57 | * 删除商品进货信息 58 | * @param id 59 | * @return 60 | */ 61 | @Override 62 | public boolean removeById(Serializable id) { 63 | //根据进货ID查询进货信息 64 | Inport inport = baseMapper.selectById(id); 65 | //根据商品ID查询商品信息 66 | Goods goods = goodsMapper.selectById(inport.getGoodsid()); 67 | //库存算法 当前库存-进货单数量 68 | goods.setNumber(goods.getNumber()-inport.getNumber()); 69 | goodsMapper.updateById(goods); 70 | //更新商品的数量 71 | return super.removeById(id); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/cache/CachePool.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.cache; 2 | 3 | 4 | 5 | import com.dev.warehouse.bus.entity.Customer; 6 | import com.dev.warehouse.bus.entity.Goods; 7 | import com.dev.warehouse.bus.entity.Provider; 8 | import com.dev.warehouse.bus.mapper.CustomerMapper; 9 | import com.dev.warehouse.bus.mapper.GoodsMapper; 10 | import com.dev.warehouse.bus.mapper.ProviderMapper; 11 | import com.dev.warehouse.sys.common.SpringUtil; 12 | import com.dev.warehouse.sys.entity.Dept; 13 | import com.dev.warehouse.sys.entity.User; 14 | import com.dev.warehouse.sys.mapper.DeptMapper; 15 | import com.dev.warehouse.sys.mapper.UserMapper; 16 | 17 | import java.util.HashMap; 18 | import java.util.List; 19 | import java.util.Map; 20 | 21 | public class CachePool { 22 | 23 | /** 24 | * 所有的缓存数据放到这个CACHE_CONTAINER类似于redis 25 | */ 26 | public static volatile Map CACHE_CONTAINER = new HashMap<>(); 27 | 28 | /** 29 | * 根据KEY删除缓存 30 | * @param key 31 | */ 32 | public static void removeCacheByKey(String key){ 33 | if (CACHE_CONTAINER.containsKey(key)){ 34 | CACHE_CONTAINER.remove(key); 35 | } 36 | } 37 | 38 | /** 39 | * 清空所有缓存 40 | */ 41 | public static void removeAll(){ 42 | CACHE_CONTAINER.clear(); 43 | } 44 | 45 | /** 46 | * 同步缓存 47 | */ 48 | public static void syncData(){ 49 | //同步部门数据 50 | DeptMapper deptMapper = SpringUtil.getBean(DeptMapper.class); 51 | List deptList = deptMapper.selectList(null); 52 | for (Dept dept : deptList) { 53 | CACHE_CONTAINER.put("dept:"+dept.getId(),dept); 54 | } 55 | //同步用户数据 56 | UserMapper userMapper = SpringUtil.getBean(UserMapper.class); 57 | List userList = userMapper.selectList(null); 58 | for (User user : userList) { 59 | CACHE_CONTAINER.put("user:"+user.getId(),user); 60 | } 61 | 62 | //同步客户数据 63 | CustomerMapper customerMapper = SpringUtil.getBean(CustomerMapper.class); 64 | List customerList = customerMapper.selectList(null); 65 | for (Customer customer : customerList) { 66 | CACHE_CONTAINER.put("customer:"+customer.getId(),customer); 67 | } 68 | 69 | //同步供应商数据 70 | ProviderMapper providerMapper = SpringUtil.getBean(ProviderMapper.class); 71 | List providerList = providerMapper.selectList(null); 72 | for (Provider provider : providerList) { 73 | CACHE_CONTAINER.put("provider:"+provider.getId(),provider); 74 | } 75 | 76 | //同步商品数据 77 | GoodsMapper goodsMapper = SpringUtil.getBean(GoodsMapper.class); 78 | List goodsList = goodsMapper.selectList(null); 79 | for (Goods goods : goodsList) { 80 | CACHE_CONTAINER.put("goods:"+goods.getId(),goods); 81 | } 82 | 83 | 84 | } 85 | 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/controller/LoginfoController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 7 | import com.dev.warehouse.sys.common.DataGridView; 8 | import com.dev.warehouse.sys.common.ResultObj; 9 | import com.dev.warehouse.sys.entity.Loginfo; 10 | import com.dev.warehouse.sys.service.ILoginfoService; 11 | import com.dev.warehouse.sys.vo.LoginfoVo; 12 | import org.apache.commons.lang3.StringUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RestController; 16 | 17 | import java.io.Serializable; 18 | import java.util.ArrayList; 19 | import java.util.Collection; 20 | 21 | 22 | @RestController 23 | @RequestMapping("loginfo") 24 | public class LoginfoController { 25 | 26 | @Autowired 27 | private ILoginfoService loginfoService; 28 | 29 | /** 30 | * 查询所有登陆日志的信息 31 | * @param loginfoVo 32 | * @return 33 | */ 34 | @RequestMapping("loadAllLoginfo") 35 | public DataGridView loadAllLoginfo(LoginfoVo loginfoVo){ 36 | IPage page = new Page(loginfoVo.getPage(),loginfoVo.getLimit()); 37 | QueryWrapper queryWrapper = new QueryWrapper(); 38 | //进行模糊查询 39 | queryWrapper.like(StringUtils.isNotBlank(loginfoVo.getLoginname()),"loginname",loginfoVo.getLoginname()); 40 | queryWrapper.like(StringUtils.isNotBlank(loginfoVo.getLoginip()),"loginip",loginfoVo.getLoginip()); 41 | //数据库中登陆时间要大于用户输入的开始时间且小于用户登陆的结束时间 42 | queryWrapper.ge(loginfoVo.getStartTime()!=null,"logintime",loginfoVo.getStartTime()); 43 | queryWrapper.le(loginfoVo.getEndTime()!=null,"logintime",loginfoVo.getEndTime()); 44 | //根据登陆时间进行降序排序 45 | queryWrapper.orderByDesc("logintime"); 46 | loginfoService.page(page,queryWrapper); 47 | return new DataGridView(page.getTotal(),page.getRecords()); 48 | } 49 | 50 | /** 51 | * 删除单条日志 52 | * @param id 53 | * @return 54 | */ 55 | @RequestMapping("deleteLoginfo") 56 | public ResultObj deleteLoginfo(Integer id){ 57 | try { 58 | loginfoService.removeById(id); 59 | return ResultObj.DELETE_SUCCESS; 60 | } catch (Exception e) { 61 | e.printStackTrace(); 62 | return ResultObj.DELETE_ERROR; 63 | } 64 | } 65 | 66 | /** 67 | * 批量删除 68 | * @param loginfoVo 69 | * @return 70 | */ 71 | @RequestMapping("batchDeleteLoginfo") 72 | public ResultObj batchDeleteLoginfo(LoginfoVo loginfoVo){ 73 | try { 74 | Collection idList = new ArrayList(); 75 | for (Integer id : loginfoVo.getIds()) { 76 | idList.add(id); 77 | } 78 | this.loginfoService.removeByIds(idList); 79 | return ResultObj.DELETE_SUCCESS; 80 | } catch (Exception e) { 81 | e.printStackTrace(); 82 | return ResultObj.DELETE_ERROR; 83 | } 84 | } 85 | 86 | } 87 | 88 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/common/AppFileUtils.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.common; 2 | 3 | import cn.hutool.core.io.FileUtil; 4 | import cn.hutool.core.util.IdUtil; 5 | import org.springframework.http.HttpHeaders; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.http.ResponseEntity; 9 | 10 | import java.io.File; 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | import java.util.Properties; 14 | 15 | public class AppFileUtils { 16 | 17 | /** 18 | * 文件上传的保存路径 默认值 19 | */ 20 | public static String UPLOAD_PATH="C:/workSpace/logistics/src/main/resources/static/upload"; 21 | 22 | static { 23 | //读取配置文件的存储地址 24 | InputStream stream = AppFileUtils.class.getClassLoader().getResourceAsStream("file.properties"); 25 | Properties properties=new Properties(); 26 | try { 27 | properties.load(stream); 28 | } catch (IOException e) { 29 | e.printStackTrace(); 30 | } 31 | String property = properties.getProperty("filepath"); 32 | if(null!=property) { 33 | UPLOAD_PATH=property; 34 | } 35 | } 36 | 37 | /** 38 | * 根据文件老名字得到新名字 39 | * @param oldName 文件老名字 40 | * @return 新名字由32位随机数加图片后缀组成 41 | */ 42 | public static String createNewFileName(String oldName) { 43 | //获取文件名后缀 44 | String stuff=oldName.substring(oldName.lastIndexOf("."), oldName.length()); 45 | //将UUID与文件名后缀进行拼接,生成新的文件名 生成的UUID为32位 46 | return IdUtil.simpleUUID().toUpperCase()+stuff; 47 | } 48 | 49 | /** 50 | * 文件下载 51 | * @param path 52 | * @return 53 | */ 54 | public static ResponseEntity createResponseEntity(String path) { 55 | //1,构造文件对象 56 | File file=new File(UPLOAD_PATH, path); 57 | if(file.exists()) { 58 | //将下载的文件,封装byte[] 59 | byte[] bytes=null; 60 | try { 61 | bytes = FileUtil.readBytes(file); 62 | } catch (Exception e) { 63 | e.printStackTrace(); 64 | } 65 | //创建封装响应头信息的对象 66 | HttpHeaders header=new HttpHeaders(); 67 | //封装响应内容类型(APPLICATION_OCTET_STREAM 响应的内容不限定) 68 | header.setContentType(MediaType.APPLICATION_OCTET_STREAM); 69 | //创建ResponseEntity对象 70 | ResponseEntity entity= new ResponseEntity(bytes, header, HttpStatus.CREATED); 71 | return entity; 72 | } 73 | return null; 74 | } 75 | 76 | /** 77 | * 更该图片的名字 去掉_temp 78 | * @param goodsimg 79 | * @return 80 | */ 81 | public static String renameFile(String goodsimg) { 82 | File file = new File(UPLOAD_PATH,goodsimg); 83 | String replace = goodsimg.replace("_temp",""); 84 | if (file.exists()){ 85 | file.renameTo(new File(UPLOAD_PATH,replace)); 86 | } 87 | return replace; 88 | } 89 | 90 | /** 91 | * 根据老路径删除图片 92 | * @param oldPath 93 | */ 94 | public static void removeFileByPath(String oldPath) { 95 | //图片的路径不是默认图片的路径 96 | if (!oldPath.equals(Constast.DEFAULT_IMG)){ 97 | File file = new File(UPLOAD_PATH,oldPath); 98 | if (file.exists()){ 99 | file.delete(); 100 | } 101 | } 102 | } 103 | 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.controller; 2 | 3 | import cn.hutool.captcha.CaptchaUtil; 4 | import cn.hutool.captcha.LineCaptcha; 5 | import com.dev.warehouse.sys.common.ActiverUser; 6 | import com.dev.warehouse.sys.common.ResultObj; 7 | import com.dev.warehouse.sys.common.WebUtils; 8 | import com.dev.warehouse.sys.entity.Loginfo; 9 | import com.dev.warehouse.sys.entity.Role; 10 | import com.dev.warehouse.sys.service.ILoginfoService; 11 | import com.dev.warehouse.sys.service.IRoleService; 12 | import com.dev.warehouse.sys.vo.UserVo; 13 | import org.apache.shiro.SecurityUtils; 14 | import org.apache.shiro.authc.AuthenticationException; 15 | import org.apache.shiro.authc.AuthenticationToken; 16 | import org.apache.shiro.authc.UsernamePasswordToken; 17 | import org.apache.shiro.subject.Subject; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RestController; 21 | 22 | import javax.servlet.ServletOutputStream; 23 | import javax.servlet.http.HttpServletResponse; 24 | import javax.servlet.http.HttpSession; 25 | import java.io.IOException; 26 | import java.util.Date; 27 | import java.util.List; 28 | 29 | 30 | @RestController 31 | @RequestMapping("login") 32 | public class LoginController { 33 | 34 | @Autowired 35 | private ILoginfoService loginfoService; 36 | 37 | @Autowired 38 | private IRoleService roleService; 39 | 40 | @RequestMapping("login") 41 | public ResultObj login(UserVo userVo, String code, HttpSession session){ 42 | 43 | //获得存储在session中的验证码 44 | String sessionCode = (String) session.getAttribute("code"); 45 | if (code!=null&&sessionCode.equals(code)){ 46 | Subject subject = SecurityUtils.getSubject(); 47 | AuthenticationToken token = new UsernamePasswordToken(userVo.getLoginname(),userVo.getPwd()); 48 | try { 49 | //对用户进行认证登陆 50 | subject.login(token); 51 | //通过subject获取以认证活动的user 52 | ActiverUser activerUser = (ActiverUser) subject.getPrincipal(); 53 | //将user存储到session中 54 | WebUtils.getSession().setAttribute("user",activerUser.getUser()); 55 | //查询当前用户拥有的角色 56 | /* List currentUserRoleIds = roleService.queryUserRoleIdsByUid(activerUser.getUser().getId()); 57 | WebUtils.getSession().setAttribute("roles",activerUser.getRoles()); 58 | System.out.println("roles:"+activerUser.getRoles());*/ 59 | //记录登陆日志 60 | Loginfo entity = new Loginfo(); 61 | entity.setLoginname(activerUser.getUser().getName()+"-"+activerUser.getUser().getLoginname()); 62 | entity.setLoginip(WebUtils.getRequest().getRemoteAddr()); 63 | entity.setLogintime(new Date()); 64 | loginfoService.save(entity); 65 | 66 | return ResultObj.LOGIN_SUCCESS; 67 | } catch (AuthenticationException e) { 68 | e.printStackTrace(); 69 | return ResultObj.LOGIN_ERROR_PASS; 70 | } 71 | }else { 72 | return ResultObj.LOGIN_ERROR_CODE; 73 | } 74 | 75 | } 76 | 77 | /** 78 | * 得到登陆验证码 79 | * @param response 80 | * @param session 81 | * @throws IOException 82 | */ 83 | @RequestMapping("getCode") 84 | public void getCode(HttpServletResponse response, HttpSession session) throws IOException{ 85 | //定义图形验证码的长和宽 86 | LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(116, 36,4,5); 87 | session.setAttribute("code",lineCaptcha.getCode()); 88 | try { 89 | ServletOutputStream outputStream = response.getOutputStream(); 90 | lineCaptcha.write(outputStream); 91 | outputStream.close(); 92 | } catch (IOException e) { 93 | e.printStackTrace(); 94 | } 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/controller/OutportController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 7 | import com.dev.warehouse.bus.entity.Goods; 8 | import com.dev.warehouse.bus.entity.Outport; 9 | import com.dev.warehouse.bus.entity.Provider; 10 | import com.dev.warehouse.bus.service.IGoodsService; 11 | import com.dev.warehouse.bus.service.IOutportService; 12 | import com.dev.warehouse.bus.service.IProviderService; 13 | import com.dev.warehouse.bus.vo.OutportVo; 14 | import com.dev.warehouse.sys.common.DataGridView; 15 | import com.dev.warehouse.sys.common.ResultObj; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RestController; 19 | 20 | import java.util.List; 21 | @RestController 22 | @RequestMapping("/outport") 23 | public class OutportController { 24 | 25 | @Autowired 26 | private IOutportService outportService; 27 | 28 | @Autowired 29 | private IProviderService providerService; 30 | 31 | @Autowired 32 | private IGoodsService goodsService; 33 | 34 | /** 35 | * 添加退货信息 36 | * @param id 进货单ID 37 | * @param number 退货数量 38 | * @param remark 备注 39 | * @return 40 | */ 41 | @RequestMapping("addOutport") 42 | public ResultObj addOutport(Integer id, Integer number, String remark){ 43 | try { 44 | outportService.addOutport(id,number,remark); 45 | return ResultObj.BACKINPORT_SUCCESS; 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | return ResultObj.BACKINPORT_ERROR; 49 | } 50 | } 51 | 52 | /**t 53 | * 查询商品退货 54 | * @param outportVo 55 | * @return 56 | */ 57 | @RequestMapping("loadAllOutport") 58 | public DataGridView loadAllOuport(OutportVo outportVo){ 59 | IPage page = new Page(outportVo.getPage(),outportVo.getLimit()); 60 | QueryWrapper queryWrapper = new QueryWrapper(); 61 | //对供应商进行查询 62 | queryWrapper.eq(outportVo.getProviderid()!=null&&outportVo.getProviderid()!=0,"providerid",outportVo.getProviderid()); 63 | //对商品进行查询 64 | queryWrapper.eq(outportVo.getGoodsid()!=null&&outportVo.getGoodsid()!=0,"goodsid",outportVo.getGoodsid()); 65 | //对时间进行查询要求大于开始时间小于结束时间 66 | queryWrapper.ge(outportVo.getStartTime()!=null,"outputtime",outportVo.getStartTime()); 67 | queryWrapper.le(outportVo.getEndTime()!=null,"outputtime",outportVo.getEndTime()); 68 | //通过进货时间对商品进行排序 69 | queryWrapper.orderByDesc("outputtime"); 70 | IPage page1 = outportService.page(page, queryWrapper); 71 | List records = page1.getRecords(); 72 | for (Outport ouport : records) { 73 | Provider provider = providerService.getById(ouport.getProviderid()); 74 | if (provider!=null){ 75 | //设置供应商姓名 76 | ouport.setProvidername(provider.getProvidername()); 77 | } 78 | Goods goods = goodsService.getById(ouport.getGoodsid()); 79 | if (goods!=null){ 80 | //设置商品名称 81 | ouport.setGoodsname(goods.getGoodsname()); 82 | //设置商品规格 83 | ouport.setSize(goods.getSize()); 84 | } 85 | } 86 | return new DataGridView(page1.getTotal(),page1.getRecords()); 87 | } 88 | 89 | /** 90 | * 删除退货信息 91 | * @param id 92 | * @return 93 | */ 94 | @RequestMapping("deleteOutport") 95 | public ResultObj deleteOutport(Integer id){ 96 | try { 97 | outportService.removeById(id); 98 | return ResultObj.DELETE_SUCCESS; 99 | } catch (Exception e) { 100 | e.printStackTrace(); 101 | return ResultObj.DELETE_ERROR; 102 | } 103 | } 104 | 105 | 106 | } 107 | 108 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/controller/SalesbackController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 7 | import com.dev.warehouse.bus.entity.Customer; 8 | import com.dev.warehouse.bus.entity.Goods; 9 | import com.dev.warehouse.bus.entity.Salesback; 10 | import com.dev.warehouse.bus.service.ICustomerService; 11 | import com.dev.warehouse.bus.service.IGoodsService; 12 | import com.dev.warehouse.bus.service.ISalesbackService; 13 | import com.dev.warehouse.bus.vo.SalesbackVo; 14 | import com.dev.warehouse.sys.common.DataGridView; 15 | import com.dev.warehouse.sys.common.ResultObj; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RestController; 19 | 20 | import java.util.List; 21 | 22 | @RestController 23 | @RequestMapping("/salesback") 24 | public class SalesbackController { 25 | 26 | @Autowired 27 | private ISalesbackService salesbackService; 28 | 29 | @Autowired 30 | private ICustomerService customerService; 31 | 32 | @Autowired 33 | private IGoodsService goodsService; 34 | 35 | /** 36 | * 添加退货信息 37 | * @param id 进货单ID 38 | * @param number 退货数量 39 | * @param remark 备注 40 | * @return 41 | */ 42 | @RequestMapping("addSalesback") 43 | public ResultObj addSalesback(Integer id, Integer number, String remark){ 44 | try { 45 | salesbackService.addSalesback(id,number,remark); 46 | return ResultObj.BACKINPORT_SUCCESS; 47 | } catch (Exception e) { 48 | e.printStackTrace(); 49 | return ResultObj.BACKINPORT_ERROR; 50 | } 51 | } 52 | 53 | /**t 54 | * 查询商品销售退货 55 | * @param salesbackVo 56 | * @return 57 | */ 58 | @RequestMapping("loadAllSalesback") 59 | public DataGridView loadAllSalesback(SalesbackVo salesbackVo){ 60 | IPage page = new Page(salesbackVo.getPage(),salesbackVo.getLimit()); 61 | QueryWrapper queryWrapper = new QueryWrapper(); 62 | //对客户进行查询 63 | queryWrapper.eq(salesbackVo.getCustomerid()!=null&&salesbackVo.getCustomerid()!=0,"customerid",salesbackVo.getCustomerid()); 64 | //对商品进行查询 65 | queryWrapper.eq(salesbackVo.getGoodsid()!=null&&salesbackVo.getGoodsid()!=0,"goodsid",salesbackVo.getGoodsid()); 66 | //对时间进行查询要求大于开始时间小于结束时间 67 | queryWrapper.ge(salesbackVo.getStartTime()!=null,"salesbacktime",salesbackVo.getStartTime()); 68 | queryWrapper.le(salesbackVo.getEndTime()!=null,"salesbacktime",salesbackVo.getEndTime()); 69 | //通过商品退货时间对商品进行排序 70 | queryWrapper.orderByDesc("salesbacktime"); 71 | salesbackService.page(page, queryWrapper); 72 | List records = page.getRecords(); 73 | for (Salesback salesback : records) { 74 | System.out.println("============================"); 75 | Customer customer = customerService.getById(salesback.getCustomerid()); 76 | if (customer!=null){ 77 | //设置客户姓名 78 | salesback.setCustomername(customer.getCustomername()); 79 | } 80 | Goods goods = goodsService.getById(salesback.getGoodsid()); 81 | if (goods!=null){ 82 | //设置商品名称 83 | salesback.setGoodsname(goods.getGoodsname()); 84 | //设置商品规格 85 | salesback.setSize(goods.getSize()); 86 | } 87 | } 88 | return new DataGridView(page.getTotal(),page.getRecords()); 89 | } 90 | 91 | /** 92 | * 删除商品销售退回信息 93 | * @param id 94 | * @return 95 | */ 96 | @RequestMapping("deleteSalesback") 97 | public ResultObj deleteSalesback(Integer id){ 98 | try { 99 | salesbackService.removeById(id); 100 | return ResultObj.DELETE_SUCCESS; 101 | } catch (Exception e) { 102 | e.printStackTrace(); 103 | return ResultObj.DELETE_ERROR; 104 | } 105 | } 106 | 107 | } 108 | 109 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/controller/SystemController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | 7 | @Controller 8 | @RequestMapping("sys") 9 | public class SystemController { 10 | 11 | /** 12 | * 跳转到登陆页面 13 | * @return 14 | */ 15 | @RequestMapping("toLogin") 16 | public String toLogin(){ 17 | return "system/index/login"; 18 | } 19 | 20 | /** 21 | * 跳转到个人资料页面 22 | * @return 23 | */ 24 | @RequestMapping("toUserInfo") 25 | public String toUserInfo(){ 26 | return "system/user/userInfo"; 27 | } 28 | 29 | /** 30 | * 跳转到修改密码页面 31 | * @return 32 | */ 33 | @RequestMapping("toChangePassword") 34 | public String toChangePassword(){ 35 | return "system/user/changePassword"; 36 | } 37 | 38 | /** 39 | * 跳转到首页 40 | * @return 41 | */ 42 | @RequestMapping("index") 43 | public String index(){ 44 | return "system/index/index"; 45 | } 46 | 47 | /** 48 | * 跳转到登陆台 49 | * @return 50 | */ 51 | @RequestMapping("toDeskManager") 52 | public String toDeskManager(){ 53 | return "system/index/deskManager"; 54 | } 55 | 56 | /** 57 | * 跳转到日志管理 58 | * @return 59 | */ 60 | @RequestMapping("toLoginfoManager") 61 | public String toLoginfoManager(){ 62 | return "system/loginfo/loginfoManager"; 63 | } 64 | 65 | /** 66 | * 跳转到公告管理 67 | * @return 68 | */ 69 | @RequestMapping("toNoticeManager") 70 | public String toNoticeManager(){ 71 | return "system/notice/noticeManager"; 72 | } 73 | 74 | /** 75 | * 跳转到部门管理 76 | * @return 77 | */ 78 | @RequestMapping("toDeptManager") 79 | public String toDeptManager(){ 80 | return "system/dept/deptManager"; 81 | } 82 | 83 | /** 84 | * 跳转到部门管理--left 85 | * @return 86 | */ 87 | @RequestMapping("toDeptLeft") 88 | public String toDeptLeft(){ 89 | return "system/dept/deptLeft"; 90 | } 91 | 92 | /** 93 | * 跳转到部门管理--right 94 | * @return 95 | */ 96 | @RequestMapping("toDeptRight") 97 | public String toDeptRight(){ 98 | return "system/dept/deptRight"; 99 | } 100 | 101 | /** 102 | * 跳转到菜单管理 103 | * @return 104 | */ 105 | @RequestMapping("toMenuManager") 106 | public String toMenuManager(){ 107 | return "system/menu/menuManager"; 108 | } 109 | 110 | /** 111 | * 跳转到菜单管理--left 112 | * @return 113 | */ 114 | @RequestMapping("toMenuLeft") 115 | public String toMenuLeft(){ 116 | return "system/menu/menuLeft"; 117 | } 118 | 119 | /** 120 | * 跳转到菜单管理--right 121 | * @return 122 | */ 123 | @RequestMapping("toMenuRight") 124 | public String toMenuRight(){ 125 | return "system/menu/menuRight"; 126 | } 127 | 128 | /** 129 | * 跳转到权限管理 130 | * @return 131 | */ 132 | @RequestMapping("toPermissionManager") 133 | public String toPermissionManager(){ 134 | return "system/permission/permissionManager"; 135 | } 136 | 137 | /** 138 | * 跳转到权限管理--left 139 | * @return 140 | */ 141 | @RequestMapping("toPermissionLeft") 142 | public String toPermissionLeft(){ 143 | return "system/permission/permissionLeft"; 144 | } 145 | 146 | /** 147 | * 跳转到权限管理--right 148 | * @return 149 | */ 150 | @RequestMapping("toPermissionRight") 151 | public String toPermissionRight(){ 152 | return "system/permission/permissionRight"; 153 | } 154 | 155 | /** 156 | * 跳转到角色管理 157 | * @return 158 | */ 159 | @RequestMapping("toRoleManager") 160 | public String toRoleManager(){ 161 | return "system/role/roleManager"; 162 | } 163 | 164 | /** 165 | * 跳转到用户管理 166 | * @return 167 | */ 168 | @RequestMapping("toUserManager") 169 | public String toUserManager(){ 170 | return "system/user/userManager"; 171 | } 172 | 173 | /** 174 | * 跳转到缓存管理 175 | * @return 176 | */ 177 | @RequestMapping("toCacheManager") 178 | public String toCacheManager(){ 179 | return "system/cache/cacheManager"; 180 | } 181 | 182 | } 183 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/controller/SalesController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 7 | import com.dev.warehouse.bus.entity.Customer; 8 | import com.dev.warehouse.bus.entity.Goods; 9 | import com.dev.warehouse.bus.entity.Sales; 10 | import com.dev.warehouse.bus.service.ICustomerService; 11 | import com.dev.warehouse.bus.service.IGoodsService; 12 | import com.dev.warehouse.bus.service.ISalesService; 13 | import com.dev.warehouse.bus.vo.SalesVo; 14 | import com.dev.warehouse.sys.common.DataGridView; 15 | import com.dev.warehouse.sys.common.ResultObj; 16 | import com.dev.warehouse.sys.common.WebUtils; 17 | import com.dev.warehouse.sys.entity.User; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RestController; 21 | 22 | import java.util.Date; 23 | import java.util.List; 24 | 25 | @RestController 26 | @RequestMapping("/sales") 27 | public class SalesController { 28 | 29 | @Autowired 30 | private ISalesService salesService; 31 | 32 | @Autowired 33 | private ICustomerService customerService; 34 | 35 | @Autowired 36 | private IGoodsService goodsService; 37 | 38 | /** 39 | * 查询所有商品销售信息 40 | * @param salesVo 41 | * @return 42 | */ 43 | @RequestMapping("loadAllSales") 44 | public DataGridView loadAllSales(SalesVo salesVo){ 45 | IPage page = new Page<>(salesVo.getPage(),salesVo.getLimit()); 46 | QueryWrapper queryWrapper = new QueryWrapper(); 47 | //根据客户进行模糊查询 48 | queryWrapper.eq(salesVo.getCustomerid()!=null&&salesVo.getCustomerid()!=0,"customerid",salesVo.getCustomerid()); 49 | //根据商品模糊查询 50 | queryWrapper.eq(salesVo.getGoodsid()!=null&&salesVo.getGoodsid()!=0,"goodsid",salesVo.getGoodsid()); 51 | //根据时间进行模糊查询 52 | queryWrapper.ge(salesVo.getStartTime()!=null,"salestime",salesVo.getStartTime()); 53 | queryWrapper.le(salesVo.getEndTime()!=null,"salestime",salesVo.getEndTime()); 54 | IPage page1 = salesService.page(page, queryWrapper); 55 | List records = page1.getRecords(); 56 | for (Sales sales : records) { 57 | //设置客户姓名 58 | Customer customer = customerService.getById(sales.getCustomerid()); 59 | sales.setCustomername(customer.getCustomername()); 60 | //设置商品名称 61 | Goods goods = goodsService.getById(sales.getGoodsid()); 62 | sales.setGoodsname(goods.getGoodsname()); 63 | //设置商品规格 64 | sales.setSize(goods.getSize()); 65 | } 66 | return new DataGridView(page1.getTotal(),page1.getRecords()); 67 | } 68 | 69 | 70 | /** 71 | * 添加商品销售信息 72 | * @param salesVo 73 | * @return 74 | */ 75 | @RequestMapping("addSales") 76 | public ResultObj addSales(SalesVo salesVo){ 77 | try { 78 | //获得当前系统用户 79 | User user = (User) WebUtils.getSession().getAttribute("user"); 80 | //设置操作人 81 | salesVo.setOperateperson(user.getName()); 82 | //设置销售时间 83 | salesVo.setSalestime(new Date()); 84 | salesService.save(salesVo); 85 | return ResultObj.ADD_SUCCESS; 86 | } catch (Exception e) { 87 | e.printStackTrace(); 88 | return ResultObj.ADD_ERROR; 89 | } 90 | } 91 | 92 | /** 93 | * 更新商品销售信息 94 | * @param salesVo 95 | * @return 96 | */ 97 | @RequestMapping("updateSales") 98 | public ResultObj updateSales(SalesVo salesVo){ 99 | try { 100 | salesService.updateById(salesVo); 101 | return ResultObj.UPDATE_SUCCESS; 102 | } catch (Exception e) { 103 | e.printStackTrace(); 104 | return ResultObj.UPDATE_ERROR; 105 | } 106 | 107 | } 108 | 109 | /** 110 | * 删除商品销售信息 111 | * @param id 112 | * @return 113 | */ 114 | @RequestMapping("deleteSales") 115 | public ResultObj deleteSales(Integer id){ 116 | try { 117 | salesService.removeById(id); 118 | return ResultObj.DELETE_SUCCESS; 119 | } catch (Exception e) { 120 | e.printStackTrace(); 121 | return ResultObj.DELETE_ERROR; 122 | } 123 | } 124 | 125 | } 126 | 127 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/controller/CustomerController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 7 | import com.dev.warehouse.bus.entity.Customer; 8 | import com.dev.warehouse.bus.service.ICustomerService; 9 | import com.dev.warehouse.bus.vo.CustomerVo; 10 | import com.dev.warehouse.sys.common.Constast; 11 | import com.dev.warehouse.sys.common.DataGridView; 12 | import com.dev.warehouse.sys.common.ResultObj; 13 | import org.apache.commons.lang3.StringUtils; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import java.io.Serializable; 19 | import java.util.ArrayList; 20 | import java.util.Collection; 21 | import java.util.List; 22 | 23 | @RestController 24 | @RequestMapping("/customer") 25 | public class CustomerController { 26 | 27 | @Autowired 28 | private ICustomerService customerService; 29 | 30 | /** 31 | * 查询所有的客户 32 | * @param customerVo 33 | * @return 34 | */ 35 | @RequestMapping("loadAllCustomer") 36 | public DataGridView loadAllCustomer(CustomerVo customerVo){ 37 | //1.声明一个分页page对象 38 | IPage page = new Page(customerVo.getPage(),customerVo.getLimit()); 39 | //2.声明一个queryWrapper 40 | QueryWrapper queryWrapper = new QueryWrapper(); 41 | queryWrapper.like(StringUtils.isNotBlank(customerVo.getCustomername()),"customername",customerVo.getCustomername()); 42 | queryWrapper.like(StringUtils.isNotBlank(customerVo.getConnectionpersion()),"connectionpersion",customerVo.getConnectionpersion()); 43 | queryWrapper.like(StringUtils.isNotBlank(customerVo.getPhone()),"phone",customerVo.getPhone()); 44 | customerService.page(page,queryWrapper); 45 | return new DataGridView(page.getTotal(),page.getRecords()); 46 | } 47 | 48 | /** 49 | * 添加一个客户 50 | * @param customerVo 51 | * @return 52 | */ 53 | @RequestMapping("addCustomer") 54 | public ResultObj addCustomer(CustomerVo customerVo){ 55 | try { 56 | customerService.save(customerVo); 57 | return ResultObj.ADD_SUCCESS; 58 | } catch (Exception e) { 59 | e.printStackTrace(); 60 | return ResultObj.ADD_ERROR; 61 | } 62 | } 63 | 64 | /** 65 | * 修改一个客户 66 | * @param customerVo 67 | * @return 68 | */ 69 | @RequestMapping("updateCustomer") 70 | public ResultObj updateCustomer(CustomerVo customerVo){ 71 | try { 72 | customerService.updateById(customerVo); 73 | return ResultObj.UPDATE_SUCCESS; 74 | } catch (Exception e) { 75 | e.printStackTrace(); 76 | return ResultObj.UPDATE_ERROR; 77 | } 78 | } 79 | 80 | /** 81 | * 删除一个客户 82 | * @param id 客户的ID 83 | * @return 84 | */ 85 | @RequestMapping("deleteCustomer") 86 | public ResultObj deleteCustomer(Integer id){ 87 | try { 88 | customerService.removeById(id); 89 | return ResultObj.DELETE_SUCCESS; 90 | } catch (Exception e) { 91 | e.printStackTrace(); 92 | return ResultObj.DELETE_ERROR; 93 | } 94 | } 95 | 96 | /** 97 | * 批量删除客户 98 | * @param customerVo 选中的客户 99 | * @return 100 | */ 101 | @RequestMapping("batchDeleteCustomer") 102 | public ResultObj batchDeleteCustomer(CustomerVo customerVo){ 103 | try { 104 | Collection idList = new ArrayList(); 105 | for (Integer id : customerVo.getIds()) { 106 | idList.add(id); 107 | } 108 | customerService.removeByIds(idList); 109 | return ResultObj.DELETE_SUCCESS; 110 | } catch (Exception e) { 111 | e.printStackTrace(); 112 | return ResultObj.DELETE_ERROR; 113 | } 114 | } 115 | 116 | /** 117 | * 加载所有客户的下拉列表 118 | * @return 119 | */ 120 | @RequestMapping("loadAllCustomerForSelect") 121 | public DataGridView loadAllCustomerForSelect(){ 122 | QueryWrapper queryWrapper = new QueryWrapper(); 123 | queryWrapper.eq("available", Constast.AVAILABLE_TRUE); 124 | List list = customerService.list(queryWrapper); 125 | return new DataGridView(list); 126 | } 127 | 128 | } 129 | 130 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/controller/ProviderController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 7 | import com.dev.warehouse.bus.entity.Provider; 8 | import com.dev.warehouse.bus.service.IProviderService; 9 | import com.dev.warehouse.bus.vo.ProviderVo; 10 | import com.dev.warehouse.sys.common.Constast; 11 | import com.dev.warehouse.sys.common.DataGridView; 12 | import com.dev.warehouse.sys.common.ResultObj; 13 | import org.apache.commons.lang3.StringUtils; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import java.io.Serializable; 19 | import java.util.ArrayList; 20 | import java.util.Collection; 21 | import java.util.List; 22 | 23 | @RestController 24 | @RequestMapping("/provider") 25 | public class ProviderController { 26 | 27 | @Autowired 28 | private IProviderService providerService; 29 | 30 | /** 31 | * 查询所有的供应商 32 | * @param providerVo 33 | * @return 34 | */ 35 | @RequestMapping("loadAllProvider") 36 | public DataGridView loadAllProvider(ProviderVo providerVo){ 37 | //1.声明一个分页page对象 38 | IPage page = new Page(providerVo.getPage(),providerVo.getLimit()); 39 | //2.声明一个queryWrapper 40 | QueryWrapper queryWrapper = new QueryWrapper(); 41 | queryWrapper.like(StringUtils.isNotBlank(providerVo.getProvidername()),"providername",providerVo.getProvidername()); 42 | queryWrapper.like(StringUtils.isNotBlank(providerVo.getConnectionperson()),"connectionperson",providerVo.getConnectionperson()); 43 | queryWrapper.like(StringUtils.isNotBlank(providerVo.getPhone()),"phone",providerVo.getPhone()); 44 | providerService.page(page,queryWrapper); 45 | return new DataGridView(page.getTotal(),page.getRecords()); 46 | } 47 | 48 | /** 49 | * 添加一个供应商 50 | * @param providerVo 51 | * @return 52 | */ 53 | @RequestMapping("addProvider") 54 | public ResultObj addProvider(ProviderVo providerVo){ 55 | try { 56 | providerService.save(providerVo); 57 | return ResultObj.ADD_SUCCESS; 58 | } catch (Exception e) { 59 | e.printStackTrace(); 60 | return ResultObj.ADD_ERROR; 61 | } 62 | } 63 | 64 | /** 65 | * 修改一个供应商 66 | * @param providerVo 67 | * @return 68 | */ 69 | @RequestMapping("updateProvider") 70 | public ResultObj updateProvider(ProviderVo providerVo){ 71 | try { 72 | providerService.updateById(providerVo); 73 | return ResultObj.UPDATE_SUCCESS; 74 | } catch (Exception e) { 75 | e.printStackTrace(); 76 | return ResultObj.UPDATE_ERROR; 77 | } 78 | } 79 | 80 | /** 81 | * 删除一个供应商 82 | * @param id 供应商的ID 83 | * @return 84 | */ 85 | @RequestMapping("deleteProvider") 86 | public ResultObj deleteProvider(Integer id){ 87 | try { 88 | providerService.removeById(id); 89 | return ResultObj.DELETE_SUCCESS; 90 | } catch (Exception e) { 91 | e.printStackTrace(); 92 | return ResultObj.DELETE_ERROR; 93 | } 94 | } 95 | 96 | /** 97 | * 批量删除供应商 98 | * @param providerVo 选中的供应商 99 | * @return 100 | */ 101 | @RequestMapping("batchDeleteProvider") 102 | public ResultObj batchDeleteProvider(ProviderVo providerVo){ 103 | try { 104 | Collection idList = new ArrayList(); 105 | for (Integer id : providerVo.getIds()) { 106 | idList.add(id); 107 | } 108 | providerService.removeByIds(idList); 109 | return ResultObj.DELETE_SUCCESS; 110 | } catch (Exception e) { 111 | e.printStackTrace(); 112 | return ResultObj.DELETE_ERROR; 113 | } 114 | } 115 | 116 | /** 117 | * 加载所有可用的供应商 118 | * @return 119 | */ 120 | @RequestMapping("loadAllProviderForSelect") 121 | public DataGridView loadAllProviderForSelect(){ 122 | QueryWrapper queryWrapper = new QueryWrapper(); 123 | queryWrapper.eq("available", Constast.AVAILABLE_TRUE); 124 | List list = providerService.list(queryWrapper); 125 | return new DataGridView(list); 126 | } 127 | 128 | 129 | } 130 | 131 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/controller/InportController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 7 | import com.dev.warehouse.bus.entity.Goods; 8 | import com.dev.warehouse.bus.entity.Inport; 9 | import com.dev.warehouse.bus.entity.Provider; 10 | import com.dev.warehouse.bus.service.IGoodsService; 11 | import com.dev.warehouse.bus.service.IInportService; 12 | import com.dev.warehouse.bus.service.IProviderService; 13 | import com.dev.warehouse.bus.vo.InportVo; 14 | import com.dev.warehouse.sys.common.DataGridView; 15 | import com.dev.warehouse.sys.common.ResultObj; 16 | import com.dev.warehouse.sys.common.WebUtils; 17 | import com.dev.warehouse.sys.entity.User; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RestController; 21 | 22 | import java.util.Date; 23 | import java.util.List; 24 | 25 | @RestController 26 | @RequestMapping("inport") 27 | public class InportController { 28 | 29 | @Autowired 30 | private IInportService inportService; 31 | 32 | @Autowired 33 | private IProviderService providerService; 34 | 35 | @Autowired 36 | private IGoodsService goodsService; 37 | 38 | /** 39 | * 查询商品进货 40 | * @param inportVo 41 | * @return 42 | */ 43 | @RequestMapping("loadAllInport") 44 | public DataGridView loadAllInport(InportVo inportVo){ 45 | IPage page = new Page(inportVo.getPage(),inportVo.getLimit()); 46 | QueryWrapper queryWrapper = new QueryWrapper(); 47 | //对供应商进行查询 48 | queryWrapper.eq(inportVo.getProviderid()!=null&&inportVo.getProviderid()!=0,"providerid",inportVo.getProviderid()); 49 | //对商品进行查询 50 | queryWrapper.eq(inportVo.getGoodsid()!=null&&inportVo.getGoodsid()!=0,"goodsid",inportVo.getGoodsid()); 51 | //对时间进行查询要求大于开始时间小于结束时间 52 | queryWrapper.ge(inportVo.getStartTime()!=null,"inporttime",inportVo.getStartTime()); 53 | queryWrapper.le(inportVo.getEndTime()!=null,"inporttime",inportVo.getEndTime()); 54 | //通过进货时间对商品进行排序 55 | queryWrapper.orderByDesc("inporttime"); 56 | IPage page1 = inportService.page(page, queryWrapper); 57 | List records = page1.getRecords(); 58 | for (Inport inport : records) { 59 | Provider provider = providerService.getById(inport.getProviderid()); 60 | if (provider!=null){ 61 | //设置供应商姓名 62 | inport.setProvidername(provider.getProvidername()); 63 | } 64 | Goods goods = goodsService.getById(inport.getGoodsid()); 65 | if (goods!=null){ 66 | //设置商品名称 67 | inport.setGoodsname(goods.getGoodsname()); 68 | //设置商品规格 69 | inport.setSize(goods.getSize()); 70 | } 71 | } 72 | return new DataGridView(page1.getTotal(),page1.getRecords()); 73 | } 74 | 75 | 76 | /** 77 | * 添加进货商品 78 | * @param inportVo 79 | * @return 80 | */ 81 | @RequestMapping("addInport") 82 | public ResultObj addInport(InportVo inportVo){ 83 | try { 84 | //获得当前系统用户 85 | User user = (User) WebUtils.getSession().getAttribute("user"); 86 | //设置操作人 87 | inportVo.setOperateperson(user.getName()); 88 | //设置进货时间 89 | inportVo.setInporttime(new Date()); 90 | inportService.save(inportVo); 91 | return ResultObj.ADD_SUCCESS; 92 | } catch (Exception e) { 93 | e.printStackTrace(); 94 | return ResultObj.ADD_ERROR; 95 | } 96 | } 97 | 98 | /** 99 | * 更新进货商品 100 | * @param inportVo 101 | * @return 102 | */ 103 | @RequestMapping("updateInport") 104 | public ResultObj updateInport(InportVo inportVo){ 105 | try { 106 | inportService.updateById(inportVo); 107 | return ResultObj.UPDATE_SUCCESS; 108 | } catch (Exception e) { 109 | e.printStackTrace(); 110 | return ResultObj.UPDATE_ERROR; 111 | } 112 | 113 | } 114 | 115 | /** 116 | * 删除进货商品 117 | * @param id 118 | * @return 119 | */ 120 | @RequestMapping("deleteInport") 121 | public ResultObj deleteInport(Integer id){ 122 | try { 123 | inportService.removeById(id); 124 | return ResultObj.DELETE_SUCCESS; 125 | } catch (Exception e) { 126 | e.printStackTrace(); 127 | return ResultObj.DELETE_ERROR; 128 | } 129 | } 130 | 131 | 132 | } 133 | 134 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/realm/UserRealm.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.realm; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.dev.warehouse.sys.common.ActiverUser; 5 | import com.dev.warehouse.sys.common.Constast; 6 | import com.dev.warehouse.sys.entity.Permission; 7 | import com.dev.warehouse.sys.entity.User; 8 | import com.dev.warehouse.sys.service.IPermissionService; 9 | import com.dev.warehouse.sys.service.IRoleService; 10 | import com.dev.warehouse.sys.service.IUserService; 11 | import org.apache.shiro.authc.AuthenticationException; 12 | import org.apache.shiro.authc.AuthenticationInfo; 13 | import org.apache.shiro.authc.AuthenticationToken; 14 | import org.apache.shiro.authc.SimpleAuthenticationInfo; 15 | import org.apache.shiro.authz.AuthorizationInfo; 16 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 17 | import org.apache.shiro.realm.AuthorizingRealm; 18 | import org.apache.shiro.subject.PrincipalCollection; 19 | import org.apache.shiro.util.ByteSource; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.context.annotation.Lazy; 22 | 23 | import java.util.ArrayList; 24 | import java.util.HashSet; 25 | import java.util.List; 26 | import java.util.Set; 27 | 28 | public class UserRealm extends AuthorizingRealm { 29 | 30 | @Autowired 31 | /** 32 | * 当需要使用的时候,才加载。 即:当CacheAspect被解析之后,userService才会解析,要不然切面会不生效 33 | */ 34 | @Lazy 35 | private IUserService userService; 36 | 37 | @Autowired 38 | @Lazy 39 | private IPermissionService permissionService; 40 | 41 | @Autowired 42 | @Lazy 43 | private IRoleService roleService; 44 | 45 | @Override 46 | public String getName(){ 47 | return this.getClass().getSimpleName(); 48 | } 49 | 50 | /** 51 | * 授权 52 | * @param principalCollection 53 | * @return 54 | */ 55 | @Override 56 | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { 57 | SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo(); 58 | ActiverUser activerUser = (ActiverUser) principalCollection.getPrimaryPrincipal(); 59 | User user = activerUser.getUser(); 60 | List superPermission = new ArrayList<>(); 61 | superPermission.add("*:*"); 62 | List permissions = activerUser.getPermission(); 63 | if (user.getType().equals(Constast.USER_TYPE_SUPER)){ 64 | authorizationInfo.addStringPermissions(superPermission); 65 | }else { 66 | if (null!=permissions&&permissions.size()>0){ 67 | authorizationInfo.addStringPermissions(permissions); 68 | } 69 | } 70 | return authorizationInfo; 71 | } 72 | 73 | /** 74 | * 认证 75 | * @param authenticationToken 76 | * @return 77 | * @throws AuthenticationException 78 | */ 79 | @Override 80 | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { 81 | 82 | QueryWrapper queryWrapper = new QueryWrapper<>(); 83 | queryWrapper.eq("loginname",authenticationToken.getPrincipal().toString()); 84 | //通过用户名从数据库中查询出该用户 85 | User user = userService.getOne(queryWrapper); 86 | if (null!=user){ 87 | ActiverUser activerUser = new ActiverUser(); 88 | activerUser.setUser(user); 89 | 90 | //根据用户ID查询percode 91 | QueryWrapper qw = new QueryWrapper<>(); 92 | //设置只能查询菜单 93 | qw.eq("type", Constast.TYPE_PERMISSION); 94 | //设置只能查询可用的菜单 95 | qw.eq("available",Constast.AVAILABLE_TRUE); 96 | Integer userId = user.getId(); 97 | //根据用户ID查询角色ID 98 | List currentUserRoleIds = roleService.queryUserRoleIdsByUid(userId); 99 | //根据角色ID查询出权限ID 100 | Set pids = new HashSet<>(); 101 | for (Integer rid : currentUserRoleIds) { 102 | List permissionIds = roleService.queryRolePermissionIdsByRid(rid); 103 | pids.addAll(permissionIds); 104 | } 105 | List list = new ArrayList<>(); 106 | if (pids.size()>0){ 107 | qw.in("id",pids); 108 | list = permissionService.list(qw); 109 | } 110 | List percodes = new ArrayList<>(); 111 | for (Permission permission : list) { 112 | percodes.add(permission.getPercode()); 113 | } 114 | //放到activerUser 115 | activerUser.setPermission(percodes); 116 | 117 | //生成盐 118 | ByteSource credentialsSalt=ByteSource.Util.bytes(user.getSalt()); 119 | /** 120 | * 参数说明: 121 | * 参数1:活动的User 122 | * 参数2:从数据库里面查询出来的密码(已经通过MD5加密) 123 | * 参数3:从数据库里面查询出来的盐 124 | * 参数4:当前类名 125 | */ 126 | SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(activerUser,user.getPwd(),credentialsSalt,this.getName()); 127 | return info; 128 | } 129 | return null; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/controller/DeptController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 7 | import com.dev.warehouse.sys.common.DataGridView; 8 | import com.dev.warehouse.sys.common.ResultObj; 9 | import com.dev.warehouse.sys.common.TreeNode; 10 | import com.dev.warehouse.sys.entity.Dept; 11 | import com.dev.warehouse.sys.service.IDeptService; 12 | import com.dev.warehouse.sys.vo.DeptVo; 13 | import org.apache.commons.lang3.StringUtils; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import java.util.*; 19 | 20 | 21 | @RestController 22 | @RequestMapping("/dept") 23 | public class DeptController { 24 | 25 | @Autowired 26 | private IDeptService deptService; 27 | 28 | /** 29 | * 加载部门左边的菜单树 30 | * @param deptVo 31 | * @return 32 | */ 33 | @RequestMapping("loadDeptManagerLeftTreeJson") 34 | public DataGridView loadManagerLeftTreeJson(DeptVo deptVo){ 35 | //查询出所有的部门,存放进list中 36 | List list = deptService.list(); 37 | 38 | List treeNodes = new ArrayList<>(); 39 | //将部门放入treeNodes中,组装成json 40 | for (Dept dept : list) { 41 | Boolean open = dept.getOpen()==1?true:false; 42 | treeNodes.add(new TreeNode(dept.getId(),dept.getPid(),dept.getName(),open)); 43 | } 44 | return new DataGridView(treeNodes); 45 | } 46 | 47 | /** 48 | * 查询所有部门数据 49 | * @param deptVo 50 | * @return 51 | */ 52 | @RequestMapping("loadAllDept") 53 | public DataGridView loadAllDept(DeptVo deptVo){ 54 | IPage page = new Page<>(deptVo.getPage(),deptVo.getLimit()); 55 | //进行模糊查询 56 | QueryWrapper queryWrapper = new QueryWrapper<>(); 57 | queryWrapper.like(StringUtils.isNotBlank(deptVo.getName()),"name",deptVo.getName()); 58 | queryWrapper.like(StringUtils.isNotBlank(deptVo.getRemark()),"remark",deptVo.getRemark()); 59 | queryWrapper.like(StringUtils.isNotBlank(deptVo.getAddress()),"address",deptVo.getAddress()); 60 | queryWrapper.eq(deptVo.getId()!=null,"id",deptVo.getId()).or().eq(deptVo.getId()!=null,"pid",deptVo.getId()); 61 | queryWrapper.orderByAsc("ordernum"); 62 | //进行查询 63 | deptService.page(page,queryWrapper); 64 | //返回DataGridView 65 | return new DataGridView(page.getTotal(),page.getRecords()); 66 | } 67 | 68 | /** 69 | * 添加部门 70 | * @param deptVo 71 | * @return 72 | */ 73 | @RequestMapping("addDept") 74 | public ResultObj addDept(DeptVo deptVo){ 75 | try { 76 | deptVo.setCreatetime(new Date()); 77 | deptService.save(deptVo); 78 | return ResultObj.ADD_SUCCESS; 79 | } catch (Exception e) { 80 | e.printStackTrace(); 81 | return ResultObj.ADD_ERROR; 82 | } 83 | } 84 | 85 | /** 86 | * 加载排序码 87 | * @return 88 | */ 89 | @RequestMapping("loadDeptMaxOrderNum") 90 | public Map loadDeptMaxOrderNum(){ 91 | Map map = new HashMap(); 92 | QueryWrapper queryWrapper = new QueryWrapper<>(); 93 | queryWrapper.orderByDesc("ordernum"); 94 | IPage page = new Page<>(1,1); 95 | List list = deptService.page(page,queryWrapper).getRecords(); 96 | if (list.size()>0){ 97 | map.put("value",list.get(0).getOrdernum()+1); 98 | }else { 99 | map.put("value",1); 100 | } 101 | return map; 102 | } 103 | 104 | /** 105 | * 更新部门 106 | * @param deptVo 107 | * @return 108 | */ 109 | @RequestMapping("updateDept") 110 | public ResultObj updateDept(DeptVo deptVo){ 111 | try { 112 | deptService.updateById(deptVo); 113 | return ResultObj.UPDATE_SUCCESS; 114 | } catch (Exception e) { 115 | e.printStackTrace(); 116 | return ResultObj.UPDATE_ERROR; 117 | } 118 | } 119 | 120 | /** 121 | * 检查当前部门是否有子部门 122 | * @param deptVo 123 | * @return 124 | */ 125 | @RequestMapping("checkDeptHasChildrenNode") 126 | public Map checkDeptHasChildrenNode(DeptVo deptVo){ 127 | Map map = new HashMap(); 128 | QueryWrapper queryWrapper = new QueryWrapper<>(); 129 | queryWrapper.eq("pid",deptVo.getId()); 130 | List list = deptService.list(queryWrapper); 131 | if (list.size()>0){ 132 | map.put("value",true); 133 | }else { 134 | map.put("value",false); 135 | } 136 | return map; 137 | } 138 | 139 | /** 140 | * 删除部门 141 | * @param deptVo 142 | * @return 143 | */ 144 | @RequestMapping("deleteDept") 145 | public ResultObj deleteDept(DeptVo deptVo){ 146 | try { 147 | deptService.removeById(deptVo.getId()); 148 | return ResultObj.DELETE_SUCCESS; 149 | } catch (Exception e) { 150 | e.printStackTrace(); 151 | return ResultObj.DELETE_ERROR; 152 | } 153 | } 154 | 155 | } 156 | 157 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/controller/RoleController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 7 | import com.dev.warehouse.sys.common.Constast; 8 | import com.dev.warehouse.sys.common.DataGridView; 9 | import com.dev.warehouse.sys.common.ResultObj; 10 | import com.dev.warehouse.sys.common.TreeNode; 11 | import com.dev.warehouse.sys.entity.Permission; 12 | import com.dev.warehouse.sys.entity.Role; 13 | import com.dev.warehouse.sys.service.IPermissionService; 14 | import com.dev.warehouse.sys.service.IRoleService; 15 | import com.dev.warehouse.sys.vo.RoleVo; 16 | import org.apache.commons.lang3.StringUtils; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.web.bind.annotation.RequestMapping; 19 | import org.springframework.web.bind.annotation.RestController; 20 | 21 | import java.util.ArrayList; 22 | import java.util.Date; 23 | import java.util.List; 24 | 25 | @RestController 26 | @RequestMapping("/role") 27 | public class RoleController { 28 | 29 | @Autowired 30 | private IRoleService roleService; 31 | 32 | @Autowired 33 | private IPermissionService permissionService; 34 | 35 | /** 36 | * 查询所有角色 37 | * @param roleVo 38 | * @return 39 | */ 40 | @RequestMapping("loadAllRole") 41 | public DataGridView loadAllRole(RoleVo roleVo){ 42 | IPage page = new Page(roleVo.getPage(),roleVo.getLimit()); 43 | QueryWrapper queryWrapper = new QueryWrapper(); 44 | queryWrapper.like(StringUtils.isNotBlank(roleVo.getName()),"name",roleVo.getName()); 45 | queryWrapper.like(StringUtils.isNotBlank(roleVo.getRemark()),"remark",roleVo.getRemark()); 46 | queryWrapper.eq(roleVo.getAvailable()!=null,"available",roleVo.getAvailable()); 47 | queryWrapper.ge(roleVo.getStartTime()!=null,"createtime",roleVo.getStartTime()); 48 | queryWrapper.le(roleVo.getEndTime()!=null,"createtime",roleVo.getEndTime()); 49 | queryWrapper.orderByDesc("createtime"); 50 | roleService.page(page,queryWrapper); 51 | return new DataGridView(page.getTotal(),page.getRecords()); 52 | } 53 | 54 | /** 55 | * 添加角色 56 | * @param roleVo 57 | * @return 58 | */ 59 | @RequestMapping("addRole") 60 | public ResultObj addRole(RoleVo roleVo){ 61 | try { 62 | roleVo.setCreatetime(new Date()); 63 | roleService.save(roleVo); 64 | return ResultObj.ADD_SUCCESS; 65 | } catch (Exception e) { 66 | e.printStackTrace(); 67 | return ResultObj.ADD_ERROR; 68 | } 69 | } 70 | 71 | /** 72 | * 修改角色 73 | * @param roleVo 74 | * @return 75 | */ 76 | @RequestMapping("updateRole") 77 | public ResultObj updateRole(RoleVo roleVo){ 78 | try { 79 | roleService.updateById(roleVo); 80 | return ResultObj.UPDATE_SUCCESS; 81 | } catch (Exception e) { 82 | e.printStackTrace(); 83 | return ResultObj.UPDATE_ERROR; 84 | } 85 | } 86 | 87 | /** 88 | * 删除角色 89 | * @param id 90 | * @return 91 | */ 92 | @RequestMapping("deleteRole") 93 | public ResultObj deleteRole(Integer id){ 94 | try { 95 | this.roleService.removeById(id); 96 | return ResultObj.DELETE_SUCCESS; 97 | } catch (Exception e) { 98 | e.printStackTrace(); 99 | return ResultObj.DELETE_ERROR; 100 | } 101 | } 102 | 103 | /** 104 | * 根据角色ID加载菜单和权限的树的json串 105 | * @param roleId 106 | * @return 107 | */ 108 | @RequestMapping("initPermissionByRoleId") 109 | public DataGridView initPermissionByRoleId(Integer roleId){ 110 | //查询所有可用的菜单和权限 111 | QueryWrapper queryWrapper = new QueryWrapper<>(); 112 | queryWrapper.eq("available", Constast.AVAILABLE_TRUE); 113 | List allPermissions = permissionService.list(queryWrapper); 114 | //1.首先根据角色id查询出当前角色所拥有的所有菜单的ID和权限的ID 115 | List currentRolePermissions = roleService.queryRolePermissionIdsByRid(roleId); 116 | //2.根据查询出来的菜单ID和权限ID,再查询出菜单的数据和权限的数据 117 | List currentPermissions = null; 118 | //如果根据角色id查询出来了菜单ID或权限ID,就去查询 119 | if (currentRolePermissions.size()>0){ 120 | queryWrapper.in("id",currentRolePermissions); 121 | currentPermissions = permissionService.list(queryWrapper); 122 | }else { 123 | currentPermissions = new ArrayList<>(); 124 | } 125 | //构造List 126 | List nodes = new ArrayList<>(); 127 | for (Permission allPermission : allPermissions) { 128 | String checkArr = "0"; 129 | for (Permission currentPermission : currentPermissions) { 130 | if (allPermission.getId().equals(currentPermission.getId())){ 131 | checkArr = "1"; 132 | break; 133 | } 134 | } 135 | Boolean spread = (allPermission.getOpen()==null||allPermission.getOpen()==1)?true:false; 136 | nodes.add(new TreeNode(allPermission.getId(),allPermission.getPid(),allPermission.getTitle(),spread,checkArr)); 137 | } 138 | return new DataGridView(nodes); 139 | } 140 | 141 | /** 142 | * 保存角色和菜单权限之间的关系 143 | * @param rid 144 | * @param ids 145 | * @return 146 | */ 147 | @RequestMapping("saveRolePermission") 148 | public ResultObj saveRolePermission(Integer rid,Integer[] ids){ 149 | try { 150 | roleService.saveRolePermission(rid,ids); 151 | return ResultObj.DISPATCH_SUCCESS; 152 | } catch (Exception e) { 153 | e.printStackTrace(); 154 | return ResultObj.DISPATCH_ERROR; 155 | } 156 | 157 | } 158 | 159 | } 160 | 161 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.1.RELEASE 9 | 10 | 11 | com.dev.warehouse 12 | warehouseSys 13 | 0.0.1-SNAPSHOT 14 | warehouseSys 15 | 仓库管理系统 16 | 17 | 18 | 1.8 19 | 3.2.0 20 | 1.1.20 21 | 1.4.0 22 | 1.2.17 23 | 4.6.8 24 | 2.5.1 25 | 1.2.62 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-aop 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-jdbc 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-thymeleaf 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-web 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-devtools 50 | runtime 51 | true 52 | 53 | 54 | mysql 55 | mysql-connector-java 56 | 5.1.26 57 | 58 | 59 | org.springframework.boot 60 | spring-boot-configuration-processor 61 | true 62 | 63 | 64 | org.projectlombok 65 | lombok 66 | true 67 | 68 | 69 | org.springframework.boot 70 | spring-boot-starter-test 71 | test 72 | 73 | 74 | org.junit.vintage 75 | junit-vintage-engine 76 | 77 | 78 | 79 | 80 | 81 | 82 | com.baomidou 83 | mybatis-plus-boot-starter 84 | ${mybatisplus.version} 85 | 86 | 87 | 88 | 89 | com.baomidou 90 | mybatis-plus-generator 91 | 3.2.0 92 | 93 | 94 | org.apache.velocity 95 | velocity-engine-core 96 | 2.1 97 | 98 | 99 | org.freemarker 100 | freemarker 101 | 2.3.29 102 | 103 | 104 | com.ibeetl 105 | beetl 106 | 3.0.13.RELEASE 107 | 108 | 109 | 110 | 111 | com.alibaba 112 | druid-spring-boot-starter 113 | ${druid.version} 114 | 115 | 116 | 117 | org.apache.shiro 118 | shiro-spring 119 | ${shiro.version} 120 | 121 | 122 | org.apache.shiro 123 | shiro-core 124 | ${shiro.version} 125 | 126 | 127 | 128 | 129 | com.github.theborakompanioni 130 | thymeleaf-extras-shiro 131 | 2.0.0 132 | 133 | 134 | 135 | log4j 136 | log4j 137 | ${log4j.version} 138 | 139 | 140 | 141 | cn.hutool 142 | hutool-all 143 | ${hutool.version} 144 | 145 | 146 | 147 | org.apache.commons 148 | commons-lang3 149 | 150 | 151 | 152 | com.belerweb 153 | pinyin4j 154 | ${pinyin4j.version} 155 | 156 | 157 | 158 | com.alibaba 159 | fastjson 160 | ${fastjson.version} 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | org.springframework.boot 169 | spring-boot-maven-plugin 170 | 171 | 172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/controller/PermissionController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 7 | import com.dev.warehouse.sys.common.Constast; 8 | import com.dev.warehouse.sys.common.DataGridView; 9 | import com.dev.warehouse.sys.common.ResultObj; 10 | import com.dev.warehouse.sys.common.TreeNode; 11 | import com.dev.warehouse.sys.entity.Permission; 12 | import com.dev.warehouse.sys.service.IPermissionService; 13 | import com.dev.warehouse.sys.vo.PermissionVo; 14 | import org.apache.commons.lang3.StringUtils; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | import java.util.ArrayList; 20 | import java.util.HashMap; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | @RestController 25 | @RequestMapping("permission") 26 | public class PermissionController { 27 | 28 | @Autowired 29 | private IPermissionService permissionService; 30 | 31 | /** 32 | * 加载权限左边的权限树 33 | * @param permissionVo 34 | * @return 35 | */ 36 | @RequestMapping("loadPermissionManagerLeftTreeJson") 37 | public DataGridView loadPermissionManagerLeftTreeJson(PermissionVo permissionVo){ 38 | QueryWrapper queryWrapper = new QueryWrapper<>(); 39 | queryWrapper.eq("type", Constast.TYPE_MENU); 40 | //查询出所有的权限,存放进list中 41 | List list = permissionService.list(queryWrapper); 42 | List treeNodes = new ArrayList<>(); 43 | //将权限放入treeNodes中,组装成json 44 | for (Permission permission : list) { 45 | Boolean open = permission.getOpen()==1?true:false; 46 | treeNodes.add(new TreeNode(permission.getId(),permission.getPid(),permission.getTitle(),open)); 47 | } 48 | return new DataGridView(treeNodes); 49 | } 50 | 51 | /** 52 | * 查询所有权限数据 53 | * @param permissionVo 54 | * @return 55 | */ 56 | @RequestMapping("loadAllPermission") 57 | public DataGridView loadAllPermission(PermissionVo permissionVo){ 58 | IPage page = new Page<>(permissionVo.getPage(),permissionVo.getLimit()); 59 | //进行模糊查询 60 | QueryWrapper queryWrapper = new QueryWrapper<>(); 61 | //只能查询权限 62 | queryWrapper.eq("type",Constast.TYPE_PERMISSION); 63 | queryWrapper.like(StringUtils.isNotBlank(permissionVo.getTitle()),"title",permissionVo.getTitle()); 64 | queryWrapper.like(StringUtils.isNotBlank(permissionVo.getPercode()),"percode",permissionVo.getPercode()); 65 | queryWrapper.eq(permissionVo.getId()!=null,"pid",permissionVo.getId()); 66 | queryWrapper.orderByAsc("ordernum"); 67 | //进行查询 68 | permissionService.page(page,queryWrapper); 69 | //返回DataGridView 70 | return new DataGridView(page.getTotal(),page.getRecords()); 71 | } 72 | 73 | /** 74 | * 添加权限 75 | * @param permissionVo 76 | * @return 77 | */ 78 | @RequestMapping("addPermission") 79 | public ResultObj addPermission(PermissionVo permissionVo){ 80 | try { 81 | //设置添加类型为 permission 82 | permissionVo.setType(Constast.TYPE_PERMISSION); 83 | permissionService.save(permissionVo); 84 | return ResultObj.ADD_SUCCESS; 85 | } catch (Exception e) { 86 | e.printStackTrace(); 87 | return ResultObj.ADD_ERROR; 88 | } 89 | } 90 | 91 | /** 92 | * 加载排序码 93 | * @return 94 | */ 95 | @RequestMapping("loadPermissionMaxOrderNum") 96 | public Map loadPermissionMaxOrderNum(){ 97 | Map map = new HashMap(); 98 | QueryWrapper queryWrapper = new QueryWrapper<>(); 99 | queryWrapper.orderByDesc("ordernum"); 100 | IPage page = new Page<>(1,1); 101 | List list = permissionService.page(page,queryWrapper).getRecords(); 102 | if (list.size()>0){ 103 | map.put("value",list.get(0).getOrdernum()+1); 104 | }else { 105 | map.put("value",1); 106 | } 107 | return map; 108 | } 109 | 110 | /** 111 | * 更新权限 112 | * @param permissionVo 113 | * @return 114 | */ 115 | @RequestMapping("updatePermission") 116 | public ResultObj updatePermission(PermissionVo permissionVo){ 117 | try { 118 | permissionService.updateById(permissionVo); 119 | return ResultObj.UPDATE_SUCCESS; 120 | } catch (Exception e) { 121 | e.printStackTrace(); 122 | return ResultObj.UPDATE_ERROR; 123 | } 124 | } 125 | 126 | /** 127 | * 检查当前权限是否有子权限 128 | * @param permissionVo 129 | * @return 130 | */ 131 | @RequestMapping("checkPermissionHasChildrenNode") 132 | public Map checkPermissionHasChildrenNode(PermissionVo permissionVo){ 133 | Map map = new HashMap(); 134 | QueryWrapper queryWrapper = new QueryWrapper<>(); 135 | queryWrapper.eq("pid",permissionVo.getId()); 136 | List list = permissionService.list(queryWrapper); 137 | if (list.size()>0){ 138 | map.put("value",true); 139 | }else { 140 | map.put("value",false); 141 | } 142 | return map; 143 | } 144 | 145 | /** 146 | * 删除权限 147 | * @param permissionVo 148 | * @return 149 | */ 150 | @RequestMapping("deletePermission") 151 | public ResultObj deletePermission(PermissionVo permissionVo){ 152 | try { 153 | permissionService.removeById(permissionVo.getId()); 154 | return ResultObj.DELETE_SUCCESS; 155 | } catch (Exception e) { 156 | e.printStackTrace(); 157 | return ResultObj.DELETE_ERROR; 158 | } 159 | } 160 | 161 | 162 | } 163 | 164 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/config/ShiroAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.config; 2 | 3 | import at.pollux.thymeleaf.shiro.dialect.ShiroDialect; 4 | 5 | import com.dev.warehouse.sys.realm.UserRealm; 6 | import lombok.Data; 7 | import org.apache.shiro.authc.credential.CredentialsMatcher; 8 | import org.apache.shiro.authc.credential.HashedCredentialsMatcher; 9 | import org.apache.shiro.mgt.SecurityManager; 10 | import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; 11 | import org.apache.shiro.spring.web.ShiroFilterFactoryBean; 12 | import org.apache.shiro.web.mgt.DefaultWebSecurityManager; 13 | import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; 14 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 15 | import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; 16 | import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; 17 | import org.springframework.boot.context.properties.ConfigurationProperties; 18 | import org.springframework.boot.web.servlet.FilterRegistrationBean; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.web.filter.DelegatingFilterProxy; 22 | 23 | import javax.servlet.Filter; 24 | import java.util.HashMap; 25 | import java.util.Map; 26 | 27 | @Configuration 28 | @ConditionalOnWebApplication(type = Type.SERVLET) 29 | @ConditionalOnClass(value = { SecurityManager.class }) 30 | @ConfigurationProperties(prefix = "shiro") 31 | @Data 32 | public class ShiroAutoConfiguration { 33 | 34 | private static final String SHIRO_DIALECT = "shiroDialect"; 35 | private static final String SHIRO_FILTER = "shiroFilter"; 36 | // 加密方式 37 | private String hashAlgorithmName = "md5"; 38 | // 散列次数 39 | private int hashIterations = 2; 40 | // 默认的登陆页面 41 | private String loginUrl = "/index.html"; 42 | 43 | private String[] anonUrls; 44 | private String logOutUrl; 45 | private String[] authcUlrs; 46 | 47 | /** 48 | * 声明凭证匹配器 49 | */ 50 | @Bean("credentialsMatcher") 51 | public HashedCredentialsMatcher hashedCredentialsMatcher() { 52 | HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(); 53 | credentialsMatcher.setHashAlgorithmName(hashAlgorithmName); 54 | credentialsMatcher.setHashIterations(hashIterations); 55 | return credentialsMatcher; 56 | } 57 | 58 | /** 59 | * 声明userRealm 60 | */ 61 | @Bean("userRealm") 62 | public UserRealm userRealm(CredentialsMatcher credentialsMatcher) { 63 | UserRealm userRealm = new UserRealm(); 64 | // 注入凭证匹配器 65 | userRealm.setCredentialsMatcher(credentialsMatcher); 66 | return userRealm; 67 | } 68 | 69 | /** 70 | * 配置SecurityManager 71 | */ 72 | @Bean("securityManager") 73 | public SecurityManager securityManager(UserRealm userRealm) { 74 | DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); 75 | // 注入userRealm 76 | securityManager.setRealm(userRealm); 77 | return securityManager; 78 | } 79 | 80 | /** 81 | * 配置shiro的过滤器 82 | */ 83 | @Bean(SHIRO_FILTER) 84 | public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) { 85 | ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean(); 86 | // 设置安全管理器 87 | factoryBean.setSecurityManager(securityManager); 88 | // 设置未登陆的时要跳转的页面 89 | factoryBean.setLoginUrl(loginUrl); 90 | Map filterChainDefinitionMap = new HashMap<>(); 91 | // 设置放行的路径 92 | if (anonUrls != null && anonUrls.length > 0) { 93 | for (String anon : anonUrls) { 94 | filterChainDefinitionMap.put(anon, "anon"); 95 | } 96 | } 97 | // 设置登出的路径 98 | if (null != logOutUrl) { 99 | filterChainDefinitionMap.put(logOutUrl, "logout"); 100 | } 101 | // 设置拦截的路径 102 | if (authcUlrs != null && authcUlrs.length > 0) { 103 | for (String authc : authcUlrs) { 104 | filterChainDefinitionMap.put(authc, "authc"); 105 | } 106 | } 107 | Map filters=new HashMap<>(); 108 | // filters.put("authc", new ShiroLoginFilter()); 109 | //配置过滤器 110 | factoryBean.setFilters(filters); 111 | factoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); 112 | return factoryBean; 113 | } 114 | 115 | /** 116 | * 注册shiro的委托过滤器,相当于之前在web.xml里面配置的 117 | * 118 | * @return 119 | */ 120 | @Bean 121 | public FilterRegistrationBean delegatingFilterProxy() { 122 | FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); 123 | DelegatingFilterProxy proxy = new DelegatingFilterProxy(); 124 | proxy.setTargetFilterLifecycle(true); 125 | proxy.setTargetBeanName(SHIRO_FILTER); 126 | filterRegistrationBean.setFilter(proxy); 127 | return filterRegistrationBean; 128 | } 129 | 130 | /* 加入注解的使用,不加入这个注解不生效--开始 */ 131 | /** 132 | * 133 | * @param securityManager 134 | * @return 135 | */ 136 | @Bean 137 | public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) { 138 | AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); 139 | authorizationAttributeSourceAdvisor.setSecurityManager(securityManager); 140 | return authorizationAttributeSourceAdvisor; 141 | } 142 | 143 | @Bean 144 | public DefaultAdvisorAutoProxyCreator getDefaultAdvisorAutoProxyCreator() { 145 | DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator(); 146 | advisorAutoProxyCreator.setProxyTargetClass(true); 147 | return advisorAutoProxyCreator; 148 | } 149 | /* 加入注解的使用,不加入这个注解不生效--结束 */ 150 | 151 | /** 152 | * 这里是为了能在html页面引用shiro标签,上面两个函数必须添加,不然会报错 153 | * 154 | * @return 155 | */ 156 | @Bean(name = SHIRO_DIALECT) 157 | public ShiroDialect shiroDialect() { 158 | return new ShiroDialect(); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/controller/NoticeController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 7 | import com.dev.warehouse.sys.common.DataGridView; 8 | import com.dev.warehouse.sys.common.ResultObj; 9 | import com.dev.warehouse.sys.common.WebUtils; 10 | import com.dev.warehouse.sys.entity.Notice; 11 | import com.dev.warehouse.sys.entity.User; 12 | import com.dev.warehouse.sys.service.INoticeService; 13 | import com.dev.warehouse.sys.vo.NoticeVo; 14 | import com.sun.javafx.collections.MappingChange; 15 | import org.apache.commons.lang3.StringUtils; 16 | import org.apache.ibatis.annotations.Param; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.beans.factory.annotation.Value; 19 | import org.springframework.util.FileCopyUtils; 20 | import org.springframework.web.bind.annotation.*; 21 | import org.springframework.web.multipart.MultipartFile; 22 | 23 | import javax.servlet.http.HttpServletRequest; 24 | import java.io.File; 25 | import java.io.FileOutputStream; 26 | import java.io.IOException; 27 | import java.io.Serializable; 28 | import java.util.ArrayList; 29 | import java.util.Collection; 30 | import java.util.Date; 31 | import java.util.HashMap; 32 | import java.util.Map; 33 | 34 | 35 | @RestController 36 | @RequestMapping("notice") 37 | public class NoticeController { 38 | 39 | @Autowired 40 | private INoticeService noticeService; 41 | 42 | @Value("${yuanlrc.photoFilePath}") 43 | private String filePath; 44 | /** 45 | * 公告的查询 46 | * @param noticeVo 47 | * @return 48 | */ 49 | @RequestMapping("loadAllNotice") 50 | public DataGridView loadAllNotice(NoticeVo noticeVo){ 51 | IPage page = new Page(noticeVo.getPage(),noticeVo.getLimit()); 52 | QueryWrapper queryWrapper = new QueryWrapper(); 53 | //进行模糊查询 54 | queryWrapper.like(StringUtils.isNotBlank(noticeVo.getTitle()),"title",noticeVo.getTitle()); 55 | queryWrapper.like(StringUtils.isNotBlank(noticeVo.getOpername()),"opername",noticeVo.getOpername()); 56 | //公告创建时间应该大于搜索开始时间小于搜索结束时间 57 | queryWrapper.ge(noticeVo.getStartTime()!=null,"createtime",noticeVo.getStartTime()); 58 | queryWrapper.le(noticeVo.getEndTime()!=null,"createtime",noticeVo.getEndTime()); 59 | //根据公告创建时间进行排序 60 | queryWrapper.orderByDesc("createtime"); 61 | noticeService.page(page,queryWrapper); 62 | return new DataGridView(page.getTotal(),page.getRecords()); 63 | } 64 | 65 | /** 66 | * 添加公告 67 | * @param noticeVo 68 | * @return 69 | */ 70 | @RequestMapping("addNotice") 71 | public ResultObj addNotice(NoticeVo noticeVo){ 72 | try { 73 | noticeVo.setCreatetime(new Date()); 74 | User user = (User) WebUtils.getSession().getAttribute("user"); 75 | noticeVo.setOpername(user.getName()); 76 | noticeService.save(noticeVo); 77 | return ResultObj.ADD_SUCCESS; 78 | } catch (Exception e) { 79 | e.printStackTrace(); 80 | return ResultObj.ADD_ERROR; 81 | } 82 | } 83 | 84 | /** 85 | * 修改公告 86 | * @param noticeVo 87 | * @return 88 | */ 89 | @RequestMapping("updateNotice") 90 | public ResultObj updateNotice(NoticeVo noticeVo){ 91 | try { 92 | noticeService.updateById(noticeVo); 93 | return ResultObj.UPDATE_SUCCESS; 94 | } catch (Exception e) { 95 | e.printStackTrace(); 96 | return ResultObj.UPDATE_ERROR; 97 | } 98 | } 99 | 100 | /** 101 | * 删除公告 102 | * @param noticeVo 103 | * @return 104 | */ 105 | @RequestMapping("deleteNotice") 106 | public ResultObj deleteNotice(NoticeVo noticeVo){ 107 | try { 108 | noticeService.removeById(noticeVo); 109 | return ResultObj.DELETE_SUCCESS; 110 | } catch (Exception e) { 111 | e.printStackTrace(); 112 | return ResultObj.DELETE_ERROR; 113 | } 114 | } 115 | 116 | /** 117 | * 批量删除公告 118 | * @param noticeVo 119 | * @return 120 | */ 121 | @RequestMapping("batchDeleteNotice") 122 | public ResultObj batchDeleteNotice(NoticeVo noticeVo){ 123 | try { 124 | Collection idList = new ArrayList<>(); 125 | for (Integer id : noticeVo.getIds()) { 126 | idList.add(id); 127 | } 128 | noticeService.removeByIds(idList); 129 | return ResultObj.DELETE_SUCCESS; 130 | } catch (Exception e) { 131 | e.printStackTrace(); 132 | return ResultObj.DELETE_ERROR; 133 | } 134 | } 135 | 136 | 137 | @ResponseBody 138 | @PostMapping(value = "/uploadFile") 139 | public Map uploadFile(@RequestParam("file") MultipartFile file) throws IOException { 140 | Map map = new HashMap<>(); 141 | Map map2 = new HashMap<>(); 142 | if (file != null) { 143 | try { 144 | String originalFilename = file.getOriginalFilename(); 145 | String suffix = originalFilename.substring(originalFilename.lastIndexOf("."),originalFilename.length()); 146 | String filename=System.currentTimeMillis()+suffix; 147 | // 图片的路径+文件名称 148 | // 图片的在服务器上面的物理路径 149 | File destFile = new File(filePath, filename); 150 | // 生成upload目录 151 | File parentFile = destFile.getParentFile(); 152 | if (!parentFile.exists()) { 153 | parentFile.mkdirs();// 自动生成upload目录 154 | } 155 | // 把上传的临时图片,复制到当前项目的webapp路径 156 | FileCopyUtils.copy(file.getInputStream(), new FileOutputStream(destFile)); 157 | map = new HashMap<>(); 158 | map2 = new HashMap<>(); 159 | map.put("code", 0);//0表示成功,1失败 160 | map.put("msg", "上传成功");//提示消息 161 | map.put("data", map2); 162 | map2.put("src", "../photo/view?filename="+filename);//图片url 163 | map2.put("title", originalFilename);//图片名称,这个会显示在输入框里 164 | } catch (Exception e) { 165 | e.printStackTrace(); 166 | } 167 | } 168 | return map; 169 | } 170 | 171 | } 172 | 173 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/controller/GoodsController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 7 | import com.dev.warehouse.bus.entity.Goods; 8 | import com.dev.warehouse.bus.entity.Provider; 9 | import com.dev.warehouse.bus.service.IGoodsService; 10 | import com.dev.warehouse.bus.service.IProviderService; 11 | import com.dev.warehouse.bus.vo.GoodsVo; 12 | import com.dev.warehouse.sys.common.AppFileUtils; 13 | import com.dev.warehouse.sys.common.Constast; 14 | import com.dev.warehouse.sys.common.DataGridView; 15 | import com.dev.warehouse.sys.common.ResultObj; 16 | import org.apache.commons.lang3.StringUtils; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.web.bind.annotation.RequestMapping; 19 | import org.springframework.web.bind.annotation.RestController; 20 | 21 | import java.util.List; 22 | 23 | @RestController 24 | @RequestMapping("/goods") 25 | public class GoodsController { 26 | 27 | @Autowired 28 | private IGoodsService goodsService; 29 | 30 | @Autowired 31 | private IProviderService providerService; 32 | 33 | /** 34 | * 查询商品 35 | * @param goodsVo 36 | * @return 37 | */ 38 | @RequestMapping("loadAllGoods") 39 | public DataGridView loadAllGoods(GoodsVo goodsVo){ 40 | IPage page = new Page<>(goodsVo.getPage(),goodsVo.getLimit()); 41 | QueryWrapper queryWrapper = new QueryWrapper(); 42 | queryWrapper.eq(goodsVo.getProviderid()!=null&&goodsVo.getProviderid()!=0,"providerid",goodsVo.getProviderid()); 43 | queryWrapper.like(StringUtils.isNotBlank(goodsVo.getGoodsname()),"goodsname",goodsVo.getGoodsname()); 44 | queryWrapper.like(StringUtils.isNotBlank(goodsVo.getProductcode()),"productcode",goodsVo.getProductcode()); 45 | queryWrapper.like(StringUtils.isNotBlank(goodsVo.getPromitcode()),"promitcode",goodsVo.getPromitcode()); 46 | queryWrapper.like(StringUtils.isNotBlank(goodsVo.getDescription()),"description",goodsVo.getDescription()); 47 | queryWrapper.like(StringUtils.isNotBlank(goodsVo.getSize()),"size",goodsVo.getSize()); 48 | queryWrapper.orderByDesc("id"); 49 | goodsService.page(page,queryWrapper); 50 | List records = page.getRecords(); 51 | for (Goods goods : records) { 52 | Provider provider = providerService.getById(goods.getProviderid()); 53 | if (null!=provider){ 54 | goods.setProvidername(provider.getProvidername()); 55 | } 56 | } 57 | return new DataGridView(page.getTotal(),page.getRecords()); 58 | } 59 | 60 | /** 61 | * 添加商品 62 | * @param goodsVo 63 | * @return 64 | */ 65 | @RequestMapping("addGoods") 66 | public ResultObj addGoods(GoodsVo goodsVo){ 67 | try { 68 | if (goodsVo.getGoodsimg()!=null&&goodsVo.getGoodsimg().endsWith("_temp")){ 69 | String newName = AppFileUtils.renameFile(goodsVo.getGoodsimg()); 70 | goodsVo.setGoodsimg(newName); 71 | } 72 | goodsService.save(goodsVo); 73 | return ResultObj.ADD_SUCCESS; 74 | } catch (Exception e) { 75 | e.printStackTrace(); 76 | return ResultObj.ADD_ERROR; 77 | } 78 | } 79 | 80 | /** 81 | * 修改商品 82 | * @param goodsVo 83 | * @return 84 | */ 85 | @RequestMapping("updateGoods") 86 | public ResultObj updateGoods(GoodsVo goodsVo){ 87 | try { 88 | //商品图片不是默认图片 89 | if (!(goodsVo.getGoodsimg()!=null&&goodsVo.getGoodsimg().equals(Constast.DEFAULT_IMG))){ 90 | if (goodsVo.getGoodsimg().endsWith("_temp")){ 91 | String newName = AppFileUtils.renameFile(goodsVo.getGoodsimg()); 92 | goodsVo.setGoodsimg(newName); 93 | //删除原先的图片 94 | String oldPath = goodsService.getById(goodsVo.getId()).getGoodsimg(); 95 | AppFileUtils.removeFileByPath(oldPath); 96 | } 97 | } 98 | goodsService.updateById(goodsVo); 99 | return ResultObj.UPDATE_SUCCESS; 100 | } catch (Exception e) { 101 | e.printStackTrace(); 102 | return ResultObj.UPDATE_ERROR; 103 | } 104 | } 105 | 106 | /** 107 | * 删除商品 108 | * @param id 109 | * @return 110 | */ 111 | @RequestMapping("deleteGoods") 112 | public ResultObj deleteGoods(Integer id,String goodsimg){ 113 | try { 114 | //删除商品的图片 115 | AppFileUtils.removeFileByPath(goodsimg); 116 | goodsService.removeById(id); 117 | return ResultObj.DELETE_SUCCESS; 118 | } catch (Exception e) { 119 | e.printStackTrace(); 120 | return ResultObj.DELETE_ERROR; 121 | } 122 | } 123 | 124 | /** 125 | * 加载所有可用的商品 126 | * @return 127 | */ 128 | @RequestMapping("loadAllGoodsForSelect") 129 | public DataGridView loadAllGoodsForSelect(){ 130 | QueryWrapper queryWrapper = new QueryWrapper(); 131 | queryWrapper.eq("available",Constast.AVAILABLE_TRUE); 132 | List list = goodsService.list(queryWrapper); 133 | for (Goods goods : list) { 134 | Provider provider = providerService.getById(goods.getProviderid()); 135 | if (null!=provider){ 136 | goods.setProvidername(provider.getProvidername()); 137 | } 138 | } 139 | return new DataGridView(list); 140 | } 141 | 142 | /** 143 | * 根据供应商ID查询商品信息 144 | * @param providerid 供应商ID 145 | * @return 146 | */ 147 | @RequestMapping("loadGoodsByProviderId") 148 | public DataGridView loadGoodsByProviderId(Integer providerid){ 149 | QueryWrapper queryWrapper = new QueryWrapper(); 150 | queryWrapper.eq("available",Constast.AVAILABLE_TRUE); 151 | queryWrapper.eq(providerid!=null,"providerid",providerid); 152 | List list = goodsService.list(queryWrapper); 153 | for (Goods goods : list) { 154 | Provider provider = providerService.getById(goods.getProviderid()); 155 | if (null!=provider){ 156 | goods.setProvidername(provider.getProvidername()); 157 | } 158 | } 159 | return new DataGridView(list); 160 | } 161 | 162 | 163 | 164 | } 165 | 166 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/cache/CacheAspect.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.cache; 2 | 3 | 4 | import com.dev.warehouse.sys.entity.Dept; 5 | import com.dev.warehouse.sys.entity.User; 6 | import org.apache.commons.logging.Log; 7 | import org.apache.commons.logging.LogFactory; 8 | import org.aspectj.lang.ProceedingJoinPoint; 9 | import org.aspectj.lang.annotation.Around; 10 | import org.aspectj.lang.annotation.Aspect; 11 | import org.springframework.beans.BeanUtils; 12 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 13 | import org.springframework.stereotype.Component; 14 | 15 | import java.util.Map; 16 | 17 | 18 | @Aspect 19 | @Component 20 | @EnableAspectJAutoProxy 21 | public class CacheAspect { 22 | 23 | /** 24 | * 日志出处 25 | */ 26 | private Log log = LogFactory.getLog(CacheAspect.class); 27 | 28 | /** 29 | * 声明一个缓存容器 30 | */ 31 | private Map CACHE_CONTAINER = CachePool.CACHE_CONTAINER; 32 | 33 | 34 | /** 35 | * 声明部门的切面表达式 36 | */ 37 | private static final String POINTCUT_DEPT_ADD="execution(* com.dev.warehouse.sys.service.impl.DeptServiceImpl.save(..))"; 38 | private static final String POINTCUT_DEPT_UPDATE="execution(* com.dev.warehouse.sys.service.impl.DeptServiceImpl.updateById(..))"; 39 | private static final String POINTCUT_DEPT_GET="execution(* com.dev.warehouse.sys.service.impl.DeptServiceImpl.getById(..))"; 40 | private static final String POINTCUT_DEPT_DELETE="execution(* com.dev.warehouse.sys.service.impl.DeptServiceImpl.removeById(..))"; 41 | 42 | private static final String CACHE_DEPT_PROFIX="dept:"; 43 | 44 | /** 45 | * 添加部门切入 46 | * @param joinPoint 47 | * @return 48 | */ 49 | @Around(value = POINTCUT_DEPT_ADD) 50 | public Object cacheDeptAdd(ProceedingJoinPoint joinPoint) throws Throwable { 51 | //取出第一个参数 52 | Dept object = (Dept) joinPoint.getArgs()[0]; 53 | Boolean res = (Boolean) joinPoint.proceed(); 54 | if (res){ 55 | CACHE_CONTAINER.put(CACHE_DEPT_PROFIX + object.getId(),object); 56 | } 57 | return res; 58 | } 59 | 60 | /** 61 | * 查询部门切入 62 | * @param joinPoint 63 | * @return 64 | */ 65 | @Around(value = POINTCUT_DEPT_GET) 66 | public Object cacheDeptGet(ProceedingJoinPoint joinPoint) throws Throwable { 67 | //取出第一个参数 68 | Integer object = (Integer) joinPoint.getArgs()[0]; 69 | //从缓存里面取 70 | Object res1 = CACHE_CONTAINER.get(CACHE_DEPT_PROFIX + object); 71 | if (res1!=null){ 72 | log.info("已从缓存里面找到部门对象"+CACHE_DEPT_PROFIX + object); 73 | return res1; 74 | }else { 75 | log.info("未从缓存里面找到部门对象,从数据库中查询并放入缓存"); 76 | Dept res2 =(Dept) joinPoint.proceed(); 77 | CACHE_CONTAINER.put(CACHE_DEPT_PROFIX+res2.getId(),res2); 78 | return res2; 79 | } 80 | } 81 | 82 | /** 83 | * 更新部门切入 84 | * @param joinPoint 85 | * @return 86 | */ 87 | @Around(value = POINTCUT_DEPT_UPDATE) 88 | public Object cacheDeptUpdate(ProceedingJoinPoint joinPoint) throws Throwable { 89 | //取出第一个参数 90 | Dept deptVo = (Dept) joinPoint.getArgs()[0]; 91 | Boolean isSuccess = (Boolean) joinPoint.proceed(); 92 | if (isSuccess){ 93 | Dept dept =(Dept) CACHE_CONTAINER.get(CACHE_DEPT_PROFIX + deptVo.getId()); 94 | if (null==dept){ 95 | dept=new Dept(); 96 | } 97 | BeanUtils.copyProperties(deptVo,dept); 98 | log.info("部门对象缓存已更新"+CACHE_DEPT_PROFIX + deptVo.getId()); 99 | CACHE_CONTAINER.put(CACHE_DEPT_PROFIX+dept.getId(),dept); 100 | } 101 | return isSuccess; 102 | } 103 | 104 | /** 105 | * 删除部门切入 106 | * @param joinPoint 107 | * @return 108 | */ 109 | @Around(value = POINTCUT_DEPT_DELETE) 110 | public Object cacheDeptDelete(ProceedingJoinPoint joinPoint) throws Throwable { 111 | 112 | //取出第一个参数 113 | Integer id = (Integer) joinPoint.getArgs()[0]; 114 | Boolean isSuccess = (Boolean) joinPoint.proceed(); 115 | if (isSuccess){ 116 | //删除缓存 117 | CACHE_CONTAINER.remove(CACHE_DEPT_PROFIX+id); 118 | } 119 | return isSuccess; 120 | } 121 | 122 | /** 123 | * 声明用户的切面表达式 124 | */ 125 | private static final String POINTCUT_USER_UPDATE="execution(* com.dev.warehouse.sys.service.impl.UserServiceImpl.updateById(..))"; 126 | private static final String POINTCUT_USER_ADD="execution(* com.dev.warehouse.sys.service.impl.UserServiceImpl.updateById(..))"; 127 | private static final String POINTCUT_USER_GET="execution(* com.dev.warehouse.sys.service.impl.UserServiceImpl.getById(..))"; 128 | private static final String POINTCUT_USER_DELETE="execution(* com.dev.warehouse.sys.service.impl.UserServiceImpl.removeById(..))"; 129 | 130 | private static final String CACHE_USER_PROFIX="user:"; 131 | 132 | /** 133 | * 添加用户切入 134 | * @param joinPoint 135 | * @return 136 | */ 137 | @Around(value = POINTCUT_USER_ADD) 138 | public Object cacheUserAdd(ProceedingJoinPoint joinPoint) throws Throwable { 139 | //取出第一个参数 140 | User object = (User) joinPoint.getArgs()[0]; 141 | Boolean res = (Boolean) joinPoint.proceed(); 142 | if (res){ 143 | CACHE_CONTAINER.put(CACHE_USER_PROFIX + object.getId(),object); 144 | } 145 | return res; 146 | } 147 | 148 | /** 149 | * 查询用户切入 150 | * @param joinPoint 151 | * @return 152 | */ 153 | @Around(value = POINTCUT_USER_GET) 154 | public Object cacheUserGet(ProceedingJoinPoint joinPoint) throws Throwable { 155 | //取出第一个参数 156 | Integer object = (Integer) joinPoint.getArgs()[0]; 157 | //从缓存里面取 158 | Object res1 = CACHE_CONTAINER.get(CACHE_USER_PROFIX + object); 159 | if (res1!=null){ 160 | log.info("已从缓存里面找到用户对象"+CACHE_USER_PROFIX + object); 161 | return res1; 162 | }else { 163 | log.info("未从缓存里面找到用户对象,从数据库中查询并放入缓存"); 164 | User res2 =(User) joinPoint.proceed(); 165 | CACHE_CONTAINER.put(CACHE_USER_PROFIX+res2.getId(),res2); 166 | return res2; 167 | } 168 | } 169 | 170 | /** 171 | * 更新用户切入 172 | * @param joinPoint 173 | * @return 174 | */ 175 | @Around(value = POINTCUT_USER_UPDATE) 176 | public Object cacheUserUpdate(ProceedingJoinPoint joinPoint) throws Throwable { 177 | //取出第一个参数 178 | User userVo = (User) joinPoint.getArgs()[0]; 179 | Boolean isSuccess = (Boolean) joinPoint.proceed(); 180 | if (isSuccess){ 181 | User user =(User) CACHE_CONTAINER.get(CACHE_USER_PROFIX + userVo.getId()); 182 | if (null==user){ 183 | user=new User(); 184 | } 185 | BeanUtils.copyProperties(userVo,user); 186 | log.info("用户对象缓存已更新"+CACHE_USER_PROFIX + userVo.getId()); 187 | CACHE_CONTAINER.put(CACHE_USER_PROFIX+user.getId(),user); 188 | } 189 | return isSuccess; 190 | } 191 | 192 | /** 193 | * 删除用户切入 194 | * @param joinPoint 195 | * @return 196 | */ 197 | @Around(value = POINTCUT_USER_DELETE) 198 | public Object cacheUserDelete(ProceedingJoinPoint joinPoint) throws Throwable { 199 | 200 | //取出第一个参数 201 | Integer id = (Integer) joinPoint.getArgs()[0]; 202 | Boolean isSuccess = (Boolean) joinPoint.proceed(); 203 | if (isSuccess){ 204 | //删除缓存 205 | CACHE_CONTAINER.remove(CACHE_USER_PROFIX+id); 206 | } 207 | return isSuccess; 208 | } 209 | 210 | } 211 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/sys/controller/MenuController.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.sys.controller; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.core.metadata.IPage; 5 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 6 | import com.dev.warehouse.sys.common.*; 7 | import com.dev.warehouse.sys.entity.Permission; 8 | import com.dev.warehouse.sys.entity.User; 9 | import com.dev.warehouse.sys.service.IPermissionService; 10 | import com.dev.warehouse.sys.service.IRoleService; 11 | import com.dev.warehouse.sys.service.IUserService; 12 | import com.dev.warehouse.sys.vo.PermissionVo; 13 | import org.apache.commons.lang3.StringUtils; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import java.util.*; 19 | 20 | 21 | @RestController 22 | @RequestMapping("/menu") 23 | public class MenuController { 24 | 25 | @Autowired 26 | private IPermissionService permissionService; 27 | 28 | @Autowired 29 | private IUserService userService; 30 | 31 | @Autowired 32 | private IRoleService roleService; 33 | 34 | @RequestMapping("loadIndexLeftMenuJson") 35 | public DataGridView loadIndexLeftMenuJson(PermissionVo permissionVo){ 36 | //查询所有菜单 37 | QueryWrapper queryWrapper = new QueryWrapper(); 38 | //设置查询条件 39 | //查询的必须是菜单,不能是crud的权限 40 | queryWrapper.eq("type", Constast.TYPE_MENU); 41 | //菜单必须可用 42 | queryWrapper.eq("available", Constast.AVAILABLE_TRUE); 43 | 44 | //获得用户 判断用户的类型 45 | User user = (User) WebUtils.getSession().getAttribute("user"); 46 | List list = null; 47 | if (user.getType().equals(Constast.USER_TYPE_SUPER)){ 48 | //用户类型为超级管理员 49 | list = permissionService.list(queryWrapper); 50 | }else { 51 | //用户类型为 普通用户 52 | //根据用户ID+角色+权限去查询 53 | Integer userId = user.getId(); 54 | //1.根据用户ID查询角色 55 | List currentUserRoleIds = roleService.queryUserRoleIdsByUid(userId); 56 | //2.根据角色ID查询菜单ID和权限ID 57 | //使用set去重 58 | Set pids = new HashSet<>(); 59 | for (Integer rid : currentUserRoleIds) { 60 | //根据角色ID查询菜单ID和权限ID 61 | List permissionIds = roleService.queryRolePermissionIdsByRid(rid); 62 | //将菜单ID和权限ID放入Set中去重 63 | pids.addAll(permissionIds); 64 | } 65 | //3.根据角色ID查询权限 66 | if (pids.size()>0){ 67 | queryWrapper.in("id",pids); 68 | list = permissionService.list(queryWrapper); 69 | }else { 70 | list=new ArrayList<>(); 71 | } 72 | 73 | } 74 | 75 | List treeNodes = new ArrayList(); 76 | for (Permission p : list) { 77 | Integer id =p.getId(); 78 | Integer pid = p.getPid(); 79 | String title = p.getTitle(); 80 | String icon = p.getIcon(); 81 | String href = p.getHref(); 82 | Boolean spread = p.getOpen().equals(Constast.OPEN_TRUE)?true:false; 83 | treeNodes.add(new TreeNode(id,pid,title,icon,href,spread)); 84 | } 85 | 86 | //构造层级关系 87 | List list2 = TreeNodeBuilder.build(treeNodes,1); 88 | return new DataGridView(list2); 89 | 90 | } 91 | 92 | 93 | /************************菜单管理*********************************/ 94 | 95 | /** 96 | * 加载菜单左边的菜单树 97 | * @param permissionVo 98 | * @return 99 | */ 100 | @RequestMapping("loadMenuManagerLeftTreeJson") 101 | public DataGridView loadMenuManagerLeftTreeJson(PermissionVo permissionVo){ 102 | 103 | QueryWrapper queryWrapper = new QueryWrapper<>(); 104 | queryWrapper.eq("type",Constast.TYPE_MENU); 105 | //查询出所有的菜单,存放进list中 106 | List list = permissionService.list(queryWrapper); 107 | List treeNodes = new ArrayList<>(); 108 | //将菜单放入treeNodes中,组装成json 109 | for (Permission menu : list) { 110 | Boolean open = menu.getOpen()==1?true:false; 111 | treeNodes.add(new TreeNode(menu.getId(),menu.getPid(),menu.getTitle(),open)); 112 | } 113 | return new DataGridView(treeNodes); 114 | } 115 | 116 | /** 117 | * 查询所有菜单数据 118 | * @param permissionVo 119 | * @return 120 | */ 121 | @RequestMapping("loadAllMenu") 122 | public DataGridView loadAllMenu(PermissionVo permissionVo){ 123 | IPage page = new Page<>(permissionVo.getPage(),permissionVo.getLimit()); 124 | //进行模糊查询 125 | QueryWrapper queryWrapper = new QueryWrapper<>(); 126 | queryWrapper.eq(permissionVo.getId()!=null,"id",permissionVo.getId()).or().eq(permissionVo.getId()!=null,"pid",permissionVo.getId()); 127 | //只能查询菜单 128 | queryWrapper.eq("type",Constast.TYPE_MENU); 129 | queryWrapper.like(StringUtils.isNotBlank(permissionVo.getTitle()),"title",permissionVo.getTitle()); 130 | queryWrapper.orderByAsc("ordernum"); 131 | //进行查询 132 | permissionService.page(page,queryWrapper); 133 | //返回DataGridView 134 | return new DataGridView(page.getTotal(),page.getRecords()); 135 | } 136 | 137 | /** 138 | * 添加菜单 139 | * @param permissionVo 140 | * @return 141 | */ 142 | @RequestMapping("addMenu") 143 | public ResultObj addMenu(PermissionVo permissionVo){ 144 | try { 145 | //设置添加类型为 menu 146 | permissionVo.setType(Constast.TYPE_MENU); 147 | permissionService.save(permissionVo); 148 | return ResultObj.ADD_SUCCESS; 149 | } catch (Exception e) { 150 | e.printStackTrace(); 151 | return ResultObj.ADD_ERROR; 152 | } 153 | } 154 | 155 | /** 156 | * 加载排序码 157 | * @return 158 | */ 159 | @RequestMapping("loadMenuMaxOrderNum") 160 | public Map loadMenuMaxOrderNum(){ 161 | Map map = new HashMap(); 162 | QueryWrapper queryWrapper = new QueryWrapper<>(); 163 | queryWrapper.orderByDesc("ordernum"); 164 | IPage page = new Page<>(1,1); 165 | List list = permissionService.page(page,queryWrapper).getRecords(); 166 | if (list.size()>0){ 167 | map.put("value",list.get(0).getOrdernum()+1); 168 | }else { 169 | map.put("value",1); 170 | } 171 | return map; 172 | } 173 | 174 | /** 175 | * 更新菜单 176 | * @param permissionVo 177 | * @return 178 | */ 179 | @RequestMapping("updateMenu") 180 | public ResultObj updateMenu(PermissionVo permissionVo){ 181 | try { 182 | permissionService.updateById(permissionVo); 183 | return ResultObj.UPDATE_SUCCESS; 184 | } catch (Exception e) { 185 | e.printStackTrace(); 186 | return ResultObj.UPDATE_ERROR; 187 | } 188 | } 189 | 190 | /** 191 | * 检查当前菜单是否有子菜单 192 | * @param permissionVo 193 | * @return 194 | */ 195 | @RequestMapping("checkMenuHasChildrenNode") 196 | public Map checkMenuHasChildrenNode(PermissionVo permissionVo){ 197 | Map map = new HashMap(); 198 | QueryWrapper queryWrapper = new QueryWrapper<>(); 199 | queryWrapper.eq("pid",permissionVo.getId()); 200 | List list = permissionService.list(queryWrapper); 201 | if (list.size()>0){ 202 | map.put("value",true); 203 | }else { 204 | map.put("value",false); 205 | } 206 | return map; 207 | } 208 | 209 | /** 210 | * 删除菜单 211 | * @param permissionVo 212 | * @return 213 | */ 214 | @RequestMapping("deleteMenu") 215 | public ResultObj deleteMenu(PermissionVo permissionVo){ 216 | try { 217 | permissionService.removeById(permissionVo.getId()); 218 | return ResultObj.DELETE_SUCCESS; 219 | } catch (Exception e) { 220 | e.printStackTrace(); 221 | return ResultObj.DELETE_ERROR; 222 | } 223 | } 224 | 225 | 226 | } 227 | -------------------------------------------------------------------------------- /src/main/java/com/dev/warehouse/bus/cache/BusinessCacheAspect.java: -------------------------------------------------------------------------------- 1 | package com.dev.warehouse.bus.cache; 2 | 3 | 4 | import com.dev.warehouse.bus.entity.Customer; 5 | import com.dev.warehouse.bus.entity.Goods; 6 | import com.dev.warehouse.sys.cache.CachePool; 7 | import org.apache.commons.logging.Log; 8 | import org.apache.commons.logging.LogFactory; 9 | import org.aspectj.lang.ProceedingJoinPoint; 10 | import org.aspectj.lang.annotation.Around; 11 | import org.aspectj.lang.annotation.Aspect; 12 | import org.springframework.beans.BeanUtils; 13 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 14 | import org.springframework.stereotype.Component; 15 | 16 | import java.io.Serializable; 17 | import java.util.Collection; 18 | import java.util.Map; 19 | 20 | @Aspect 21 | @Component 22 | @EnableAspectJAutoProxy 23 | public class BusinessCacheAspect { 24 | /** 25 | * 日志出处 26 | */ 27 | private Log log = LogFactory.getLog(BusinessCacheAspect.class); 28 | 29 | /** 30 | * 声明一个缓存容器 31 | */ 32 | private Map CACHE_CONTAINER = CachePool.CACHE_CONTAINER; 33 | 34 | 35 | /** 36 | * 声明客户的切面表达式 37 | */ 38 | private static final String POINTCUT_CUSTOMER_ADD="execution(* com.dev.warehouse.bus.service.impl.CustomerServiceImpl.save(..))"; 39 | private static final String POINTCUT_CUSTOMER_UPDATE="execution(* com.dev.warehouse.bus.service.impl.CustomerServiceImpl.updateById(..))"; 40 | private static final String POINTCUT_CUSTOMER_GET="execution(* com.dev.warehouse.bus.service.impl.CustomerServiceImpl.getById(..))"; 41 | private static final String POINTCUT_CUSTOMER_DELETE="execution(* com.dev.warehouse.bus.service.impl.CustomerServiceImpl.removeById(..))"; 42 | private static final String POINTCUT_CUSTOMER_BATCHDELETE="execution(* com.dev.warehouse.bus.service.impl.CustomerServiceImpl.removeByIds(..))"; 43 | 44 | private static final String CACHE_CUSTOMER_PROFIX="customer:"; 45 | 46 | /** 47 | * 添加客户切入 48 | * @param joinPoint 49 | * @return 50 | */ 51 | @Around(value = POINTCUT_CUSTOMER_ADD) 52 | public Object cacheCustomerAdd(ProceedingJoinPoint joinPoint) throws Throwable { 53 | //取出第一个参数 54 | Customer object = (Customer) joinPoint.getArgs()[0]; 55 | Boolean res = (Boolean) joinPoint.proceed(); 56 | if (res){ 57 | CACHE_CONTAINER.put(CACHE_CUSTOMER_PROFIX + object.getId(),object); 58 | } 59 | return res; 60 | } 61 | 62 | /** 63 | * 查询客户切入 64 | * @param joinPoint 65 | * @return 66 | */ 67 | @Around(value = POINTCUT_CUSTOMER_GET) 68 | public Object cacheCustomerGet(ProceedingJoinPoint joinPoint) throws Throwable { 69 | //取出第一个参数 70 | Integer object = (Integer) joinPoint.getArgs()[0]; 71 | //从缓存里面取 72 | Object res1 = CACHE_CONTAINER.get(CACHE_CUSTOMER_PROFIX + object); 73 | if (res1!=null){ 74 | log.info("已从缓存里面找到客户对象"+CACHE_CUSTOMER_PROFIX + object); 75 | return res1; 76 | }else { 77 | log.info("未从缓存里面找到客户对象,从数据库中查询并放入缓存"); 78 | Customer res2 =(Customer) joinPoint.proceed(); 79 | CACHE_CONTAINER.put(CACHE_CUSTOMER_PROFIX+res2.getId(),res2); 80 | return res2; 81 | } 82 | } 83 | 84 | /** 85 | * 更新客户切入 86 | * @param joinPoint 87 | * @return 88 | */ 89 | @Around(value = POINTCUT_CUSTOMER_UPDATE) 90 | public Object cacheCustomerUpdate(ProceedingJoinPoint joinPoint) throws Throwable { 91 | //取出第一个参数 92 | Customer customerVo = (Customer) joinPoint.getArgs()[0]; 93 | Boolean isSuccess = (Boolean) joinPoint.proceed(); 94 | if (isSuccess){ 95 | Customer customer =(Customer) CACHE_CONTAINER.get(CACHE_CUSTOMER_PROFIX + customerVo.getId()); 96 | if (null==customer){ 97 | customer=new Customer(); 98 | } 99 | BeanUtils.copyProperties(customerVo,customer); 100 | log.info("客户对象缓存已更新"+CACHE_CUSTOMER_PROFIX + customerVo.getId()); 101 | CACHE_CONTAINER.put(CACHE_CUSTOMER_PROFIX+customer.getId(),customer); 102 | } 103 | return isSuccess; 104 | } 105 | 106 | /** 107 | * 删除客户切入 108 | * @param joinPoint 109 | * @return 110 | */ 111 | @Around(value = POINTCUT_CUSTOMER_DELETE) 112 | public Object cacheCustomerDelete(ProceedingJoinPoint joinPoint) throws Throwable { 113 | 114 | //取出第一个参数 115 | Integer id = (Integer) joinPoint.getArgs()[0]; 116 | Boolean isSuccess = (Boolean) joinPoint.proceed(); 117 | if (isSuccess){ 118 | //删除缓存 119 | CACHE_CONTAINER.remove(CACHE_CUSTOMER_PROFIX+id); 120 | } 121 | return isSuccess; 122 | } 123 | 124 | /** 125 | * 批量删除客户切入 126 | * 127 | * @throws Throwable 128 | */ 129 | @Around(value = POINTCUT_CUSTOMER_BATCHDELETE) 130 | public Object cacheCustomerBatchDelete(ProceedingJoinPoint joinPoint) throws Throwable { 131 | // 取出第一个参数 132 | @SuppressWarnings("unchecked") 133 | Collection idList = (Collection) joinPoint.getArgs()[0]; 134 | Boolean isSuccess = (Boolean) joinPoint.proceed(); 135 | if (isSuccess) { 136 | for (Serializable id : idList) { 137 | // 删除缓存 138 | CACHE_CONTAINER.remove(CACHE_CUSTOMER_PROFIX + id); 139 | log.info("客户对象缓存已删除" + CACHE_CUSTOMER_PROFIX + id); 140 | } 141 | } 142 | return isSuccess; 143 | } 144 | 145 | 146 | /** 147 | * 声明商品的切面表达式 148 | */ 149 | private static final String POINTCUT_GOODS_ADD="execution(* com.dev.warehouse.bus.service.impl.GoodsServiceImpl.save(..))"; 150 | private static final String POINTCUT_GOODS_UPDATE="execution(* com.dev.warehouse.bus.service.impl.GoodsServiceImpl.updateById(..))"; 151 | private static final String POINTCUT_GOODS_GET="execution(* com.dev.warehouse.bus.service.impl.GoodsServiceImpl.getById(..))"; 152 | private static final String POINTCUT_GOODS_DELETE="execution(* com.dev.warehouse.bus.service.impl.GoodsServiceImpl.removeById(..))"; 153 | 154 | private static final String CACHE_GOODS_PROFIX="goods:"; 155 | 156 | /** 157 | * 添加商品切入 158 | * @param joinPoint 159 | * @return 160 | */ 161 | @Around(value = POINTCUT_GOODS_ADD) 162 | public Object cacheGoodsAdd(ProceedingJoinPoint joinPoint) throws Throwable { 163 | //取出第一个参数 164 | Goods object = (Goods) joinPoint.getArgs()[0]; 165 | Boolean res = (Boolean) joinPoint.proceed(); 166 | if (res){ 167 | CACHE_CONTAINER.put(CACHE_GOODS_PROFIX + object.getId(),object); 168 | } 169 | return res; 170 | } 171 | 172 | /** 173 | * 查询商品切入 174 | * @param joinPoint 175 | * @return 176 | */ 177 | @Around(value = POINTCUT_GOODS_GET) 178 | public Object cacheGoodsGet(ProceedingJoinPoint joinPoint) throws Throwable { 179 | //取出第一个参数 180 | Integer object = (Integer) joinPoint.getArgs()[0]; 181 | //从缓存里面取 182 | Object res1 = CACHE_CONTAINER.get(CACHE_GOODS_PROFIX + object); 183 | if (res1!=null){ 184 | log.info("已从缓存里面找到商品对象"+CACHE_GOODS_PROFIX + object); 185 | return res1; 186 | }else { 187 | log.info("未从缓存里面找到商品对象,从数据库中查询并放入缓存"); 188 | Goods res2 =(Goods) joinPoint.proceed(); 189 | CACHE_CONTAINER.put(CACHE_GOODS_PROFIX+res2.getId(),res2); 190 | return res2; 191 | } 192 | } 193 | 194 | /** 195 | * 更新商品切入 196 | * @param joinPoint 197 | * @return 198 | */ 199 | @Around(value = POINTCUT_GOODS_UPDATE) 200 | public Object cacheGoodsUpdate(ProceedingJoinPoint joinPoint) throws Throwable { 201 | //取出第一个参数 202 | Goods goodsVo = (Goods) joinPoint.getArgs()[0]; 203 | Boolean isSuccess = (Boolean) joinPoint.proceed(); 204 | if (isSuccess){ 205 | Goods goods =(Goods) CACHE_CONTAINER.get(CACHE_GOODS_PROFIX + goodsVo.getId()); 206 | if (null==goods){ 207 | goods=new Goods(); 208 | } 209 | BeanUtils.copyProperties(goodsVo,goods); 210 | log.info("商品对象缓存已更新"+CACHE_GOODS_PROFIX + goodsVo.getId()); 211 | CACHE_CONTAINER.put(CACHE_GOODS_PROFIX+goods.getId(),goods); 212 | } 213 | return isSuccess; 214 | } 215 | 216 | /** 217 | * 删除商品切入 218 | * @param joinPoint 219 | * @return 220 | */ 221 | @Around(value = POINTCUT_GOODS_DELETE) 222 | public Object cacheGoodsDelete(ProceedingJoinPoint joinPoint) throws Throwable { 223 | 224 | //取出第一个参数 225 | Integer id = (Integer) joinPoint.getArgs()[0]; 226 | Boolean isSuccess = (Boolean) joinPoint.proceed(); 227 | if (isSuccess){ 228 | //删除缓存 229 | CACHE_CONTAINER.remove(CACHE_GOODS_PROFIX+id); 230 | } 231 | return isSuccess; 232 | } 233 | 234 | 235 | } 236 | --------------------------------------------------------------------------------