dev-discount
parent
efd4d10627
commit
15e1d89441
@ -0,0 +1,96 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.security.SessionObject; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.entity.BsMsg; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.BsMsgService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author sum1dream |
||||
*/ |
||||
@Controller |
||||
@RequestMapping(value = "/bsMsg") |
||||
@Api(value = "站内信") |
||||
public class BsMsgController { |
||||
|
||||
Logger log = LoggerFactory.getLogger(ApiProductController.class); |
||||
|
||||
@Resource |
||||
private BsMsgService bsMsgService; |
||||
|
||||
@Autowired |
||||
private UserCenter userCenter; |
||||
|
||||
@RequestMapping(value = "/getMsgByList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询站内信列表") |
||||
public ResponseData getMsgByList( |
||||
@RequestParam(value = "type", required = false) Integer type, |
||||
@RequestParam(value = "jumpType", required = false) Integer jumpType, |
||||
@RequestParam(value = "msgType", required = false) Integer msgType, |
||||
@RequestParam(value = "title", required = false) String title, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request |
||||
) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
|
||||
Map<String, Object> map = new HashMap<>(5); |
||||
|
||||
map.put("type", type); |
||||
map.put("jumpType", jumpType); |
||||
map.put("msgType", msgType); |
||||
map.put("title", title); |
||||
map.put("companyId" , userInfoModel.getBsCompany().getId()); |
||||
|
||||
PageHelper.startPage(pageNum,pageSize); |
||||
|
||||
List<BsMsg> list = bsMsgService.getMsgByList(map); |
||||
return ResponseMsgUtil.success(new PageInfo<>(list)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsMsgController --> getMsgByList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "insertMsg" , method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "新增站内信") |
||||
public ResponseData insertMsg(@RequestBody BsMsg bsMsg , HttpServletRequest request) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
|
||||
bsMsg.setCompanyId(userInfoModel.getBsCompany().getId()); |
||||
bsMsg.setOpId(userInfoModel.getSecUser().getId()); |
||||
bsMsg.setOpName(userInfoModel.getSecUser().getUserName()); |
||||
bsMsgService.insertMsg(bsMsg); |
||||
return ResponseMsgUtil.success("新增成功"); |
||||
} catch (Exception e) { |
||||
log.error("BsMsgController --> insertMsg() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,57 @@ |
||||
package com.hai.service; |
||||
|
||||
import com.hai.entity.BsMsg; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @serviceName BsMsgService.java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // 站内信接口
|
||||
* @createTime 14:27 2022/9/20 |
||||
**/ |
||||
public interface BsMsgService { |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name insertMsg |
||||
* @Description // 新增站内信
|
||||
* @Date 14:30 2022/9/20 |
||||
* @Param [bsMsg] |
||||
* @Return void |
||||
*/ |
||||
void insertMsg(BsMsg bsMsg); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name updateMsg |
||||
* @Description //修改站内信
|
||||
* @Date 14:30 2022/9/20 |
||||
* @Param [bsMsg] |
||||
* @Return void |
||||
*/ |
||||
void updateMsg(BsMsg bsMsg); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name findMsg |
||||
* @Description // 根据id查询站内信
|
||||
* @Date 14:33 2022/9/20 |
||||
* @Param [id] |
||||
* @Return com.hai.entity.BsMsg |
||||
*/ |
||||
BsMsg findMsg(Long id); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name getMsgByList |
||||
* @Description // 查询站内信列表
|
||||
* @Date 14:34 2022/9/20 |
||||
* @Param [map] |
||||
* @Return java.util.List<com.hai.entity.BsMsg> |
||||
*/ |
||||
List<BsMsg> getMsgByList(Map<String , Object> map); |
||||
|
||||
} |
@ -0,0 +1,62 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
import com.hai.dao.BsMsgMapper; |
||||
import com.hai.entity.BsMsg; |
||||
import com.hai.entity.BsMsgExample; |
||||
import com.hai.service.BsMsgService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author sum1dream |
||||
*/ |
||||
@Service("bsMsgService") |
||||
public class BsMsgServiceImpl implements BsMsgService { |
||||
|
||||
@Resource |
||||
private BsMsgMapper bsMsgMapper; |
||||
|
||||
@Override |
||||
public void insertMsg(BsMsg bsMsg) { |
||||
bsMsgMapper.insert(bsMsg); |
||||
} |
||||
|
||||
@Override |
||||
public void updateMsg(BsMsg bsMsg) { |
||||
bsMsgMapper.updateByPrimaryKey(bsMsg); |
||||
} |
||||
|
||||
@Override |
||||
public BsMsg findMsg(Long id) { |
||||
return bsMsgMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<BsMsg> getMsgByList(Map<String, Object> map) { |
||||
|
||||
BsMsgExample example = new BsMsgExample(); |
||||
BsMsgExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getInteger(map , "type") != null) { |
||||
criteria.andTypeEqualTo(MapUtils.getInteger(map , "type")); |
||||
} |
||||
if (MapUtils.getInteger(map , "jumpType") != null) { |
||||
criteria.andJumpTypeEqualTo(MapUtils.getInteger(map , "jumpType")); |
||||
} |
||||
if (MapUtils.getInteger(map , "msgType") != null) { |
||||
criteria.andMsgTypeEqualTo(MapUtils.getInteger(map , "msgType")); |
||||
} |
||||
if (MapUtils.getInteger(map , "title") != null) { |
||||
criteria.andTitleLike("%" + MapUtils.getString(map , "title") + "%" ); |
||||
} |
||||
if (MapUtils.getLong(map , "companyId") != null) { |
||||
criteria.andCompanyIdEqualTo(MapUtils.getLong(map , "companyId")); |
||||
} |
||||
|
||||
return bsMsgMapper.selectByExample(example); |
||||
} |
||||
} |
Loading…
Reference in new issue