src/main/java/com/xcong/farmer/cms/modules/system/controller/AdminCompanyController.java
File was renamed from src/main/java/com/xcong/farmer/cms/modules/system/controller/AdminBelongController.java @@ -2,8 +2,8 @@ import com.xcong.farmer.cms.common.response.Result; import com.xcong.farmer.cms.modules.system.dto.*; import com.xcong.farmer.cms.modules.system.service.IBelongService; import com.xcong.farmer.cms.modules.system.vo.AdminBelongVo; import com.xcong.farmer.cms.modules.system.service.ICompanyService; import com.xcong.farmer.cms.modules.system.vo.AdminCompanyVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; @@ -18,20 +18,20 @@ @RequestMapping(value = "/api/belong") @Slf4j @Api(value = "系统所属公司", tags = "系统所属公司") public class AdminBelongController { public class AdminCompanyController { @Resource private IBelongService iBelongService; private ICompanyService iBelongService; @ApiOperation(value = "系统所属公司分页列表", notes = "系统所属公司分页列表") @ApiResponses({@ApiResponse(code = 200, message = "ok", response = AdminBelongVo.class)}) @ApiResponses({@ApiResponse(code = 200, message = "ok", response = AdminCompanyVo.class)}) @PostMapping(value = "/belongInPage") public Result getBelongInPage(@RequestBody @Valid AdminBelongDto adminBelongDto) { return iBelongService.getBelongInPage(adminBelongDto); } @ApiOperation(value = "系统所属公司列表", notes = "系统所属公司列表") @ApiResponses({@ApiResponse(code = 200, message = "ok", response = AdminBelongVo.class)}) @ApiResponses({@ApiResponse(code = 200, message = "ok", response = AdminCompanyVo.class)}) @GetMapping(value = "/belongInList") public Result getBelongInList() { return iBelongService.getBelongInList(); @@ -39,8 +39,8 @@ @ApiOperation(value = "添加系统所属公司", notes = "添加系统所属公司") @PostMapping(value = "/addBelong") public Result addBelong(@RequestBody @Valid AdminAddBelongDto adminAddBelongDto) { return iBelongService.addBelong(adminAddBelongDto); public Result addBelong(@RequestBody @Valid AdminAddCompanyDto adminAddCompanyDto) { return iBelongService.addBelong(adminAddCompanyDto); } @ApiOperation(value = "查看系统所属公司", notes = "查看系统所属公司") @@ -51,8 +51,8 @@ @ApiOperation(value = "更新系统所属公司", notes = "更新系统所属公司") @PostMapping(value = "/updateBelong") public Result updateBelong(@RequestBody @Valid AdminUpdateBelongDto adminUpdateBelongDto) { return iBelongService.updateBelong(adminUpdateBelongDto); public Result updateBelong(@RequestBody @Valid AdminUpdateCompanyDto adminUpdateCompanyDto) { return iBelongService.updateBelong(adminUpdateCompanyDto); } @ApiOperation(value = "删除系统所属公司", notes = "删除系统所属公司") src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminAddArticleDto.java
@@ -51,4 +51,7 @@ @ApiModelProperty(value = "文章详情") private String articleDetails; @ApiModelProperty(value = "上传附件") private String uploadFile; } src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminAddBarDto.java
@@ -4,11 +4,14 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; @Data @ApiModel(value = "AdminAddBarDto", description = "参数接收类") public class AdminAddBarDto { //导航栏标题 @ApiModelProperty(value = "导航栏标题") @NotBlank(message = "请输入导航栏标题") private String barName; //链接地址 @ApiModelProperty(value = "链接地址") src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminAddColumnDto.java
@@ -4,14 +4,18 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; @Data @ApiModel(value = "AdminAddColumnDto", description = "参数接收类") public class AdminAddColumnDto { @ApiModelProperty(value = "栏目名称") @NotBlank(message = "请输入栏目名称") private String columnName; @ApiModelProperty(value = "栏目编码") @NotBlank(message = "请输入栏目编码") private String columnCode; @ApiModelProperty(value = "描述") src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminAddCompanyDto.java
File was renamed from src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminAddBelongDto.java @@ -4,14 +4,18 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; @Data @ApiModel(value = "AdminAddBelongDto", description = "参数接收类") public class AdminAddBelongDto { public class AdminAddCompanyDto { @ApiModelProperty(value = "名称") @NotBlank(message = "请输入文章标题") private String name; @ApiModelProperty(value = "编码") @NotBlank(message = "请输入编码") private String code; @ApiModelProperty(value = "网址") src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminAddMenuDto.java
@@ -4,14 +4,19 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "AdminAddMenuDto", description = "参数接收类") public class AdminAddMenuDto { @ApiModelProperty(value = "菜单按钮标题") @NotBlank(message = "请输入菜单名称") private String menuName; @ApiModelProperty(value = "菜单类型 1:菜单 2:按钮") @NotNull(message = "请输入菜单类型") private Integer menuType; @ApiModelProperty(value = "路由地址") src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminUpdateArticleDto.java
@@ -55,4 +55,7 @@ @ApiModelProperty(value = "文章详情") private String articleDetails; @ApiModelProperty(value = "上传附件") private String uploadFile; } src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminUpdateBarDto.java
@@ -4,12 +4,15 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; @Data @ApiModel(value = "AdminUpdateBarDto", description = "参数接收类") public class AdminUpdateBarDto { private Long id; //导航栏标题 @ApiModelProperty(value = "导航栏标题") @NotBlank(message = "请输入导航栏标题") private String barName; //链接地址 @ApiModelProperty(value = "链接地址") src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminUpdateColumnDto.java
@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; @Data @ApiModel(value = "AdminUpdateColumnDto", description = "参数接收类") public class AdminUpdateColumnDto { @@ -11,9 +13,11 @@ private Long id; @ApiModelProperty(value = "栏目名称") @NotBlank(message = "请输入栏目名称") private String columnName; @ApiModelProperty(value = "栏目编码") @NotBlank(message = "请输入栏目编码") private String columnCode; @ApiModelProperty(value = "描述") src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminUpdateCompanyDto.java
File was renamed from src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminUpdateBelongDto.java @@ -4,16 +4,20 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; @Data @ApiModel(value = "AdminUpdateBelongDto", description = "参数接收类") public class AdminUpdateBelongDto { public class AdminUpdateCompanyDto { private Long id; @ApiModelProperty(value = "名称") @NotBlank(message = "请输入文章标题") private String name; @ApiModelProperty(value = "编码") @NotBlank(message = "请输入编码") private String code; @ApiModelProperty(value = "网址") src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminUpdateMenuDto.java
@@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "AdminUpdateMenuDto", description = "参数接收类") public class AdminUpdateMenuDto { @@ -12,9 +15,11 @@ private Long id; @ApiModelProperty(value = "菜单按钮标题") @NotBlank(message = "请输入菜单名称") private String menuName; @ApiModelProperty(value = "菜单类型 1:菜单 2:按钮") @NotNull(message = "请输入菜单类型") private Integer menuType; @ApiModelProperty(value = "路由地址") src/main/java/com/xcong/farmer/cms/modules/system/entity/ArticleEntity.java
@@ -59,9 +59,11 @@ private Integer releaseStatus; //文章详情 private String articleDetails; //上传附件 private String uploadFile; //是否删除 0:已删除 1:未删除 private Integer delStatus; //所属ID private Long belongId; private Long companyId; } src/main/java/com/xcong/farmer/cms/modules/system/entity/ColumnEntity.java
@@ -28,5 +28,5 @@ //上级类目ID private Long parentId; //所属ID private Long belongId; private Long companyId; } src/main/java/com/xcong/farmer/cms/modules/system/entity/CompanyEntity.java
File was renamed from src/main/java/com/xcong/farmer/cms/modules/system/entity/BelongEntity.java @@ -9,8 +9,8 @@ * 所属公司范围表 */ @Data @TableName("t_belong") public class BelongEntity { @TableName("t_company") public class CompanyEntity { //ID @TableId(value = "id",type = IdType.AUTO) src/main/java/com/xcong/farmer/cms/modules/system/entity/NavigationBarEntity.java
@@ -28,6 +28,6 @@ //上级类目ID private Long parentId; //所属ID private Long belongId; private Long companyId; } src/main/java/com/xcong/farmer/cms/modules/system/entity/RoleEntity.java
@@ -26,5 +26,5 @@ //拓展备注 private String remark; //所属ID private Long belongId; private Long companyId; } src/main/java/com/xcong/farmer/cms/modules/system/entity/UserEntity.java
@@ -47,7 +47,7 @@ //拓展备注 private String remark; //所属ID private Long belongId; private Long companyId; @TableField(exist = false) private String roleName; src/main/java/com/xcong/farmer/cms/modules/system/entity/WebSetEntity.java
@@ -24,5 +24,5 @@ //网页LOGO private String webPic; //所属ID private Long belongId; private Long companyId; } src/main/java/com/xcong/farmer/cms/modules/system/mapper/BelongMapper.java
File was deleted src/main/java/com/xcong/farmer/cms/modules/system/mapper/CompanyMapper.java
New file @@ -0,0 +1,14 @@ package com.xcong.farmer.cms.modules.system.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.xcong.farmer.cms.modules.system.entity.CompanyEntity; import com.xcong.farmer.cms.modules.system.vo.AdminCompanyVo; import org.apache.ibatis.annotations.Param; public interface CompanyMapper extends BaseMapper<CompanyEntity> { IPage<AdminCompanyVo> selectAdminBelongInPage(Page<AdminCompanyVo> page, @Param("record") CompanyEntity companyEntity); } src/main/java/com/xcong/farmer/cms/modules/system/service/IBelongService.java
File was deleted src/main/java/com/xcong/farmer/cms/modules/system/service/ICompanyService.java
New file @@ -0,0 +1,24 @@ package com.xcong.farmer.cms.modules.system.service; import com.baomidou.mybatisplus.extension.service.IService; import com.xcong.farmer.cms.common.response.Result; import com.xcong.farmer.cms.modules.system.dto.AdminAddCompanyDto; import com.xcong.farmer.cms.modules.system.dto.AdminBelongDto; import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto; import com.xcong.farmer.cms.modules.system.dto.AdminUpdateCompanyDto; import com.xcong.farmer.cms.modules.system.entity.CompanyEntity; public interface ICompanyService extends IService<CompanyEntity> { Result getBelongInPage(AdminBelongDto adminBelongDto); Result addBelong(AdminAddCompanyDto adminAddCompanyDto); Result seeBelongInfo(Long id); Result updateBelong(AdminUpdateCompanyDto adminUpdateCompanyDto); Result getBelongInList(); Result delObjs(AdminDeleteDto adminDeleteDto); } src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java
@@ -43,7 +43,7 @@ @Override public Result getArticleInPage(AdminArticleDto adminArticleDto) { UserEntity userlogin = LoginUserUtil.getLoginUser(); long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); Page<AdminArticleVo> page = new Page<>(adminArticleDto.getPageNum(), adminArticleDto.getPageSize()); ArticleEntity articleEntity = new ArticleEntity(); Long columnId = adminArticleDto.getColumnId() == null ? 0L : adminArticleDto.getColumnId(); @@ -54,8 +54,8 @@ if(StrUtil.isNotEmpty(title)){ articleEntity.setTitle(title); } if(UserEntity.USER_BELONG_TOP != belongId){ articleEntity.setBelongId(belongId); if(UserEntity.USER_BELONG_TOP != companyId){ articleEntity.setCompanyId(companyId); } IPage<AdminArticleVo> list = this.baseMapper.selectAdminArticleInPage(page,articleEntity); return Result.ok(list); @@ -65,27 +65,19 @@ @Transactional public Result addArticle(AdminAddArticleDto adminAddArticleDto) { UserEntity userlogin = LoginUserUtil.getLoginUser(); long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); ArticleEntity articleEntity = new ArticleEntity(); articleEntity.setBelongId(belongId); articleEntity.setCompanyId(companyId); String title = adminAddArticleDto.getTitle(); articleEntity.setTitle(title); String childTitle = adminAddArticleDto.getChildTitle(); if(StrUtil.isNotEmpty(childTitle)){ articleEntity.setChildTitle(childTitle); } String author = adminAddArticleDto.getAuthor(); if(StrUtil.isNotEmpty(author)){ articleEntity.setAuthor(author); } String authorBelong = adminAddArticleDto.getAuthorBelong(); if(StrUtil.isNotEmpty(authorBelong)){ articleEntity.setAuthorBelong(authorBelong); } String remark = adminAddArticleDto.getRemark(); if(StrUtil.isNotEmpty(remark)){ articleEntity.setRemark(remark); } long columnId = adminAddArticleDto.getColumnId() == null ? 0L : adminAddArticleDto.getColumnId(); ColumnEntity columnEntity = columnMapper.selectById(columnId); if(ObjectUtil.isEmpty(columnEntity)){ @@ -95,24 +87,17 @@ Integer visits = adminAddArticleDto.getVisits() == null ? 0 : adminAddArticleDto.getVisits(); articleEntity.setVisits(visits); String mainDiagram = adminAddArticleDto.getMainDiagram(); if(StrUtil.isNotEmpty(mainDiagram)){ articleEntity.setMainDiagram(mainDiagram); } String atlas = adminAddArticleDto.getAtlas(); if(StrUtil.isNotEmpty(atlas)){ articleEntity.setAtlas(atlas); } Date releaseTime = adminAddArticleDto.getReleaseTime(); if(ObjectUtil.isNotEmpty(releaseTime)){ articleEntity.setReleaseTime(releaseTime); } Integer releaseStatus = adminAddArticleDto.getReleaseStatus(); articleEntity.setReleaseStatus(releaseStatus); String articleDetails = adminAddArticleDto.getArticleDetails(); if(StrUtil.isNotEmpty(articleDetails)){ articleEntity.setArticleDetails(articleDetails); } String uploadFile = adminAddArticleDto.getUploadFile(); articleEntity.setUploadFile(uploadFile); this.baseMapper.insert(articleEntity); return Result.ok("添加成功"); } @@ -180,6 +165,8 @@ articleEntity.setReleaseStatus(releaseStatus); String articleDetails = adminUpdateArticleDto.getArticleDetails(); articleEntity.setArticleDetails(articleDetails); String uploadFile = adminUpdateArticleDto.getUploadFile(); articleEntity.setUploadFile(uploadFile); this.baseMapper.updateById(articleEntity); return Result.ok("更新成功"); } src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/BelongServiceImpl.java
File was deleted src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ColumnServiceImpl.java
@@ -35,10 +35,10 @@ @Override public Result getColumnInPage(AdminColumnDto adminColumnDto) { UserEntity userlogin = LoginUserUtil.getLoginUser(); long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); Page<AdminColumnVo> page = new Page<>(adminColumnDto.getPageNum(), adminColumnDto.getPageSize()); ColumnEntity columnEntity = new ColumnEntity(); columnEntity.setBelongId(belongId); columnEntity.setCompanyId(companyId); columnEntity.setParentId(ColumnEntity.PARENTID_DEFAULT); IPage<AdminColumnVo> list = this.baseMapper.selectAdminColumnVoInPage(page,columnEntity); List<AdminColumnVo> records = list.getRecords(); @@ -47,7 +47,7 @@ Long id = adminColumnVo.getId(); QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>(); objectQueryWrapper.eq("parent_id",id); objectQueryWrapper.eq("belong_id",belongId); objectQueryWrapper.eq("company_id",companyId); List<ColumnEntity> columnEntities = this.baseMapper.selectList(objectQueryWrapper); List<AdminColumnVo> adminColumnVoChilds = new ArrayList<>(); if(CollUtil.isNotEmpty(columnEntities)){ @@ -72,18 +72,12 @@ @Transactional public Result addColumn(AdminAddColumnDto adminAddColumnDto) { UserEntity userlogin = LoginUserUtil.getLoginUser(); long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); ColumnEntity columnEntity = new ColumnEntity(); columnEntity.setBelongId(belongId); columnEntity.setCompanyId(companyId); String columnName = adminAddColumnDto.getColumnName(); if(StrUtil.isEmpty(columnName)){ return Result.fail("请输入栏目名称"); } columnEntity.setColumnName(columnName); String columnCode = adminAddColumnDto.getColumnCode(); if(StrUtil.isEmpty(columnCode)){ return Result.fail("请输入栏目编码"); } QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>(); objectQueryWrapper.eq("column_code",columnCode); List<ColumnEntity> columnEntities = this.baseMapper.selectList(objectQueryWrapper); @@ -92,13 +86,9 @@ } columnEntity.setColumnCode(columnCode); String remark = adminAddColumnDto.getRemark(); if(StrUtil.isNotEmpty(remark)){ columnEntity.setRemark(remark); } String pic = adminAddColumnDto.getPic(); if(StrUtil.isNotEmpty(pic)){ columnEntity.setPic(pic); } Integer orderNum = adminAddColumnDto.getOrderNum(); if(ObjectUtil.isNotEmpty(orderNum)){ columnEntity.setOrderNum(orderNum); @@ -159,14 +149,8 @@ return Result.fail("栏目不存在"); } String columnName = adminUpdateColumnDto.getColumnName(); if(StrUtil.isEmpty(columnName)){ return Result.fail("请输入栏目名称"); } columnEntity.setColumnName(columnName); String columnCode = adminUpdateColumnDto.getColumnCode(); if(StrUtil.isEmpty(columnCode)){ return Result.fail("请输入栏目编码"); } QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>(); objectQueryWrapper.eq("column_code",columnCode); List<ColumnEntity> columnEntities = this.baseMapper.selectList(objectQueryWrapper); @@ -175,13 +159,9 @@ } columnEntity.setColumnCode(columnCode); String remark = adminUpdateColumnDto.getRemark(); if(StrUtil.isNotEmpty(remark)){ columnEntity.setRemark(remark); } String pic = adminUpdateColumnDto.getPic(); if(StrUtil.isNotEmpty(pic)){ columnEntity.setPic(pic); } Integer orderNum = adminUpdateColumnDto.getOrderNum(); if(ObjectUtil.isNotEmpty(orderNum)){ columnEntity.setOrderNum(orderNum); @@ -199,14 +179,14 @@ @Override public Result getColumnInList() { UserEntity userlogin = LoginUserUtil.getLoginUser(); long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); List<AdminColumnVo> records = this.baseMapper.selectColumnInListByParentId(ColumnEntity.PARENTID_DEFAULT,belongId); long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); List<AdminColumnVo> records = this.baseMapper.selectColumnInListByParentId(ColumnEntity.PARENTID_DEFAULT,companyId); if(CollUtil.isNotEmpty(records)){ for(AdminColumnVo adminColumnVo : records){ Long id = adminColumnVo.getId(); QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>(); objectQueryWrapper.eq("parent_id",id); objectQueryWrapper.eq("belong_id",belongId); objectQueryWrapper.eq("company_id",companyId); List<ColumnEntity> columnEntities = this.baseMapper.selectList(objectQueryWrapper); List<AdminColumnVo> adminColumnVoChilds = new ArrayList<>(); if(CollUtil.isNotEmpty(columnEntities)){ src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CompanyServiceImpl.java
New file @@ -0,0 +1,156 @@ package com.xcong.farmer.cms.modules.system.service.Impl; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xcong.farmer.cms.common.response.Result; import com.xcong.farmer.cms.modules.system.dto.AdminAddCompanyDto; import com.xcong.farmer.cms.modules.system.dto.AdminBelongDto; import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto; import com.xcong.farmer.cms.modules.system.dto.AdminUpdateCompanyDto; import com.xcong.farmer.cms.modules.system.entity.CompanyEntity; import com.xcong.farmer.cms.modules.system.entity.UserEntity; import com.xcong.farmer.cms.modules.system.mapper.CompanyMapper; import com.xcong.farmer.cms.modules.system.service.ICompanyService; import com.xcong.farmer.cms.modules.system.util.LoginUserUtil; import com.xcong.farmer.cms.modules.system.vo.AdminCompanyVo; import com.xcong.farmer.cms.modules.system.vo.AdminSeeCompanyInfoVo; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import org.springframework.transaction.annotation.Transactional; @Service @Slf4j public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyEntity> implements ICompanyService { @Override public Result getBelongInPage(AdminBelongDto adminBelongDto) { UserEntity userlogin = LoginUserUtil.getLoginUser(); Long belongId = userlogin.getCompanyId(); Page<AdminCompanyVo> page = new Page<>(adminBelongDto.getPageNum(), adminBelongDto.getPageSize()); CompanyEntity companyEntity = new CompanyEntity(); String name = adminBelongDto.getName(); if(StrUtil.isNotEmpty(name)){ companyEntity.setName(name); } if(belongId != UserEntity.USER_BELONG_TOP){ companyEntity.setId(belongId); } IPage<AdminCompanyVo> list = this.baseMapper.selectAdminBelongInPage(page, companyEntity); return Result.ok(list); } @Override @Transactional public Result addBelong(AdminAddCompanyDto adminAddCompanyDto) { String name = adminAddCompanyDto.getName(); String code = adminAddCompanyDto.getCode(); QueryWrapper<CompanyEntity> objectQueryWrapper = new QueryWrapper<>(); objectQueryWrapper.eq("code",code); List<CompanyEntity> belongEntities = this.baseMapper.selectList(objectQueryWrapper); if(CollUtil.isNotEmpty(belongEntities)){ return Result.fail("编码已存在,请重新输入"); } CompanyEntity companyEntity = new CompanyEntity(); companyEntity.setName(name); companyEntity.setCode(code); String webAddress = adminAddCompanyDto.getWebAddress(); companyEntity.setWebAddress(webAddress); String remark = adminAddCompanyDto.getRemark(); companyEntity.setRemark(remark); String pic = adminAddCompanyDto.getPic(); companyEntity.setPic(pic); this.baseMapper.insert(companyEntity); return Result.ok("添加成功"); } @Override public Result seeBelongInfo(Long id) { CompanyEntity companyEntity = this.baseMapper.selectById(id); if(ObjectUtil.isEmpty(companyEntity)){ Result.fail("所属公司不存在"); } AdminSeeCompanyInfoVo adminSeeCompanyInfoVo = new AdminSeeCompanyInfoVo(); adminSeeCompanyInfoVo.setId(companyEntity.getId()); adminSeeCompanyInfoVo.setName(companyEntity.getName()); adminSeeCompanyInfoVo.setCode(companyEntity.getCode()); adminSeeCompanyInfoVo.setRemark(companyEntity.getRemark()); adminSeeCompanyInfoVo.setWebAddress(companyEntity.getWebAddress()); adminSeeCompanyInfoVo.setPic(companyEntity.getPic()); return Result.ok(adminSeeCompanyInfoVo); } @Override @Transactional public Result updateBelong(AdminUpdateCompanyDto adminUpdateCompanyDto) { Long id = adminUpdateCompanyDto.getId(); CompanyEntity companyEntity = this.baseMapper.selectById(id); if(ObjectUtil.isEmpty(companyEntity)){ Result.fail("所属公司不存在"); } String name = adminUpdateCompanyDto.getName(); companyEntity.setName(name); String code = adminUpdateCompanyDto.getCode(); if(!companyEntity.getCode().equals(code)){ QueryWrapper<CompanyEntity> objectQueryWrapper = new QueryWrapper<>(); objectQueryWrapper.eq("code",code); List<CompanyEntity> belongEntities = this.baseMapper.selectList(objectQueryWrapper); if(CollUtil.isNotEmpty(belongEntities)){ return Result.fail("编码已存在,请重新输入"); } companyEntity.setCode(code); } companyEntity.setWebAddress(adminUpdateCompanyDto.getWebAddress()); companyEntity.setRemark(adminUpdateCompanyDto.getRemark()); companyEntity.setPic(adminUpdateCompanyDto.getPic()); this.baseMapper.updateById(companyEntity); return Result.ok("更新成功"); } @Override public Result getBelongInList() { UserEntity userlogin = LoginUserUtil.getLoginUser(); Long companyId = userlogin.getCompanyId(); QueryWrapper<CompanyEntity> objectQueryWrapper = new QueryWrapper<>(); if(companyId != UserEntity.USER_BELONG_TOP){ objectQueryWrapper.eq("id",companyId); } List<CompanyEntity> belongEntities = this.baseMapper.selectList(objectQueryWrapper); List<AdminCompanyVo> adminCompanyVos = new ArrayList<>(); if(CollUtil.isNotEmpty(belongEntities)){ for(CompanyEntity companyEntity : belongEntities){ AdminCompanyVo adminCompanyVo = new AdminCompanyVo(); adminCompanyVo.setId(companyEntity.getId()); adminCompanyVo.setName(companyEntity.getName()); adminCompanyVo.setCode(companyEntity.getCode()); adminCompanyVos.add(adminCompanyVo); } } return Result.ok(adminCompanyVos); } @Override public Result delObjs(AdminDeleteDto adminDeleteDto) { String ids = adminDeleteDto.getIds(); UserEntity userlogin = LoginUserUtil.getLoginUser(); if(userlogin.getCompanyId() != UserEntity.USER_BELONG_TOP){ return Result.fail("没有删除权限"); } if(StrUtil.isNotEmpty(ids)){ String[] companyIds = ids.split(StringPool.COMMA); for(String companyIdStr : companyIds){ Long companyId = Long.valueOf(companyIdStr); this.baseMapper.deleteById(companyId); } } return Result.ok("删除成功"); } } src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/MenuServiceImpl.java
@@ -80,13 +80,7 @@ public Result addMenu(AdminAddMenuDto adminAddMenuDto) { UserEntity userlogin = LoginUserUtil.getLoginUser(); String menuName = adminAddMenuDto.getMenuName(); if(StrUtil.isEmpty(menuName)){ return Result.fail("请输入菜单名称"); } Integer menuType = adminAddMenuDto.getMenuType(); if(ObjectUtil.isEmpty(menuType)){ return Result.fail("请输入菜单类型"); } MenuEntity menuEntity = new MenuEntity(); menuEntity.setMenuName(menuName); menuEntity.setMenuType(menuType); @@ -151,14 +145,8 @@ return Result.fail("菜单不存在"); } String menuName = adminUpdateMenuDto.getMenuName(); if(StrUtil.isEmpty(menuName)){ return Result.fail("请输入菜单名称"); } menuEntity.setMenuName(menuName); Integer menuType = adminUpdateMenuDto.getMenuType(); if(ObjectUtil.isEmpty(menuType)){ return Result.fail("请输入菜单类型"); } menuEntity.setMenuType(menuType); String routeUrl = adminUpdateMenuDto.getRouteUrl(); if(StrUtil.isNotEmpty(routeUrl)){ @@ -207,7 +195,6 @@ Long id = adminMenuVo.getId(); QueryWrapper<MenuEntity> objectQueryWrapper = new QueryWrapper<>(); objectQueryWrapper.eq("parent_id",id); // objectQueryWrapper.eq("belong_id",belongId); List<MenuEntity> menuEntities = this.baseMapper.selectList(objectQueryWrapper); List<AdminMenuVo> adminMenuVoChilds = new ArrayList<>(); if(CollUtil.isNotEmpty(menuEntities)){ src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/NavigationBarServiceImpl.java
@@ -42,11 +42,11 @@ @Override public Result getBarInPage(AdminNavigationBarDto adminNavigationBarDto) { UserEntity userlogin = LoginUserUtil.getLoginUser(); long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); Page<AdminNavigationBarVo> page = new Page<>(adminNavigationBarDto.getPageNum(), adminNavigationBarDto.getPageSize()); NavigationBarEntity navigationBarEntity = new NavigationBarEntity(); navigationBarEntity.setParentId(NavigationBarEntity.PARENTID_DEFAULT); navigationBarEntity.setBelongId(belongId); navigationBarEntity.setCompanyId(companyId); IPage<AdminNavigationBarVo> list = navigationBarMapper.selectAdminNavigationBarVoInPage(page,navigationBarEntity); List<AdminNavigationBarVo> records = list.getRecords(); if(CollUtil.isNotEmpty(records)){ @@ -78,13 +78,10 @@ @Transactional public Result addBar(AdminAddBarDto adminAddBarDto) { UserEntity userlogin = LoginUserUtil.getLoginUser(); long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); NavigationBarEntity navigationBarEntity = new NavigationBarEntity(); navigationBarEntity.setBelongId(belongId); navigationBarEntity.setCompanyId(companyId); String barName = adminAddBarDto.getBarName(); if(StrUtil.isEmpty(barName)){ return Result.fail("请输入导航栏标题"); } navigationBarEntity.setBarName(barName); Long parentId = adminAddBarDto.getParentId(); if(ObjectUtil.isEmpty(parentId)){ @@ -93,21 +90,13 @@ navigationBarEntity.setParentId(parentId); } String linkUrl = adminAddBarDto.getLinkUrl(); if(StrUtil.isNotEmpty(linkUrl)){ navigationBarEntity.setLinkUrl(linkUrl); } Integer orderNum = adminAddBarDto.getOrderNum(); if(ObjectUtil.isNotEmpty(orderNum)){ navigationBarEntity.setOrderNum(orderNum); } String pic = adminAddBarDto.getPic(); if(StrUtil.isNotEmpty(pic)){ navigationBarEntity.setPic(pic); } String remark = adminAddBarDto.getRemark(); if(StrUtil.isNotEmpty(remark)){ navigationBarEntity.setRemark(remark); } navigationBarMapper.insert(navigationBarEntity); return Result.ok("添加成功"); } @@ -158,9 +147,6 @@ return Result.fail("导航栏不存在"); } String barName = adminUpdateMenuDto.getBarName(); if(StrUtil.isEmpty(barName)){ return Result.fail("请输入导航栏标题"); } navigationBarEntity.setBarName(barName); Long parentId = adminUpdateMenuDto.getParentId(); if(ObjectUtil.isEmpty(parentId)){ @@ -169,21 +155,13 @@ navigationBarEntity.setParentId(parentId); } String linkUrl = adminUpdateMenuDto.getLinkUrl(); if(StrUtil.isNotEmpty(linkUrl)){ navigationBarEntity.setLinkUrl(linkUrl); } Integer orderNum = adminUpdateMenuDto.getOrderNum(); if(ObjectUtil.isNotEmpty(orderNum)){ navigationBarEntity.setOrderNum(orderNum); } String pic = adminUpdateMenuDto.getPic(); if(StrUtil.isNotEmpty(pic)){ navigationBarEntity.setPic(pic); } String remark = adminUpdateMenuDto.getRemark(); if(StrUtil.isNotEmpty(remark)){ navigationBarEntity.setRemark(remark); } navigationBarMapper.updateById(navigationBarEntity); return Result.ok("更新成功"); } @@ -191,12 +169,12 @@ @Override public Result getBarInList() { UserEntity userlogin = LoginUserUtil.getLoginUser(); long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); List<AdminNavigationBarVo> records = navigationBarMapper.selectAdminNavigationBarVoByParentId(NavigationBarEntity.PARENTID_DEFAULT,belongId); long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); List<AdminNavigationBarVo> records = navigationBarMapper.selectAdminNavigationBarVoByParentId(NavigationBarEntity.PARENTID_DEFAULT,companyId); if(CollUtil.isNotEmpty(records)){ for(AdminNavigationBarVo adminNavigationBarVo : records){ Long id = adminNavigationBarVo.getId(); List<NavigationBarEntity> navigationBarEntities = navigationBarMapper.selectListByParentId(id,belongId); List<NavigationBarEntity> navigationBarEntities = navigationBarMapper.selectListByParentId(id,companyId); List<AdminNavigationBarVo> adminNavigationBarVoChilds = new ArrayList<>(); if(CollUtil.isNotEmpty(navigationBarEntities)){ for(NavigationBarEntity navigationBarEntityChild : navigationBarEntities){ src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/RoleServiceImpl.java
@@ -50,12 +50,12 @@ UserEntity userlogin = LoginUserUtil.getLoginUser(); Page<AdminRoleVo> page = new Page<>(adminRoleDto.getPageNum(), adminRoleDto.getPageSize()); RoleEntity roleEntity = new RoleEntity(); Long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); Long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); if(StrUtil.isNotEmpty(adminRoleDto.getRoleName())){ roleEntity.setRoleName(adminRoleDto.getRoleName()); } if(belongId > UserEntity.USER_BELONG_TOP){ roleEntity.setBelongId(belongId); if(companyId > UserEntity.USER_BELONG_TOP){ roleEntity.setCompanyId(companyId); } IPage<AdminRoleVo> list = this.baseMapper.selectAdminRoleVoInPage(page,roleEntity); return Result.ok(list); @@ -73,7 +73,7 @@ roleEntity.setRemark(remark); } roleEntity.setRoleName(roleName); roleEntity.setBelongId(userlogin.getBelongId() == null?UserEntity.USER_BELONG_TOP:userlogin.getBelongId()); roleEntity.setCompanyId(userlogin.getCompanyId() == null?UserEntity.USER_BELONG_TOP:userlogin.getCompanyId()); int insert = this.baseMapper.insert(roleEntity); if(insert > 0){ saveRoleMenus(menuIds,roleEntity.getId()); src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/UserServiceImpl.java
@@ -43,11 +43,11 @@ UserEntity userlogin = LoginUserUtil.getLoginUser(); Page<AdminUserVo> page = new Page<>(adminUserDto.getPageNum(), adminUserDto.getPageSize()); UserEntity userEntity = new UserEntity(); long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); if(belongId > UserEntity.USER_BELONG_TOP){ userEntity.setBelongId(belongId); long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); if(companyId > UserEntity.USER_BELONG_TOP){ userEntity.setCompanyId(companyId); userEntity.setRoleName(RoleEntity.ROLE_ADMIN_NAME); }else if(belongId == UserEntity.USER_BELONG_TOP){ }else if(companyId == UserEntity.USER_BELONG_TOP){ userEntity.setRoleName(RoleEntity.ROLE_SUPER_NAME); } if(StrUtil.isNotEmpty(adminUserDto.getUsername())){ @@ -105,7 +105,7 @@ } userEntity.setPassword(SecureUtil.md5(UserEntity.PASSWORD_DEFAULT)); userEntity.setStatus(UserEntity.STATUS_ENABLE); userEntity.setBelongId(belongId); userEntity.setCompanyId(belongId); int insert = this.baseMapper.insert(userEntity); if(insert > 0){ saveUserRole(roleIds,userEntity.getId()); @@ -165,7 +165,7 @@ adminSeeUserInfoVo.setNickname(userEntity.getNickname()); adminSeeUserInfoVo.setPhone(userEntity.getPhone()); adminSeeUserInfoVo.setEmail(userEntity.getEmail()); adminSeeUserInfoVo.setBelongId(userEntity.getBelongId()); adminSeeUserInfoVo.setBelongId(userEntity.getCompanyId()); List<AdminRoleVo> adminRoleVos = new ArrayList<>(); QueryWrapper<UserRoleEntity> objectQueryWrapper = new QueryWrapper<>(); @@ -207,7 +207,7 @@ if(ObjectUtil.isEmpty(userEntity)){ return Result.fail("用户不存在"); } userEntity.setBelongId(belongId); userEntity.setCompanyId(belongId); userEntity.setUsername(username); userEntity.setPhone(phone); if(StrUtil.isNotEmpty(adminUpdateUserDto.getNickname())){ src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/WebSetServiceImpl.java
@@ -25,10 +25,10 @@ @Override public Result seeWebSetInfo() { UserEntity userlogin = LoginUserUtil.getLoginUser(); long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); AdminSeeWebSetInfoVo adminSeeWebSetInfoVo = new AdminSeeWebSetInfoVo(); QueryWrapper<WebSetEntity> objectQueryWrapper = new QueryWrapper<>(); objectQueryWrapper.eq("belong_id",belongId); objectQueryWrapper.eq("company_id",companyId); List<WebSetEntity> webSetEntities = this.baseMapper.selectList(new QueryWrapper<>()); if(CollUtil.isNotEmpty(webSetEntities)){ WebSetEntity webSetEntity = webSetEntities.get(0); @@ -44,12 +44,12 @@ @Override public Result updateWebSet(AdminUpdateWebSetDto adminUpdateWebSetDto) { UserEntity userlogin = LoginUserUtil.getLoginUser(); long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); String webTitle = adminUpdateWebSetDto.getWebTitle(); String webKeyword = adminUpdateWebSetDto.getWebKeyword(); Long id = adminUpdateWebSetDto.getId() == null ? 0L : adminUpdateWebSetDto.getId(); QueryWrapper<WebSetEntity> objectQueryWrapper = new QueryWrapper<>(); objectQueryWrapper.eq("belong_id",belongId); objectQueryWrapper.eq("company_id",companyId); WebSetEntity webSetEntity = this.baseMapper.selectOne(objectQueryWrapper); if(ObjectUtil.isEmpty(webSetEntity)){ WebSetEntity webSetEntityAdd = new WebSetEntity(); @@ -63,7 +63,7 @@ if(StrUtil.isNotEmpty(webPic)){ webSetEntityAdd.setWebPic(webPic); } webSetEntityAdd.setBelongId(belongId); webSetEntityAdd.setCompanyId(companyId); this.baseMapper.insert(webSetEntityAdd); return Result.ok("保存成功"); } src/main/java/com/xcong/farmer/cms/modules/system/vo/AdminCompanyVo.java
File was renamed from src/main/java/com/xcong/farmer/cms/modules/system/vo/AdminBelongVo.java @@ -6,7 +6,7 @@ @Data @ApiModel(value = "AdminBelongVo", description = "所属公司列表返回") public class AdminBelongVo { public class AdminCompanyVo { private Long id; src/main/java/com/xcong/farmer/cms/modules/system/vo/AdminSeeArticleInfoVo.java
@@ -48,4 +48,7 @@ @ApiModelProperty(value = "文章详情") private String articleDetails; @ApiModelProperty(value = "附件") private String uploadFile; } src/main/java/com/xcong/farmer/cms/modules/system/vo/AdminSeeCompanyInfoVo.java
File was renamed from src/main/java/com/xcong/farmer/cms/modules/system/vo/AdminSeeBelongInfoVo.java @@ -6,7 +6,7 @@ @Data @ApiModel(value = "AdminSeeBelongInfoVo", description = "所属公司返回") public class AdminSeeBelongInfoVo { public class AdminSeeCompanyInfoVo { private Long id; src/main/resources/mapper/ArticleMapper.xml
@@ -16,7 +16,7 @@ and a.column_id = #{record.columnId} </if> <if test="record.belongId != null"> and a.belong_id = #{record.belongId} and a.company_id = #{record.belongId} </if> <if test="record.title!=null"> and a.title like concat ('%',#{record.title},'%') src/main/resources/mapper/ColumnMapper.xml
@@ -13,7 +13,7 @@ and a.parent_id = #{record.parentId} </if> <if test="record.belongId != null"> and a.belong_id = #{record.belongId} and a.company_id = #{record.belongId} </if> </if> </where> @@ -25,7 +25,7 @@ a.* FROM t_column a where a.parent_id = #{parentId} and a.belong_id = #{belongId} where a.parent_id = #{parentId} and a.company_id = #{belongId} order by a.create_time desc </select> src/main/resources/mapper/CompanyMapper.xml
File was renamed from src/main/resources/mapper/BelongMapper.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.xcong.farmer.cms.modules.system.mapper.BelongMapper"> <mapper namespace="com.xcong.farmer.cms.modules.system.mapper.CompanyMapper"> <select id="selectAdminBelongInPage" resultType="com.xcong.farmer.cms.modules.system.vo.AdminBelongVo"> <select id="selectAdminBelongInPage" resultType="com.xcong.farmer.cms.modules.system.vo.AdminCompanyVo"> SELECT a.* FROM t_belong a t_company a <where> <if test="record != null" > <if test="record.name!=null"> src/main/resources/mapper/NavigationBarMapper.xml
@@ -13,7 +13,7 @@ and a.parent_id = #{record.parentId} </if> <if test="record.belongId != null"> and a.belong_id = #{record.belongId} and a.company_id = #{record.belongId} </if> </if> </where> @@ -26,7 +26,7 @@ FROM t_navigation_bar a where a.parent_id = #{parentId} and a.belong_id = #{belongId} and a.company_id = #{belongId} order by a.create_time desc </select> @@ -36,7 +36,7 @@ FROM t_navigation_bar a where a.parent_id = #{parentId} and a.belong_id = #{belongId} and a.company_id = #{belongId} order by a.create_time desc </select> src/main/resources/mapper/RoleMapper.xml
@@ -13,7 +13,7 @@ and a.role_name like concat ('%',#{record.roleName},'%') </if> <if test="record.belongId!=null"> and a.belong_id = #{record.belongId} and a.company_id = #{record.belongId} </if> </if> </where> src/main/resources/mapper/UserMapper.xml
@@ -7,7 +7,7 @@ a.* FROM t_user a left join t_belong b on a.belong_id = b.id left join t_company b on a.company_id = b.id <where> and a.id not in ( SELECT b.user_id FROM t_user_role b @@ -18,7 +18,7 @@ and a.username like concat ('%',#{record.username},'%') </if> <if test="record.belongId!=null"> and a.belong_id = #{record.belongId} and a.company_id = #{record.belongId} </if> </if> </where>