|
|
@@ -6,6 +6,9 @@ import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
import com.jpsoft.employment.modules.base.entity.NewsInfo;
|
|
|
import com.jpsoft.employment.modules.base.service.NewsInfoService;
|
|
|
+import com.jpsoft.employment.modules.sys.entity.User;
|
|
|
+import com.jpsoft.employment.modules.sys.service.DataDictionaryService;
|
|
|
+import com.jpsoft.employment.modules.sys.service.UserService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
@@ -18,13 +21,18 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
@RestController
|
|
|
-@RequestMapping("/newsInfo")
|
|
|
+@RequestMapping("/base/newsInfo")
|
|
|
public class NewsInfoController {
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
@Autowired
|
|
|
private NewsInfoService newsInfoService;
|
|
|
-
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
|
|
|
@ApiOperation(value="创建空记录")
|
|
|
@GetMapping("create")
|
|
|
@@ -195,7 +203,7 @@ public class NewsInfoController {
|
|
|
@ApiOperation(value="列表")
|
|
|
@RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
public MessageResult<Map> pageList(
|
|
|
- String id,
|
|
|
+ String title,String type,
|
|
|
@RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
@RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
HttpServletRequest request){
|
|
|
@@ -209,19 +217,65 @@ public class NewsInfoController {
|
|
|
Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
- sortList.add(new Sort("id_","asc"));
|
|
|
+ sortList.add(new Sort("create_time","desc"));
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(id)) {
|
|
|
- searchParams.put("id","%" + id + "%");
|
|
|
+ if (StringUtils.isNotEmpty(title)) {
|
|
|
+ searchParams.put("title","%" + title + "%");
|
|
|
}
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(type)) {
|
|
|
+ searchParams.put("type",type);
|
|
|
+ }
|
|
|
|
|
|
Page<NewsInfo> page = newsInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
|
|
|
+ for (NewsInfo newsInfo:page) {
|
|
|
+ String typeN = dataDictionaryService.findNameByCatalogNameAndValue("新闻类型", newsInfo.getType());
|
|
|
+ if (StringUtils.isNotEmpty(typeN)) {
|
|
|
+ newsInfo.setTypeN(typeN);
|
|
|
+ }
|
|
|
+
|
|
|
+ User user = userService.get(newsInfo.getCreateBy());
|
|
|
+ if(user!=null){
|
|
|
+ newsInfo.setCreateByN(user.getRealName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
msgResult.setResult(true);
|
|
|
msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
|
|
|
return msgResult;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="更改状态")
|
|
|
+ @PostMapping("changeStatus")
|
|
|
+ public MessageResult<NewsInfo> changeStatus(String id,boolean status,@RequestAttribute String subject){
|
|
|
+ MessageResult<NewsInfo> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ NewsInfo newsInfo = newsInfoService.get(id);
|
|
|
+ newsInfo.setIsTop(status);
|
|
|
+ newsInfo.setUpdateBy(subject);
|
|
|
+ newsInfo.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ int affectCount = newsInfoService.update(newsInfo);
|
|
|
+
|
|
|
+ if (affectCount > 0) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("数据库修改失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
}
|