diff --git a/bweb/src/main/java/com/bweb/config/AuthConfig.java b/bweb/src/main/java/com/bweb/config/AuthConfig.java index 3bee573..27fb01f 100644 --- a/bweb/src/main/java/com/bweb/config/AuthConfig.java +++ b/bweb/src/main/java/com/bweb/config/AuthConfig.java @@ -87,8 +87,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/**/swagger-ui.html") .excludePathPatterns("/client/*") .excludePathPatterns("/sms/*") - .excludePathPatterns("/secUser/login") - .excludePathPatterns("/secUser/loginOut") + .excludePathPatterns("/login/*") ; } diff --git a/bweb/src/main/java/com/bweb/controller/BsAgentController.java b/bweb/src/main/java/com/bweb/controller/BsAgentController.java index d92a034..b357cc9 100644 --- a/bweb/src/main/java/com/bweb/controller/BsAgentController.java +++ b/bweb/src/main/java/com/bweb/controller/BsAgentController.java @@ -11,9 +11,9 @@ import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.BsAgent; import com.hfkj.entity.SecUser; import com.hfkj.model.ResponseData; -import com.hfkj.model.UserInfoModel; +import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.BsAgentService; -import com.hfkj.service.SecUserService; +import com.hfkj.service.sec.SecUserService; import com.hfkj.sysenum.SecUserObjectTypeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -47,13 +47,6 @@ public class BsAgentController { @ApiOperation(value = "创建代理商") public ResponseData createAgent(@RequestBody JSONObject body) { try { - - UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); - if (userInfoModel == null || !userInfoModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type2.getNumber())) { - log.error("BsAgentController --> createAgent() error!", "用户身份错误或已过期"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); - } - if (body == null || StringUtils.isBlank(body.getString("loginName")) || StringUtils.isBlank(body.getString("name")) @@ -65,8 +58,6 @@ public class BsAgentController { } BsAgent agent = new BsAgent(); - agent.setCompanyId(userInfoModel.getBsCompany().getId()); - agent.setCompanyName(userInfoModel.getBsCompany().getName()); agent.setName(body.getString("name")); agent.setContactsName(body.getString("contactsName")); agent.setContactsTelephone(body.getString("contactsTelephone")); @@ -84,13 +75,6 @@ public class BsAgentController { @ApiOperation(value = "修改代理商") public ResponseData updateAgent(@RequestBody JSONObject body) { try { - - UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); - if (userInfoModel == null || !userInfoModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type2.getNumber())) { - log.error("BsAgentController --> updateAgent() error!", "用户身份错误或已过期"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); - } - if (body == null || StringUtils.isBlank(body.getString("agentNo")) || StringUtils.isBlank(body.getString("name")) @@ -134,13 +118,14 @@ public class BsAgentController { Map param = new HashMap<>(); param.put("agent", agent); - SecUser secUser = secUserService.getMainAccount(SecUserObjectTypeEnum.type3.getNumber(), agent.getId()); + /* SecUser secUser = secUserService.getDetail(SecUserObjectTypeEnum.type2.getNumber(), agent.getId()); if (secUser == null) { log.error("BsAgentController --> queryAgentDetail() error!", "未找到代理商登录账户"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到代理商登录账户"); } secUser.setPassword(null); - param.put("account", secUser); + param.put("account", secUser);*/ + param.put("account", null); return ResponseMsgUtil.success(param); } catch (Exception e) { diff --git a/bweb/src/main/java/com/bweb/controller/BsDeviceController.java b/bweb/src/main/java/com/bweb/controller/BsDeviceController.java index 1d97e70..1a41176 100644 --- a/bweb/src/main/java/com/bweb/controller/BsDeviceController.java +++ b/bweb/src/main/java/com/bweb/controller/BsDeviceController.java @@ -11,8 +11,7 @@ import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.config.SpPrinterConfig; import com.hfkj.entity.*; import com.hfkj.model.ResponseData; -import com.hfkj.model.UserInfoModel; -import com.hfkj.service.BsCompanyService; +import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.BsDeviceService; import com.hfkj.service.BsMerchantService; import com.hfkj.sysenum.DeviceTypeEnum; @@ -42,9 +41,6 @@ public class BsDeviceController { private BsDeviceService deviceService; @Resource private BsMerchantService merchantService; - @Resource - private BsCompanyService companyService; - @RequestMapping(value="/editDevice",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "编辑设备") @@ -87,12 +83,6 @@ public class BsDeviceController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户"); } - // 查询分公司 - BsCompany company = companyService.getCompanyById(merchant.getCompanyId()); - if (company == null) { - log.error("HighDeviceController -> editDevice() error!","参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的分公司"); - } if (body.getId() == null) { if (body.getType().equals(DeviceTypeEnum.type1.getType())) { @@ -103,11 +93,6 @@ public class BsDeviceController { } } } - - device.setCompanyId(company.getId()); - device.setCompanyName(company.getName()); - device.setAgentId(merchant.getAgentId()); - device.setAgentName(merchant.getAgentName()); device.setMerId(merchant.getId()); device.setMerNo(merchant.getMerNo()); device.setMerName(merchant.getMerName()); @@ -184,47 +169,23 @@ public class BsDeviceController { @RequestMapping(value="/getDeviceList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询设备列表") - public ResponseData getDeviceList(@RequestParam(name = "companyId", required = false) Long companyId, - @RequestParam(name = "merNo", required = false) String merNo, + public ResponseData getDeviceList(@RequestParam(name = "merNo", required = false) String merNo, @RequestParam(name = "merName", required = false) String merName, @RequestParam(name = "deviceName", required = false) String deviceName, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize) { try { - UserInfoModel sessionModel = userCenter.getSessionModel(UserInfoModel.class); + SecUserSessionObject sessionModel = userCenter.getSessionModel(SecUserSessionObject.class); if (sessionModel == null) { log.error("HighDeviceController -> getDeviceList() error!",""); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到"); } Map param = new HashMap<>(); + param.put("merNo", merNo); param.put("deviceName", deviceName); - if (sessionModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type0.getNumber()) - || sessionModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type1.getNumber())) { - param.put("companyId", companyId); - param.put("merNo", merNo); - param.put("merName", merName); - - } else if (sessionModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type2.getNumber())) { - param.put("companyId", sessionModel.getBsCompany().getId()); - param.put("merNo", merNo); - param.put("merName", merName); - - } else if (sessionModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type3.getNumber())) { - param.put("agentId", sessionModel.getAgent().getId()); - param.put("merNo", merNo); - param.put("merName", merName); - - }else if (sessionModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type4.getNumber())) { - param.put("merNo", sessionModel.getMerchant().getMerNo()); - - } else { - log.error("HighDeviceController -> getDeviceList() error!",""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); - } - PageHelper.startPage(pageNum, pageSize); return ResponseMsgUtil.success(new PageInfo<>(deviceService.getDeviceList(param))); diff --git a/bweb/src/main/java/com/bweb/controller/BsDiscountController.java b/bweb/src/main/java/com/bweb/controller/BsDiscountController.java index 0440336..caf915d 100644 --- a/bweb/src/main/java/com/bweb/controller/BsDiscountController.java +++ b/bweb/src/main/java/com/bweb/controller/BsDiscountController.java @@ -9,13 +9,10 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.config.SpPrinterConfig; -import com.hfkj.entity.BsCompany; import com.hfkj.entity.BsDevice; import com.hfkj.entity.BsDiscount; import com.hfkj.entity.BsMerchant; import com.hfkj.model.ResponseData; -import com.hfkj.model.UserInfoModel; -import com.hfkj.service.BsCompanyService; import com.hfkj.service.BsDeviceService; import com.hfkj.service.BsDiscountService; import com.hfkj.service.BsMerchantService; diff --git a/bweb/src/main/java/com/bweb/controller/BsGasOilGunNoController.java b/bweb/src/main/java/com/bweb/controller/BsGasOilGunNoController.java index 355187d..9418851 100644 --- a/bweb/src/main/java/com/bweb/controller/BsGasOilGunNoController.java +++ b/bweb/src/main/java/com/bweb/controller/BsGasOilGunNoController.java @@ -13,7 +13,7 @@ import com.hfkj.entity.BsGasOilPrice; import com.hfkj.entity.BsMerchant; import com.hfkj.entity.SecDictionary; import com.hfkj.model.ResponseData; -import com.hfkj.model.UserInfoModel; +import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.BsGasOilGunNoService; import com.hfkj.service.BsGasOilPriceService; import com.hfkj.service.BsMerchantService; @@ -55,10 +55,10 @@ public class BsGasOilGunNoController { @ApiOperation(value = "创建油品枪号") public ResponseData createOilGunNo(@RequestBody BsGasOilGunNo body) { try { - UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); - if (userInfoModel == null || !userInfoModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type4.getNumber())) { + SecUserSessionObject userInfoModel = userCenter.getSessionModel(SecUserSessionObject.class); + if (userInfoModel == null) { log.error("BsGasOilGunNoController --> createOilGunNo() error!", "用户身份错误或已过期"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, ""); } if (body == null || body.getMerNo() == null @@ -73,10 +73,6 @@ public class BsGasOilGunNoController { log.error("BsGasOilGunNoController --> createOilGunNo() error!", "未知的商户"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户"); } - if (!merchant.getId().equals(userInfoModel.getMerchant().getId())) { - log.error("BsGasOilGunNoController --> createOilGunNo() error!", "权限不足"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); - } // 油品 BsGasOilPrice oilPrice = gasOilPriceService.getGasOilPrice(merchant.getId(), body.getOilNo()); if (oilPrice == null) { diff --git a/bweb/src/main/java/com/bweb/controller/BsGasOilPriceController.java b/bweb/src/main/java/com/bweb/controller/BsGasOilPriceController.java index be1c2bc..991f663 100644 --- a/bweb/src/main/java/com/bweb/controller/BsGasOilPriceController.java +++ b/bweb/src/main/java/com/bweb/controller/BsGasOilPriceController.java @@ -10,7 +10,7 @@ import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.*; import com.hfkj.model.ResponseData; -import com.hfkj.model.UserInfoModel; +import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.BsGasOilPriceService; import com.hfkj.service.BsMerchantService; import com.hfkj.service.CommonService; @@ -49,11 +49,9 @@ public class BsGasOilPriceController { @ApiOperation(value = "创建油品") public ResponseData createOil(@RequestBody BsGasOilPrice body) { try { - - UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); - if (userInfoModel == null || !userInfoModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type4.getNumber())) { - log.error("BsGasOilPriceController --> createOil() error!", "用户身份错误或已过期"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); + SecUserSessionObject sessionObject = userCenter.getSessionModel(SecUserSessionObject.class); + if (sessionObject == null || !sessionObject.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); } if (body == null @@ -71,10 +69,6 @@ public class BsGasOilPriceController { log.error("BsGasOilPriceController --> createOil() error!", "未知的商户"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户"); } - if (!merchant.getId().equals(userInfoModel.getMerchant().getId())) { - log.error("BsGasOilPriceController --> createOil() error!", "权限不足"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); - } // 是否重复添加商户油品 if (gasOilPriceService.getGasOilPrice(merchant.getId(), body.getOilNo()) != null) { log.error("BsGasOilPriceController --> createOil() error!", "重复添加" + body.getOilNo() + "油品"); diff --git a/bweb/src/main/java/com/bweb/controller/BsGasOilPriceTaskController.java b/bweb/src/main/java/com/bweb/controller/BsGasOilPriceTaskController.java index 1b903ce..b61e67a 100644 --- a/bweb/src/main/java/com/bweb/controller/BsGasOilPriceTaskController.java +++ b/bweb/src/main/java/com/bweb/controller/BsGasOilPriceTaskController.java @@ -13,7 +13,7 @@ import com.hfkj.entity.BsMerchant; import com.hfkj.entity.SecDictionary; import com.hfkj.entity.SecRegion; import com.hfkj.model.ResponseData; -import com.hfkj.model.UserInfoModel; +import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.BsAgentService; import com.hfkj.service.BsGasOilPriceTaskService; import com.hfkj.service.BsMerchantService; @@ -56,10 +56,10 @@ public class BsGasOilPriceTaskController { @ApiOperation(value = "批量增加任务") public ResponseData batchAddTask(@RequestBody List taskList) { try { - UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + SecUserSessionObject userInfoModel = userCenter.getSessionModel(SecUserSessionObject.class); if (userInfoModel == null) { log.error("BsGasOilPriceTaskController -> batchAddTask() error!",""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, ""); } if (taskList == null || taskList.size() == 0) { log.error("BsGasOilPriceTaskController -> batchAddTask() error!",""); @@ -133,8 +133,8 @@ public class BsGasOilPriceTaskController { task.setOilType(Integer.valueOf(oilNoType.getCodeValue())); task.setOilTypeName(oilNoType.getCodeName()); task.setOilNoName(oil.getCodeName()); - task.setOpUserId(userInfoModel.getSecUser().getId()); - task.setOpUserName(userInfoModel.getSecUser().getUserName()); + task.setOpUserId(userInfoModel.getAccount().getId()); + task.setOpUserName(userInfoModel.getAccount().getUserName()); if (task.getOilPriceZoneId() != null) { // 查询价区 @@ -206,10 +206,10 @@ public class BsGasOilPriceTaskController { @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize) { try { - UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + SecUserSessionObject userInfoModel = userCenter.getSessionModel(SecUserSessionObject.class); if (userInfoModel == null) { log.error("HighGasController -> disabledOil() error!",""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, ""); } Map param = new HashMap<>(); @@ -219,37 +219,10 @@ public class BsGasOilPriceTaskController { param.put("merNo", merNo); param.put("merName", merName); - if (userInfoModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type0.getNumber()) - || userInfoModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type1.getNumber())) { + if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { - } else if (userInfoModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type2.getNumber())) { - param.put("regionId", userInfoModel.getBsCompany().getRegionId()); - - } else if (userInfoModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type3.getNumber())) { - if (merId == null) { - Map merParam = new HashMap<>(); - merParam.put("agentId", userInfoModel.getAgent().getId()); - // 查询代理商下的商户 - List merchantList = merchantService.getMerchantList(merParam); - String merNoListStr = ""; - if (merchantList.size() > 0) { - for (BsMerchant merchant : merchantList) { - if (StringUtils.isBlank(merNoListStr)) { - merNoListStr += merchant.getMerNo(); - } else { - merNoListStr += ","+merchant.getMerNo(); - } - } - param.put("merNoList", merNoListStr); - } else { - // 代理商没有商户 直接返回空数据 - return ResponseMsgUtil.success(new PageInfo<>(new ArrayList<>())); - } - } else { - param.put("merId", merId); - } - } else if (userInfoModel.getSecUser().getObjectType().equals(SecUserObjectTypeEnum.type4.getNumber())) { - param.put("merId", userInfoModel.getMerchant().getId()); + } else if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { + param.put("merId", userInfoModel.getAccount().getId()); } param.put("oilType", oilType); param.put("oilNo", oilNo); diff --git a/bweb/src/main/java/com/bweb/controller/BsMerchantController.java b/bweb/src/main/java/com/bweb/controller/BsMerchantController.java index 59e8e7f..9ebb6b9 100644 --- a/bweb/src/main/java/com/bweb/controller/BsMerchantController.java +++ b/bweb/src/main/java/com/bweb/controller/BsMerchantController.java @@ -10,7 +10,6 @@ import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.*; import com.hfkj.model.ResponseData; -import com.hfkj.model.UserInfoModel; import com.hfkj.service.*; import com.hfkj.sysenum.MerchantStatusEnum; import com.hfkj.sysenum.SecUserObjectTypeEnum; diff --git a/bweb/src/main/java/com/bweb/controller/BsMerchantQrCodeController.java b/bweb/src/main/java/com/bweb/controller/BsMerchantQrCodeController.java index b00f9d0..9c06492 100644 --- a/bweb/src/main/java/com/bweb/controller/BsMerchantQrCodeController.java +++ b/bweb/src/main/java/com/bweb/controller/BsMerchantQrCodeController.java @@ -1,30 +1,21 @@ package com.bweb.controller; import com.alibaba.fastjson.JSONObject; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.model.ResponseData; -import com.hfkj.model.UserInfoModel; import com.hfkj.service.BsMerchantQrCodeService; -import com.hfkj.service.BsMerchantService; import com.hfkj.sysenum.MerchantQrCodeStatusEnum; -import com.hfkj.sysenum.MerchantStatusEnum; -import com.hfkj.sysenum.SecUserObjectTypeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; @Controller @RequestMapping(value = "/merchantQrCode") diff --git a/bweb/src/main/java/com/bweb/controller/CmsCategoryController.java b/bweb/src/main/java/com/bweb/controller/CmsCategoryController.java deleted file mode 100644 index 2aaf1f4..0000000 --- a/bweb/src/main/java/com/bweb/controller/CmsCategoryController.java +++ /dev/null @@ -1,187 +0,0 @@ -package com.bweb.controller; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.hfkj.common.exception.ErrorCode; -import com.hfkj.common.exception.ErrorHelp; -import com.hfkj.common.exception.SysCode; -import com.hfkj.common.utils.ResponseMsgUtil; -import com.hfkj.entity.CmsCategory; -import com.hfkj.model.ResponseData; -import com.hfkj.service.CmsCategoryService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Controller -@Api(value = "内容分类管理") -@RequestMapping(value = "/cmsCategory") -public class CmsCategoryController { - - private static Logger log = LoggerFactory.getLogger(CmsCategoryController.class); - @Resource - private CmsCategoryService cmsCategoryService; - - @RequestMapping(value = "/addCategory", method = RequestMethod.POST) - @ApiOperation(value = "增加 分类") - @ResponseBody - public ResponseData addCategory(@RequestBody JSONObject jsonObject) { - try { - - CmsCategory cmsCategory = jsonObject.getObject("category", CmsCategory.class); - JSONArray jsonArray = jsonObject.getJSONArray("roles"); - Object[] roleArray = jsonArray.toArray(); - - if (cmsCategory == null || roleArray == null || roleArray.length == 0 - || StringUtils.isBlank(cmsCategory.getName()) - || StringUtils.isBlank(cmsCategory.getCode())) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - List roleList = new ArrayList<>(); - for (Object object : roleArray) { - roleList.add(Integer.valueOf(object.toString())); - } - - if (cmsCategoryService.addCategory(cmsCategory, roleList) > 0) { - return ResponseMsgUtil.success("添加数据成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.ADD_DATA_ERROR, ""); - } - - } catch (Exception e) { - log.error("CmsCategoryController --> addCategory() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/updateCategory", method = RequestMethod.POST) - @ApiOperation(value = "修改 内容分类") - @ResponseBody - public ResponseData updateCategory(@RequestBody JSONObject jsonObject) { - try { - - CmsCategory cmsCategory = jsonObject.getObject("category", CmsCategory.class); - JSONArray jsonArray = jsonObject.getJSONArray("roles"); - Object[] roleArray = jsonArray.toArray(); - - if (cmsCategory == null || roleArray == null || roleArray.length == 0 - || cmsCategory.getId() == null - || StringUtils.isBlank(cmsCategory.getName()) - || StringUtils.isBlank(cmsCategory.getCode())) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - List roleList = new ArrayList<>(); - for (Object object : roleArray) { - roleList.add(Integer.valueOf(object.toString())); - } - - if (cmsCategoryService.updateCategory(cmsCategory, roleList) > 0) { - return ResponseMsgUtil.success("修改数据成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.UPDATE_DATA_ERROR, ""); - } - - } catch (Exception e) { - log.error("CmsCategoryController --> updateCategory() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/delCategory", method = RequestMethod.GET) - @ApiOperation(value = "删除 内容分类") - @ResponseBody - public ResponseData delCategory(@RequestParam(value = "id", required = true) Long id) { - try { - if (cmsCategoryService.delCategory(id) > 0) { - return ResponseMsgUtil.success("删除成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.DELETE_DATA_ERROR, ""); - } - } catch (Exception e) { - log.error("CmsCategoryController --> updateCategory() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getCategoryById", method = RequestMethod.GET) - @ApiOperation(value = "查询 分类详情") - @ResponseBody - public ResponseData getCategoryById(@RequestParam(value = "id", required = true) Long id) { - try { - return ResponseMsgUtil.success(cmsCategoryService.getCategoryById(id)); - } catch (Exception e) { - log.error("CmsCategoryController --> getCategoryById() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getCategoryTree", method = RequestMethod.GET) - @ApiOperation(value = "获取分类树") - @ResponseBody - public ResponseData getCategoryTree(@RequestParam(value = "roleType", required = false) Integer roleType, - @RequestParam(value = "parentCode", required = false) String parentCode) { - try { - Map paramMap = new HashMap<>(); - if (roleType != null) { - paramMap.put("roleType", roleType); - } - if (StringUtils.isNotBlank(parentCode)) { - paramMap.put("parentCode", parentCode); - } - - return ResponseMsgUtil.success(cmsCategoryService.getCategoryTree(paramMap)); - } catch (Exception e) { - log.error("CmsCategoryController --> getCategoryTree() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getOwnCategoryTree", method = RequestMethod.GET) - @ApiOperation(value = "获取拥有的分类树") - @ResponseBody - public ResponseData getOwnCategoryTree(@RequestParam(value = "roleType", required = false) Integer roleType) { - try { - Map paramMap = new HashMap<>(); - if (roleType != null) { - paramMap.put("roleType", roleType); - } - - return ResponseMsgUtil.success(cmsCategoryService.getOwnCategoryTree(paramMap)); - } catch (Exception e) { - log.error("CmsCategoryController --> getCategoryTree() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getRolesOfCategory", method = RequestMethod.GET) - @ApiOperation(value = "根据id查询 分类角色列表") - @ResponseBody - public ResponseData getRolesOfCategory(@RequestParam(value = "id", required = false) Long id) { - try { - List roleList = new ArrayList<>(); - if (id != null) { - roleList = cmsCategoryService.getRolesOfCategory(id); - } else { - roleList.add(1); - } - - return ResponseMsgUtil.success(roleList); - } catch (Exception e) { - log.error("CmsCategoryController --> getCategoryById() error!", e); - return ResponseMsgUtil.exception(e); - } - } - -} diff --git a/bweb/src/main/java/com/bweb/controller/CmsCategoryModuleController.java b/bweb/src/main/java/com/bweb/controller/CmsCategoryModuleController.java deleted file mode 100644 index 307379b..0000000 --- a/bweb/src/main/java/com/bweb/controller/CmsCategoryModuleController.java +++ /dev/null @@ -1,220 +0,0 @@ -package com.bweb.controller; - -import com.alibaba.fastjson.JSONObject; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import com.hfkj.common.exception.ErrorCode; -import com.hfkj.common.exception.ErrorHelp; -import com.hfkj.common.exception.SysCode; -import com.hfkj.common.security.SessionObject; -import com.hfkj.common.security.UserCenter; -import com.hfkj.common.utils.ResponseMsgUtil; -import com.hfkj.entity.CmsCategoryModule; -import com.hfkj.model.ResponseData; -import com.hfkj.model.UserInfoModel; -import com.hfkj.service.CmsCategoryModuleService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -@Controller -@Api(value = "内容管理 模板") -@RequestMapping(value = "/cmsCategoryModule") -public class CmsCategoryModuleController { - - private static Logger log = LoggerFactory.getLogger(CmsCategoryModuleController.class); - - @Resource - private UserCenter userCenter; - - @Resource - private CmsCategoryModuleService cmsCategoryModuleService; - - @RequestMapping(value = "/addCategoryModule", method = RequestMethod.POST) - @ApiOperation(value = "增加 模板") - @ResponseBody - public ResponseData addCategoryModule(@RequestBody CmsCategoryModule cmsCategoryModule, - HttpServletRequest request - ) { - try { - if (cmsCategoryModule == null - || cmsCategoryModule.getCategoryId() == null - || StringUtils.isBlank(cmsCategoryModule.getModuleName()) - || StringUtils.isBlank(cmsCategoryModule.getModulePath()) - ) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - // 获取操作者 - SessionObject sessionObject = userCenter.getSessionObject(request); - if(sessionObject == null){ - throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); - } - UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); - - cmsCategoryModule.setStatus(1); - cmsCategoryModule.setCreateTime(new Date()); - cmsCategoryModule.setOpId(userInfoModel.getSecUser().getId()); - if (cmsCategoryModuleService.addCategoryModule(cmsCategoryModule) > 0) { - return ResponseMsgUtil.success("添加成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.ADD_DATA_ERROR, ""); - } - - } catch (Exception e) { - log.error("CmsCategoryModuleController --> addCategoryModule() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/updateCategoryModule", method = RequestMethod.POST) - @ApiOperation(value = "修改 模板") - @ResponseBody - public ResponseData updateCategoryModule(@RequestBody CmsCategoryModule cmsCategoryModule) { - try { - if (cmsCategoryModule == null - || cmsCategoryModule.getId() == null - || cmsCategoryModule.getCategoryId() == null - || StringUtils.isBlank(cmsCategoryModule.getModuleName()) - || StringUtils.isBlank(cmsCategoryModule.getModulePath()) - ) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - CmsCategoryModule categoryModule = cmsCategoryModuleService.getCategoryModuleById(cmsCategoryModule.getId()); - if (categoryModule == null || categoryModule.getStatus() == 0) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.CMS_CATEGORY_MODULE_NOT_FOUND, ""); - } - - cmsCategoryModule.setStatus(categoryModule.getStatus()); - cmsCategoryModule.setCreateTime(categoryModule.getCreateTime()); - cmsCategoryModule.setOpId(categoryModule.getOpId()); - if (cmsCategoryModuleService.updateCategoryModule(cmsCategoryModule) > 0) { - return ResponseMsgUtil.success("修改成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.UPDATE_DATA_ERROR, ""); - } - } catch (Exception e) { - log.error("CmsCategoryModuleController --> updateCategoryModule() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/delCategoryModule", method = RequestMethod.GET) - @ApiOperation(value = "删除 模板") - @ResponseBody - public ResponseData delCategoryModule(@RequestParam(value = "id", required = true) Long id) { - try { - if (cmsCategoryModuleService.delCategoryModule(id) > 0) { - return ResponseMsgUtil.success("删除成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.DELETE_DATA_ERROR, ""); - } - } catch (Exception e) { - log.error("CmsCategoryModuleController --> delCategoryModule() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getCategoryModuleById", method = RequestMethod.GET) - @ApiOperation(value = "根据id 查询模板") - @ResponseBody - public ResponseData getCategoryModuleById(@RequestParam(value = "id", required = true) Long id) { - try { - return ResponseMsgUtil.success(cmsCategoryModuleService.getCategoryModuleById(id)); - } catch (Exception e) { - log.error("CmsCategoryModuleController --> getCategoryModuleById() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getModuleByCategoryId", method = RequestMethod.GET) - @ApiOperation(value = "根据分类id 查询模板列表") - @ResponseBody - public ResponseData getModuleByCategoryId(@RequestParam(value = "categoryId", required = true) Long categoryId) { - try { - Map paramsMap = new HashMap<>(); - paramsMap.put("categoryId", categoryId); - - return ResponseMsgUtil.success(cmsCategoryModuleService.getListCategoryModule(paramsMap)); - } catch (Exception e) { - log.error("CmsCategoryModuleController --> getCategoryModuleById() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getListCategoryModule", method = RequestMethod.GET) - @ApiOperation(value = "查询列表 模板") - @ResponseBody - public ResponseData getListCategoryModule(@RequestParam(value = "categoryId", required = false) Long categoryId, - @RequestParam(value = "categoryCode", required = false) String categoryCode, - @RequestParam(value = "moduleName", required = false) String moduleName, - @RequestParam(value = "status", required = false) Integer status, - @RequestParam(name = "pageNum", required = true) Integer pageNum, - @RequestParam(name = "pageSize", required = true) Integer pageSize) { - try { - Map paramsMap = new HashMap<>(); - if (categoryId != null) { - paramsMap.put("categoryId", categoryId); - } - if (StringUtils.isNotBlank(categoryCode)) { - paramsMap.put("categoryCode", categoryCode); - } - if (StringUtils.isNotBlank(moduleName)) { - paramsMap.put("moduleName", moduleName); - } - if (status != null) { - paramsMap.put("status", status); - } - - PageHelper.startPage(pageNum, pageSize); - return ResponseMsgUtil.success(new PageInfo<>(cmsCategoryModuleService.getListCategoryModule(paramsMap))); - } catch (Exception e) { - log.error("CmsCategoryModuleController --> getListCategoryModule() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/updateStatusOfModule", method = RequestMethod.POST) - @ApiOperation(value = "更新 模板状态") - @ResponseBody - public ResponseData updateStatusOfContent(@RequestBody JSONObject jsonObject) { - try { - Long id = jsonObject.getLong("id"); - Integer status = jsonObject.getInteger("status"); - - if (id == null - || status == null - || (status != 1 && status != 2) - ) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - CmsCategoryModule categoryModule = cmsCategoryModuleService.getCategoryModuleById(id); - if (categoryModule == null || categoryModule.getStatus() == 0) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.CMS_CATEGORY_MODULE_NOT_FOUND, ""); - } - - categoryModule.setStatus(status); - if (cmsCategoryModuleService.updateCategoryModule(categoryModule) > 0) { - return ResponseMsgUtil.success("修改成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.UPDATE_DATA_ERROR, ""); - } - } catch (Exception e) { - log.error("CmsContentController --> updateStatusOfContent() error!", e); - return ResponseMsgUtil.exception(e); - } - } - -} diff --git a/bweb/src/main/java/com/bweb/controller/CmsContentController.java b/bweb/src/main/java/com/bweb/controller/CmsContentController.java deleted file mode 100644 index 03a508d..0000000 --- a/bweb/src/main/java/com/bweb/controller/CmsContentController.java +++ /dev/null @@ -1,392 +0,0 @@ -package com.bweb.controller; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import com.hfkj.common.exception.ErrorCode; -import com.hfkj.common.exception.ErrorHelp; -import com.hfkj.common.exception.SysCode; -import com.hfkj.common.security.SessionObject; -import com.hfkj.common.security.UserCenter; -import com.hfkj.common.utils.ResponseMsgUtil; -import com.bweb.config.SysConfig; -import com.hfkj.entity.CmsContent; -import com.hfkj.entity.CmsPatch; -import com.hfkj.model.CmsContentModel; -import com.hfkj.model.ResponseData; -import com.hfkj.model.UserInfoModel; -import com.hfkj.service.CmsContentService; -import com.hfkj.service.CmsPatchService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.util.*; - -@Controller -@Api(value = "内容管理 内容发布") -@RequestMapping(value = "/cmsContent") -public class CmsContentController { - - private static Logger log = LoggerFactory.getLogger(CmsContentController.class); - - @Resource - private SysConfig sysConfig; - - @Resource - private UserCenter userCenter; - - @Resource - private CmsContentService cmsContentService; - @Resource - private CmsPatchService cmsPatchService; - - @RequestMapping(value = "/addContent", method = RequestMethod.POST) - @ApiOperation(value = "创建内容") - @ResponseBody - public ResponseData addContent(@RequestBody JSONObject jsonObject, HttpServletRequest request) { - try { - CmsContent cmsContent = jsonObject.getObject("cmsContent", CmsContent.class); - Long moduleId = jsonObject.getLong("moduleId"); - JSONArray jsonArray = jsonObject.getJSONArray("patches"); - List patchList = new ArrayList<>(); - if (jsonArray != null) { - patchList = JSONObject.parseArray(jsonArray.toJSONString(), CmsPatch.class); - } - - if (cmsContent == null - || StringUtils.isBlank(cmsContent.getTitle()) - || cmsContent.getCategoryId() == null - || cmsContent.getStatus() == null - || (cmsContent.getStatus() != 1 && cmsContent.getStatus() != 2) - ) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - // 获取操作者 - SessionObject sessionObject = userCenter.getSessionObject(request); - if(sessionObject == null){ - throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); - } - UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); - - Map paramsMap = new HashMap<>(); - if (moduleId != null) { - paramsMap.put("moduleId", moduleId.toString()); - } - - cmsContent.setCreateTime(new Date()); - cmsContent.setVisitCount(0); - cmsContent.setUpdateTime(cmsContent.getCreateTime()); - cmsContent.setCompanyId(userInfoModel.getBsCompany().getId()); - cmsContent.setOpId(userInfoModel.getSecUser().getId()); - if (cmsContentService.addContent(cmsContent, patchList, paramsMap,sysConfig.getFileUrl()) > 0) { - return ResponseMsgUtil.success("添加成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.ADD_DATA_ERROR, ""); - } - } catch (Exception e) { - log.error("CmsContentController --> addContent() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/updateContent", method = RequestMethod.POST) - @ApiOperation(value = "修改内容") - @ResponseBody - public ResponseData updateContent(@RequestBody CmsContent cmsContent) { - try { - if (cmsContent == null - || cmsContent.getId() == null - || StringUtils.isBlank(cmsContent.getTitle()) - || cmsContent.getCategoryId() == null - ) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - CmsContent content = cmsContentService.getContentById(cmsContent.getId()); - if (content == null || content.getStatus() == 0) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.CMS_CONTENT_NOT_FOUND, ""); - } else if (content.getStatus() != 1 && content.getStatus() != 3) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); - } - - cmsContent.setCreateTime(content.getCreateTime()); - cmsContent.setStatus(content.getStatus()); - cmsContent.setVisitCount(content.getVisitCount()); - cmsContent.setJumpUrl(content.getJumpUrl()); - cmsContent.setUpdateTime(new Date()); - cmsContent.setCompanyId(content.getCompanyId()); - cmsContent.setOpId(content.getOpId()); - if (cmsContentService.updateContent(cmsContent, "updateContent", null,sysConfig.getFileUrl()) > 0) { - return ResponseMsgUtil.success("修改成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.UPDATE_DATA_ERROR, ""); - } - } catch (Exception e) { - log.error("CmsContentController --> updateContent() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/delContent", method = RequestMethod.GET) - @ApiOperation(value = "删除 内容") - @ResponseBody - public ResponseData delContent(@RequestParam(value = "id", required = true) Long id) { - try { - if (cmsContentService.delContent(id,sysConfig.getFileUrl()) > 0) { - return ResponseMsgUtil.success("删除成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.DELETE_DATA_ERROR, ""); - } - } catch (Exception e) { - log.error("CmsContentController --> delContent() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getContentById", method = RequestMethod.GET) - @ApiOperation(value = "根据id 查询内容基础信息") - @ResponseBody - public ResponseData getContentById(@RequestParam(value = "id", required = true) Long id) { - try { - return ResponseMsgUtil.success(cmsContentService.getContentDetail(id, null)); - } catch (Exception e) { - log.error("CmsContentController --> getContentDetail() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getContentDetail", method = RequestMethod.GET) - @ApiOperation(value = "根据id 查询内容详情(包括附件列表)") - @ResponseBody - public ResponseData getContentDetail(@RequestParam(value = "id", required = true) Long id) { - try { - return ResponseMsgUtil.success(cmsContentService.getContentDetail(id, "queryWithPatches")); - } catch (Exception e) { - log.error("CmsContentController --> getContentDetail() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getListContent", method = RequestMethod.GET) - @ApiOperation(value = "查询内容列表(不包括附件)") - @ResponseBody - public ResponseData getListContent(@RequestParam(value = "title", required = false) String title, - @RequestParam(value = "category", required = false) Long category, - @RequestParam(value = "categoryCode", required = false) String categoryCode, - @RequestParam(value = "tag", required = false) String tag, - @RequestParam(value = "status", required = false) Integer status, - @RequestParam(value = "companyId", required = false) Long companyId, - @RequestParam(name = "pageNum", required = true) Integer pageNum, - @RequestParam(name = "pageSize", required = true) Integer pageSize) { - try { - Map paramsMap = new HashMap<>(); - if (StringUtils.isNotBlank(title)) { - paramsMap.put("title", title); - } - if (category != null) { - paramsMap.put("category", category.toString()); - } - if (categoryCode != null) { - paramsMap.put("categoryCode", categoryCode); - } - if (StringUtils.isNotBlank(tag)) { - paramsMap.put("tag", tag); - } - if (status != null) { - paramsMap.put("status", status.toString()); - } - if (companyId != null) { - paramsMap.put("companyId", companyId.toString()); - } - - PageHelper.startPage(pageNum, pageSize); - return ResponseMsgUtil.success(new PageInfo<>(cmsContentService.getListContent(paramsMap))); - } catch (Exception e) { - log.error("CmsContentController --> getListContent() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/updateStatusOfContent", method = RequestMethod.POST) - @ApiOperation(value = "更新 内容发布状态") - @ResponseBody - public ResponseData updateStatusOfContent(@RequestBody JSONObject jsonObject) { - try { - Long id = jsonObject.getLong("id"); - Integer status = jsonObject.getInteger("status"); - Long moduleId = jsonObject.getLong("moduleId"); - - if (id == null - || status == null - || (status != 1 && status != 2 && status != 3) - ) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - CmsContent content = cmsContentService.getContentById(id); - if (content == null || content.getStatus() == 0) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.CMS_CONTENT_NOT_FOUND, ""); - } - - Map paramsMap = new HashMap<>(); - if (moduleId != null) { - paramsMap.put("moduleId", moduleId.toString()); - } - - content.setStatus(status); - if (cmsContentService.updateContent(content, "updateStatusOfContent", paramsMap,sysConfig.getFileUrl()) > 0) { - return ResponseMsgUtil.success("修改成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.UPDATE_DATA_ERROR, ""); - } - } catch (Exception e) { - log.error("CmsContentController --> updateStatusOfContent() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/updateContentQuantity", method = RequestMethod.GET) - @ApiOperation(value = "内容访问量+1") - @ResponseBody - public ResponseData updateContentQuantity(@RequestParam(value = "id", required = true) Long id) { - try { - CmsContent content = cmsContentService.getContentById(id); - if (content == null || content.getStatus() == 0) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.CMS_CONTENT_NOT_FOUND, ""); - } - - if (content.getVisitCount() != null) { - content.setVisitCount(content.getVisitCount() + 1); - } else { - content.setVisitCount(1); - } - if (cmsContentService.updateContent(content, "updateContent", null,null) > 0) { - return ResponseMsgUtil.success("修改成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.UPDATE_DATA_ERROR, ""); - } - } catch (Exception e) { - log.error("CmsContentController --> updateContentQuantity() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getListPatches", method = RequestMethod.GET) - @ApiOperation(value = "查询内容附件列表") - @ResponseBody - public ResponseData getListPatches(@RequestParam(value = "contentId", required = true) Long contentId, - @RequestParam(value = "patchType", required = false) Integer patchType, - @RequestParam(name = "pageNum", required = true) Integer pageNum, - @RequestParam(name = "pageSize", required = true) Integer pageSize) { - try { - Map paramsMap = new HashMap<>(); - if (contentId != null) { - paramsMap.put("contentId", contentId.toString()); - } - if (patchType != null) { - paramsMap.put("patchType", patchType.toString()); - } - - PageHelper.startPage(pageNum, pageSize); - return ResponseMsgUtil.success(new PageInfo<>(cmsPatchService.getListPatch(paramsMap))); - } catch (Exception e) { - log.error("CmsContentController --> getListContent() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getCompleteContentList", method = RequestMethod.GET) - @ApiOperation(value = "查询内容列表(包括附件)") - @ResponseBody - public ResponseData getCompleteContentList(@RequestParam(value = "title", required = false) String title, - @RequestParam(value = "category", required = false) Long category, - @RequestParam(value = "categoryCode", required = false) String categoryCode, - @RequestParam(value = "tag", required = false) String tag, - @RequestParam(value = "status", required = false) Integer status, - @RequestParam(value = "companyId", required = false) Long companyId, - @RequestParam(name = "pageNum", required = true) Integer pageNum, - @RequestParam(name = "pageSize", required = true) Integer pageSize) { - try { - Map paramsMap = new HashMap<>(); - if (StringUtils.isNotBlank(title)) { - paramsMap.put("title", title); - } - if (category != null) { - paramsMap.put("category", category.toString()); - } - if (categoryCode != null) { - paramsMap.put("categoryCode", categoryCode); - } - if (StringUtils.isNotBlank(tag)) { - paramsMap.put("tag", tag); - } - if (status != null) { - paramsMap.put("status", status.toString()); - } - if (companyId != null) { - paramsMap.put("companyId", companyId.toString()); - } - PageHelper.startPage(pageNum, pageSize); - List result = cmsContentService.getListContent(paramsMap); - - // 查询附件列表 - Map params = new HashMap<>(); - List patchList = cmsPatchService.getListPatch(params); - // 将附件按类型挂到对应的内容 - for (CmsContentModel item : result) { - item.setPictures(new ArrayList<>()); - item.setMusics(new ArrayList<>()); - item.setVideos(new ArrayList<>()); - item.setDocuments(new ArrayList<>()); - item.setOthers(new ArrayList<>()); - - patchList.stream().filter(patch -> item.getId().equals(patch.getContentId())) - .forEach(patch -> { - switch (patch.getPatchType()){ - case 1: - item.getPictures().add(patch); - break; - case 2: - item.getMusics().add(patch); - break; - case 3: - item.getVideos().add(patch); - break; - case 4: - item.getDocuments().add(patch); - break; - case 5: - item.getOthers().add(patch); - break; - } - }); - } - - return ResponseMsgUtil.success(new PageInfo<>(result)); - } catch (Exception e) { - log.error("CmsContentController --> getListContent() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getCorporateAdvertising", method = RequestMethod.GET) - @ApiOperation(value = "查询首页轮播图") - @ResponseBody - public ResponseData getCorporateAdvertising() { - try { - return ResponseMsgUtil.success(cmsContentService.getCorporateAdvertising()); - } catch (Exception e) { - log.error("CmsContentController --> getCorporateAdvertising() error!", e); - return ResponseMsgUtil.exception(e); - } - } -} diff --git a/bweb/src/main/java/com/bweb/controller/CmsPatchController.java b/bweb/src/main/java/com/bweb/controller/CmsPatchController.java deleted file mode 100644 index 3d7e4f1..0000000 --- a/bweb/src/main/java/com/bweb/controller/CmsPatchController.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.bweb.controller; - - -import com.hfkj.common.exception.ErrorCode; -import com.hfkj.common.exception.ErrorHelp; -import com.hfkj.common.exception.SysCode; -import com.hfkj.common.utils.ResponseMsgUtil; -import com.hfkj.entity.CmsPatch; -import com.hfkj.model.ResponseData; -import com.hfkj.service.CmsPatchService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Date; - -@Controller -@RequestMapping(value = "/cmsPatch") -@Api(value = "内容管理->附件") -public class CmsPatchController { - - private static Logger log = LoggerFactory.getLogger(CmsPatchController.class); - @Resource - private CmsPatchService cmsPatchService; - - @RequestMapping(value = "/addPatch", method = RequestMethod.POST) - @ApiOperation(value = "添加 附件") - @ResponseBody - public ResponseData addPatch(@RequestBody CmsPatch cmsPatch) { - try { - if (cmsPatch == null - || cmsPatch.getContentId() == null - || StringUtils.isBlank(cmsPatch.getPatchName()) - || cmsPatch.getPatchType() == null - || StringUtils.isBlank(cmsPatch.getPatchPath()) - ) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - cmsPatch.setAddTime(new Date()); - if (cmsPatchService.addPatch(cmsPatch) > 0) { - return ResponseMsgUtil.success("添加成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.ADD_DATA_ERROR, ""); - } - } catch (Exception e) { - log.error("CmsPatchController --> addPatch() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/delPatch", method = RequestMethod.GET) - @ApiOperation(value = "删除附件") - @ResponseBody - public ResponseData delPatch(@RequestParam(value = "id", required = true) Long id) { - try { - if (cmsPatchService.delPatch(id) > 0) { - return ResponseMsgUtil.success("删除成功"); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.DELETE_DATA_ERROR, ""); - } - } catch (Exception e) { - log.error("CmsPatchController --> delPatch() error!", e); - return ResponseMsgUtil.exception(e); - } - } - -} diff --git a/bweb/src/main/java/com/bweb/controller/LoginController.java b/bweb/src/main/java/com/bweb/controller/LoginController.java index 673eeb5..0d27d1d 100644 --- a/bweb/src/main/java/com/bweb/controller/LoginController.java +++ b/bweb/src/main/java/com/bweb/controller/LoginController.java @@ -5,16 +5,11 @@ import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.*; -import com.hfkj.common.utils.MD5Util; import com.hfkj.common.utils.ResponseMsgUtil; -import com.hfkj.entity.*; -import com.hfkj.model.MenuTreeModel; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; -import com.hfkj.model.UserInfoModel; import com.hfkj.service.*; import com.hfkj.service.sec.SecUserService; -import com.hfkj.sysenum.SecUserObjectTypeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -28,8 +23,6 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.List; @Controller @RequestMapping(value = "/login") diff --git a/bweb/src/main/java/com/bweb/controller/SecMenuController.java b/bweb/src/main/java/com/bweb/controller/SecMenuController.java index a2e6e2e..89d1fd0 100644 --- a/bweb/src/main/java/com/bweb/controller/SecMenuController.java +++ b/bweb/src/main/java/com/bweb/controller/SecMenuController.java @@ -7,8 +7,8 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.SecMenu; import com.hfkj.model.ResponseData; -import com.hfkj.service.SecMenuService; -import com.hfkj.service.SecRoleMenuRelService; +import com.hfkj.service.sec.SecMenuService; +import com.hfkj.service.sec.SecRoleMenuRelService; import com.hfkj.sysenum.SecMenuTypeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/bweb/src/main/java/com/bweb/controller/SecRoleController.java b/bweb/src/main/java/com/bweb/controller/SecRoleController.java index 7bcd380..614c067 100644 --- a/bweb/src/main/java/com/bweb/controller/SecRoleController.java +++ b/bweb/src/main/java/com/bweb/controller/SecRoleController.java @@ -8,7 +8,7 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.SecRole; import com.hfkj.model.ResponseData; -import com.hfkj.service.SecRoleService; +import com.hfkj.service.sec.SecRoleService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; diff --git a/service/src/main/java/com/hfkj/common/exception/ErrorCode.java b/service/src/main/java/com/hfkj/common/exception/ErrorCode.java index 7cbafb6..ff3bbd4 100644 --- a/service/src/main/java/com/hfkj/common/exception/ErrorCode.java +++ b/service/src/main/java/com/hfkj/common/exception/ErrorCode.java @@ -32,6 +32,7 @@ public enum ErrorCode { REQ_PARAMS_ERROR("2001","请求参数校验失败"), ACCOUNT_LOGIN_EXPIRE("2002","登录账户已过期"), ACCOUNT_LOGIN_NOT("2003","账户未登录"), + ROLE_NOT_PERMISSIONS("2004","该角色没有权限"), MSG_EVENT_NULL("2999","消息类型为空"), USE_VISIT_ILLEGAL("4001","用户身份错误"), diff --git a/service/src/main/java/com/hfkj/service/impl/BsMerchantUserServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsMerchantUserServiceImpl.java index ca26778..945ed45 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsMerchantUserServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsMerchantUserServiceImpl.java @@ -6,6 +6,7 @@ import com.hfkj.entity.BsMerchantUserExample; import com.hfkj.service.BsMerchantUserService; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; @@ -17,6 +18,7 @@ import java.util.Map; * @author: HuRui * @date: 2024/5/31 **/ +@Service("merchantUserService") public class BsMerchantUserServiceImpl implements BsMerchantUserService { @Resource