jinpengyong
2020-10-21 d3c5982218db1413c8f609f1f51b49c49a2db496
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.moral.controller;
 
import static com.moral.common.util.WebUtils.getParametersStartingWith;
 
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import com.moral.common.bean.PageBean;
import com.moral.common.bean.ResultBean;
import com.moral.entity.Account;
import com.moral.service.AccountService;
 
@RestController
@RequestMapping("account")
public class AccountController {
 
    @Resource
    private AccountService accountService;
 
    @GetMapping("list")
    public ResultBean<PageBean<Account>> getAccountListByPage(HttpServletRequest request) {
        Map<String, Object> parameters = getParametersStartingWith(request, null);
        PageBean<Account> accounts = accountService.getAccountListByPage(parameters);
        return new ResultBean<PageBean<Account>>(accounts);
    }
 
    @PostMapping("account")
    public ResultBean<Integer> saveOrUpdateAccount(@RequestBody Account account) {
        Integer result = accountService.saveOrUpdateAccount(account);
        return new ResultBean<Integer>(result);
    }
    
    @PostMapping("ids")
    public ResultBean<Integer> deleteAccountsByLogic(@RequestBody List<Integer> ids) {
        Integer result = accountService.deleteAccountsByLogic(ids);
        return new ResultBean<Integer>(result);
    }
 
    @GetMapping("{accountName}")
    public ResultBean<Integer> getAccountCountByAccountName(@PathVariable("accountName") String accountName) {
        Integer result = accountService.getAccountCountByAccountName(accountName);
        return new ResultBean<Integer>(result);
    }
 
}